From 203eef71e435a58e57289852809521a43753ef4d Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Thu, 22 Mar 2018 18:25:57 +0900 Subject: [PATCH 01/16] common: Remove build warning Change-Id: I9c4bd8067cf3547e6becdff244bb9291fde2144d Signed-off-by: pr.jung --- src/core/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/main.c b/src/core/main.c index 5b5acf2..2c06b1b 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -87,7 +87,6 @@ static gboolean watchdog_cb(void *data) static int deviced_main(int argc, char **argv) { int ret; - guint timer; mainloop = g_main_loop_new(NULL, FALSE); @@ -103,7 +102,7 @@ static int deviced_main(int argc, char **argv) signal(SIGTERM, sig_quit); signal(SIGUSR1, sig_usr1); - timer = g_timeout_add_seconds_full(G_PRIORITY_HIGH, WATCHDOG_TIMEOUT, watchdog_cb, NULL, NULL); + g_timeout_add_seconds_full(G_PRIORITY_HIGH, WATCHDOG_TIMEOUT, watchdog_cb, NULL, NULL); /* g_main_loop */ g_main_loop_run(mainloop); -- 2.7.4 From a8dc36abc06f99bd67b0f38bd31cbf3e38353060 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Fri, 23 Mar 2018 15:39:55 +0900 Subject: [PATCH 02/16] libgdbus: Remove dbus_handle_method_sync_with_reply usage - Change dbus_handle_method_sync_with_reply to dbus_handle_method_sync_with_reply_var Change-Id: Ifab9ea4cff00f643964f09187d77117ecbcbe563 Signed-off-by: pr.jung --- src/auto-test/battery.c | 12 ++++++------ src/auto-test/display.c | 16 ++++++++-------- src/auto-test/extcon.c | 4 ++-- src/auto-test/led.c | 4 ++-- src/auto-test/proc.c | 4 ++-- src/devicectl/devicectl.c | 16 ++++++++-------- src/libdeviced/led.c | 8 ++++---- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/auto-test/battery.c b/src/auto-test/battery.c index 389553f..bb1d7be 100644 --- a/src/auto-test/battery.c +++ b/src/auto-test/battery.c @@ -126,10 +126,10 @@ static bool get_battery_method(const char *method, int *value) int val; bool ret = FALSE; - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY, - method, NULL, NULL); + method, NULL); if (!msg) { _E("fail (%s): no reply", method); return ret; @@ -154,10 +154,10 @@ static bool get_battery_method_vconf(const char *method) int val; bool ret = FALSE; - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY, - method, NULL, NULL); + method, NULL); if (!msg) { _E("fail (%s): no reply", method); return ret; @@ -287,10 +287,10 @@ static bool get_battery_info() bool ret = FALSE; char *argv[3]; - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY, - METHOD_BATTERY_GETINFO, NULL, NULL); + METHOD_BATTERY_GETINFO, NULL); if (!msg) { _E("fail: no reply"); return ret; diff --git a/src/auto-test/display.c b/src/auto-test/display.c index 13e7f05..c7d30eb 100644 --- a/src/auto-test/display.c +++ b/src/auto-test/display.c @@ -58,10 +58,10 @@ static bool get_display_method(const char *method, int *value) int val; bool ret = FALSE; - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - method, NULL, NULL); + method, NULL); if (!msg) { _E("fail (%s): no reply", method); return ret; @@ -112,14 +112,14 @@ static bool set_display_method(const char *method, GVariant *param) return ret; } -static bool set_display_method_noreply(const char *method, char *sig, const char *param[]) +static bool set_display_method_noreply(const char *method, GVariant *var) { GVariant *msg; - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - method, sig, param); + method, var); if (!msg) { _E("fail (%s): no reply", method); return FALSE; @@ -332,7 +332,7 @@ static bool set_display_savelog() if (!stat(PM_STATE_LOG_FILE, &buf)) remove(PM_STATE_LOG_FILE); - if (!set_display_method_noreply(METHOD_DISPLAY_SAVELOG, NULL, NULL)) + if (!set_display_method_noreply(METHOD_DISPLAY_SAVELOG, NULL)) return ret; sleep(3); @@ -410,12 +410,12 @@ static bool set_display_actorcontrol(char *command, int actor, int caps) static bool set_display_start() { - return set_display_method_noreply(METHOD_DISPLAY_START, NULL, NULL); + return set_display_method_noreply(METHOD_DISPLAY_START, NULL); } static bool set_display_stop() { - return set_display_method_noreply(METHOD_DISPLAY_STOP, NULL, NULL); + return set_display_method_noreply(METHOD_DISPLAY_STOP, NULL); } void display_test_all(int *success, int *fail) diff --git a/src/auto-test/extcon.c b/src/auto-test/extcon.c index a2ef544..ed2c187 100644 --- a/src/auto-test/extcon.c +++ b/src/auto-test/extcon.c @@ -64,10 +64,10 @@ static bool get_sysnoti_method(const char *method) int val; bool ret = FALSE; - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, - method, NULL, NULL); + method, NULL); if (!msg) { _E("fail (%s): no reply", method); return ret; diff --git a/src/auto-test/led.c b/src/auto-test/led.c index e47aa5e..79cfae3 100644 --- a/src/auto-test/led.c +++ b/src/auto-test/led.c @@ -38,10 +38,10 @@ static bool get_led_method(const char *method) int val; bool ret = FALSE; - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_LED, DEVICED_INTERFACE_LED, - method, NULL, NULL); + method, NULL); if (!msg) { _E("fail (%s): no reply", method); return ret; diff --git a/src/auto-test/proc.c b/src/auto-test/proc.c index 532c4a1..44bb8dc 100755 --- a/src/auto-test/proc.c +++ b/src/auto-test/proc.c @@ -26,10 +26,10 @@ static bool get_sysnoti_revision() int val; bool ret = FALSE; - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, - METHOD_SYSNOTI_GETREVISION, NULL, NULL); + METHOD_SYSNOTI_GETREVISION, NULL); if (!msg) { _E("fail : no reply"); return ret; diff --git a/src/devicectl/devicectl.c b/src/devicectl/devicectl.c index 50b251a..52455f2 100644 --- a/src/devicectl/devicectl.c +++ b/src/devicectl/devicectl.c @@ -70,11 +70,11 @@ static int start_device(char **args) printf("start %s device!\n", args[1]); - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, devices[arg_id].path, devices[arg_id].iface, "start", - NULL, NULL); + NULL); if (!msg) return -EBADMSG; @@ -92,11 +92,11 @@ static int stop_device(char **args) printf("stop %s device!\n", args[1]); - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, devices[arg_id].path, devices[arg_id].iface, "stop", - NULL, NULL); + NULL); if (!msg) return -EBADMSG; @@ -179,11 +179,11 @@ static int save_dbus_name(char **args) printf("save dbus name!\n"); - msg = dbus_handle_method_sync_with_reply(DBUS_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DBUS_BUS_NAME, DBUS_OBJECT_PATH, DBUS_INTERFACE_NAME, "ListNames", - NULL, NULL); + NULL); if (!msg) { printf("failed to get list names"); return -EBADMSG; @@ -218,11 +218,11 @@ static int device_list(char **args) printf("print %s to dlog!\n", args[1]); - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, devices[arg_id].path, devices[arg_id].iface, "DeviceList", - NULL, NULL); + NULL); if (!msg) return -EBADMSG; diff --git a/src/libdeviced/led.c b/src/libdeviced/led.c index e7da673..bf152b4 100644 --- a/src/libdeviced/led.c +++ b/src/libdeviced/led.c @@ -35,11 +35,11 @@ API int led_get_brightness(void) GVariant *msg = NULL; int ret_val = 0; - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_LED, DEVICED_INTERFACE_LED, METHOD_GET_BRIGHTNESS, - NULL, NULL); + NULL); if (!msg) return -EBADMSG; @@ -58,11 +58,11 @@ API int led_get_max_brightness(void) GVariant *msg = NULL; int ret_val; - msg = dbus_handle_method_sync_with_reply(DEVICED_BUS_NAME, + msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_LED, DEVICED_INTERFACE_LED, METHOD_GET_MAX_BRIGHTNESS, - NULL, NULL); + NULL); if (!msg) return -EBADMSG; -- 2.7.4 From 2a97e96e8156f83323f0e69703ab17c63f6f4124 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Mon, 26 Mar 2018 18:16:25 +0900 Subject: [PATCH 03/16] dbus-policy: add rule default deny own Change-Id: I1cc4b02d3d20c2e12c4675352f51384c04ec71fa Signed-off-by: sanghyeok.oh --- conf/org.tizen.system.deviced.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf/org.tizen.system.deviced.conf b/conf/org.tizen.system.deviced.conf index 656af38..81c31c6 100644 --- a/conf/org.tizen.system.deviced.conf +++ b/conf/org.tizen.system.deviced.conf @@ -2,8 +2,8 @@ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> + - @@ -18,6 +18,7 @@ + -- 2.7.4 From 9daacb9a9e82ecb41f7d3c71d19ee732f927ed36 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 19 Mar 2018 17:48:21 +0900 Subject: [PATCH 04/16] Fix build error that occurred with a new version of cmake(3.9.4) Change-Id: Ifc95d7062cf63674032fdf6e2684fc0a4437ef2f Signed-off-by: Hyotaek Shim --- CMakeLists.txt | 1 + src/auto-test/CMakeLists.txt | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1a67f3..7ef248b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,6 +218,7 @@ ENDIF() ADD_DEFINITIONS("-DDEBUG") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) +SET(deviced_LDFLAGS ${pkgs_LDFLAGS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-lrt -ldl -lm" shared) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt index 185958c..aef9346 100644 --- a/src/auto-test/CMakeLists.txt +++ b/src/auto-test/CMakeLists.txt @@ -23,8 +23,6 @@ SET(SRCS time.c ) -INCLUDE(FindPkgConfig) - FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) @@ -37,7 +35,7 @@ ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DENABLE_TEST_DLOG") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} shared) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${deviced_LDFLAGS} shared) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/auto-test.conf DESTINATION /etc/deviced) -- 2.7.4 From e5a87899fa229d51c22e9b18d646156e14764064 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Wed, 28 Mar 2018 22:16:34 +0900 Subject: [PATCH 05/16] Check the existence of mtp responder service for usb configuration Change-Id: I62ccb18060f1ff9f967a996b919ef347319f1685 Signed-off-by: lokilee73 Signed-off-by: Hyotaek Shim --- src/usb/usb-state.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) mode change 100644 => 100755 src/usb/usb-state.c diff --git a/src/usb/usb-state.c b/src/usb/usb-state.c old mode 100644 new mode 100755 index f87da53..e516916 --- a/src/usb/usb-state.c +++ b/src/usb/usb-state.c @@ -34,6 +34,7 @@ #include "usb-tethering.h" #include "usb-debug.h" +#define MTP_RESPONDER_PATH "/usr/lib/systemd/system/mtp-responder.service" static usb_connection_state_e usb_connection = USB_DISCONNECTED; static unsigned int usb_mode = USB_FUNCTION_NONE; static unsigned int usb_selected_mode = USB_FUNCTION_SDB; /* for debugging */ @@ -78,6 +79,8 @@ usb_connection_state_e usb_state_get_connection(void) void usb_state_retrieve_selected_mode(void) { int ret, mode; + char buf[PATH_MAX]; + ret = vconf_get_int(VCONFKEY_USB_SEL_MODE, &mode); if (ret != 0) { _E("Failed to retrieve selected mode"); @@ -93,6 +96,16 @@ void usb_state_retrieve_selected_mode(void) #endif usb_selected_mode = (unsigned int)mode; + + if (snprintf(buf, PATH_MAX, "%s", MTP_RESPONDER_PATH) < 0) { + _E("Fail to copy MTP_RESPONDER_PATH"); + return; + } + + if (access(buf, R_OK) != 0) { + mode &= ~USB_FUNCTION_MTP; + usb_state_set_selected_mode(mode); + } } void usb_state_set_selected_mode(unsigned int mode) -- 2.7.4 From 51f73ffc292a36676f1ba666b9160744a8e5e9cb Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Wed, 4 Apr 2018 21:39:46 +0900 Subject: [PATCH 06/16] Refactor dbus_handle_init into two parts It's to solve timing issue caused by telephony. When it requests AddPoweroffWait, it fails because dbus in deviced is not ready. Change-Id: I03f64928e361301ba87330298a19bd7482317081 Signed-off-by: lokilee73 --- src/core/main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) mode change 100644 => 100755 src/core/main.c diff --git a/src/core/main.c b/src/core/main.c old mode 100644 new mode 100755 index 2c06b1b..8d4768c --- a/src/core/main.c +++ b/src/core/main.c @@ -87,6 +87,7 @@ static gboolean watchdog_cb(void *data) static int deviced_main(int argc, char **argv) { int ret; + dbus_handle_h handle = NULL; mainloop = g_main_loop_new(NULL, FALSE); @@ -94,11 +95,18 @@ static int deviced_main(int argc, char **argv) if (ret) return 0; - if (!dbus_handle_init(G_BUS_TYPE_SYSTEM, DEVICED_BUS_NAME, deviced_dbus_name_acquired, NULL)) { - _E("failed to init dbus connection"); - } + handle = dbus_handle_get_connection(G_BUS_TYPE_SYSTEM, FALSE); + if (!handle) + _E("Fail to get dbus connection"); + devices_init(NULL); + ret = dbus_handle_request_bus_name(handle, DEVICED_BUS_NAME, deviced_dbus_name_acquired, NULL); + if (ret <= 0) { + _E("Fail to request bus name"); + dbus_handle_check_owner_name(NULL, DEVICED_BUS_NAME); + } + signal(SIGTERM, sig_quit); signal(SIGUSR1, sig_usr1); -- 2.7.4 From 05360d61e610053753df46da1330123aef0edb5c Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Fri, 6 Apr 2018 11:16:24 +0900 Subject: [PATCH 07/16] Change the method for thermal From ChangedCooldownMode to thermal_scenario Change-Id: Ie5dd8ec75a2018b1dc61dee34f37777e9a88a455 Signed-off-by: lokilee73 --- src/thermal/thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thermal/thermal.c b/src/thermal/thermal.c index d1b99e2..17d5857 100755 --- a/src/thermal/thermal.c +++ b/src/thermal/thermal.c @@ -33,7 +33,7 @@ static int noti; /* Dbus Interfaces */ #define THERMAL_PATH "/Org/Tizen/System/Pass/Monitor/Thermal" #define THERMAL_INTERFACE "org.tizen.system.pass.monitor.thermal" -#define THERMAL_METHOD_TEMP_CHANGED "ChangedCooldownMode" +#define THERMAL_METHOD_TEMP_CHANGED "thermal_scenario" /* Action types */ #define RELEASE_ACTION "ReleaseAction" -- 2.7.4 From d61002ca57126a5be4a9b9c7ecddbc58cf683c03 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Fri, 6 Apr 2018 16:26:37 +0900 Subject: [PATCH 08/16] Fix a build problem that occurred with a new version of cmake(3.9.4) Change-Id: I4531dc40550ea2feb29a90abc0329b0557cc1229 Signed-off-by: Hyotaek Shim --- src/devicectl/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/devicectl/CMakeLists.txt b/src/devicectl/CMakeLists.txt index 8f96cab..04f543b 100644 --- a/src/devicectl/CMakeLists.txt +++ b/src/devicectl/CMakeLists.txt @@ -12,7 +12,11 @@ SET(SRCS INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src) INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED glib-2.0 gio-2.0 gio-unix-2.0) +pkg_check_modules(pkgs REQUIRED + glib-2.0 + gio-2.0 + gio-unix-2.0 + libgdbus) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -- 2.7.4 From f50deea1efd5062415f43eb0722983daae77413f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Szewczyk?= Date: Wed, 4 Apr 2018 12:58:08 +0200 Subject: [PATCH 09/16] Revert "Revert "usb: Remove usb-operation"" MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This revert was only temporary solution and with updated HAL implementation deviced should not start any services itself. This reverts commit 64bec949084f2bff0dce333052eda84d0244ee3f. Change-Id: Ifd5ccb3b2bbdf764ef0f3a2a191755494cdb7b64 Signed-off-by: Paweł Szewczyk --- CMakeLists.txt | 2 - conf/usb-operation.conf | 14 ------ packaging/deviced.spec | 1 - src/usb/usb-operation.c | 114 ------------------------------------------------ src/usb/usb.c | 8 ---- src/usb/usb.h | 3 -- 6 files changed, 142 deletions(-) delete mode 100644 conf/usb-operation.conf delete mode 100644 src/usb/usb-operation.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ef248b..7ee72a5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,8 +243,6 @@ ENDIF() # USB connection IF(USB_MODULE STREQUAL on) - INSTALL_CONF(conf usb-operation) - # USB (Manual setting) INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/direct_set_debug.sh DESTINATION bin) IF(${SDB_PRESTART} STREQUAL on) diff --git a/conf/usb-operation.conf b/conf/usb-operation.conf deleted file mode 100644 index da6c71c..0000000 --- a/conf/usb-operation.conf +++ /dev/null @@ -1,14 +0,0 @@ -[sdb] -StartService=sdbd.service -StopService=sdbd.service - -[mtp] -StartService=mtp-responder.service -StopService=mtp-responder.service - -[rndis] -Start=/sbin/ifconfig usb0 192.168.129.3 up -Start=/sbin/route add -net 192.168.129.0 netmask 255.255.255.0 dev usb0 -StartService=sshd.service -StopService=sshd.service -Stop=/sbin/ifconfig usb0 down diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 8c68f05..7adb606 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -218,7 +218,6 @@ mv %{_libdir}/display-tv.so %{_libdir}/deviced/display.so %config %{_sysconfdir}/deviced/power.conf %config %{_sysconfdir}/deviced/battery.conf %config %{_sysconfdir}/deviced/display.conf -%config %{_sysconfdir}/deviced/usb-operation.conf # usbhost_test %{_sysconfdir}/deviced/usb-host-test/test_gadget.gs %{_bindir}/usb-host-ffs-test-daemon diff --git a/src/usb/usb-operation.c b/src/usb/usb-operation.c deleted file mode 100644 index 1bc8efc..0000000 --- a/src/usb/usb-operation.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include - -#include "core/log.h" -#include "core/common.h" -#include "core/config-parser.h" -#include "core/launch.h" -#include "shared/deviced-systemd.h" -#include "usb.h" - -#define USB_OPERATION "/etc/deviced/usb-operation.conf" - -#define KEY_START_STR "Start" -#define KEY_STOP_STR "Stop" - -#define BUF_MAX 128 - -typedef enum { - OPERATION_STOP, - OPERATION_START, -} operation_e; - -struct oper_data { - char mode_str[BUF_MAX]; - operation_e type; -}; - -static int load_operation_config(struct parse_result *result, void *user_data) -{ - struct oper_data *data = user_data; - int ret; - operation_e type; - - if (!data || !result) - return -EINVAL; - - if (!strstr(data->mode_str, result->section)) - return 0; - - if (!strncmp(result->name, KEY_START_STR, strlen(KEY_START_STR))) - type = OPERATION_START; - else if (!strncmp(result->name, KEY_STOP_STR, strlen(KEY_STOP_STR))) - type = OPERATION_STOP; - else { - _E("Invalid name (%s)", result->name); - return -EINVAL; - } - - if (type != data->type) - return 0; - - if (strstr(result->name, "Service")) { - if (type == OPERATION_START) - ret = deviced_systemd_start_unit(result->value); - if (type == OPERATION_STOP) - ret = deviced_systemd_stop_unit(result->value); - } else - ret = launch_app_cmd(result->value); - - _I("Execute(%s %s: %d)", result->name, result->value, ret); - - return 0; -} - -static int usb_execute_operation(unsigned int mode, operation_e type) -{ - int ret; - struct oper_data data; - - usb_state_get_mode_str(mode, data.mode_str, sizeof(data.mode_str)); - - data.type = type; - - ret = config_parse(USB_OPERATION, - load_operation_config, &data); - if (ret < 0) - _E("Failed to load usb operation (%d)", ret); - - return ret; -} - -int usb_operation_start(unsigned int mode) -{ - if (is_emulator()) - return 0; - return usb_execute_operation(mode, OPERATION_START); -} - -int usb_operation_stop(unsigned int mode) -{ - if (is_emulator()) - return 0; - return usb_execute_operation(mode, OPERATION_STOP); -} diff --git a/src/usb/usb.c b/src/usb/usb.c index 66ac8b1..db380f5 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -315,8 +315,6 @@ int usb_change_mode(unsigned mode) unsigned int curr = usb_state_get_current_mode(); if (curr != USB_FUNCTION_NONE) { - usb_operation_stop(curr); - ret = usb_disable(); if (ret < 0) { _E("Failed to disable current usb mode"); @@ -339,8 +337,6 @@ int usb_change_mode(unsigned mode) _E("Failed to enable usb mode (%d)"); return ret; } - - usb_operation_start(mode); } return 0; @@ -359,15 +355,11 @@ static int usb_connected(void) return ret; } - usb_operation_start(mode); - return 0; } static int usb_disconnected(void) { - usb_operation_stop(usb_state_get_current_mode()); - usb_state_update_state(USB_DISCONNECTED, USB_FUNCTION_NONE); return usb_disable(); diff --git a/src/usb/usb.h b/src/usb/usb.h index ae26162..0e6165b 100644 --- a/src/usb/usb.h +++ b/src/usb/usb.h @@ -67,9 +67,6 @@ void usb_state_set_selected_mode(unsigned int mode); unsigned int usb_state_get_current_mode(void); usb_connection_state_e usb_state_get_connection(void); -int usb_operation_start(unsigned int mode); -int usb_operation_stop(unsigned int mode); - /* dbus methods/signals (usb-dbus.c) */ enum { DISABLED, -- 2.7.4 From 2541da181ba3c2b0b8dfff4c12721b586c1e0816 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Tue, 17 Apr 2018 18:19:21 +0900 Subject: [PATCH 10/16] Revert "To prevent Watchdog Kill during the dbus sync call" This reverts commit 19f28633e69ec61b9bd32d904b89f0b5a6f48aee. Change-Id: I57727e680fa9351fd1a3254f25d10bd639302ab6 Signed-off-by: Hyotaek Shim --- src/display/dpms-wayland-none.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/display/dpms-wayland-none.c b/src/display/dpms-wayland-none.c index 3766df5..cf1db2e 100644 --- a/src/display/dpms-wayland-none.c +++ b/src/display/dpms-wayland-none.c @@ -87,8 +87,6 @@ int dpms_get_power(enum dpms_state *state) if (!state) return -EINVAL; - watchdog_notify(); - ret = dbus_handle_method_sync(ENLIGHTENMENT_BUS_NAME, ENLIGHTENMENT_OBJECT_PATH, ENLIGHTENMENT_INTERFACE_NAME, -- 2.7.4 From c6f2bce7ac599c578db44caff1c9de5310a58251 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 18 Apr 2018 09:13:21 +0900 Subject: [PATCH 11/16] Revert "Revert "Revert "usb: Remove usb-operation""" This reverts commit f50deea1efd5062415f43eb0722983daae77413f. Change-Id: I3dc62a8c786376039dcc2592ecc61d8f348a6885 Signed-off-by: Hyotaek Shim --- CMakeLists.txt | 2 + conf/usb-operation.conf | 14 ++++++ packaging/deviced.spec | 1 + src/usb/usb-operation.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ src/usb/usb.c | 8 ++++ src/usb/usb.h | 3 ++ 6 files changed, 142 insertions(+) create mode 100644 conf/usb-operation.conf create mode 100644 src/usb/usb-operation.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ee72a5..7ef248b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,6 +243,8 @@ ENDIF() # USB connection IF(USB_MODULE STREQUAL on) + INSTALL_CONF(conf usb-operation) + # USB (Manual setting) INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/direct_set_debug.sh DESTINATION bin) IF(${SDB_PRESTART} STREQUAL on) diff --git a/conf/usb-operation.conf b/conf/usb-operation.conf new file mode 100644 index 0000000..da6c71c --- /dev/null +++ b/conf/usb-operation.conf @@ -0,0 +1,14 @@ +[sdb] +StartService=sdbd.service +StopService=sdbd.service + +[mtp] +StartService=mtp-responder.service +StopService=mtp-responder.service + +[rndis] +Start=/sbin/ifconfig usb0 192.168.129.3 up +Start=/sbin/route add -net 192.168.129.0 netmask 255.255.255.0 dev usb0 +StartService=sshd.service +StopService=sshd.service +Stop=/sbin/ifconfig usb0 down diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 7adb606..8c68f05 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -218,6 +218,7 @@ mv %{_libdir}/display-tv.so %{_libdir}/deviced/display.so %config %{_sysconfdir}/deviced/power.conf %config %{_sysconfdir}/deviced/battery.conf %config %{_sysconfdir}/deviced/display.conf +%config %{_sysconfdir}/deviced/usb-operation.conf # usbhost_test %{_sysconfdir}/deviced/usb-host-test/test_gadget.gs %{_bindir}/usb-host-ffs-test-daemon diff --git a/src/usb/usb-operation.c b/src/usb/usb-operation.c new file mode 100644 index 0000000..1bc8efc --- /dev/null +++ b/src/usb/usb-operation.c @@ -0,0 +1,114 @@ +/* + * deviced + * + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include + +#include "core/log.h" +#include "core/common.h" +#include "core/config-parser.h" +#include "core/launch.h" +#include "shared/deviced-systemd.h" +#include "usb.h" + +#define USB_OPERATION "/etc/deviced/usb-operation.conf" + +#define KEY_START_STR "Start" +#define KEY_STOP_STR "Stop" + +#define BUF_MAX 128 + +typedef enum { + OPERATION_STOP, + OPERATION_START, +} operation_e; + +struct oper_data { + char mode_str[BUF_MAX]; + operation_e type; +}; + +static int load_operation_config(struct parse_result *result, void *user_data) +{ + struct oper_data *data = user_data; + int ret; + operation_e type; + + if (!data || !result) + return -EINVAL; + + if (!strstr(data->mode_str, result->section)) + return 0; + + if (!strncmp(result->name, KEY_START_STR, strlen(KEY_START_STR))) + type = OPERATION_START; + else if (!strncmp(result->name, KEY_STOP_STR, strlen(KEY_STOP_STR))) + type = OPERATION_STOP; + else { + _E("Invalid name (%s)", result->name); + return -EINVAL; + } + + if (type != data->type) + return 0; + + if (strstr(result->name, "Service")) { + if (type == OPERATION_START) + ret = deviced_systemd_start_unit(result->value); + if (type == OPERATION_STOP) + ret = deviced_systemd_stop_unit(result->value); + } else + ret = launch_app_cmd(result->value); + + _I("Execute(%s %s: %d)", result->name, result->value, ret); + + return 0; +} + +static int usb_execute_operation(unsigned int mode, operation_e type) +{ + int ret; + struct oper_data data; + + usb_state_get_mode_str(mode, data.mode_str, sizeof(data.mode_str)); + + data.type = type; + + ret = config_parse(USB_OPERATION, + load_operation_config, &data); + if (ret < 0) + _E("Failed to load usb operation (%d)", ret); + + return ret; +} + +int usb_operation_start(unsigned int mode) +{ + if (is_emulator()) + return 0; + return usb_execute_operation(mode, OPERATION_START); +} + +int usb_operation_stop(unsigned int mode) +{ + if (is_emulator()) + return 0; + return usb_execute_operation(mode, OPERATION_STOP); +} diff --git a/src/usb/usb.c b/src/usb/usb.c index db380f5..66ac8b1 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -315,6 +315,8 @@ int usb_change_mode(unsigned mode) unsigned int curr = usb_state_get_current_mode(); if (curr != USB_FUNCTION_NONE) { + usb_operation_stop(curr); + ret = usb_disable(); if (ret < 0) { _E("Failed to disable current usb mode"); @@ -337,6 +339,8 @@ int usb_change_mode(unsigned mode) _E("Failed to enable usb mode (%d)"); return ret; } + + usb_operation_start(mode); } return 0; @@ -355,11 +359,15 @@ static int usb_connected(void) return ret; } + usb_operation_start(mode); + return 0; } static int usb_disconnected(void) { + usb_operation_stop(usb_state_get_current_mode()); + usb_state_update_state(USB_DISCONNECTED, USB_FUNCTION_NONE); return usb_disable(); diff --git a/src/usb/usb.h b/src/usb/usb.h index 0e6165b..ae26162 100644 --- a/src/usb/usb.h +++ b/src/usb/usb.h @@ -67,6 +67,9 @@ void usb_state_set_selected_mode(unsigned int mode); unsigned int usb_state_get_current_mode(void); usb_connection_state_e usb_state_get_connection(void); +int usb_operation_start(unsigned int mode); +int usb_operation_stop(unsigned int mode); + /* dbus methods/signals (usb-dbus.c) */ enum { DISABLED, -- 2.7.4 From 2ba981c32cca7b0e6469e220ad0b6bf1aa15f571 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 25 Apr 2018 13:52:09 +0900 Subject: [PATCH 12/16] Remove unnecessary "Requires" to avoid build issues regarding noarch Dear All, I came up today with a dependency problem, that blocks verification of SR. The SR submit/tizen/20180424.062711 for tef-simulator (platform/core/security/tef-simulator) failed to create 5 images. Although, there is nothing wrong in changes proposed in tef-simulator. The images that failed to build do not even contain tef-simulator and should not be affected anyway. Here is what happened: 1) tef -simulator builds only for Intel archs, because of this line in tef-simulator.spec: ExcludeArch: armv6l armv7hl armv7l aarch64 2) build of tef-simulator triggers build of key-manager-ta, which triggers build of deviced, but still only for Intel archs. Build is not retriggered for arm (armv7l and aarch64) architectures, because there were no changes in code there. 3) Five of images requires deviced-config-profile-wearable or deviced-config-enable-display-timer package which are part of deviced and is noarch. They have been rebuild in the SR so is published as deviced-config-profile-wearable-5.0.0-20180424.062711.noarch, deviced-config-enable-display-timer-5.0.0-20180424.062711.noarch 4) According to deviced.spec (platform/core/system/deviced) config-profile-wearable, deviced-config-enable-display-timer packages requires deviced package with exactly same version and release: %package config-profile-wearable Summary: Configuration files for wearable profile Group: System/Management Requires: %{name} = %{version}-%{release} BuildArch: noarch %package config-enable-display-timer Summary: Configuration files for display Group: System/Management Requires: %{name} = %{version}-%{release} BuildArch: noarch However deviced package in version and release 5.0.0-20180424.062711 is not found for armv7l architecture, because version from reference snapshot is 5.0.0-36.3. So the problem is that the noarch package (config-profile-wearable) can be rebuild without rebuilding main package (deviced) for arm architectures. And then it is impossible to satisfy "Requires" criteria and match exactly same version during image creation. The proposed solution would be to remove these 2 lines (Requires: %{name} = %{version}-%{release}) from deviced.spec as these packages providing conf does not really depend on deviced package. I verified that it won't break images as deviced itself is also included in meta files for wearable and mobile images which have this issue. Lukasz Wojciechowski Principal Software Engineer Samsung R&D Institute Poland Samsung Electronics Change-Id: I95061848b3bb0429840122e01fd72db5adda5f2a Signed-off-by: Hyotaek Shim --- packaging/deviced.spec | 2 -- 1 file changed, 2 deletions(-) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 8c68f05..ffcd0e7 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -84,7 +84,6 @@ This package can be installed optional for auto dbus test. %package config-profile-wearable Summary: Configuration files for wearable profile Group: System/Management -Requires: %{name} = %{version}-%{release} BuildArch: noarch %description config-profile-wearable @@ -93,7 +92,6 @@ This package is used for wearable profile %package config-enable-display-timer Summary: Configuration files for display Group: System/Management -Requires: %{name} = %{version}-%{release} BuildArch: noarch %description config-enable-display-timer -- 2.7.4 From 4425cc54326396ca773310f5ede0af7b0159bf53 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 24 Apr 2018 20:32:55 +0900 Subject: [PATCH 13/16] Modify dbus for DIM Change-Id: I706f6f55accc9858939fc8ae3e621b489f637b15 Signed-off-by: lokilee73 --- CMakeLists.txt | 1 + packaging/deviced.spec | 1 + src/display/device-interface.c | 10 ++++-- src/display/device-interface.h | 2 +- src/display/display-dbus.c | 73 +++++++++++++++++++++++++----------------- src/libdeviced/display.c | 1 - 6 files changed, 55 insertions(+), 33 deletions(-) mode change 100644 => 100755 src/display/device-interface.h mode change 100644 => 100755 src/display/display-dbus.c mode change 100644 => 100755 src/libdeviced/display.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ef248b..7000c7d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,7 @@ SET(PKG_MODULES hwcommon mount capi-system-info + capi-system-device libsystemd libgdbus ) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index ffcd0e7..a908a6d 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -36,6 +36,7 @@ BuildRequires: pkgconfig(minizip) BuildRequires: pkgconfig(libkmod) BuildRequires: pkgconfig(libusbgx) BuildRequires: pkgconfig(libgdbus) +BuildRequires: pkgconfig(capi-system-device) Requires: %{name}-tools = %{version}-%{release} %{?systemd_requires} diff --git a/src/display/device-interface.c b/src/display/device-interface.c index 897906f..1aa0c50 100755 --- a/src/display/device-interface.c +++ b/src/display/device-interface.c @@ -104,7 +104,7 @@ static int bl_brt(int brightness, int delay) if (delay > 0) usleep(delay); - if (force_brightness > 0 && brightness != PM_DIM_BRIGHTNESS) { + if (force_brightness > 0) { _I("brightness(%d), force brightness(%d)", brightness, force_brightness); brightness = force_brightness; @@ -281,8 +281,14 @@ static int backlight_off(enum device_flags flags) static int backlight_dim(void) { int ret; + int brightness; - ret = bl_brt(PM_DIM_BRIGHTNESS, 0); + if (vconf_get_int(VCONFKEY_SETAPPL_LCD_DIM_BRIGHTNESS, &brightness) != 0) { + _E("Failed to get VCONFKEY_SETAPPL_LCD_DIM_BRIGHTNESS value"); + return -EPERM; + } + + ret = bl_brt(brightness, 0); #ifdef ENABLE_PM_LOG if (!ret) pm_history_save(PM_LOG_LCD_DIM, pm_cur_state); diff --git a/src/display/device-interface.h b/src/display/device-interface.h old mode 100644 new mode 100755 index cd29d23..88e25cf --- a/src/display/device-interface.h +++ b/src/display/device-interface.h @@ -34,13 +34,13 @@ #define PM_MAX_BRIGHTNESS 100 #define PM_MIN_BRIGHTNESS 1 #define PM_DEFAULT_BRIGHTNESS 60 -#define PM_DIM_BRIGHTNESS 0 #define DISP_INDEX_SHIFT 16 #define DISP_CMD(prop, index) ((index << DISP_INDEX_SHIFT) | prop) #define DEFAULT_DISPLAY_COUNT 1 #define DEFAULT_DISPLAY_MAX_BRIGHTNESS 100 +#define DEFAULT_DISPLAY_MAX_DIM_BRIGHTNESS 50 /* * Event type enumeration diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c old mode 100644 new mode 100755 index 3e374cf..04fcbe7 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -41,10 +41,10 @@ #include "dd-display.h" #include "display-actor.h" #include "display-ops.h" +#include #define SIGNAL_HOMESCREEN "HomeScreen" -#define DISPLAY_DIM_BRIGHTNESS 0 #define DUMP_MODE_WATING_TIME 600000 #define EXPIRED_POPUP_TYPE_POWER "power_lock_expired" @@ -338,11 +338,17 @@ GVariant *dbus_getmaxbrightness(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { - int ret; + int ret, state; CHECK_POWEROFF(); - ret = DEFAULT_DISPLAY_MAX_BRIGHTNESS; + g_variant_get(param, "(i)", &state); + if (state == DISPLAY_STATE_NORMAL) + ret = DEFAULT_DISPLAY_MAX_BRIGHTNESS; + else if (state == DISPLAY_STATE_SCREEN_DIM) + ret = DEFAULT_DISPLAY_MAX_DIM_BRIGHTNESS; + else + ret = -EINVAL; return g_variant_new("(i)", ret); } @@ -364,11 +370,19 @@ GVariant *dbus_getbrightness(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { - int brt, ret; + int brt = -1, state, ret; CHECK_POWEROFF(); - ret = backlight_ops.get_brightness(&brt); + g_variant_get(param, "(i)", &state); + + if (state == DISPLAY_STATE_NORMAL) { + ret = backlight_ops.get_brightness(&brt); + } else if (state == DISPLAY_STATE_SCREEN_DIM) { + ret = vconf_get_int(VCONFKEY_SETAPPL_LCD_DIM_BRIGHTNESS, &brt); + } else + ret = -EINVAL; + if (ret >= 0) ret = brt; @@ -381,7 +395,7 @@ GVariant *dbus_setbrightness(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { - int brt, autobrt, ret, caps; + int state, brt, autobrt, ret = 0, caps; CHECK_POWEROFF(); @@ -393,13 +407,7 @@ GVariant *dbus_setbrightness(GDBusConnection *conn, goto error; } - g_variant_get(param, "(i)", &brt); - - if (brt == DISPLAY_DIM_BRIGHTNESS) { - _E("application can not set this value(DIM VALUE:%d)", brt); - ret = -EPERM; - goto error; - } + g_variant_get(param, "(ii)", &state, &brt); if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &autobrt) != 0) { _E("Failed to get VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT value"); @@ -412,11 +420,24 @@ GVariant *dbus_setbrightness(GDBusConnection *conn, goto error; } - ret = backlight_ops.set_brightness(brt); - if (ret < 0) - goto error; - if (vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt) != 0) - _E("Failed to set VCONFKEY_SETAPPL_LCD_BRIGHTNESS value"); + if (state == DISPLAY_STATE_NORMAL) { + ret = backlight_ops.set_brightness(brt); + if (ret < 0) + goto error; + + if (vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt) != 0) + _E("Failed to set VCONFKEY_SETAPPL_LCD_BRIGHTNESS value"); + } else if (state == DISPLAY_STATE_SCREEN_DIM) { + if (pm_cur_state == S_LCDDIM) { + ret = backlight_ops.set_brightness(brt); + if (ret < 0) + goto error; + } + + if (vconf_set_int(VCONFKEY_SETAPPL_LCD_DIM_BRIGHTNESS, brt) != 0) + _E("Failed to set VCONFKEY_SETAPPL_LCD_DIM_BRIGHTNESS value"); + } else + ret = -EINVAL; _I("set brightness %d, %d", brt, ret); @@ -442,12 +463,6 @@ GVariant *dbus_holdbrightness(GDBusConnection *conn, g_variant_get(param, "(i)", &brt); - if (brt == DISPLAY_DIM_BRIGHTNESS) { - _E("application can not set this value(DIM VALUE:%d)", brt); - ret = -EPERM; - goto error; - } - if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &autobrt) != 0) { _E("Failed to get VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT value"); autobrt = SETTING_BRIGHTNESS_AUTOMATIC_OFF; @@ -1018,17 +1033,17 @@ static const dbus_method_s dbus_methods[] = { { "unlockstate", "ss", "i", dbus_unlockstate }, { "changestate", "s", "i", dbus_changestate }, { "ChangeState", "s", "i", dbus_changestate }, - { "getbrightness", NULL, "i", dbus_getbrightness }, /* deprecated */ - { "setbrightness", "i", "i", dbus_setbrightness }, /* deprecated */ + { "getbrightness", "i", "i", dbus_getbrightness }, /* deprecated */ + { "setbrightness", "ii", "i", dbus_setbrightness }, /* deprecated */ { "setframerate", "ii", "i", dbus_setrefreshrate }, /* deprecated */ { "setautobrightnessmin", "i", "i", dbus_setautobrightnessmin }, { "setlcdtimeout", "iii", "i", dbus_setlcdtimeout }, { "LockScreenBgOn", "s", "i", dbus_lockscreenbgon }, { "GetDisplayCount", NULL, "i", dbus_getdisplaycount }, - { "GetMaxBrightness", NULL, "i", dbus_getmaxbrightness }, + { "GetMaxBrightness", "i", "i", dbus_getmaxbrightness }, { "SetMaxBrightness", "i", "i", dbus_setmaxbrightness }, - { "GetBrightness", NULL, "i", dbus_getbrightness }, - { "SetBrightness", "i", "i", dbus_setbrightness }, + { "GetBrightness", "i", "i", dbus_getbrightness }, + { "SetBrightness", "ii", "i", dbus_setbrightness }, { "HoldBrightness", "i", "i", dbus_holdbrightness }, { "ReleaseBrightness", NULL, "i", dbus_releasebrightness }, { "SetRefreshRate", "ii", "i", dbus_setrefreshrate }, diff --git a/src/libdeviced/display.c b/src/libdeviced/display.c old mode 100644 new mode 100755 index 5df5e3f..63a7c5c --- a/src/libdeviced/display.c +++ b/src/libdeviced/display.c @@ -27,7 +27,6 @@ #define DISPLAY_MAX_BRIGHTNESS 100 #define DISPLAY_MIN_BRIGHTNESS 1 -#define DISPLAY_DIM_BRIGHTNESS 0 #define HOLDKEY_BLOCK_BIT 0x1 -- 2.7.4 From 4afe19f35576a7743908aedd3ad61f14bd419da5 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 9 May 2018 09:07:00 +0900 Subject: [PATCH 14/16] Remove README.error.code Change-Id: I78881d49d62c37f107cc048dc448fed29531bf8d Signed-off-by: Hyotaek Shim --- README.error.code | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 README.error.code diff --git a/README.error.code b/README.error.code deleted file mode 100644 index 61cd9c6..0000000 --- a/README.error.code +++ /dev/null @@ -1,9 +0,0 @@ -DBus Error note - -Functions Defines Values -====================================================================== -dbus_bus_get EPERM 1 -dbus_message_get_args ENOMSG 42 -dbus_connection_send_with_reply_and_block ECOMM 70 -dbus_connection_send ECOMM 70 -dbus_message_new_method_call EBADMSG 74 -- 2.7.4 From 228981a2218315a76a2d9b53bc104ffd4ca79e7f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Szewczyk?= Date: Wed, 7 Mar 2018 14:35:40 +0100 Subject: [PATCH 15/16] usb-host-ffs-test-daemon: Improve error handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - Added ep0 thread for handling disable requests - Errors are handled by simply reseting the threads - Added few race-condition protecting locks and conditions. - Sleep at few critical points (workaround for race conditions that couldn't be identified so far) Change-Id: I9e0f9de975493390251763d6f07eea550b77ed6d Signed-off-by: Paweł Szewczyk --- .../usb-host-ffs-test-daemon.c | 155 +++++++++++++++------ 1 file changed, 110 insertions(+), 45 deletions(-) diff --git a/src/usb-host-ffs-test-daemon/usb-host-ffs-test-daemon.c b/src/usb-host-ffs-test-daemon/usb-host-ffs-test-daemon.c index ecac763..0899f4f 100644 --- a/src/usb-host-ffs-test-daemon/usb-host-ffs-test-daemon.c +++ b/src/usb-host-ffs-test-daemon/usb-host-ffs-test-daemon.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,11 @@ enum { char int_buf[BUFSIZE]; char bulk_buf[BUFSIZE]; +pthread_cond_t enable_cond = PTHREAD_COND_INITIALIZER; +pthread_cond_t disable_cond = PTHREAD_COND_INITIALIZER; +pthread_mutex_t ready_lock; +int connected = 0; + /* Close all ep files */ void cleanup_ffs(int *ep) { @@ -65,42 +71,72 @@ void cleanup_ffs(int *ep) } /* Handle events generated by kernel and provided via ep0 */ -int handle_ep0(int ep0, int *connected) +void *loop_ep0(void *data) { struct usb_functionfs_event event; int ret; + int *ep = data; - ret = read(ep0, &event, sizeof(event)); - if (!ret) { - report_error("unable to read event from ep0"); - return -EIO; - } - - switch (event.type) { - case FUNCTIONFS_SETUP: - /* stall for all setuo requests */ - if (event.u.setup.bRequestType & USB_DIR_IN) { - if (write(ep0, NULL, 0) < 0) - report_error("write error %d", errno); - } else { - if (read(ep0, NULL, 0) < 0) - report_error("read error %d", errno); + while (1) { + ret = read(ep[0], &event, sizeof(event)); + if (!ret) { + report_error("unable to read event from ep0"); + return NULL; } - break; - - case FUNCTIONFS_ENABLE: - *connected = 1; - break; - - case FUNCTIONFS_DISABLE: - *connected = 0; - break; - default: - break; + switch (event.type) { + case FUNCTIONFS_SETUP: + /* stall for all setuo requests */ + if (event.u.setup.bRequestType & USB_DIR_IN) { + if (write(ep[0], NULL, 0) < 0) + report_error("write error %d", errno); + } else { + if (read(ep[0], NULL, 0) < 0) + report_error("read error %d", errno); + } + + fprintf(stderr, "Functionfs setup request\n"); + break; + + case FUNCTIONFS_ENABLE: + usleep(200000); + pthread_mutex_lock(&ready_lock); + fprintf(stderr, "Functionfs enable request\n"); + if (connected) { + report_error("Already enabled!\n"); + pthread_cond_broadcast(&disable_cond); + } + + connected = 1; + pthread_cond_broadcast(&enable_cond); + pthread_mutex_unlock(&ready_lock); + break; + + case FUNCTIONFS_DISABLE: + pthread_mutex_lock(&ready_lock); + fprintf(stderr, "Functionfs disable request\n"); + exit(0); + if (!connected) { + report_error("Already disabled!\n"); + pthread_cond_broadcast(&enable_cond); + } + + connected = 0; + pthread_cond_broadcast(&disable_cond); + pthread_mutex_unlock(&ready_lock); + break; + + case FUNCTIONFS_BIND: + fprintf(stderr, "Functionfs bind request\n"); + break; + + default: + fprintf(stderr, "Functionf unknown request: %d\n", event.type); + break; + } } - return 0; + return NULL; } struct tdata { @@ -114,25 +150,29 @@ void *loop_thread(void *data) struct tdata *d = data; int ret; + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + while (1) { ret = read(d->ep_out, d->buf, BUFSIZE); if (ret < 0) { report_error("read error on fd %d: %m\n", d->ep_out); - if (errno != ECONNRESET && errno != ESHUTDOWN) + usleep(200000); + if (errno != ECONNRESET && errno != ESHUTDOWN && errno != EINTR) exit(ret); - return NULL; + pthread_exit(NULL); } fprintf(stderr, "received %d bytes\n", ret); + usleep(200000); ret = write(d->ep_in, d->buf, ret); if (ret < 0) { report_error("write error on fd %d: %m\n", d->ep_in); - if (errno != ECONNRESET && errno != ESHUTDOWN) + if (errno != ECONNRESET && errno != ESHUTDOWN && errno != EINTR) exit(ret); - return NULL; + pthread_exit(NULL); } fprintf(stderr, "sent %d bytes\n", ret); @@ -141,12 +181,20 @@ void *loop_thread(void *data) return NULL; } +void clear_halt(int ep) +{ + int ret; + + ret = ioctl(ep, FUNCTIONFS_CLEAR_HALT); + if (ret < 0) + fprintf(stderr, "could not reset endpoint %d: %m", ep); +} + /* main chat function */ void do_chat(int *ep) { - int connected = 0; int ret; - pthread_t int_thread, bulk_thread; + pthread_t int_thread, bulk_thread, ep0_thread; struct tdata int_data, bulk_data; int_data.ep_in = ep[EP_IN_INT_IDX]; @@ -156,28 +204,45 @@ void do_chat(int *ep) bulk_data.ep_out = ep[EP_OUT_BULK_IDX]; bulk_data.buf = bulk_buf; + pthread_mutex_init(&ready_lock, NULL); + + ret = pthread_create(&ep0_thread, NULL, loop_ep0, ep); + if (ret < 0) + exit(1); + while (1) { - while (!connected) { - ret = handle_ep0(ep[0], &connected); - if (ret < 0) - return; - } + pthread_mutex_lock(&ready_lock); + if (!connected) + pthread_cond_wait(&enable_cond, &ready_lock); + + fprintf(stderr, "Connected\n"); ret = pthread_create(&bulk_thread, NULL, loop_thread, &bulk_data); if (ret < 0) - return; + exit(1); ret = pthread_create(&int_thread, NULL, loop_thread, &int_data); - if (ret < 0) { - pthread_cancel(bulk_thread); - return; - } + if (ret < 0) + exit(1); + pthread_cond_wait(&disable_cond, &ready_lock); + fprintf(stderr, "Disconnected\n"); + + pthread_cancel(bulk_thread); + pthread_cancel(int_thread); pthread_join(bulk_thread, NULL); pthread_join(int_thread, NULL); - connected = 0; + clear_halt(ep[EP_IN_BULK_IDX]); + clear_halt(ep[EP_OUT_BULK_IDX]); + clear_halt(ep[EP_IN_INT_IDX]); + clear_halt(ep[EP_OUT_INT_IDX]); + + pthread_mutex_unlock(&ready_lock); } + + pthread_join(ep0_thread, NULL); + pthread_mutex_destroy(&ready_lock); } int main(int argc, char **argv) -- 2.7.4 From b4852135817bf6fcf247a2dd5c237af5a15a1ee3 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Wed, 16 May 2018 16:02:26 +0900 Subject: [PATCH 16/16] dbus-policy: remove unnecessary rule Change-Id: Ie0520916de700ec531062b99e099546ab9bd0e2c Signed-off-by: sanghyeok.oh --- conf/org.tizen.system.deviced.conf | 3 --- 1 file changed, 3 deletions(-) diff --git a/conf/org.tizen.system.deviced.conf b/conf/org.tizen.system.deviced.conf index 81c31c6..75ad7f6 100644 --- a/conf/org.tizen.system.deviced.conf +++ b/conf/org.tizen.system.deviced.conf @@ -52,8 +52,5 @@ - - -- 2.7.4