From 54a7e2699c39fe10fd28fb57ba4cb32002bcf5e3 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 24 Jul 2018 19:41:57 +0900 Subject: [PATCH 01/16] Change notification method from synchronization to asynchronization for battery and temperature There was a bug that caused delayed boot-up issue because of media notification. Basically, we don't have to wait until notification is finished. The same bug can be protected by chaning notification way to asynchronization Change-Id: I52c8bd9d752b2ed4178090fd6ecdc78b0a9a9a0d Signed-off-by: lokilee73 --- src/apps/apps.c | 34 ----------------------------- src/apps/apps.h | 1 - src/battery/lowbat-handler.c | 52 +++++++++++++++++++++++++++++++++++++++----- src/thermal/thermal.c | 31 ++++++++++++++++++++++++-- 4 files changed, 75 insertions(+), 43 deletions(-) diff --git a/src/apps/apps.c b/src/apps/apps.c index 4af8ee0..cf72e6c 100755 --- a/src/apps/apps.c +++ b/src/apps/apps.c @@ -114,40 +114,6 @@ int launch_message_post(char *type) return ret; } -int add_sync_notification(char *type, char *sig, ...) -{ - int ret; - int count; - int len; - char *data = NULL; - const char *param[BUFF_MAX] = {NULL}; - va_list args; - - if (!type) - return -EINVAL; - - if (sig) { - len = strlen(sig); - va_start(args, sig); - - for (count = 0; count < len; count++) { - data = va_arg(args, char *); - param[count] = data; - } - - va_end(args); - } - - ret = dbus_handle_method_sync(POPUP_BUS_NAME, - POPUP_PATH_NOTI, - POPUP_INTERFACE_NOTI, - type, - sig, - param); - - return ret; -} - int add_async_notification(char *type, dbus_pending_cb func, char *sig, ...) { int ret; diff --git a/src/apps/apps.h b/src/apps/apps.h index 1621d06..9f62771 100755 --- a/src/apps/apps.h +++ b/src/apps/apps.h @@ -31,7 +31,6 @@ int launch_system_app(char *type, int num, ...); int launch_message_post(char *type); -int add_sync_notification(char *type, char *sig, ...); int add_async_notification(char *type, dbus_pending_cb func, char *sig, ...); int remove_notification(char *type, int id); diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 0df328d..f944aa8 100755 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -305,6 +305,50 @@ static int get_lowbat_noti_value(int low_battery_type, char **active_noti, char return ret; } +static void event_noti_cb(GVariant *var, void *user_data, GError *err) +{ + int id = 0; + + if (!var) { + if (err) + _E("%s", err->message); + return; + } + + if (!dh_get_param_from_var(var, "(i)", &id)) { + _E("no message [%s]", g_variant_get_type_string(var)); + goto out; + } + + event_noti_num = id; + _D("event noti : %d", event_noti_num); + +out: + g_variant_unref(var); +} + +static void active_noti_cb(GVariant *var, void *user_data, GError *err) +{ + int id = 0; + + if (!var) { + if (err) + _E("%s", err->message); + return; + } + + if (!dh_get_param_from_var(var, "(i)", &id)) { + _E("no message [%s]", g_variant_get_type_string(var)); + goto out; + } + + active_noti_num = id; + _D("active noti : %d", active_noti_num); + +out: + g_variant_unref(var); +} + int lowbat_popup(char *option) { static int launched_poweroff; @@ -396,11 +440,9 @@ direct_launch: event_noti_num = -1; } - ret = add_sync_notification(event_noti, NULL, NULL); + ret = add_async_notification(event_noti, event_noti_cb, NULL, NULL); if (ret < 0) _E("Failed to launch event_noti : %d", ret); - else - event_noti_num = ret; if (active_noti_num > 0) { ret = remove_notification("BatteryLowCriticalNotiOff", active_noti_num); @@ -411,11 +453,9 @@ direct_launch: } snprintf(temp, sizeof(temp), "%d", cur_bat_capacity); - ret = add_sync_notification(active_noti, "s", temp); + ret = add_async_notification(active_noti, active_noti_cb, "s", temp); if (ret < 0) _E("Failed to launch active noti : %d", ret); - else - active_noti_num = ret; _D("active_noti = %d, event_noti = %d", active_noti_num, event_noti_num); return 0; diff --git a/src/thermal/thermal.c b/src/thermal/thermal.c index 64366f4..cc16557 100755 --- a/src/thermal/thermal.c +++ b/src/thermal/thermal.c @@ -94,11 +94,38 @@ static void thermal_remove_popup(void) _E("Fail to launch remove_cooldown_popups"); } +static void thermal_noti_cb(GVariant *var, void *user_data, GError *err) +{ + int id = 0; + + if (!var) { + if (err) + _E("%s", err->message); + return; + } + + if (!dh_get_param_from_var(var, "(i)", &id)) { + _E("no message [%s]", g_variant_get_type_string(var)); + goto out; + } + + noti = id; + _D("thermal noti : %d", noti); + +out: + g_variant_unref(var); +} + static void thermal_add_noti(void) { + int ret = 0; + thermal_remove_noti(); - if (!noti) - noti = add_sync_notification("TempCooldownNotiOn", NULL, NULL); + if (!noti) { + ret = add_async_notification("TempCooldownNotiOn", thermal_noti_cb, NULL, NULL); + if (ret < 0) + _E("Failed to show notification for temperature"); + } } static void broadcast_thermal_state_legacy(const char *action_type) -- 2.7.4 From 926bc710c69a2ff62bb4728c2269c9da3097b429 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Wed, 25 Jul 2018 11:36:38 +0900 Subject: [PATCH 02/16] Remove delay time for power off animation Time for power off animation is guanranteed by resourced. Change-Id: I7bd70ca3c31f66d20a918a838e5d4ab11e484dfe Signed-off-by: lokilee73 --- src/power/power-handler.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/power/power-handler.c b/src/power/power-handler.c index d098697..99bd308 100755 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -300,7 +300,6 @@ static void poweroff_start_animation(void) if (ret < 0) _E("Failed to start shutdown animation"); - usleep(500000); gettimeofday(&tv_start_poweroff, NULL); } -- 2.7.4 From 47d9ccf43a07537a2d37ed0fc9df86943f956feb Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 25 Jul 2018 16:58:46 +0900 Subject: [PATCH 03/16] Minor fixes on poweroff functions Change-Id: I9edb6c0692cbcb86b0abe63673a8ef5faa95a111 Signed-off-by: Hyotaek Shim --- src/power/power-handler.c | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/power/power-handler.c b/src/power/power-handler.c index 99bd308..661a845 100755 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -180,18 +180,6 @@ static int stop_systemd_journald(void) return 0; } -static void stop_systemd_service(void) -{ - _I("Request to stop systemd service to resourced"); - dbus_handle_method_sync_timeout(RESOURCED_BUS_NAME, - RESOURCED_PATH_PROCESS, - RESOURCED_INTERFACE_PROCESS, - "PrePoweroff", - NULL, - NULL, - POWEROFF_WAIT_RESOURCED); -} - /* umount usr data partition */ static void unmount_rw_partition(void) { @@ -292,17 +280,6 @@ static void system_shutdown_send_system_event(void) bundle_free(b); } -static void poweroff_start_animation(void) -{ - int ret; - - ret = deviced_systemd_start_unit("shutdown-animation.service"); - if (ret < 0) - _E("Failed to start shutdown animation"); - - gettimeofday(&tv_start_poweroff, NULL); -} - static int pwroff_popup(void) { return launch_system_app(APP_POWERKEY, @@ -433,6 +410,29 @@ static void make_power_flag(enum poweroff_type type, char *option) close(fd); } +static void poweroff_start_animation(void) +{ + int ret; + + ret = deviced_systemd_start_unit("shutdown-animation.service"); + if (ret < 0) + _E("Failed to start shutdown animation"); + + gettimeofday(&tv_start_poweroff, NULL); +} + +static void poweroff_notify_resourced(void) +{ + _I("Request to stop systemd service to resourced"); + dbus_handle_method_sync_timeout(RESOURCED_BUS_NAME, + RESOURCED_PATH_PROCESS, + RESOURCED_INTERFACE_PROCESS, + "PrePoweroff", + NULL, + NULL, + POWEROFF_WAIT_RESOURCED); +} + /* * Notice : Don't change sequence of poweroff_fixed_flow * It will make blocking issue during poweroff @@ -442,7 +442,7 @@ static void poweroff_fixed_flow(enum poweroff_type type) int off = (int)type; poweroff_start_animation(); - stop_systemd_service(); + poweroff_notify_resourced(); device_notify(DEVICE_NOTIFIER_POWEROFF, &off); } -- 2.7.4 From c064c43c29717bf0c20cc015fef1c9a1496a48dd Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 26 Jul 2018 11:01:04 +0900 Subject: [PATCH 04/16] Remove X related code Display server was already changed to Wayland. So, X related code is removed. Change-Id: Id9d8ebe174e6eb98230a42310ba1b7daa6b89bf2 Signed-off-by: lokilee73 --- src/display/device-interface.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/display/device-interface.c b/src/display/device-interface.c index 8531cd8..3e7144f 100755 --- a/src/display/device-interface.c +++ b/src/display/device-interface.c @@ -695,15 +695,8 @@ int init_sysfs() int exit_sysfs(void) { - int fd; const struct device_ops *ops = NULL; - fd = open("/tmp/sem.pixmap_1", O_RDONLY); - if (fd == -1) { - _E("X server disable"); - backlight_on(NORMAL_MODE); - } - backlight_update(); ops = find_device("touchscreen"); @@ -714,8 +707,5 @@ int exit_sysfs(void) if (!check_default(ops)) ops->start(NORMAL_MODE); - if (fd != -1) - close(fd); - return 0; } -- 2.7.4 From 366f9f577a0504e121c7f3dd1809d29230788996 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Fri, 27 Jul 2018 15:23:27 +0900 Subject: [PATCH 05/16] coverity fix Change-Id: I5c3518dcb897fa95f49fcb7dd34b5ce8ae5bc232 Signed-off-by: sanghyeok.oh --- src/core/common.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/common.c b/src/core/common.c index a79f080..42dcf54 100755 --- a/src/core/common.c +++ b/src/core/common.c @@ -395,6 +395,9 @@ static int freeze_processes_on_path(const char *frz_name, const char *part_path) freezer_fd = open(freezer_state, O_RDWR); free(freezer_state); + if (freezer_fd < 0) + return -1; + ret = write(freezer_fd, CMD_FROZEN, strlen(CMD_FROZEN)); close(freezer_fd); if (ret < 0) @@ -448,6 +451,9 @@ static int thaw_processes_on_path(const char *frz_name) freezer_fd = open(freezer_state, O_RDWR); free(freezer_state); + if (freezer_fd < 0) + return -1; + ret = write(freezer_fd, CMD_THAWED, strlen(CMD_THAWED)); close(freezer_fd); if (ret < 0) -- 2.7.4 From 385c7c73eff7b2bf7bff0d7a0e9bbb1989da4791 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Thu, 9 Aug 2018 10:06:39 +0900 Subject: [PATCH 06/16] coverity fix Change-Id: I8f26ba62367c6087350dfca570e7cf3e1a584fc6 Signed-off-by: sanghyeok.oh --- src/core/common.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/common.c b/src/core/common.c index 42dcf54..eacbf4f 100755 --- a/src/core/common.c +++ b/src/core/common.c @@ -374,6 +374,11 @@ static int freeze_processes_on_path(const char *frz_name, const char *part_path) task_fd = open(freezer_procs, O_RDWR); free(freezer_procs); + if (task_fd < 0) { + pclose(fuser_fp); + return -1; + } + while (getline(&line, &len, fuser_fp) != -1) { int ret; int str_len = strlen(line); -- 2.7.4 From d5171d5c336d776401bea50060df14e59761946d Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 13 Aug 2018 21:11:22 +0900 Subject: [PATCH 07/16] Fix devices_init procedure to prevent starting dev before probing Change-Id: I3fac32e208cd6412e0646bbf9c047b2730e9eed9 Signed-off-by: Hyotaek Shim --- src/core/devices.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/devices.c b/src/core/devices.c index 8df13be..6dba16c 100644 --- a/src/core/devices.c +++ b/src/core/devices.c @@ -103,23 +103,25 @@ void devices_init(void *data) DD_LIST_FOREACH_SAFE(dev_head, elem, elem_n, dev) { if (dev->probe && dev->probe(data) != 0) { - _E("[%s] probe fail", dev->name); + _E("[%s] Failed to probe", dev->name); DD_LIST_REMOVE(dev_head, dev); continue; } + } - _D("[%s] initialize", dev->name); + DD_LIST_FOREACH_SAFE(dev_head, elem, elem_n, dev) { + _D("[%s] Initialization", dev->name); if (dev->init) dev->init(data); } ret = dbus_handle_add_dbus_object(NULL, DEVICED_PATH_CORE, &dbus_interface); if (ret < 0) - _E("fail to init dbus method(%d)", ret); + _E("Failed to init dbus method: ret=%d", ret); /* register every objects */ if (dbus_handle_register_dbus_object_all(NULL) < 0) - _E("Failed to register dbus method! %d", ret); + _E("Failed to register dbus method: ret=%d", ret); } void devices_exit(void *data) -- 2.7.4 From aadde800d3b3bc5e59a9487e8d05a36a2c1d07dd Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Tue, 14 Aug 2018 14:03:22 +0900 Subject: [PATCH 08/16] dbus: remove inappropriate usage of gdbus proxy Change-Id: Ief812a5cf282fb2113e18fea7e5dde19c52b8ba1 Signed-off-by: sanghyeok.oh --- src/power/boot.c | 23 +++-- src/shared/deviced-systemd.c | 212 ++++++++++++++++++++++--------------------- src/shared/deviced-systemd.h | 8 +- 3 files changed, 130 insertions(+), 113 deletions(-) diff --git a/src/power/boot.c b/src/power/boot.c index e6e95b5..a7e6638 100644 --- a/src/power/boot.c +++ b/src/power/boot.c @@ -38,17 +38,19 @@ int booting_finished(void) { - char *state; - int ret; + char *state = NULL; + int ret = 0; size_t len; + GVariant *reply = NULL; - ret = deviced_systemd_get_manager_property_as_string( - SYSTEMD_DBUS_IFACE_MANAGER, - SYSTEMD_DBUS_METHOD_SYSTEM_STATE, - &state); - if (ret < 0) { - _E("Failed to get System State (%d)", ret); - return ret; + reply = deviced_systemd_get_manager_property(SYSTEMD_DBUS_METHOD_SYSTEM_STATE); + if (!reply) { + _E("Failed to get System State: no reply"); + goto err; + } + if (!dh_get_param_from_var(reply, "s", &state)) { + _E("Failed to get System State %s", g_variant_get_type_string(reply)); + goto err; } _I("System State: (%s)", state); @@ -60,6 +62,9 @@ int booting_finished(void) else ret = 0; +err: + if (reply) + g_variant_unref(reply); free(state); return ret; diff --git a/src/shared/deviced-systemd.c b/src/shared/deviced-systemd.c index d4a85b1..67da906 100644 --- a/src/shared/deviced-systemd.c +++ b/src/shared/deviced-systemd.c @@ -110,46 +110,48 @@ static int deviced_systemd_proxy_call_sync(const char *name, static int deviced_systemd_start_or_stop_unit(char *method, char *name) { - int ret; GVariant *reply = NULL; + gchar *objpath = NULL; + int ret = 0; _I("Starting: %s %s", method, name); - ret = deviced_systemd_proxy_call_sync(SYSTEMD_DBUS_DEST, - SYSTEMD_DBUS_PATH, - SYSTEMD_DBUS_IFACE_MANAGER, - method, - g_variant_new("(ss)", - name, - "replace"), - &reply); - if (ret < 0) - goto finish; - - if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(o)"))) { + reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST, + SYSTEMD_DBUS_PATH, + SYSTEMD_DBUS_IFACE_MANAGER, + method, + g_variant_new("(ss)", name, "replace")); + + if (!reply || !dh_get_param_from_var(reply, "(o)", &objpath)) { + _E("fail (%s): no message", method); ret = -EBADMSG; goto finish; } - ret = 0; + _I("Finished: %s %s", method, name); finish: - _I("Finished(%d): %s %s", ret, method, name); - if (reply) g_variant_unref(reply); + g_free(objpath); return ret; } int deviced_systemd_start_unit(char *name) { - assert(name); + if (name == NULL) { + _E("Wrong name : %s", name); + return -1; + } return deviced_systemd_start_or_stop_unit("StartUnit", name); } int deviced_systemd_stop_unit(char *name) { - assert(name); + if (name == NULL) { + _E("Wrong name : %s", name); + return -1; + } return deviced_systemd_start_or_stop_unit("StopUnit", name); } @@ -200,129 +202,136 @@ static char *deviced_systemd_get_unit_dbus_path(const char *unit) return path; } -static int deviced_systemd_get_property(const char *name, +static GVariant * deviced_systemd_get_property(const char *name, const char *path, const char *iface, const char *method, const char *interface, - const char *property, - GVariant **reply) + const char *property) { + GVariant *reply; int ret; - GVariant *variant; - variant = g_variant_new("(ss)", - interface, - property); + reply = dbus_handle_method_sync_with_reply_var(name, + path, + iface, + method, + g_variant_new("(ss)", interface, property)); - ret = deviced_systemd_proxy_call_sync(name, - path, - iface, - method, - variant, - reply); - - return ret; + return reply; } -int deviced_systemd_get_manager_property(const char *iface, - const char *property, - GVariant **variant) +GVariant * deviced_systemd_get_manager_property(const char *property) { - assert(iface); + GVariant *reply = NULL; + GVariant *val = NULL; + assert(property); - return deviced_systemd_get_property(SYSTEMD_DBUS_DEST, - SYSTEMD_DBUS_PATH, - DBUS_IFACE_DBUS_PROPERTIES, - "Get", - iface, - property, - variant); + reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST, + SYSTEMD_DBUS_PATH, + DBUS_IFACE_DBUS_PROPERTIES, + "Get", + g_variant_new("(ss)", SYSTEMD_DBUS_IFACE_MANAGER, property)); + if (!reply || !dh_get_param_from_var(reply, "(v)", &val)) + _E("Failed to get variant"); + if (reply) + g_variant_unref(reply); + + return val; } -int deviced_systemd_get_unit_property(const char *unit, - const char *property, - GVariant **variant) +GVariant * deviced_systemd_get_unit_property(const char *unit, + const char *property) { - int r; char *escaped; + GVariant * reply = NULL; + GVariant *val = NULL; assert(unit); assert(property); escaped = deviced_systemd_get_unit_dbus_path(unit); - r = deviced_systemd_get_property(SYSTEMD_DBUS_DEST, - escaped, - DBUS_IFACE_DBUS_PROPERTIES, - "Get", - SYSTEMD_DBUS_IFACE_UNIT, - property, - variant); + reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST, + escaped, + DBUS_IFACE_DBUS_PROPERTIES, + "Get", + g_variant_new("(ss)", SYSTEMD_DBUS_IFACE_UNIT, property)); + + if (!reply || !dh_get_param_from_var(reply, "(v)", &val)) + _E("Failed to get variant"); + if (reply) + g_variant_unref(reply); free(escaped); - return r; + + return val; } -int deviced_systemd_get_service_property(const char *unit, - const char *property, - GVariant **variant) +GVariant * deviced_systemd_get_service_property(const char *unit, + const char *property) { int ret; char *escaped; + GVariant * reply = NULL; + GVariant *val = NULL; assert(unit); assert(property); escaped = deviced_systemd_get_unit_dbus_path(unit); - ret = deviced_systemd_get_property(SYSTEMD_DBUS_DEST, - escaped, - DBUS_IFACE_DBUS_PROPERTIES, - "Get", - SYSTEMD_DBUS_IFACE_SERVICE, - property, - variant); + reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST, + escaped, + DBUS_IFACE_DBUS_PROPERTIES, + "Get", + g_variant_new("(ss)", SYSTEMD_DBUS_IFACE_SERVICE, property)); + if (!reply || !dh_get_param_from_var(reply, "(v)", &val)) + _E("Failed to get variant"); + if (reply) + g_variant_unref(reply); free(escaped); - return ret; + return val; } +#if 0 #define DEFINE_SYSTEMD_GET_PROPERTY(iface, type, value) \ int deviced_systemd_get_##iface##_property_as_##type( \ - const char *target, \ - const char *property, \ - value*result) \ - { \ - \ - GVariant *var; \ - GVariant *inner; \ - int r; \ - \ - r = deviced_systemd_get_##iface##_property(target, \ - property, \ - &var); \ - if (r < 0) { \ - _E("Failed to get property:\n" \ - " target: %s\n" \ - " property: %s", \ - target, property); \ - return r; \ - } \ - \ - if (!g_variant_is_of_type(var, \ - G_VARIANT_TYPE("(v)"))) \ - return -EBADMSG; \ - \ - g_variant_get(var, "(v)", &inner); \ - if (!g_variant_is_of_type(inner, \ - g_variant_type_##type)) \ - return -EBADMSG; \ - \ - *result = g_variant_get_function_##type(inner); \ - g_variant_unref(var); \ - \ - return 0; \ - } + const char *target, \ + const char *property, \ + value*result) \ +{ \ + \ + GVariant *var; \ + GVariant *inner; \ + int r; \ + \ + r = deviced_systemd_get_##iface##_property(target, \ + property, \ + &var); \ + if (r < 0) { \ + _E("Failed to get property:\n" \ + " target: %s\n" \ + " property: %s", \ + target, property); \ + return r; \ + } \ + \ + if (!g_variant_is_of_type(var, \ + G_VARIANT_TYPE("(v)"))) \ + return -EBADMSG; \ + \ + g_variant_get(var, "(v)", &inner); \ + if (!g_variant_is_of_type(inner, \ + g_variant_type_##type)) \ + return -EBADMSG; \ + \ + *result = g_variant_get_function_##type(inner); \ + g_variant_unref(var); \ + \ + return 0; \ +} + /* int deviced_systemd_get_manager_property_as_int32(const char *iface, const char *property, int *result); */ DEFINE_SYSTEMD_GET_PROPERTY(manager, int32, int) @@ -404,3 +413,4 @@ finish: return r; } +#endif diff --git a/src/shared/deviced-systemd.h b/src/shared/deviced-systemd.h index 7fc46af..715bb46 100644 --- a/src/shared/deviced-systemd.h +++ b/src/shared/deviced-systemd.h @@ -36,9 +36,10 @@ int deviced_systemd_start_unit(char *name); int deviced_systemd_stop_unit(char *name); -int deviced_systemd_get_manager_property(const char *iface, const char *property, GVariant **variant); -int deviced_systemd_get_unit_property(const char *unit, const char *property, GVariant **variant); -int deviced_systemd_get_service_property(const char* unit, const char* property, GVariant **variant); +GVariant * deviced_systemd_get_manager_property(const char *property); +GVariant * deviced_systemd_get_unit_property(const char *unit, const char *property); +GVariant * deviced_systemd_get_service_property(const char* unit, const char* property); +#if 0 int deviced_systemd_get_manager_property_as_int32(const char *iface, const char *property, int *result); int deviced_systemd_get_manager_property_as_uint32(const char *iface, const char *property, unsigned int *result); @@ -57,5 +58,6 @@ int deviced_systemd_get_service_property_as_uint64(const char *unit, const char int deviced_systemd_get_service_property_as_string(const char *unit, const char *property, char **result); int deviced_systemd_instance_new_from_template(const char *template, const char *instance, const char **name); +#endif #endif -- 2.7.4 From 512e40d8224fd0f346861fdd76e0a891c8125b67 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Thu, 6 Sep 2018 20:31:02 +0900 Subject: [PATCH 09/16] dbus: replace iter_loop with iter_next In case of g_variant_iter_loop, in spite of it reaches end of iteration, trying to assign 0(or null) to param. If array(with size - g_variant_iter_n_children(iter);) is used as param, it will causes segfault. So change iter_loop to iter_next. iter_next don't trying to assign value to param when it reaches end of iteration. it just return FALSE Change-Id: I11668d7ff6ee9ad71b62e829921dfd640469e5d7 Signed-off-by: sanghyeok.oh --- src/ir/ir.c | 2 +- src/led/rgb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ir/ir.c b/src/ir/ir.c index 4b60777..4132ff7 100644 --- a/src/ir/ir.c +++ b/src/ir/ir.c @@ -76,7 +76,7 @@ static GVariant *dbus_ir_transmit(GDBusConnection *conn, size = g_variant_iter_n_children(iter); freq_pattern = (int*)malloc(sizeof(int) * size); - while (g_variant_iter_loop(iter, "i", &freq_pattern[i++])) + while (g_variant_iter_next(iter, "i", &freq_pattern[i++])) ; g_variant_iter_free(iter); diff --git a/src/led/rgb.c b/src/led/rgb.c index 921aab2..23f8994 100644 --- a/src/led/rgb.c +++ b/src/led/rgb.c @@ -251,7 +251,7 @@ static GVariant *dbus_multi_playcustom(GDBusConnection *conn, color = (unsigned int*)malloc(sizeof(unsigned int) * num_of_leds); i = 0; - while (g_variant_iter_loop(iter, "u", &color[i])) + while (g_variant_iter_next(iter, "u", &color[i])) ++i; g_variant_iter_free(iter); -- 2.7.4 From 53b9197deefb2207fda19938bf6dbeb1cd40a39f Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 17 Sep 2018 11:46:48 +0900 Subject: [PATCH 10/16] Remove build warnings Change-Id: I67bfaf29299825a9b8df19acd969a903af9e5dbc Signed-off-by: pr.jung --- src/shared/deviced-systemd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/shared/deviced-systemd.c b/src/shared/deviced-systemd.c index 67da906..8484dc8 100644 --- a/src/shared/deviced-systemd.c +++ b/src/shared/deviced-systemd.c @@ -50,7 +50,7 @@ typedef unsigned long long uint64; #define g_variant_get_function_uint64(v) g_variant_get_uint64(v) #define g_variant_get_function_string(v) g_variant_dup_string(v, NULL) - +/* static int deviced_systemd_proxy_call_sync(const char *name, const char *path, const char *iface, @@ -70,11 +70,11 @@ static int deviced_systemd_proxy_call_sync(const char *name, error = NULL; proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, - NULL, /* GDBusInterfaceInfo */ + NULL, // GDBusInterfaceInfo name, path, iface, - NULL, /* GCancellable */ + NULL, // GCancellable &error); if (proxy == NULL) { @@ -90,7 +90,7 @@ static int deviced_systemd_proxy_call_sync(const char *name, variant, G_DBUS_CALL_FLAGS_NONE, -1, - NULL, /* GCancellable */ + NULL, // GCancellable &error); if (error) { @@ -107,6 +107,7 @@ static int deviced_systemd_proxy_call_sync(const char *name, return 0; } +*/ static int deviced_systemd_start_or_stop_unit(char *method, char *name) { @@ -202,6 +203,7 @@ static char *deviced_systemd_get_unit_dbus_path(const char *unit) return path; } +/* static GVariant * deviced_systemd_get_property(const char *name, const char *path, const char *iface, @@ -210,7 +212,6 @@ static GVariant * deviced_systemd_get_property(const char *name, const char *property) { GVariant *reply; - int ret; reply = dbus_handle_method_sync_with_reply_var(name, path, @@ -220,6 +221,7 @@ static GVariant * deviced_systemd_get_property(const char *name, return reply; } +*/ GVariant * deviced_systemd_get_manager_property(const char *property) { @@ -271,7 +273,6 @@ GVariant * deviced_systemd_get_unit_property(const char *unit, GVariant * deviced_systemd_get_service_property(const char *unit, const char *property) { - int ret; char *escaped; GVariant * reply = NULL; GVariant *val = NULL; -- 2.7.4 From 3761ae2da4c799524152c007ab704a058ebde682 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 18 Sep 2018 16:38:14 +0900 Subject: [PATCH 11/16] Add two function to support multi leds. 1. dbus_multi_led_control : to control leds 2. dbus_getnumofleds : to get the number of leds Change-Id: I1b2101c4532b266416a88f5f5bf5ad67dea6fd73 Signed-off-by: lokilee73 --- src/led/rgb.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 15 deletions(-) mode change 100644 => 100755 src/led/rgb.c diff --git a/src/led/rgb.c b/src/led/rgb.c old mode 100644 new mode 100755 index 23f8994..6b3cf30 --- a/src/led/rgb.c +++ b/src/led/rgb.c @@ -143,7 +143,7 @@ static gboolean remove_not_handled_req(gpointer data) if (ret < 0) _E("Failed to remove rgb request (%d)", ret); } - } +} if (!top) { ret = rgb_play(NULL); @@ -169,6 +169,40 @@ static void add_timer_to_check_invalid_req(void) _E("Failed to add timer"); } +static int get_led_num(void) +{ + static bool initialized = false; + static int num_of_leds = -1; + int ret; + + if (initialized) + return num_of_leds; + + if (!rgb_dev) { + _E("There is NO HAL"); + ret = -ENODEV; + goto out; + } + + if (!rgb_dev->get_number) { + _E("LED HAL does not support get_number()"); + ret = -ENOTSUP; + goto out; + } + + ret = rgb_dev->get_number(); + if (ret < 0) { + _E("Failed to get LED number : %d", ret); + goto out; + } + + num_of_leds = ret; + initialized = true; + +out: + return ret; +} + static GVariant *dbus_playcustom(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) @@ -235,30 +269,66 @@ out: return g_variant_new("(i)", ret); } -static GVariant *dbus_multi_playcustom(GDBusConnection *conn, +static GVariant *dbus_get_num_of_leds(GDBusConnection *conn, + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) +{ + int ret; + + ret = get_led_num(); + + return g_variant_new("(i)", ret); +} + +static GVariant *dbus_multi_led_control(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; - unsigned int *color; - int num_of_leds; - GVariantIter *iter; - int i; + int num_of_leds, size, i; + unsigned int *color = NULL; + GVariantIter *iter = NULL; + pid_t pid; + struct led_state state; + + pid = dbus_connection_get_sender_pid(conn, sender); + + _I("pid %d multi led play control", pid); + + ret = get_led_num(); + if (ret < 0) + goto out; + else + num_of_leds = ret; g_variant_get(param, "(au)", &iter); - num_of_leds = g_variant_iter_n_children(iter); + size = g_variant_iter_n_children(iter); + if (num_of_leds != size) { + _E("Led number is not matched"); + ret = -EINVAL; + goto out; + } - color = (unsigned int*)malloc(sizeof(unsigned int) * num_of_leds); + color = (unsigned int*)malloc(sizeof(unsigned int) * size); i = 0; - while (g_variant_iter_next(iter, "u", &color[i])) - ++i; + state.duty_on = 0; + state.duty_off = 0; + state.type = LED_TYPE_MANUAL; - g_variant_iter_free(iter); - - /* To be implemented */ + while (g_variant_iter_next(iter, "u", &color[i])) { + state.color = color[i]; + ret = rgb_play(&state); + if (ret < 0) + _E("Failed to play LED notification (%d)", ret); + ++i; + } - free(color); +out: + if (iter) + g_variant_iter_free(iter); + if (color) + free(color); return g_variant_new("(i)", ret); } @@ -266,7 +336,8 @@ static GVariant *dbus_multi_playcustom(GDBusConnection *conn, static const dbus_method_s dbus_methods[] = { { "playcustom", "iiuu", "i", dbus_playcustom }, { "stopcustom", NULL, "i", dbus_stopcustom }, - { "multi_playcustom", "au", "i", dbus_multi_playcustom }, + { "GetNumOfLeds", NULL, "i", dbus_get_num_of_leds}, + { "multi_led_control", "au", "i", dbus_multi_led_control }, /* Add methods here */ }; -- 2.7.4 From 7b51c4bb56b4585cab7c735fa8b264185556a027 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 1 Oct 2018 13:27:44 +0900 Subject: [PATCH 12/16] Remove svace error Change-Id: I25e34b89a92fbe495ddc8f00e3daca3f4ac35cbb Signed-off-by: pr.jung --- src/auto-test/display.c | 8 ++++++-- src/led/rgb.c | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/auto-test/display.c b/src/auto-test/display.c index c7d30eb..7266866 100644 --- a/src/auto-test/display.c +++ b/src/auto-test/display.c @@ -327,10 +327,14 @@ static bool set_display_dumpmode(char *on) static bool set_display_savelog() { struct stat buf; + int r; bool ret = FALSE; - if (!stat(PM_STATE_LOG_FILE, &buf)) - remove(PM_STATE_LOG_FILE); + if (!stat(PM_STATE_LOG_FILE, &buf)) { + r = remove(PM_STATE_LOG_FILE); + if (r < 0) + _E("Remove file error : %d", r); + } if (!set_display_method_noreply(METHOD_DISPLAY_SAVELOG, NULL)) return ret; diff --git a/src/led/rgb.c b/src/led/rgb.c index 6b3cf30..2c320f2 100755 --- a/src/led/rgb.c +++ b/src/led/rgb.c @@ -310,6 +310,10 @@ static GVariant *dbus_multi_led_control(GDBusConnection *conn, } color = (unsigned int*)malloc(sizeof(unsigned int) * size); + if (!color) { + ret = -ENOMEM; + goto fail; + } i = 0; state.duty_on = 0; @@ -325,10 +329,11 @@ static GVariant *dbus_multi_led_control(GDBusConnection *conn, } out: - if (iter) - g_variant_iter_free(iter); if (color) free(color); +fail: + if (iter) + g_variant_iter_free(iter); return g_variant_new("(i)", ret); } -- 2.7.4 From 9f88117ede52b4e44a393b19ad52694f14d317bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Szewczyk?= Date: Mon, 1 Oct 2018 11:37:27 +0200 Subject: [PATCH 13/16] usb-host-test: disable unit start rate limiting in ffs daemon MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The usb-host-ffs-test-daemon is, by design, an on-demand daemon. It is restarted by each test case. The test cases, however, are run very fast in big series, triggering unit restart limiting mechanism in systemd and entering it into failure state. To prevent this from happening, this commit disables the limiting. Change-Id: I6b107442cea14015df9ab8d01ce23382b51fd872 Signed-off-by: Paweł Szewczyk --- systemd/usb-host-ffs-test-daemon.service | 1 + 1 file changed, 1 insertion(+) diff --git a/systemd/usb-host-ffs-test-daemon.service b/systemd/usb-host-ffs-test-daemon.service index c991f7b..e8ad37d 100644 --- a/systemd/usb-host-ffs-test-daemon.service +++ b/systemd/usb-host-ffs-test-daemon.service @@ -1,5 +1,6 @@ [Unit] Description=FFS daemon required by usb-host test suite +StartLimitIntervalSec=0 [Service] User=system_fw -- 2.7.4 From 4c0892b468a85bee0dfd7b6cb114e68f5cca0bb2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Szewczyk?= Date: Tue, 27 Feb 2018 17:16:29 +0100 Subject: [PATCH 14/16] usb: Remove usb-operation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Starting and stopping usb operation is specific to the implementation. This responsibility is moved to USB HAL. Change-Id: I8a729a1343d27dc04e5a5611c9fd6ccdf394d4a4 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 7000c7d..4632a10 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,8 +244,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 a908a6d..17848f2 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -217,7 +217,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 a2b546e15b5c1a2cbc8be0c44f6de3e95abe4828 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 29 Oct 2018 14:35:35 +0900 Subject: [PATCH 15/16] Change usb sequence to broadcast usb state after setting vconf value Change-Id: Ifbbbc70b160e3a351a484d633c3b955ecb6d98d0 --- src/usb/usb-state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usb/usb-state.c b/src/usb/usb-state.c index eff7835..85b5c64 100755 --- a/src/usb/usb-state.c +++ b/src/usb/usb-state.c @@ -252,8 +252,8 @@ void usb_state_update_state(usb_connection_state_e state, unsigned int mode) if (old_status != status) { usb_state_send_system_event(status); - broadcast_usb_state_changed(); vconf_set_int(VCONFKEY_SYSMAN_USB_STATUS, status); + broadcast_usb_state_changed(); old_status = status; } -- 2.7.4 From 08befafa4e9e4241efb8500d837ab3f4f4194d06 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Tue, 30 Oct 2018 21:50:36 +0900 Subject: [PATCH 16/16] Plugin architecture - mobile profile Change-Id: I65811fb7958cb4865c5e5c616953ca9267bbfd76 Signed-off-by: Hyotaek Shim --- CMakeLists.txt | 5 +- ...profile-wearable.conf => profile-wearable.conf} | 0 packaging/deviced.spec | 75 ++++++++++++++-------- plugins/mobile/display/CMakeLists.txt | 27 ++++++++ {src => plugins/mobile}/display/ambient-mode.c | 10 +-- {src => plugins/mobile}/display/auto-brightness.c | 0 {src => plugins/mobile}/display/core.c | 56 ++++++++-------- {src => plugins/mobile}/display/device-interface.c | 0 {src => plugins/mobile}/display/display-actor.c | 0 {src => plugins/mobile}/display/display-dbus.c | 40 +++++++----- {src => plugins/mobile}/display/display-ops.c | 0 .../mobile}/display/dpms-wayland-none.c | 0 {src => plugins/mobile}/display/input.c | 0 {src => plugins/mobile}/display/key-filter.c | 16 +++-- {src => plugins/mobile}/display/lock-detector.c | 0 {src => plugins/mobile}/display/poll.c | 15 ++++- {src => plugins/mobile}/display/setting.c | 32 +++------ plugins/{ => tv}/display/CMakeLists.txt | 0 plugins/{ => tv}/display/state-tv.c | 3 +- src/apps/apps.c | 10 ++- src/battery/battery-time.c | 13 +++- src/battery/battery.h | 1 + src/battery/lowbat-handler.c | 30 ++++++--- src/battery/power-supply.c | 52 ++++++++++----- src/core/main.c | 3 + src/display/core.h | 2 - src/display/display-ops.h | 9 +++ src/display/poll.h | 4 -- src/display/setting.h | 23 +------ src/extcon/cradle.c | 19 ++++-- src/extcon/earjack.c | 9 ++- src/extcon/hdmi.c | 19 ++++-- src/led/touch-key.c | 4 +- src/power/boot.c | 6 +- src/power/power-handler.c | 13 ++-- src/shared/plugin.c | 23 +++++-- src/shared/plugin.h | 1 + src/time/time-handler.c | 24 +++++-- src/usb/usb.c | 11 ++-- src/usbhost/usb-host.c | 14 ++-- 40 files changed, 366 insertions(+), 203 deletions(-) rename conf/{display-profile-wearable.conf => profile-wearable.conf} (100%) create mode 100644 plugins/mobile/display/CMakeLists.txt rename {src => plugins/mobile}/display/ambient-mode.c (93%) rename {src => plugins/mobile}/display/auto-brightness.c (100%) rename {src => plugins/mobile}/display/core.c (98%) rename {src => plugins/mobile}/display/device-interface.c (100%) rename {src => plugins/mobile}/display/display-actor.c (100%) rename {src => plugins/mobile}/display/display-dbus.c (96%) rename {src => plugins/mobile}/display/display-ops.c (100%) rename {src => plugins/mobile}/display/dpms-wayland-none.c (100%) rename {src => plugins/mobile}/display/input.c (100%) rename {src => plugins/mobile}/display/key-filter.c (97%) rename {src => plugins/mobile}/display/lock-detector.c (100%) rename {src => plugins/mobile}/display/poll.c (87%) rename {src => plugins/mobile}/display/setting.c (91%) rename plugins/{ => tv}/display/CMakeLists.txt (100%) rename plugins/{ => tv}/display/state-tv.c (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4632a10..a59ca96 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,8 +234,8 @@ ENDIF() IF(DISPLAY_MODULE STREQUAL on) INSTALL_CONF(conf display) - INSTALL_CONF(conf display-profile-wearable) INSTALL_CONF(conf display-enable-timer) + INSTALL_CONF(conf profile-wearable) ENDIF() IF(POWER_MODULE STREQUAL on) @@ -278,4 +278,5 @@ IF(TIZEN_FEATURE_USBHOST_TEST STREQUAL on) ADD_SUBDIRECTORY(src/usb-host-ffs-test-daemon) ENDIF() ADD_SUBDIRECTORY(src/auto-test) -ADD_SUBDIRECTORY(plugins/display) +ADD_SUBDIRECTORY(plugins/mobile/display) +#ADD_SUBDIRECTORY(plugins/display/tv) diff --git a/conf/display-profile-wearable.conf b/conf/profile-wearable.conf similarity index 100% rename from conf/display-profile-wearable.conf rename to conf/profile-wearable.conf diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 17848f2..c6e1f17 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -82,14 +82,6 @@ Group: System/Utilities Deviced helper programs. This package can be installed optional for auto dbus test. -%package config-profile-wearable -Summary: Configuration files for wearable profile -Group: System/Management -BuildArch: noarch - -%description config-profile-wearable -This package is used for wearable profile - %package config-enable-display-timer Summary: Configuration files for display Group: System/Management @@ -98,13 +90,29 @@ BuildArch: noarch %description config-enable-display-timer This package is used for enabling a display timer. -%package plugin-profile-tv -Summary: Plugin libraries for TV profile +%package plugin-profile-mobile +Summary: Plugin libraries for mobile devices Group: System/Management Requires: %{name} = %{version}-%{release} -%description plugin-profile-tv -Plugin libraries for TV profile +%description plugin-profile-mobile +Plugin libraries for mobile devices + +%package plugin-profile-wearable +Summary: Plugin libraries for wearable devices +Group: System/Management +Requires: %{name} = %{version}-%{release} + +%description plugin-profile-wearable +Plugin libraries for wearable devices + +#%package plugin-display-tv +#Summary: Plugin libraries for TV display devices +#Group: System/Management +#Requires: %{name} = %{version}-%{release} + +#%description plugin-display-tv +#Plugin libraries for TV display devices %prep %setup -q @@ -187,19 +195,22 @@ fi %postun -n libdeviced -p /sbin/ldconfig -%post config-profile-wearable -cat %{_sysconfdir}/deviced/display-profile-wearable.conf >> %{_sysconfdir}/deviced/display.conf -rm -rf %{_sysconfdir}/deviced/display-profile-wearable.conf - %post config-enable-display-timer cat %{_sysconfdir}/deviced/display-enable-timer.conf >> %{_sysconfdir}/deviced/display.conf rm -rf %{_sysconfdir}/deviced/display-enable-timer.conf -%post plugin-profile-tv +%post plugin-profile-mobile mkdir -p %{_libdir}/deviced -mv %{_libdir}/display-tv.so %{_libdir}/deviced/display.so +mv %{_libdir}/mobile-display.so %{_libdir}/deviced/display.so + +%post plugin-profile-wearable +cat %{_sysconfdir}/deviced/profile-wearable.conf >> %{_sysconfdir}/deviced/wearable.conf +rm -rf %{_sysconfdir}/deviced/profile-wearable.conf +#mv %{_libdir}/mobile-wearable.so %{_libdir}/deviced/display.so -%postun plugin-profile-tv +#%post plugin-display-tv +#mkdir -p %{_libdir}/deviced +#mv %{_libdir}/display-tv.so %{_libdir}/deviced/display.so %files %manifest %{name}.manifest @@ -252,18 +263,30 @@ mv %{_libdir}/display-tv.so %{_libdir}/deviced/display.so %{_bindir}/deviced-auto-test %config %{_sysconfdir}/deviced/auto-test.conf -%files config-profile-wearable -%manifest deviced.manifest -%license LICENSE.Apache-2.0 -%config %{_sysconfdir}/deviced/display-profile-wearable.conf - %files config-enable-display-timer %manifest deviced.manifest %license LICENSE.Apache-2.0 %config %{_sysconfdir}/deviced/display-enable-timer.conf -%files plugin-profile-tv +%files plugin-profile-mobile %manifest deviced.manifest %license LICENSE.Apache-2.0 %defattr(-,root,root,-) -%{_libdir}/display-tv.so +%{_libdir}/mobile-display.so + +%files plugin-profile-wearable +%manifest deviced.manifest +%license LICENSE.Apache-2.0 +%config %{_sysconfdir}/deviced/profile-wearable.conf +#%{_libdir}/mobile-wearable.so + +#%files plugin-profile-tv +#%manifest deviced.manifest +#%license LICENSE.Apache-2.0 +#%defattr(-,root,root,-) +#%{_libdir}/display-tv.so + +#%files plugin-profile-iot +#%manifest deviced.manifest +#%license LICENSE.Apache-2.0 +#%defattr(-,root,root,-) diff --git a/plugins/mobile/display/CMakeLists.txt b/plugins/mobile/display/CMakeLists.txt new file mode 100644 index 0000000..7aad0f4 --- /dev/null +++ b/plugins/mobile/display/CMakeLists.txt @@ -0,0 +1,27 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(mobile-display C) + +FILE(GLOB ALL_SRCS "*.c") +SET(SRCS ${ALL_SRCS}) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/core ${CMAKE_SOURCE_DIR}/src/display) + +INCLUDE(FindPkgConfig) +pkg_check_modules(libpkgs REQUIRED + dlog + glib-2.0 + gio-2.0 + gio-unix-2.0 + libinput + capi-system-sensor) + +FOREACH(flag ${libpkgs_CFLAGS}) + SET(EXTRA_LIB_CFLAGS "${EXTRA_LIB_CFLAGS} ${flag}") +ENDFOREACH(flag) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}") + +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME mobile-display) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) diff --git a/src/display/ambient-mode.c b/plugins/mobile/display/ambient-mode.c similarity index 93% rename from src/display/ambient-mode.c rename to plugins/mobile/display/ambient-mode.c index a275500..7b0e399 100644 --- a/src/display/ambient-mode.c +++ b/plugins/mobile/display/ambient-mode.c @@ -36,6 +36,7 @@ #define TIMEOUT_NONE (-1) #define AMBIENT_CLOCK_WAITING_TIME 5000 /* ms */ +extern struct display_plugin disp_plgn; static int ambient_state; static pid_t ambient_pid; /* Ambient Clock pid */ static int ambient_condition; @@ -133,8 +134,9 @@ static void start_clock(void) ambient_state == false) return; - pm_lock_internal(INTERNAL_LOCK_AMBIENT, - LCD_OFF, STAY_CUR_STATE, AMBIENT_CLOCK_WAITING_TIME); + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, STAY_CUR_STATE, + AMBIENT_CLOCK_WAITING_TIME); } static void end_clock(pid_t pid) @@ -147,8 +149,8 @@ static void end_clock(pid_t pid) if (update_count == 0) broadcast_lcd_off_late(LCD_OFF_LATE_MODE); - pm_unlock_internal(INTERNAL_LOCK_AMBIENT, - LCD_OFF, PM_SLEEP_MARGIN); + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, PM_SLEEP_MARGIN); update_count++; if (update_count == UINT_MAX) diff --git a/src/display/auto-brightness.c b/plugins/mobile/display/auto-brightness.c similarity index 100% rename from src/display/auto-brightness.c rename to plugins/mobile/display/auto-brightness.c diff --git a/src/display/core.c b/plugins/mobile/display/core.c similarity index 98% rename from src/display/core.c rename to plugins/mobile/display/core.c index 0c623d4..670a6bc 100755 --- a/src/display/core.c +++ b/plugins/mobile/display/core.c @@ -51,6 +51,7 @@ #include "core/udev.h" #include "core/list.h" #include "core/common.h" +#include "battery/battery.h" #include "shared/plugin.h" #include "core/config-parser.h" #include "core/launch.h" @@ -79,6 +80,8 @@ #define TIMEOUT_STR "timeout" #define UNKNOWN_STR "unknown" +extern void init_pm_internal(); +extern struct display_plugin disp_plgn; unsigned int pm_status_flag; static int trans_condition; @@ -88,7 +91,6 @@ static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; int pm_cur_state; int pm_old_state; guint timeout_src_id; -int system_wakeup_flag = false; static unsigned int custom_normal_timeout = 0; static unsigned int custom_dim_timeout = 0; static int custom_holdkey_block = false; @@ -103,7 +105,6 @@ static int stay_touchscreen_off = false; static dd_list *lcdon_ops; static bool lcdon_broadcast = true; static bool touch_blocked = false; -static void *plugin_handle; /* default transition, action fuctions */ static int default_trans(int evt); @@ -770,7 +771,7 @@ static void update_display_time(void) } /* third priority : lock state */ - if ((get_lock_screen_state() == VCONFKEY_IDLE_LOCK) && + if ((__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) && !get_lock_screen_bg_state()) { /* timeout is different according to key or event. */ states[S_NORMAL].timeout = lock_screen_timeout; @@ -830,7 +831,7 @@ void lcd_on_direct(enum device_flags flags) #else ret = vconf_get_int(VCONFKEY_CALL_STATE, &call_state); if ((ret >= 0 && call_state != VCONFKEY_CALL_OFF) || - (get_lock_screen_state() == VCONFKEY_IDLE_LOCK)) { + (__get_lock_screen_state() == VCONFKEY_IDLE_LOCK)) { _D("LOCK state, lcd is on directly"); lcd_on_procedure(LCD_NORMAL, flags); } @@ -1323,7 +1324,7 @@ void save_display_log(void) _E("write() failed (%d)", errno); snprintf(buf, sizeof(buf), "screen lock status : %d\n", - get_lock_screen_state()); + __get_lock_screen_state()); ret = write(fd, buf, strlen(buf)); if (ret < 0) _E("write() failed (%d)", errno); @@ -1357,7 +1358,7 @@ int check_lcdoff_direct(void) if (pm_cur_state != S_LCDDIM) return false; - lock = get_lock_screen_state(); + lock = __get_lock_screen_state(); if (lock != VCONFKEY_IDLE_LOCK && hallic_open) return false; @@ -1374,7 +1375,7 @@ int check_lcdoff_direct(void) return true; } -int check_lcdoff_lock_state(void) +static int __check_lcdoff_lock_state(void) { if (cond_head[S_LCDOFF] != NULL) return true; @@ -1633,7 +1634,7 @@ go_suspend: } _I("system wakeup!!"); - system_wakeup_flag = true; + disp_plgn.system_wakeup_flag = true; /* Resume !! */ if (power_ops.check_wakeup_src() == EVENT_DEVICE) /* system waked up by devices */ @@ -1844,6 +1845,12 @@ static int update_setting(int key_idx, int val) return 0; } +extern int get_charging_status(int *val); +//static int get_charging_status(int *val) +//{ + //return vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, val); +//} + static void check_seed_status(void) { int ret = -1; @@ -2016,8 +2023,10 @@ static int booting_done(void *data) return done; _I("booting done. Release display and power lock"); - pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN); - pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, PM_SLEEP_MARGIN); + if (disp_plgn.pm_unlock_internal) { + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN); + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, PM_SLEEP_MARGIN); + } return done; } @@ -2174,16 +2183,6 @@ static void add_timer_for_wm_ready(void) _E("Failed to add wm_ready timeout"); } -static int display_plugin_load() -{ - return load_plugin("display", &plugin_handle); -} - -static int display_plugin_unload() -{ - return unload_plugin(plugin_handle); -} - /** * Power manager Main * @@ -2201,7 +2200,9 @@ static int display_probe(void *data) if (ret) return ret; - display_plugin_load(); + /* display_plugin instance initialization */ + init_pm_internal(); + disp_plgn.check_lcdoff_lock_state = __check_lcdoff_lock_state; return 0; } @@ -2229,7 +2230,6 @@ static void display_init(void *data) register_notifier(DEVICE_NOTIFIER_PROCESS_FOREGROUND, process_foreground); register_notifier(DEVICE_NOTIFIER_POWEROFF, device_poweroff); - for (i = INIT_SETTING; i < INIT_END; i++) { switch (i) { case INIT_SETTING: @@ -2303,10 +2303,12 @@ static void display_init(void *data) * 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 (disp_plgn.pm_lock_internal) { + disp_plgn.pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, + STAY_CUR_STATE, BOOTING_DONE_WATING_TIME); + disp_plgn.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)) @@ -2318,8 +2320,6 @@ static void display_exit(void *data) { int i = INIT_END; - display_plugin_unload(); - status = DEVICE_OPS_STATUS_STOP; /* Set current state to S_NORMAL */ diff --git a/src/display/device-interface.c b/plugins/mobile/display/device-interface.c similarity index 100% rename from src/display/device-interface.c rename to plugins/mobile/display/device-interface.c diff --git a/src/display/display-actor.c b/plugins/mobile/display/display-actor.c similarity index 100% rename from src/display/display-actor.c rename to plugins/mobile/display/display-actor.c diff --git a/src/display/display-dbus.c b/plugins/mobile/display/display-dbus.c similarity index 96% rename from src/display/display-dbus.c rename to plugins/mobile/display/display-dbus.c index 02bc8c4..be40ed8 100755 --- a/src/display/display-dbus.c +++ b/plugins/mobile/display/display-dbus.c @@ -60,6 +60,8 @@ } \ } while (0) +extern struct display_plugin disp_plgn; + GVariant *dbus_start(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) @@ -179,7 +181,8 @@ GVariant *dbus_lockstate(GDBusConnection *conn, flag |= STAY_CUR_STATE; } - ret = pm_lock_internal(pid, state, flag, timeout); + if (disp_plgn.pm_lock_internal) + ret = disp_plgn.pm_lock_internal(pid, state, flag, timeout); out: g_free(state_str); g_free(option1_str); @@ -241,7 +244,8 @@ GVariant *dbus_unlockstate(GDBusConnection *conn, flag = PM_RESET_TIMER; } - ret = pm_unlock_internal(pid, state, flag); + if (disp_plgn.pm_unlock_internal) + ret = disp_plgn.pm_unlock_internal(pid, state, flag); out: g_free(state_str); g_free(option_str); @@ -315,7 +319,8 @@ GVariant *dbus_changestate(GDBusConnection *conn, goto out; } - ret = pm_change_internal(pid, state); + if (disp_plgn.pm_change_internal) + ret = disp_plgn.pm_change_internal(pid, state); if (!ret && state == LCD_OFF) update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); @@ -665,12 +670,15 @@ GVariant *dbus_lockscreenbgon(GDBusConnection *conn, g_variant_get(param, "(s)", &on); - if (!strcmp(on, "true")) - update_pm_setting(SETTING_LOCK_SCREEN_BG, true); - else if (!strcmp(on, "false")) - update_pm_setting(SETTING_LOCK_SCREEN_BG, false); - else + if (!strcmp(on, "true")) { + if (disp_plgn.update_pm_setting) + disp_plgn.update_pm_setting(SETTING_LOCK_SCREEN_BG, true); + } else if (!strcmp(on, "false")) { + if (disp_plgn.update_pm_setting) + disp_plgn.update_pm_setting(SETTING_LOCK_SCREEN_BG, false); + } else { ret = -EINVAL; + } g_free(on); return g_variant_new("(i)", ret); @@ -687,14 +695,16 @@ GVariant *dbus_dumpmode(GDBusConnection *conn, g_variant_get(param, "(s)", &on); - if (!strcmp(on, "on")) - pm_lock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF, - STAY_CUR_STATE, DUMP_MODE_WATING_TIME); - else if (!strcmp(on, "off")) - pm_unlock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF, - PM_SLEEP_MARGIN); - else + if (!strcmp(on, "on")) { + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF, + STAY_CUR_STATE, DUMP_MODE_WATING_TIME); + } else if (!strcmp(on, "off")) { + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF, PM_SLEEP_MARGIN); + } else { ret = -EINVAL; + } g_free(on); return g_variant_new("(i)", ret); diff --git a/src/display/display-ops.c b/plugins/mobile/display/display-ops.c similarity index 100% rename from src/display/display-ops.c rename to plugins/mobile/display/display-ops.c diff --git a/src/display/dpms-wayland-none.c b/plugins/mobile/display/dpms-wayland-none.c similarity index 100% rename from src/display/dpms-wayland-none.c rename to plugins/mobile/display/dpms-wayland-none.c diff --git a/src/display/input.c b/plugins/mobile/display/input.c similarity index 100% rename from src/display/input.c rename to plugins/mobile/display/input.c diff --git a/src/display/key-filter.c b/plugins/mobile/display/key-filter.c similarity index 97% rename from src/display/key-filter.c rename to plugins/mobile/display/key-filter.c index 98904b6..5e7cde7 100644 --- a/src/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -32,6 +32,7 @@ #include "poll.h" #include "device-node.h" #include "display-actor.h" +#include "display-ops.h" #include "core/common.h" #include "core/devices.h" #include "core/device-notifier.h" @@ -67,6 +68,8 @@ #define GLOVE_MODE 1 +extern struct display_plugin disp_plgn; + enum key_combination_flags { KEY_COMBINATION_STOP = 0, KEY_COMBINATION_POWERKEY = BIT(0), @@ -138,7 +141,8 @@ static void longkey_pressed() if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) { /* change state - LCD on */ - pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); (*pm_callback)(INPUT_POLL_EVENT, NULL); } @@ -359,7 +363,8 @@ static int lcdoff_powerkey(void) delete_condition(S_NORMAL); delete_condition(S_LCDDIM); update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); - pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); } } else { ignore = false; @@ -464,7 +469,8 @@ static int process_screenlock_key(struct input_event *pinput) update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ - pm_change_internal(-1, LCD_OFF); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(-1, LCD_OFF); } return true; @@ -492,7 +498,7 @@ static void process_hardkey_backlight(struct input_event *pinput) return; } /* Sound & Vibrate only in unlock state */ - if (get_lock_screen_state() == VCONFKEY_IDLE_UNLOCK + if (__get_lock_screen_state() == VCONFKEY_IDLE_UNLOCK || get_lock_screen_bg_state()) sound_vibrate_hardkey(); @@ -502,7 +508,7 @@ static void process_hardkey_backlight(struct input_event *pinput) } } else if (pinput->value == KEY_RELEASED) { /* if lockscreen is idle lock */ - if (get_lock_screen_state() == VCONFKEY_IDLE_LOCK) { + if (__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) { _D("Lock state, key backlight is off when phone is unlocked!"); return; } diff --git a/src/display/lock-detector.c b/plugins/mobile/display/lock-detector.c similarity index 100% rename from src/display/lock-detector.c rename to plugins/mobile/display/lock-detector.c diff --git a/src/display/poll.c b/plugins/mobile/display/poll.c similarity index 87% rename from src/display/poll.c rename to plugins/mobile/display/poll.c index 1381f98..e5087dd 100644 --- a/src/display/poll.c +++ b/plugins/mobile/display/poll.c @@ -27,6 +27,7 @@ #include "util.h" #include "core.h" #include "poll.h" +#include "display/display-ops.h" #define SHIFT_UNLOCK 4 #define SHIFT_UNLOCK_PARAMETER 12 @@ -37,6 +38,7 @@ #define HOLDKEY_BLOCK_BIT (__HOLDKEY_BLOCK_BIT << LOCK_FLAG_SHIFT) static PMMsg recv_data; +extern struct display_plugin disp_plgn; int check_dimstay(int next_state, int flag) { @@ -77,7 +79,7 @@ static bool state_supported(enum state_t st) return false; } -int pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout) +static int __pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout) { int cond; @@ -109,7 +111,7 @@ int pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout) return 0; } -int pm_unlock_internal(pid_t pid, int s_bits, int flag) +static int __pm_unlock_internal(pid_t pid, int s_bits, int flag) { int cond; @@ -140,7 +142,7 @@ int pm_unlock_internal(pid_t pid, int s_bits, int flag) return 0; } -int pm_change_internal(pid_t pid, int s_bits) +static int __pm_change_internal(pid_t pid, int s_bits) { int cond; @@ -164,3 +166,10 @@ int pm_change_internal(pid_t pid, int s_bits) return 0; } + +void init_pm_internal() +{ + disp_plgn.pm_lock_internal = __pm_lock_internal; + disp_plgn.pm_unlock_internal = __pm_unlock_internal; + disp_plgn.pm_change_internal = __pm_change_internal; +} diff --git a/src/display/setting.c b/plugins/mobile/display/setting.c similarity index 91% rename from src/display/setting.c rename to plugins/mobile/display/setting.c index 10e3387..4a41250 100644 --- a/src/display/setting.c +++ b/plugins/mobile/display/setting.c @@ -28,11 +28,13 @@ #include "core.h" #include "util.h" #include "setting.h" +#include "display-ops.h" #define LCD_DIM_RATIO 0.3 #define LCD_MAX_DIM_TIMEOUT 7000 #define LCD_MIN_DIM_TIMEOUT 500 +extern struct display_plugin disp_plgn; static const char *setting_keys[SETTING_GET_END] = { [SETTING_TO_NORMAL] = VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, [SETTING_BRT_LEVEL] = VCONFKEY_SETAPPL_LCD_BRIGHTNESS, @@ -47,8 +49,6 @@ static int custom_on_timeout = 0; static int custom_normal_timeout = 0; static int custom_dim_timeout = 0; -int (*update_pm_setting) (int key_idx, int val); - static void display_state_send_system_event(int state) { bundle *b; @@ -81,7 +81,7 @@ int set_force_lcdtimeout(int timeout) return 0; } -int get_lock_screen_state(void) +int __get_lock_screen_state(void) { return lock_screen_state; } @@ -109,21 +109,6 @@ void set_lock_screen_bg_state(bool state) lock_screen_bg_state = state; } -int get_charging_status(int *val) -{ - return vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, val); -} - -int get_lowbatt_status(int *val) -{ - return vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, val); -} - -int get_usb_status(int *val) -{ - return vconf_get_int(VCONFKEY_SYSMAN_USB_STATUS, val); -} - int set_setting_pmstate(int val) { static int old = -1; @@ -237,8 +222,8 @@ static int setting_cb(keynode_t *key_nodes, void *data) vconf_keynode_get_name(tmp), index); return -1; } - if (update_pm_setting != NULL) - update_pm_setting(index, vconf_keynode_get_int(tmp)); + if (disp_plgn.update_pm_setting) + disp_plgn.update_pm_setting(index, vconf_keynode_get_int(tmp)); return 0; } @@ -247,8 +232,9 @@ int init_setting(int (*func) (int key_idx, int val)) { int i; - if (func != NULL) - update_pm_setting = func; + if (func != NULL) { + disp_plgn.update_pm_setting = func; + } for (i = SETTING_BEGIN; i < SETTING_GET_END; i++) { /* @@ -260,6 +246,8 @@ int init_setting(int (*func) (int key_idx, int val)) (void *)((intptr_t)i)); } + disp_plgn.get_lock_screen_state = __get_lock_screen_state; + return 0; } diff --git a/plugins/display/CMakeLists.txt b/plugins/tv/display/CMakeLists.txt similarity index 100% rename from plugins/display/CMakeLists.txt rename to plugins/tv/display/CMakeLists.txt diff --git a/plugins/display/state-tv.c b/plugins/tv/display/state-tv.c similarity index 99% rename from plugins/display/state-tv.c rename to plugins/tv/display/state-tv.c index 8c0d7f3..218c2e7 100644 --- a/plugins/display/state-tv.c +++ b/plugins/tv/display/state-tv.c @@ -307,7 +307,8 @@ static gboolean standby_go_next_state(void *data) standby_timer = 0; } - ret = pm_change_internal(INTERNAL_LOCK_SUSPEND, SUSPEND); + if (disp_ops.pm_change_internal) + ret = disp_ops.pm_change_internal(INTERNAL_LOCK_SUSPEND, SUSPEND); if (ret < 0) { _E("Failed to change state to S_SUSPEND. Now Power off !!"); poweroff_trans(0); diff --git a/src/apps/apps.c b/src/apps/apps.c index cf72e6c..240d97e 100755 --- a/src/apps/apps.c +++ b/src/apps/apps.c @@ -19,11 +19,14 @@ #include #include "core/log.h" #include "core/common.h" +#include "display/display-ops.h" #include "apps.h" #define POPUP_METHOD "PopupLaunch" #define BUFF_MAX 255 +extern struct display_plugin disp_plgn; + static const struct app_dbus_match { const char *type; const char *bus; @@ -93,7 +96,8 @@ int launch_system_app(char *type, int num, ...) NULL); va_end(args); - pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); return ret; } @@ -110,7 +114,9 @@ int launch_message_post(char *type) POPUP_INTERFACE_NOTI, "MessagePostOn", g_variant_new("(s)", type)); - pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); return ret; } diff --git a/src/battery/battery-time.c b/src/battery/battery-time.c index 989ad37..94a4202 100644 --- a/src/battery/battery-time.c +++ b/src/battery/battery-time.c @@ -30,6 +30,7 @@ #include "core/log.h" #include "core/udev.h" #include "display/setting.h" +#include "display/display-ops.h" #include "power-supply.h" #define CHARGING_STATE(x) ((x) & CHRGR_FLAG) @@ -43,6 +44,8 @@ #define SIGNAL_TIMETOFULL "TimeToFull" #define SIGNAL_TIMETOEMPTY "TimeToEmpty" +extern struct display_plugin disp_plgn; + enum state_b { B_UNCHARGING = 0, B_CHARGING = 1, @@ -70,10 +73,14 @@ static int MAX_VALUE_COUNT[B_END] = {MAX_COUNT_UNCHARGING, MAX_COUNT_CHARGING}; static double avg_factor[B_END] = {-1.0, -1.0}; static int old_capacity; static int charging_state; -extern int system_wakeup_flag; static int time_to_full = -1; static int time_to_empty = -1; +int get_charging_status(int *val) +{ + return vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, val); +} + static int add_batt_node(enum state_b b_index, time_t clock, int capacity) { struct Batt_node *node = NULL; @@ -280,9 +287,9 @@ static int battinfo_calculation(void) update_time(A_TIMETOFULL, estimated_time); } else { del_all_batt_node(B_CHARGING); - if (system_wakeup_flag == true) { + if (disp_plgn.system_wakeup_flag == true) { del_all_batt_node(B_UNCHARGING); - system_wakeup_flag = false; + disp_plgn.system_wakeup_flag = false; } if (batt_head[B_UNCHARGING] == NULL) { add_batt_node(B_UNCHARGING, clock, capacity); diff --git a/src/battery/battery.h b/src/battery/battery.h index f1496bb..0b0f7b8 100644 --- a/src/battery/battery.h +++ b/src/battery/battery.h @@ -41,4 +41,5 @@ struct battery_config_info { int battery_charge_err_low_act(void *data); int battery_charge_err_high_act(void *data); + #endif /* __BATTERY_H__ */ diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index f944aa8..03d7c05 100755 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -40,6 +40,7 @@ #include "device-node.h" #include "display/setting.h" #include "display/poll.h" +#include "display/display-ops.h" #include "power/power-handler.h" #include "apps/apps.h" #include "power-supply.h" @@ -78,6 +79,8 @@ #define VCONF_KEY_BATTERY_WARNING_LEVEL "db/sysman/battery_warning_level" +extern struct display_plugin disp_plgn; + enum low_battery_type { LOW_BATTERY, CRITICAL_BATTERY, @@ -222,7 +225,8 @@ out: static void power_off_pm_lock(void) { if (power_off_lock == POWER_OFF_UNLOCK) { - pm_lock_internal(INTERNAL_LOCK_LOWBAT, LCD_OFF, STAY_CUR_STATE, 0); + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_LOWBAT, LCD_OFF, STAY_CUR_STATE, 0); power_off_lock = POWER_OFF_LOCK; } } @@ -230,7 +234,8 @@ static void power_off_pm_lock(void) static void power_off_pm_unlock(void) { if (power_off_lock == POWER_OFF_LOCK) { - pm_unlock_internal(INTERNAL_LOCK_LOWBAT, LCD_OFF, PM_SLEEP_MARGIN); + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_LOWBAT, LCD_OFF, PM_SLEEP_MARGIN); power_off_lock = POWER_OFF_UNLOCK; } } @@ -419,10 +424,12 @@ direct_launch: r_block = vconf_get_bool("db/setting/blockmode_wearable", &s_block); if ((r_disturb != 0 && r_block != 0) || (s_disturb == 0 && s_block == 0) || - lowbat_popup_option == LOWBAT_OPT_CHARGEERR) - pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_NORMAL); - else + lowbat_popup_option == LOWBAT_OPT_CHARGEERR) { + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_NORMAL); + } else { _I("block LCD"); + } if (lowbat_popup_option == LOWBAT_OPT_CHECK || lowbat_popup_option == LOWBAT_OPT_WARNING) { @@ -722,11 +729,12 @@ static int lowbat_process(int bat_percent, void *ad) } if (status != -1) { - lock = pm_lock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, STAY_CUR_STATE, 0); + if (disp_plgn.pm_lock_internal) + lock = disp_plgn.pm_lock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, STAY_CUR_STATE, 0); ret = vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, status); power_supply_broadcast(CHARGE_LEVEL_SIGNAL, status); - if (update_pm_setting) - update_pm_setting(SETTING_LOW_BATT, status); + if (disp_plgn.update_pm_setting) + disp_plgn.update_pm_setting(SETTING_LOW_BATT, status); } if (ret < 0) { @@ -761,8 +769,10 @@ static int lowbat_process(int bat_percent, void *ad) if (result == 1) cur_bat_state = new_bat_state; exit: - if (lock == 0) - pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN); + if (lock == 0) { + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN); + } return result; } diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index eee38bb..0116417 100755 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -32,6 +32,7 @@ #include "core/config-parser.h" #include "display/poll.h" #include "display/setting.h" +#include "display/display-ops.h" #include "apps/apps.h" #include "power-supply.h" #include "battery.h" @@ -62,6 +63,8 @@ #define RETRY_MAX 5 #define BATTERY_CHECK_TIMER_INTERVAL (0.5) +extern struct display_plugin disp_plgn; + enum power_supply_init_type { POWER_SUPPLY_NOT_READY = 0, POWER_SUPPLY_INITIALIZED = 1, @@ -91,7 +94,8 @@ static void pm_check_and_change(int bInserted) if (old == bInserted) return; old = bInserted; - pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); } static int changed_battery_cf(enum present_type status) @@ -142,8 +146,10 @@ static gboolean health_timer_cb(void *data) _I("popup - Battery health status is not good"); device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&value); - pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); - pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); if (battery.temp == TEMP_LOW) battery_charge_err_low_act(NULL); else if (battery.temp == TEMP_HIGH) @@ -354,11 +360,12 @@ static void noti_batt_full(void) bat_full_noti = 1; /* turn on LCD, if battery is full charged */ noti = check_power_supply_noti(); - if (noti) - pm_change_internal(INTERNAL_LOCK_BATTERY_FULL, - LCD_NORMAL); - else + if (noti) { + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_BATTERY_FULL, LCD_NORMAL); + } else { _I("block LCD"); + } /* on the full charge state */ device_notify(DEVICE_NOTIFIER_FULLBAT, (void *)&bat_full_noti); } @@ -367,8 +374,8 @@ static void noti_batt_full(void) static void check_power_supply(int state) { pm_check_and_change(state); - if (update_pm_setting) - update_pm_setting(SETTING_CHARGING, state); + if (disp_plgn.update_pm_setting) + disp_plgn.update_pm_setting(SETTING_CHARGING, state); } static void charger_state_send_system_event(int state) @@ -412,15 +419,18 @@ static void update_present(enum battery_noti_status status) return; _I("charge %d present %d", battery.charge_now, battery.present); old = status; - pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); if (status == DEVICE_NOTI_ON) { present = PRESENT_ABNORMAL; device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&present); - pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); } else { present = PRESENT_NORMAL; device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&present); - pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); } changed_battery_cf(present); } @@ -435,16 +445,21 @@ static void update_health(enum battery_noti_status status) _I("charge %d health %d", battery.charge_now, battery.health); old = status; - pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + if (status == DEVICE_NOTI_ON) { _I("popup - Battery health status is not good"); - pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); + + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); if (battery.temp == TEMP_LOW) battery_charge_err_low_act(NULL); else if (battery.temp == TEMP_HIGH) battery_charge_err_high_act(NULL); } else { - pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); abnormal_popup_timer_init(); launch_system_app(APP_DEFAULT, 2, APP_KEY_TYPE, REMOVE_POPUP); } @@ -460,7 +475,8 @@ static void update_ovp(enum battery_noti_status status) return; _I("charge %d ovp %d", battery.charge_now, battery.ovp); old = status; - pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); if (status == DEVICE_NOTI_ON) value = OVP_ABNORMAL; else @@ -1076,7 +1092,9 @@ static int display_changed(void *data) return 0; if (battery.health != HEALTH_BAD && battery.present != PRESENT_ABNORMAL) return 0; - pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); + + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); return 0; } diff --git a/src/core/main.c b/src/core/main.c index 0ce5b03..bf798f4 100755 --- a/src/core/main.c +++ b/src/core/main.c @@ -30,6 +30,7 @@ #include "devices.h" #include "power/boot.h" #include "power/power-handler.h" +#include "shared/plugin.h" #include "device-notifier.h" #define PIDFILE_PATH "/var/run/.deviced.pid" @@ -99,6 +100,8 @@ static int deviced_main(int argc, char **argv) if (!handle) _E("Fail to get dbus connection"); + load_plugins(); + devices_init(NULL); ret = dbus_handle_request_bus_name(handle, DEVICED_BUS_NAME, deviced_dbus_name_acquired, NULL); diff --git a/src/display/core.h b/src/display/core.h index 298a170..eb2b1b4 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -167,8 +167,6 @@ void reset_lcd_timeout(GDBusConnection *conn, const gchar *unique_name, gpointer data); -int check_lcdoff_lock_state(void); - /* setting.c */ int get_lock_screen_bg_state(void); int set_custom_lcdon_timeout(int timeout); diff --git a/src/display/display-ops.h b/src/display/display-ops.h index 1c1102d..478cf30 100644 --- a/src/display/display-ops.h +++ b/src/display/display-ops.h @@ -46,4 +46,13 @@ void add_display(const struct display_ops *disp); void remove_display(const struct display_ops *disp); const struct display_ops *find_display_feature(const char *name); +struct display_plugin { + int (*pm_lock_internal) (pid_t pid, int s_bits, int flag, int timeout); + int (*pm_unlock_internal) (pid_t pid, int s_bits, int flag); + int (*pm_change_internal) (pid_t pid, int s_bits); + int (*check_lcdoff_lock_state) (); + int (*update_pm_setting) (int key_idx, int val); + int (*get_lock_screen_state) (); + bool system_wakeup_flag; +}; #endif diff --git a/src/display/poll.h b/src/display/poll.h index a3e12a8..819ef97 100644 --- a/src/display/poll.h +++ b/src/display/poll.h @@ -147,10 +147,6 @@ extern int (*pm_callback) (int, PMMsg *); int init_input(void); int exit_input(void); -extern int pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout); -extern int pm_unlock_internal(pid_t pid, int s_bits, int flag); -extern int pm_change_internal(pid_t pid, int s_bits); - /** * @} */ diff --git a/src/display/setting.h b/src/display/setting.h index 9763c97..31dc03d 100644 --- a/src/display/setting.h +++ b/src/display/setting.h @@ -47,8 +47,6 @@ enum { SETTING_END }; -extern int (*update_pm_setting) (int key_idx, int val); - int get_setting_brightness(int *level); /* @@ -98,25 +96,8 @@ extern int get_usb_status(int *val); */ extern int set_setting_pmstate(int val); -/* - * get charging status at SLP-setting "memory/Battery/Charger" - * - * @internal - * @param[in] val charging or not (1 or 0 respectively). - * @return 0 : success, -1 : error - */ -extern int get_charging_status(int *val); - -/* - * get current battery low status at SLP-setting "memory/Battery/Status/Low" - * - * @internal - * @param[in] val current low battery status - * @return 0 : success, -1 : error - */ -extern int get_lowbatt_status(int *val); - -int get_lock_screen_state(void); +//FIXME +int __get_lock_screen_state(void); /* * @} diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c index 26780e1..4e03793 100644 --- a/src/extcon/cradle.c +++ b/src/extcon/cradle.c @@ -25,11 +25,13 @@ #include "core/device-notifier.h" #include "core/udev.h" #include "display/core.h" +#include "display/display-ops.h" #include "extcon/extcon.h" #define METHOD_GET_CRADLE "GetCradle" #define SIGNAL_CRADLE_STATE "ChangedCradle" +extern struct display_plugin disp_plgn; static struct extcon_ops cradle_extcon_ops; static void cradle_send_broadcast(int status) @@ -51,17 +53,21 @@ static void cradle_send_broadcast(int status) static int cradle_update(int status) { _I("jack - cradle changed %d", status); - pm_change_internal(INTERNAL_LOCK_CRADLE, LCD_NORMAL); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_CRADLE, LCD_NORMAL); cradle_send_broadcast(status); if (vconf_set_int(VCONFKEY_SYSMAN_CRADLE_STATUS, status) != 0) { _E("failed to set vconf status"); return -EIO; } - if (status == DOCK_SOUND) - pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); - else if (status == DOCK_NONE) - pm_unlock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, PM_SLEEP_MARGIN); + if (status == DOCK_SOUND) { + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); + } else if (status == DOCK_NONE) { + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, PM_SLEEP_MARGIN); + } return 0; } @@ -80,7 +86,8 @@ static int display_changed(void *data) cradle = cradle_extcon_ops.status; if (cradle == DOCK_SOUND) { - pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); _I("sound dock is connected! dim lock is on."); } diff --git a/src/extcon/earjack.c b/src/extcon/earjack.c index 3ab2ede..90748ff 100644 --- a/src/extcon/earjack.c +++ b/src/extcon/earjack.c @@ -24,12 +24,15 @@ #include "core/log.h" #include "display/poll.h" +#include "display/display-ops.h" #include "extcon/extcon.h" #include "extcon/extcon_count.h" #define SIGNAL_EARJACK_STATE "ChangedEarjack" #define GET_EARJACK_STATE "Earjack" +extern struct display_plugin disp_plgn; + static void earjack_send_broadcast(int status) { static int old = 0; @@ -68,8 +71,10 @@ static int earjack_update(int status) vconf_set_int(VCONFKEY_SYSMAN_EARJACK, status); earjack_send_broadcast(status); earjack_send_system_event(status); - if (status != 0) - pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL); + if (status != 0) { + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL); + } if (CONNECTED(status)) { extcon_get_count(EXTCON_EARJACK); diff --git a/src/extcon/hdmi.c b/src/extcon/hdmi.c index 6f80bfc..0331a0d 100644 --- a/src/extcon/hdmi.c +++ b/src/extcon/hdmi.c @@ -22,11 +22,13 @@ #include "core/log.h" #include "core/device-notifier.h" #include "display/core.h" +#include "display/display-ops.h" #include "extcon.h" #define METHOD_GET_HDMI "GetHDMI" #define SIGNAL_HDMI_STATE "ChangedHDMI" +extern struct display_plugin disp_plgn; static struct extcon_ops hdmi_extcon_ops; static void hdmi_send_broadcast(int status) @@ -48,14 +50,18 @@ static void hdmi_send_broadcast(int status) static int hdmi_update(int status) { _I("jack - hdmi changed %d", status); - pm_change_internal(INTERNAL_LOCK_HDMI, LCD_NORMAL); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_HDMI, LCD_NORMAL); vconf_set_int(VCONFKEY_SYSMAN_HDMI, status); hdmi_send_broadcast(status); - if (status == 1) - pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0); - else - pm_unlock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, PM_SLEEP_MARGIN); + if (status == 1) { + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0); + } else { + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, PM_SLEEP_MARGIN); + } return 0; } @@ -74,7 +80,8 @@ static int display_changed(void *data) hdmi = hdmi_extcon_ops.status; if (hdmi == 0) { - pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0); + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0); _I("hdmi is connected! dim lock is on."); } return 0; diff --git a/src/led/touch-key.c b/src/led/touch-key.c index c38eb9b..312150e 100644 --- a/src/led/touch-key.c +++ b/src/led/touch-key.c @@ -27,6 +27,7 @@ #include "core/device-notifier.h" #include "display/core.h" #include "display/setting.h" +#include "display/display-ops.h" #include "touch-key.h" #define KEYBACKLIGHT_TIME_90 90 /* 1.5 second */ @@ -43,6 +44,7 @@ #define GET_BRIGHTNESS(val) (((val) >> 24) & 0xFF) #define SET_BRIGHTNESS(val) (((val) & 0xFF) << 24) +extern struct display_plugin disp_plgn; struct led_device *touchled_dev; static guint hardkey_timeout_id; static int hardkey_duration; @@ -136,7 +138,7 @@ static void process_touchkey_enable(bool enable) touchled_set_state(true); /* do not create turnoff timer in case of idle lock state */ - if (get_lock_screen_state() == VCONFKEY_IDLE_LOCK) + if (disp_plgn.get_lock_screen_state && disp_plgn.get_lock_screen_state() == VCONFKEY_IDLE_LOCK) return; /* start timer */ diff --git a/src/power/boot.c b/src/power/boot.c index a7e6638..fe51e28 100644 --- a/src/power/boot.c +++ b/src/power/boot.c @@ -26,6 +26,7 @@ #include "core/device-notifier.h" #include "core/common.h" #include "display/poll.h" +#include "display/display-ops.h" #include "shared/deviced-systemd.h" #define SIGNAL_BOOTING_DONE "BootingDone" @@ -36,6 +37,8 @@ #define SYSTEMD_STATE_RUNNING "running" #define SYSTEMD_STATE_DEGRADED "degraded" +extern struct display_plugin disp_plgn; + int booting_finished(void) { char *state = NULL; @@ -115,7 +118,8 @@ static void booting_done_received(GDBusConnection *conn, remove_booting_done_handler(NULL); _I("real booting done, unlock LCD_OFF"); - pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN); + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN); _I("signal booting done"); diff --git a/src/power/power-handler.c b/src/power/power-handler.c index 661a845..76e04a7 100755 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -50,6 +50,7 @@ #include "display/poll.h" #include "display/setting.h" #include "display/core.h" +#include "display/display-ops.h" #include "power-handler.h" #include "apps/apps.h" #include "shared/deviced-systemd.h" @@ -71,6 +72,8 @@ #define POWER_CONF_FILE "/etc/deviced/power.conf" +extern struct display_plugin disp_plgn; + struct power_flag { enum poweroff_type type; const char *path; @@ -290,7 +293,8 @@ static void disable_display(void) { const struct device_ops *display_device_ops = NULL; FIND_DEVICE_VOID(display_device_ops, "display"); - pm_change_internal(INTERNAL_LOCK_POWEROFF, LCD_NORMAL); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_POWEROFF, LCD_NORMAL); display_device_ops->exit(NULL); } @@ -501,7 +505,8 @@ static gboolean poweroff_timeout_cb(void *data) make_power_flag(poweroff_opt.type, poweroff_opt.option); - pm_lock_internal(INTERNAL_LOCK_POWEROFF, LCD_OFF, STAY_CUR_STATE, 0); + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_POWEROFF, LCD_OFF, STAY_CUR_STATE, 0); poweroff_fixed_flow(poweroff_opt.type); @@ -513,8 +518,8 @@ static gboolean poweroff_timeout_cb(void *data) _E("Failed to %s (%d)", poweroff_opt.name, ret); out: - if (update_pm_setting) - update_pm_setting(SETTING_POWEROFF, poweroff_opt.type); + if (disp_plgn.update_pm_setting) + disp_plgn.update_pm_setting(SETTING_POWEROFF, poweroff_opt.type); during_poweroff = false; return G_SOURCE_REMOVE; } diff --git a/src/shared/plugin.c b/src/shared/plugin.c index 034aac3..ba96073 100644 --- a/src/shared/plugin.c +++ b/src/shared/plugin.c @@ -18,14 +18,19 @@ #define _GNU_SOURCE +#include #include #include #include #include #include +#include #include #include +#include +#include +#include "display/display-ops.h" #include "common.h" #include "core/log.h" @@ -34,12 +39,14 @@ #endif #define MODULE_PATH LIBPATH"/deviced" +struct display_plugin disp_plgn; + int load_plugin(const char *id, void **h) { char path[PATH_MAX]; void *handle; - if (!id || !h) + if (!id) return -EINVAL; /* Find matched module path */ @@ -50,19 +57,18 @@ int load_plugin(const char *id, void **h) } /* Load module */ - handle = dlopen(path, RTLD_LAZY|RTLD_GLOBAL); - //handle = dlopen(path, RTLD_NOW|RTLD_GLOBAL); + handle = dlopen(path, RTLD_NOW|RTLD_GLOBAL); if (!handle) { _E("fail to open module : %s", dlerror()); return -ENOENT; } - *h = handle; + if (h) + *h = handle; return 0; } - int unload_plugin(void *h) { if (!h) @@ -70,3 +76,10 @@ int unload_plugin(void *h) else return dlclose(h); } + +void load_plugins() +{ + load_plugin("display", NULL); + + return; +} diff --git a/src/shared/plugin.h b/src/shared/plugin.h index fefaef4..ba9c633 100755 --- a/src/shared/plugin.h +++ b/src/shared/plugin.h @@ -21,5 +21,6 @@ int load_plugin(const char *id, void **h); int unload_plugin(void *h); +void load_plugins(); #endif /* __DD_PLUGIN_H__ */ diff --git a/src/time/time-handler.c b/src/time/time-handler.c index e078439..e2f7db2 100644 --- a/src/time/time-handler.c +++ b/src/time/time-handler.c @@ -36,6 +36,7 @@ #include "core/devices.h" #include "display/poll.h" #include "display/core.h" +#include "display/display-ops.h" #include "core/common.h" #include "core/device-notifier.h" @@ -63,6 +64,7 @@ #define TIME_CHANGE_SIGNAL "STimeChanged" +extern struct display_plugin disp_plgn; static const time_t default_time = 2147483645; /* max(32bit) -3sec */ static guint tfdh; /* tfd change noti */ int tfd = -1; @@ -179,9 +181,14 @@ int set_datetime_action(int argc, char **argv) else pm_state = 0x4; - pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); + ret = handle_date(argv[0]); - pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); + + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); + return ret; } @@ -200,9 +207,14 @@ int set_timezone_action(int argc, char **argv) else pm_state = 0x4; - pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); + ret = handle_timezone(argv[0]); - pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); + + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); + return ret; } @@ -338,7 +350,9 @@ static int time_lcd_changed_cb(void *data) if (lcd_state < S_LCDOFF) goto restart; - lcd_state = check_lcdoff_lock_state(); + if (disp_plgn.check_lcdoff_lock_state) + lcd_state = disp_plgn.check_lcdoff_lock_state(); + if (lcd_state || !tfdh || tfd == -1) goto out; diff --git a/src/usb/usb.c b/src/usb/usb.c index db380f5..f6cb515 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -27,12 +27,14 @@ #include "core/common.h" #include "core/device-notifier.h" #include "display/poll.h" +#include "display/display-ops.h" #include "extcon/extcon.h" #include "apps/apps.h" #include "usb.h" #include "usb-tethering.h" #include "usb-debug.h" +extern struct display_plugin disp_plgn; static struct usb_gadget_translator *gadget_translator; static struct usb_client *usb_client; @@ -280,8 +282,9 @@ static int usb_enable(unsigned int mode) } usb_state_update_state(USB_CONNECTED, mode); - pm_lock_internal(INTERNAL_LOCK_USB, - LCD_OFF, STAY_CUR_STATE, 0); + + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0); return 0; } @@ -303,8 +306,8 @@ static int usb_disable(void) _E("Failed to disable usb config (%d)", ret); } - pm_unlock_internal(INTERNAL_LOCK_USB, - LCD_OFF, STAY_CUR_STATE); + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE); return 0; } diff --git a/src/usbhost/usb-host.c b/src/usbhost/usb-host.c index 074bab0..06b0d14 100755 --- a/src/usbhost/usb-host.c +++ b/src/usbhost/usb-host.c @@ -32,6 +32,7 @@ #include "core/device-idler.h" #include "apps/apps.h" #include "extcon/extcon.h" +#include "display/display-ops.h" #define USB_INTERFACE_CLASS "bInterfaceClass" #define USB_INTERFACE_SUBCLASS "bInterfaceSubClass" @@ -50,6 +51,7 @@ #define ROOTPATH tzplatform_getenv(TZ_SYS_VAR) #define POLICY_FILENAME "usbhost-policy" +extern struct display_plugin disp_plgn; char *POLICY_FILEPATH; /** @@ -250,7 +252,8 @@ static int add_usbhost_list(struct udev_device *dev, const char *devpath) broadcast_usbhost_signal(USB_HOST_ADDED, usbhost); - pm_change_internal(INTERNAL_LOCK_USB, LCD_NORMAL); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_USB, LCD_NORMAL); /* for debugging */ _I("USB HOST Added"); @@ -278,7 +281,8 @@ static int remove_usbhost_list(const char *devpath) broadcast_usbhost_signal(USB_HOST_REMOVED, usbhost); - pm_change_internal(INTERNAL_LOCK_USB, LCD_NORMAL); + if (disp_plgn.pm_change_internal) + disp_plgn.pm_change_internal(INTERNAL_LOCK_USB, LCD_NORMAL); /* for debugging */ _I("USB HOST Removed"); @@ -1179,10 +1183,12 @@ static int extcon_usbhost_state_changed(int status) { if (status == 0) { _I("USB host connector disconnected"); - pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE); + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE); } else { _I("USB host connector connected"); - pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0); + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0); } return 0; } -- 2.7.4