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 01/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 02/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 From 2be723bc1c2bd2b808348cec74fa30346e70187c Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Fri, 18 May 2018 22:25:12 +0900 Subject: [PATCH 03/16] Remove logs in timeout_handler Change-Id: Ibc35dc73f7cd7615b6d37a9853c0505d6d11bdcd Signed-off-by: lokilee73 --- src/display/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/display/core.c b/src/display/core.c index 44f550e..e91264c 100755 --- a/src/display/core.c +++ b/src/display/core.c @@ -674,17 +674,14 @@ gboolean timeout_handler(void *data) { int run_timeout; - _I("Time out state %s\n", states[pm_cur_state].name); /* default setting */ get_run_timeout(&run_timeout); /* for sdk * if the run_timeout is zero, it regards AlwaysOn state */ - if (run_timeout == 0 || display_conf.lcd_always_on) { - _D("run_timeout is always on"); + if (run_timeout == 0 || display_conf.lcd_always_on) return G_SOURCE_CONTINUE; - } if (timeout_src_id) { g_source_remove(timeout_src_id); -- 2.7.4 From a63b2793c19d372649628536b7277f459fd0150c Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Fri, 25 May 2018 16:43:51 +0900 Subject: [PATCH 04/16] Add condition to remove unnecessary logs in timeout_handler Lots of logs in timeout_handler are printed in special condition. LCD always on + changestate of S_LCDOFF by dbus request So, add condition of pm_cur_state to remove timer. Change-Id: Ibaed3baa638097771a53d02028bd0f32694794fb Signed-off-by: lokilee73 --- src/display/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/display/core.c b/src/display/core.c index e91264c..25b8016 100755 --- a/src/display/core.c +++ b/src/display/core.c @@ -674,14 +674,17 @@ gboolean timeout_handler(void *data) { int run_timeout; + _I("Time out state %s\n", states[pm_cur_state].name); /* default setting */ get_run_timeout(&run_timeout); /* for sdk * if the run_timeout is zero, it regards AlwaysOn state */ - if (run_timeout == 0 || display_conf.lcd_always_on) + if (pm_cur_state == S_NORMAL && (run_timeout == 0 || display_conf.lcd_always_on)) { + _D("run_timeout is always on"); return G_SOURCE_CONTINUE; + } if (timeout_src_id) { g_source_remove(timeout_src_id); -- 2.7.4 From 63ac56a1c3945fc2eeec815e5f411adfcff1e502 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 28 May 2018 22:17:20 +0900 Subject: [PATCH 05/16] Sychronize internal apis with ones in device Change-Id: I4023ce26db5befde2da12661e0d3bf5191580cc6 Signed-off-by: lokilee73 --- src/libdeviced/display.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libdeviced/display.c b/src/libdeviced/display.c index 63a7c5c..73a2ec5 100755 --- a/src/libdeviced/display.c +++ b/src/libdeviced/display.c @@ -24,6 +24,7 @@ #include "log.h" #include "common.h" #include "dd-display.h" +#include #define DISPLAY_MAX_BRIGHTNESS 100 #define DISPLAY_MIN_BRIGHTNESS 1 @@ -62,11 +63,11 @@ API int display_get_max_brightness(void) { int ret; - ret = dbus_handle_method_sync(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_GET_MAX_BRIGHTNESS, - NULL, NULL); + g_variant_new("(i)", DISPLAY_STATE_NORMAL)); if (ret < 0) return DISPLAY_MAX_BRIGHTNESS; @@ -85,7 +86,7 @@ API int display_set_brightness_with_setting(int val) DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_SET_BRIGHTNESS, - g_variant_new("(i)", val)); + g_variant_new("(ii)", DISPLAY_STATE_NORMAL, val)); if (ret < 0) _E("no message : failed to setting"); -- 2.7.4 From 21859f00e5e5a8a76469d5982f8356b6620d8506 Mon Sep 17 00:00:00 2001 From: Donghwan Jeong Date: Fri, 25 May 2018 13:40:25 +0900 Subject: [PATCH 06/16] pm: set powerlock at deviced init time While the powerlock is unlocked, system can fall asleep even at the Normal state. For instance, you can see this problem right after deviced is restarted by suspend-time crash. Change-Id: Ibb5422409de1cf45d7e70df25c58b0f6bea0e049 Signed-off-by: Donghwan Jeong Signed-off-by: Hyotaek Shim --- src/display/core.c | 47 +++++++++++++++++++++--------------------- src/display/core.h | 1 - src/display/device-interface.c | 2 +- src/display/device-interface.h | 4 +--- 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/display/core.c b/src/display/core.c index 25b8016..f5be97b 100755 --- a/src/display/core.c +++ b/src/display/core.c @@ -2194,7 +2194,6 @@ static int display_probe(void *data) static void display_init(void *data) { int ret, i; - unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS); int timeout = 0; bool wm_ready; @@ -2224,7 +2223,7 @@ static void display_init(void *data) case INIT_INTERFACE: if (display_conf.timeout_enable) get_lcd_timeout_from_settings(); - ret = init_sysfs(flags); + ret = init_sysfs(); break; case INIT_POLL: _I("input init"); @@ -2267,33 +2266,33 @@ static void display_init(void *data) trans_table[S_NORMAL][EVENT_TIMEOUT] = S_NORMAL; } - if (flags & WITHOUT_STARTNOTI) { /* start without noti */ - _I("Start Power managing without noti"); - pm_cur_state = S_NORMAL; - set_setting_pmstate(pm_cur_state); - - if (display_conf.timeout_enable) { - timeout = states[S_NORMAL].timeout; - /* check minimun lcd on time */ - if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) - timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT); + _I("Start Power managing without noti"); + if (power_ops.get_power_lock_support()) + power_ops.power_lock(); - reset_timeout(timeout); - } + pm_cur_state = S_NORMAL; + set_setting_pmstate(pm_cur_state); - status = DEVICE_OPS_STATUS_START; - /* - * Lock lcd off until booting is done. - * deviced guarantees all booting script is executing. - * Last script of booting unlocks this suspend blocking state. - */ - pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, - STAY_CUR_STATE, BOOTING_DONE_WATING_TIME); - pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, - STAY_CUR_STATE, BOOTING_DONE_WATING_TIME); + if (display_conf.timeout_enable) { + timeout = states[S_NORMAL].timeout; + /* check minimun lcd on time */ + if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) + timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT); + reset_timeout(timeout); } + status = DEVICE_OPS_STATUS_START; + /* + * Lock lcd off until booting is done. + * deviced guarantees all booting script is executing. + * Last script of booting unlocks this suspend blocking state. + */ + pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, + STAY_CUR_STATE, BOOTING_DONE_WATING_TIME); + pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, + STAY_CUR_STATE, BOOTING_DONE_WATING_TIME); + if (display_conf.input_support) if (CHECK_OPS(keyfilter_ops, init)) keyfilter_ops->init(); diff --git a/src/display/core.h b/src/display/core.h index 57261de..298a170 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -28,7 +28,6 @@ #include "device-interface.h" #include "setting.h" -#define WITHOUT_STARTNOTI 0x1 #define MASK_BIT 0x7 /* 111 */ #define MASK_NORMAL 0x1 /* 001 */ #define MASK_DIM 0x2 /* 010 */ diff --git a/src/display/device-interface.c b/src/display/device-interface.c index 1aa0c50..4d77030 100755 --- a/src/display/device-interface.c +++ b/src/display/device-interface.c @@ -665,7 +665,7 @@ int display_service_free(void) return 0; } -int init_sysfs(unsigned int flags) +int init_sysfs() { _init_ops(); return 0; diff --git a/src/display/device-interface.h b/src/display/device-interface.h index 88e25cf..7f2be5c 100755 --- a/src/display/device-interface.h +++ b/src/display/device-interface.h @@ -27,8 +27,6 @@ #include #include "core/devices.h" -#define FLAG_X_DPMS 0x2 - #define DEFAULT_DISPLAY 0 #define PM_MAX_BRIGHTNESS 100 @@ -52,7 +50,7 @@ enum { EVENT_END, }; -int init_sysfs(unsigned int); +int init_sysfs(void); int exit_sysfs(void); int display_service_load(void); int display_service_free(void); -- 2.7.4 From 657fd9b698c0e09a5dde54b7a4247a1b484b6f19 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Fri, 1 Jun 2018 11:18:24 +0900 Subject: [PATCH 07/16] libdeviced: Remove unused internal APIs - RequestSecureMount and RequestSecureUnmount doesn't exist. Change-Id: I3fa24b8a4b245f102dca56bf004400ceaa84fa6c Signed-off-by: pr.jung --- src/libdeviced/mmc.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/libdeviced/mmc.c b/src/libdeviced/mmc.c index f1c6484..9879325 100644 --- a/src/libdeviced/mmc.c +++ b/src/libdeviced/mmc.c @@ -28,39 +28,12 @@ #include "common.h" #include "dd-mmc.h" -#define METHOD_REQUEST_SECURE_MOUNT "RequestSecureMount" -#define METHOD_REQUEST_SECURE_UNMOUNT "RequestSecureUnmount" - #define ODE_MOUNT_STATE 1 #define FORMAT_TIMEOUT (120*1000) #define STORAGE_MMC 1 #define BUF_MAX 256 -API int mmc_secure_mount(const char *mount_point) -{ - if (mount_point == NULL) - return -EINVAL; - - return dbus_handle_method_sync_var(DEVICED_BUS_NAME, - DEVICED_PATH_MMC, - DEVICED_INTERFACE_MMC, - METHOD_REQUEST_SECURE_MOUNT, - g_variant_new("(s)", mount_point)); -} - -API int mmc_secure_unmount(const char *mount_point) -{ - if (mount_point == NULL) - return -EINVAL; - - return dbus_handle_method_sync_var(DEVICED_BUS_NAME, - DEVICED_PATH_MMC, - DEVICED_INTERFACE_MMC, - METHOD_REQUEST_SECURE_UNMOUNT, - g_variant_new("(s)", mount_point)); -} - static int get_mmc_primary_id() { GVariant *reply; -- 2.7.4 From 31bb400a292fc59beeca245fca4d83bb7f15ef67 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Fri, 8 Jun 2018 10:57:36 +0900 Subject: [PATCH 08/16] Fix dbus policy to allow group users in Tzip Change-Id: Ibc76b9c7c1c562286e82974937bdd54204e68bc1 Signed-off-by: Hyotaek Shim --- conf/org.tizen.system.deviced.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf/org.tizen.system.deviced.conf b/conf/org.tizen.system.deviced.conf index 75ad7f6..1063ff8 100644 --- a/conf/org.tizen.system.deviced.conf +++ b/conf/org.tizen.system.deviced.conf @@ -14,6 +14,10 @@ + + + + -- 2.7.4 From 16cb612e1598379c28b3230ba40099fd8bd7c880 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 11 Jun 2018 14:02:30 +0900 Subject: [PATCH 09/16] Modify WATCHDOG_TIMEOUT to 5 seconds Change-Id: I41f635437cb8c6930780efbac4548311d5eeffce Signed-off-by: Hyotaek Shim --- src/core/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/main.c b/src/core/main.c index 8d4768c..0ce5b03 100755 --- a/src/core/main.c +++ b/src/core/main.c @@ -33,7 +33,7 @@ #include "device-notifier.h" #define PIDFILE_PATH "/var/run/.deviced.pid" -#define WATCHDOG_TIMEOUT 15 +#define WATCHDOG_TIMEOUT 5 static GMainLoop *mainloop; -- 2.7.4 From 95359826ccd4cbc45a262e289615a048f2cc8dcc Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 11 Jun 2018 14:16:27 +0900 Subject: [PATCH 10/16] Add a debugging code for blocked dpms_get_power() Program terminated with signal SIGABRT, Aborted. #0 0xb68c1964 in poll () at ../sysdeps/unix/syscall-template.S:84 84 ../sysdeps/unix/syscall-template.S: No such file or directory. [Current thread is 1 (Thread 0xb6f4a180 (LWP 7281))] (gdb) bt #0 0xb68c1964 in poll () at ../sysdeps/unix/syscall-template.S:84 #1 0xb6b7fc18 in g_main_context_poll (priority=, n_fds=1, fds=0xb8c177a8, timeout=, context=0xb8c10cf0) at gmain.c:4259 #2 g_main_context_iterate (context=0xb8c10cf0, block=block@entry=1, dispatch=dispatch@entry=1, self=) at gmain.c:3955 #3 0xb6b7ffd8 in g_main_loop_run (loop=0xb8c10800) at gmain.c:4156 #4 0xb6e3f5c0 in g_dbus_connection_send_message_with_reply_sync ( connection=connection@entry=0xb8bd0868, message=message@entry=0xb51d8630, flags=G_DBUS_SEND_MESSAGE_FLAGS_NONE, timeout_msec=10000, timeout_msec@entry=-1225985936, out_serial=out_serial@entry=0x0, cancellable=0x0, error=0xbeb38994, error@entry=0xbeb3898c) at gdbusconnection.c:2844 #5 0xb6e3fb70 in g_dbus_connection_call_sync_internal (connection=0xb8bd0868, bus_name=, object_path=object_path@entry=0xb6f9f0f4 "/org/enlightenment/wm", interface_name=0xb6f9f0d8 "org.enlightenment.wm.dpms", method_name=, method_name@entry=0xb6f9f0f4 "/org/enlightenment/wm", parameters=0x0, parameters@entry=0xb6c9bce1 , reply_type=reply_type@entry=0xb6fa02a8, flags=flags@entry=G_DBUS_CALL_FLAGS_NONE, timeout_msec=timeout_msec@entry=10000, fd_list=fd_list@entry=0x0, out_fd_list=out_fd_list@entry=0x0, cancellable=cancellable@entry=0x0, error=0xbeb38a24, error@entry=0x2710) at gdbusconnection.c:6901 #6 0xb6e42294 in g_dbus_connection_call_sync (connection=, bus_name=, object_path=object_path@entry=0xb6f9f0f4 "/org/enlightenment/wm", interface_name=, method_name=method_name@entry=0xb6fa02a8 "get", parameters=parameters@entry=0x0, reply_type=reply_type@entry=0x0, flags=flags@entry=G_DBUS_CALL_FLAGS_NONE, timeout_msec=timeout_msec@entry=10000, cancellable=cancellable@entry=0x0, error=error@entry=0xbeb38a24) at gdbusconnection.c:7128 #7 0xb6c9bce0 in dbus_handle_method_sync (dest=, path=0xb6f9f0f4 "/org/enlightenment/wm", iface=, method=0xb6fa02a8 "get", signature=signature@entry=0x0, param=param@entry=0x0) at /usr/src/debug/libsyscommon-4.1/src/libgdbus/dbus-system.c:1994 #8 0xb6f87100 in dpms_get_power (state=0xbeb38a6c) at /usr/src/debug/deviced-5.0.0/src/display/dpms-wayland-none.c:90 Change-Id: Ia53fb83140509b9ed4db213df2ef09af1ae2f649 Signed-off-by: Hyotaek Shim --- src/display/dpms-wayland-none.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/display/dpms-wayland-none.c b/src/display/dpms-wayland-none.c index cf1db2e..4e3edbc 100644 --- a/src/display/dpms-wayland-none.c +++ b/src/display/dpms-wayland-none.c @@ -80,20 +80,29 @@ int dpms_set_power(enum dpms_state state) return 0; } +#define DPMS_TIMEOUT 5000 +#define DPMS_GET_MAX_RETRY 3 int dpms_get_power(enum dpms_state *state) { + int try = 0; int ret; if (!state) return -EINVAL; - ret = dbus_handle_method_sync(ENLIGHTENMENT_BUS_NAME, - ENLIGHTENMENT_OBJECT_PATH, - ENLIGHTENMENT_INTERFACE_NAME, - "get", - NULL, NULL); - if (ret < 0) - return ret; + do { + try++; + if (try > DPMS_GET_MAX_RETRY) { + _E("Dbus Timeout occurred %d times in a row.", DPMS_GET_MAX_RETRY); + assert(0); + } + + ret = dbus_handle_method_sync_timeout(ENLIGHTENMENT_BUS_NAME, + ENLIGHTENMENT_OBJECT_PATH, + ENLIGHTENMENT_INTERFACE_NAME, + "get", + NULL, NULL, DPMS_TIMEOUT); + } while (ret < 0); *state = ret; return 0; -- 2.7.4 From aec291266b94fe4ed55102d4a1a364dcc85211f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Szewczyk?= Date: Wed, 13 Jun 2018 11:44:16 +0200 Subject: [PATCH 11/16] usbhost: Fix signature of OpenDevice result MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The OpenDevice method is expected to return two values: return code and a file descriptor. Change-Id: I523f7a74a132e6aef198fb97d1f58d64a2901367 Signed-off-by: Paweł Szewczyk --- src/usbhost/usb-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usbhost/usb-host.c b/src/usbhost/usb-host.c index 24876f2..79f97e7 100644 --- a/src/usbhost/usb-host.c +++ b/src/usbhost/usb-host.c @@ -833,7 +833,7 @@ static void finish_opening(struct usbhost_open_request *req, int policy) goto out; } - g_dbus_method_invocation_return_value_with_unix_fd_list(req->invocation, g_variant_new("(i)", ret), fd_list); + g_dbus_method_invocation_return_value_with_unix_fd_list(req->invocation, g_variant_new("(ih)", ret, 0), fd_list); g_object_unref(fd_list); -- 2.7.4 From a9ab28b52d7e38c272194629ecd26cdb45d7784d Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Tue, 19 Jun 2018 14:26:55 +0900 Subject: [PATCH 12/16] Revert "Add a debugging code for blocked dpms_get_power()" This reverts commit 95359826ccd4cbc45a262e289615a048f2cc8dcc. Change-Id: Idf8c02227c1534637a8aad025764fe177f8da9b0 Signed-off-by: Hyotaek Shim --- src/display/dpms-wayland-none.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/display/dpms-wayland-none.c b/src/display/dpms-wayland-none.c index 4e3edbc..cf1db2e 100644 --- a/src/display/dpms-wayland-none.c +++ b/src/display/dpms-wayland-none.c @@ -80,29 +80,20 @@ int dpms_set_power(enum dpms_state state) return 0; } -#define DPMS_TIMEOUT 5000 -#define DPMS_GET_MAX_RETRY 3 int dpms_get_power(enum dpms_state *state) { - int try = 0; int ret; if (!state) return -EINVAL; - do { - try++; - if (try > DPMS_GET_MAX_RETRY) { - _E("Dbus Timeout occurred %d times in a row.", DPMS_GET_MAX_RETRY); - assert(0); - } - - ret = dbus_handle_method_sync_timeout(ENLIGHTENMENT_BUS_NAME, - ENLIGHTENMENT_OBJECT_PATH, - ENLIGHTENMENT_INTERFACE_NAME, - "get", - NULL, NULL, DPMS_TIMEOUT); - } while (ret < 0); + ret = dbus_handle_method_sync(ENLIGHTENMENT_BUS_NAME, + ENLIGHTENMENT_OBJECT_PATH, + ENLIGHTENMENT_INTERFACE_NAME, + "get", + NULL, NULL); + if (ret < 0) + return ret; *state = ret; return 0; -- 2.7.4 From bbeb204e57fb68e210377deefa794c8b1cf46fc7 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 19 Jun 2018 20:43:11 +0900 Subject: [PATCH 13/16] Add privilege check for dbus_changestate Change-Id: I7b65c139857ad85830f8e4a89e7745bf25874329 Signed-off-by: lokilee73 --- src/display/display-dbus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index 04fcbe7..02bc8c4 100755 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -255,7 +255,7 @@ GVariant *dbus_changestate(GDBusConnection *conn, char *state_str; pid_t pid; int state; - int ret; + int ret = 0; unsigned int caps; CHECK_POWEROFF(); @@ -268,6 +268,9 @@ GVariant *dbus_changestate(GDBusConnection *conn, goto out; } + if (!strcmp(state_str, "privilege check")) + goto out; + pid = dbus_connection_get_sender_pid(conn, sender); if (kill(pid, 0) == -1) { _E("%d process does not exist, dbus ignored!", pid); -- 2.7.4 From 77c2212f78e24fcd23c2dab22c6e71f965c11fb6 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 20 Jun 2018 13:23:35 +0900 Subject: [PATCH 14/16] Refactoring on check_lcd_is_on() return values Change-Id: I82398431e64c5d9d94da0ba46979ddecf90b00fc Signed-off-by: Hyotaek Shim --- src/display/core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/display/core.c b/src/display/core.c index f5be97b..9a8f743 100755 --- a/src/display/core.c +++ b/src/display/core.c @@ -839,12 +839,12 @@ void lcd_on_direct(enum device_flags flags) update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT); } -static inline bool check_lcd_on(void) +static inline bool check_lcd_is_on(void) { if (backlight_ops.get_lcd_power() != DPMS_ON) - return true; + return false; - return false; + return true; } int custom_lcdon(int timeout) @@ -854,7 +854,7 @@ int custom_lcdon(int timeout) if (timeout <= 0) return -EINVAL; - if (check_lcd_on() == true) + if (check_lcd_is_on() == false) lcd_on_direct(LCD_ON_BY_GESTURE); _I("custom lcd on %d ms", timeout); @@ -899,7 +899,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) switch (next) { case S_NORMAL: - if (check_lcd_on()) + if (check_lcd_is_on() == false) lcd_on_direct(LCD_ON_BY_EVENT); update_display_locktime(LOCK_SCREEN_CONTROL_TIMEOUT); default_proc_change_state_action(next, -1); @@ -1446,7 +1446,7 @@ static gboolean lcd_on_expired(void *data) return G_SOURCE_REMOVE; /* lock screen is not launched yet, but lcd is on */ - if (check_lcd_on() == true) + if (check_lcd_is_on() == false) lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); return G_SOURCE_REMOVE; @@ -1487,7 +1487,7 @@ static void check_lock_screen(void) return; lcd_on: - if (check_lcd_on() == true) + if (check_lcd_is_on() == false) lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); } @@ -1550,7 +1550,7 @@ static int default_action(int timeout) else if (pm_old_state == S_LCDDIM) backlight_ops.update(); - if (check_lcd_on() == true) + if (check_lcd_is_on() == false) lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); break; -- 2.7.4 From 2c12d72288443851be1408b4613e74b3df1a35c4 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 21 Jun 2018 16:00:41 +0900 Subject: [PATCH 15/16] Fix dbus returned error by unmatched signature between deviced and system-popup Change-Id: I00ed9d5acf2c4f19a0e5488c74a4e7a7c358c3d2 Signed-off-by: lokilee73 --- src/apps/apps.c | 37 ++++++++++++++++++---- .../usb-host-ffs-test-daemon.c | 1 + 2 files changed, 32 insertions(+), 6 deletions(-) mode change 100644 => 100755 src/apps/apps.c mode change 100644 => 100755 src/usb-host-ffs-test-daemon/usb-host-ffs-test-daemon.c diff --git a/src/apps/apps.c b/src/apps/apps.c old mode 100644 new mode 100755 index b49b291..91b9cba --- a/src/apps/apps.c +++ b/src/apps/apps.c @@ -36,6 +36,27 @@ static const struct app_dbus_match { { APP_OVERHEAT, POPUP_BUS_NAME, POPUP_PATH_OVERHEAT, POPUP_INTERFACE_OVERHEAT, POPUP_METHOD }, }; +static void __cb(GVariant *var, void *user_data, GError *err) +{ + int ret; + + if (!var) { + _E("no message [%s]", err->message); + return; + } + + if (!dh_get_param_from_var(var, "(i)", &ret)) { + _E("no message [%s]", g_variant_get_type_string(var)); + goto out; + } + + _D("reply value : %d", ret); + +out: + g_variant_unref(var); +} + + int launch_system_app(char *type, int num, ...) { char *app_type; @@ -50,7 +71,7 @@ int launch_system_app(char *type, int num, ...) match = -1; for (i = 0 ; i < ARRAY_SIZE(app_match) ; i++) { if (strncmp(app_type, app_match[i].type, strlen(app_type))) - continue; + continue; match = i; break; } @@ -61,11 +82,15 @@ int launch_system_app(char *type, int num, ...) va_start(args, num); - ret = dbus_handle_method_async_pairs(app_match[match].bus, - app_match[match].path, - app_match[match].iface, - app_match[match].method, - num, args); + ret = dbus_handle_method_async_pairs_with_reply(app_match[match].bus, + app_match[match].path, + app_match[match].iface, + app_match[match].method, + num, + args, + __cb, + -1, + NULL); va_end(args); pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); 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 old mode 100644 new mode 100755 index 0899f4f..48051be --- 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 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include -- 2.7.4 From 692a287c41f913b518d036ead6f50a6a558f242e Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 25 Jun 2018 10:43:32 +0900 Subject: [PATCH 16/16] To fix dbus policy error with dpm Change policy user from system_fw to security_fw Change-Id: Ie79eb6e059746ca3a4042124b857e7eb03786e2d Signed-off-by: lokilee73 --- conf/org.tizen.system.deviced.conf | 3 +++ 1 file changed, 3 insertions(+) mode change 100644 => 100755 conf/org.tizen.system.deviced.conf diff --git a/conf/org.tizen.system.deviced.conf b/conf/org.tizen.system.deviced.conf old mode 100644 new mode 100755 index 1063ff8..83f4d1a --- a/conf/org.tizen.system.deviced.conf +++ b/conf/org.tizen.system.deviced.conf @@ -9,6 +9,9 @@ + + + -- 2.7.4