From d2ec47c434e5dfe9433358ef11e34eeed859583d Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 10 Sep 2020 16:14:30 +0900 Subject: [PATCH 01/16] Change function name ex) dh_get_param_from_var to g_variant_get_safe Change-Id: Ie8f2efe288b983debe60ec29100a4e146e280827 Signed-off-by: lokilee73 --- plugins/mobile/battery/battery-notification.c | 4 ++-- plugins/wearable/display/display-handler.c | 2 +- plugins/wearable/display/swim.c | 2 +- src/apps/apps.c | 2 +- src/auto-test/battery.c | 14 +++++++------- src/auto-test/brightness.c | 2 +- src/auto-test/display.c | 6 +++--- src/auto-test/extcon.c | 6 +++--- src/auto-test/ir.c | 4 ++-- src/auto-test/led.c | 4 ++-- src/auto-test/power.c | 4 ++-- src/auto-test/proc.c | 2 +- src/auto-test/test.c | 2 +- src/auto-test/time.c | 2 +- src/auto-test/udev.c | 2 +- src/battery-monitor/battery-monitor.c | 2 +- src/battery/power-supply.c | 6 +++--- src/devicectl/devicectl.c | 12 ++++++------ src/display/ambient-mode.c | 2 +- src/display/display-dbus.c | 2 +- src/display/display-lock.c | 2 +- src/dump/dump.c | 2 +- src/libdeviced/deviced-noti.c | 10 +++++----- src/libdeviced/display.c | 6 +++--- src/libdeviced/led.c | 6 +++--- src/libdeviced/usbhost.c | 6 +++--- src/usb-host-test/usb-host-test.c | 4 ++-- src/usb/usb-dbus.c | 2 +- src/usb/usb-state.c | 2 +- src/usbhost/usb-host.c | 2 +- 30 files changed, 62 insertions(+), 62 deletions(-) mode change 100644 => 100755 src/auto-test/led.c mode change 100644 => 100755 src/auto-test/time.c diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c index 11cd6d7..6b9c4b4 100644 --- a/plugins/mobile/battery/battery-notification.c +++ b/plugins/mobile/battery/battery-notification.c @@ -92,7 +92,7 @@ static void low_noti_cb(GVariant *var, void *user_data, GError *err) return; } - if (!dh_get_param_from_var(var, "(i)", ¬i_low)) { + if (!g_variant_get_safe(var, "(i)", ¬i_low)) { _E("Failed to notify low: no message(%s)", g_variant_get_type_string(var)); goto out; } @@ -110,7 +110,7 @@ static void critical_noti_cb(GVariant *var, void *user_data, GError *err) if (!var) return; - if (!dh_get_param_from_var(var, "(i)", &id)) { + if (!g_variant_get_safe(var, "(i)", &id)) { _E("Failed to notify critical: no message(%s)", g_variant_get_type_string(var)); goto out; } diff --git a/plugins/wearable/display/display-handler.c b/plugins/wearable/display/display-handler.c index 1c2f778..27b97a8 100644 --- a/plugins/wearable/display/display-handler.c +++ b/plugins/wearable/display/display-handler.c @@ -122,7 +122,7 @@ static void aod_change_signal(GDBusConnection *conn, { char *screen = NULL; - if (!dh_get_param_from_var(param, "(s)", &screen)) { + if (!g_variant_get_safe(param, "(s)", &screen)) { _E("failed to get params from gvariant. expected:%s, type:%s", "(s)", g_variant_get_type_string(param)); goto out; } diff --git a/plugins/wearable/display/swim.c b/plugins/wearable/display/swim.c index 0361d62..2b093dc 100644 --- a/plugins/wearable/display/swim.c +++ b/plugins/wearable/display/swim.c @@ -78,7 +78,7 @@ static void swimmode_signal_handler(GDBusConnection *conn, pid_t pid; bool lcd_state = false; - if (!dh_get_param_from_var(param, "(i)", &val)) { + if (!g_variant_get_safe(param, "(i)", &val)) { _E("failed to get params from gvariant. expected:%s, type:%s", "(i)", g_variant_get_type_string(param)); return; } diff --git a/src/apps/apps.c b/src/apps/apps.c index 744e3af..a192797 100644 --- a/src/apps/apps.c +++ b/src/apps/apps.c @@ -50,7 +50,7 @@ static void __cb(GVariant *var, void *user_data, GError *err) return; } - if (!dh_get_param_from_var(var, "(i)", &ret)) { + if (!g_variant_get_safe(var, "(i)", &ret)) { _E("No message: %s", g_variant_get_type_string(var)); goto out; } diff --git a/src/auto-test/battery.c b/src/auto-test/battery.c index 4ebf33e..93a69c4 100644 --- a/src/auto-test/battery.c +++ b/src/auto-test/battery.c @@ -236,7 +236,7 @@ static bool get_battery_method(const char *method, int *value) } if (!strncmp(method, METHOD_BATTERY_HEALTH, strlen(METHOD_BATTERY_HEALTH))) { - if (!dh_get_param_from_var(msg, "(s)", &health)) { + if (!g_variant_get_safe(msg, "(s)", &health)) { _E("Failed to call dbus method(%s): No message.", METHOD_BATTERY_HEALTH); } else { _I("Success. %s=%s", METHOD_BATTERY_HEALTH, health); @@ -245,7 +245,7 @@ static bool get_battery_method(const char *method, int *value) } else { - if (!dh_get_param_from_var(msg, "(i)", &val)) { + if (!g_variant_get_safe(msg, "(i)", &val)) { _E("Failed to call dbus method(%s): No message.", method); } else { _I("Success. %s=%d", method, val); @@ -277,7 +277,7 @@ static bool get_battery_method_vconf(const char *method) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("Failed to call dbus method(%s): No message.", method); else { if (val == -EIO) { @@ -324,7 +324,7 @@ static bool set_battery_low_level(int newlevel) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) { + if (!g_variant_get_safe(msg, "(i)", &val)) { _E("Failed to call dbus method(%s): No message", METHOD_BATTERY_SETLOWBATLEVEL); goto out; } else { @@ -410,7 +410,7 @@ static bool get_battery_info() return ret; } - if (!dh_get_param_from_var(msg, "(isssiiiiiiii)", &val[0], //return value + if (!g_variant_get_safe(msg, "(isssiiiiiiii)", &val[0], //return value &argv[0],//status &argv[1],//health &argv[2],//power source @@ -709,7 +709,7 @@ static bool set_battery_power_supply(int index) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) { + if (!g_variant_get_safe(msg, "(i)", &val)) { _E("Failed to call dbus method(%s): No message", POWER_SUBSYSTEM); val = -EBADMSG; } else { @@ -742,7 +742,7 @@ static bool get_battery_power_supply(int rsp[], char **power_source) return ret; } - if (!dh_get_param_from_var(msg, "(iiiiiiiisiiiii)", &val, //return value + if (!g_variant_get_safe(msg, "(iiiiiiiisiiiii)", &val, //return value &rsp[0], //capacity &rsp[1], //charge_status &rsp[2], //health diff --git a/src/auto-test/brightness.c b/src/auto-test/brightness.c index 97d9912..424adb6 100644 --- a/src/auto-test/brightness.c +++ b/src/auto-test/brightness.c @@ -72,7 +72,7 @@ static void check_result(int expect_default, int expect_current) return; } - if (!dh_get_param_from_var(msg, "(ii)", &result_default, &result_current)) { + if (!g_variant_get_safe(msg, "(ii)", &result_default, &result_current)) { _D("Return type mismatching from GetBrightnessInfo."); return; } diff --git a/src/auto-test/display.c b/src/auto-test/display.c index c2494f5..0b92d84 100644 --- a/src/auto-test/display.c +++ b/src/auto-test/display.c @@ -68,7 +68,7 @@ static bool get_display_method(const char *method, GVariant *param, int *value) _E("fail (%s): no reply", method); return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail (%s): no message", method); else { _I("success (%s): %d", method, val); @@ -96,7 +96,7 @@ static bool set_display_method(const char *method, GVariant *param) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail (%s): no message", method); else { if ((val == -ENOTSUP) || (val == -ENOSYS)) { @@ -167,7 +167,7 @@ static bool set_display_autobrightness_min(int min) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) { + if (!g_variant_get_safe(msg, "(i)", &val)) { _E("fail : no message"); } else { if ((min < 1) || (min > 100)) { diff --git a/src/auto-test/extcon.c b/src/auto-test/extcon.c index ed2c187..645eda6 100644 --- a/src/auto-test/extcon.c +++ b/src/auto-test/extcon.c @@ -40,7 +40,7 @@ static bool request_extcon_method(const char *method, GVariant *param) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail (%s): no message", method); else { if ((val == -ENOTSUP) || (val == -ENOSYS)) { @@ -73,7 +73,7 @@ static bool get_sysnoti_method(const char *method) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail (%s): no message", method); else { if ((val == -ENOTSUP) || (val == -ENOSYS)) { @@ -107,7 +107,7 @@ static bool get_extcon_status(char *device_name) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail : no message"); else { if ((val == -ENOTSUP) || (val == -ENOSYS)) { diff --git a/src/auto-test/ir.c b/src/auto-test/ir.c index de548b9..48ad1c0 100644 --- a/src/auto-test/ir.c +++ b/src/auto-test/ir.c @@ -52,7 +52,7 @@ static bool request_ir_method(const char *method, const char *sig, int *param) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail (%s): no message", method); else { if ((val == -ENOTSUP) || (val == -ENOSYS)) { @@ -106,7 +106,7 @@ static bool set_ir_command(char *command) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail : no message"); else { if ((val == -ENOTSUP) || (val == -ENOSYS)) { diff --git a/src/auto-test/led.c b/src/auto-test/led.c old mode 100644 new mode 100755 index 7e4356d..9d3ffe8 --- a/src/auto-test/led.c +++ b/src/auto-test/led.c @@ -52,7 +52,7 @@ static bool get_led_method(const char *method) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail (%s): no message", method); else { _I("success (%s): %d", method, val); @@ -78,7 +78,7 @@ static bool set_led_method(const char *method, GVariant *param) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail (%s): no message", method); else { if ((val == -ENOTSUP) || (val == -ENOSYS)) { diff --git a/src/auto-test/power.c b/src/auto-test/power.c index 96a6a85..2a88a98 100644 --- a/src/auto-test/power.c +++ b/src/auto-test/power.c @@ -40,7 +40,7 @@ static bool set_reboot_method(const char *method, GVariant *param) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail (%s): no message", method); else { if ((val == -ENOTSUP) || (val == -ENOSYS)) { @@ -86,7 +86,7 @@ static bool request_lowpower_method(const char *method, GVariant *param) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail (%s): no message", method); else { if (val == -EAGAIN) { diff --git a/src/auto-test/proc.c b/src/auto-test/proc.c index 44bb8dc..914d922 100644 --- a/src/auto-test/proc.c +++ b/src/auto-test/proc.c @@ -35,7 +35,7 @@ static bool get_sysnoti_revision() return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail : no message"); else { if ((val == -ENOTSUP) || (val == -ENOSYS)) { diff --git a/src/auto-test/test.c b/src/auto-test/test.c index 794bb74..6039944 100644 --- a/src/auto-test/test.c +++ b/src/auto-test/test.c @@ -92,7 +92,7 @@ void __cb(void *data, GVariant *result, GError *err) return; } - if (!dh_get_param_from_var(result, "(i)", &temp)) { + if (!g_variant_get_safe(result, "(i)", &temp)) { _E("Failed to get variant(%s): no call back message", g_variant_get_type_string(result)); goto out; } diff --git a/src/auto-test/time.c b/src/auto-test/time.c old mode 100644 new mode 100755 index 036b919..5b9daae --- a/src/auto-test/time.c +++ b/src/auto-test/time.c @@ -36,7 +36,7 @@ static bool request_sysnoti_method(const char *method, GVariant *param) return ret; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail (%s): no message", method); else { if ((val == -ENOTSUP) || (val == -ENOSYS)) { diff --git a/src/auto-test/udev.c b/src/auto-test/udev.c index 25e3c8e..cc48c43 100644 --- a/src/auto-test/udev.c +++ b/src/auto-test/udev.c @@ -42,7 +42,7 @@ static int udev(int index) return -EBADMSG; } - if (!dh_get_param_from_var(msg, "(i)", &val)) + if (!g_variant_get_safe(msg, "(i)", &val)) _E("fail : no message"); else { if ((val == -ENOTSUP) || (val == -ENOSYS)) { diff --git a/src/battery-monitor/battery-monitor.c b/src/battery-monitor/battery-monitor.c index 50e719a..f6168dc 100644 --- a/src/battery-monitor/battery-monitor.c +++ b/src/battery-monitor/battery-monitor.c @@ -439,7 +439,7 @@ static void _dbus_cb_AppStatusChange(GDBusConnection *conn, char *status = NULL; /* (issss) : pid, appid, pkgid, status, type */ - if (!dh_get_param_from_var(param, "(issss)", &pid, &appid, NULL, &status, NULL)) { + if (!g_variant_get_safe(param, "(issss)", &pid, &appid, NULL, &status, NULL)) { _E("Failed to get params from gvariant. expected:%s, type:%s", "(issss)", g_variant_get_type_string(param)); goto out; } diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 06b2ed7..34722aa 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -184,7 +184,7 @@ static void full_noti_cb(GVariant *var, void *user_data, GError *err) if (!var) return; - if (!dh_get_param_from_var(var, "(i)", &id)) { + if (!g_variant_get_safe(var, "(i)", &id)) { _E("Failed to notify full: no message(%s)", g_variant_get_type_string(var)); goto out; } @@ -200,7 +200,7 @@ static void noti_off_cb(GVariant *var, void *user_data, GError *err) { int ret = 0; - if (!dh_get_param_from_var(var, "(i)", &ret)) { + if (!g_variant_get_safe(var, "(i)", &ret)) { _E("Failed to off notification: no message(%s)", g_variant_get_type_string(var)); goto out; } @@ -267,7 +267,7 @@ static void charge_noti_on(GVariant *var, void *user_data, GError *err) if (!var) return; - if (!dh_get_param_from_var(var, "(i)", &id)) { + if (!g_variant_get_safe(var, "(i)", &id)) { _E("Failed to notify charge: no message(%s)", g_variant_get_type_string(var)); goto out; } diff --git a/src/devicectl/devicectl.c b/src/devicectl/devicectl.c index 1b4b0c4..8358377 100644 --- a/src/devicectl/devicectl.c +++ b/src/devicectl/devicectl.c @@ -128,7 +128,7 @@ static int dump_mode(char **args) goto out; } - if (!dh_get_param_from_var(msg, "(i)", &ret)) { + if (!g_variant_get_safe(msg, "(i)", &ret)) { printf("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); ret = -EBADMSG; } @@ -163,7 +163,7 @@ static int display_state(char **args) goto out; } - if (!dh_get_param_from_var(msg, "(i)", &ret)) { + if (!g_variant_get_safe(msg, "(i)", &ret)) { printf("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); ret = -EBADMSG; } @@ -242,7 +242,7 @@ static int save_dbus_name(char **args) return -EBADMSG; } - if (!dh_get_param_from_var(msg, "(as)", &iter)) { + if (!g_variant_get_safe(msg, "(as)", &iter)) { printf("Invalid list name arguments."); g_variant_unref(msg); return -EINVAL; @@ -316,7 +316,7 @@ static int enable_device(char **args) goto out; } - if (!dh_get_param_from_var(msg, "(i)", &ret)) { + if (!g_variant_get_safe(msg, "(i)", &ret)) { printf("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); ret = -EBADMSG; } @@ -349,7 +349,7 @@ static int disable_device(char **args) goto out; } - if (!dh_get_param_from_var(msg, "(i)", &ret)) { + if (!g_variant_get_safe(msg, "(i)", &ret)) { printf("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); ret = -EBADMSG; } @@ -382,7 +382,7 @@ static int power_operation(char **args, char *type) goto out; } - if (!dh_get_param_from_var(msg, "(i)", &ret)) { + if (!g_variant_get_safe(msg, "(i)", &ret)) { printf("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); ret = -EBADMSG; } diff --git a/src/display/ambient-mode.c b/src/display/ambient-mode.c index a0bb2bc..0e5e478 100644 --- a/src/display/ambient-mode.c +++ b/src/display/ambient-mode.c @@ -209,7 +209,7 @@ static void homescreen_signal_handler(GDBusConnection *conn, char *screen = NULL; pid_t pid; - if (!dh_get_param_from_var(param, "(s)", &screen)) { + if (!g_variant_get_safe(param, "(s)", &screen)) { _E("failed to get params from gvariant. expected:%s, type:%s", "(s)", g_variant_get_type_string(param)); goto out; } diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index 7dbb69a..e56c7f3 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -1240,7 +1240,7 @@ static void changestate_signal_handler(GDBusConnection *conn, char *state = NULL; pid_t pid; - if (!dh_get_param_from_var(param, "(issss)", &val, NULL, NULL, &state, NULL)) { + if (!g_variant_get_safe(param, "(issss)", &val, NULL, NULL, &state, NULL)) { _E("failed to get params from gvariant. expected:%s, type:%s", "(issss)", g_variant_get_type_string(param)); goto out; } diff --git a/src/display/display-lock.c b/src/display/display-lock.c index b1e08d4..b0d2568 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -77,7 +77,7 @@ static void default_pmlock_check_cb(GVariant *var, void *user_data, GError *err) if (!var) return; - if (!dh_get_param_from_var(var, "(iis)", &pid, &detected, &app_id)) { + if (!g_variant_get_safe(var, "(iis)", &pid, &detected, &app_id)) { _E("Failed to get params from gvariant. expected:%s, type:%s", "(iis)", g_variant_get_type_string(var)); goto out; } diff --git a/src/dump/dump.c b/src/dump/dump.c index da2d4fb..dc39db1 100644 --- a/src/dump/dump.c +++ b/src/dump/dump.c @@ -98,7 +98,7 @@ static void dump_signal_handler(GDBusConnection *conn, int mode = 0; char *log_path = NULL; - if (!dh_get_param_from_var(param, "(is)", &mode, &log_path)) { + if (!g_variant_get_safe(param, "(is)", &mode, &log_path)) { _E("failed to get params from gvariant. expected:%s, type:%s", "(is)", g_variant_get_type_string(param)); goto out; } diff --git a/src/libdeviced/deviced-noti.c b/src/libdeviced/deviced-noti.c index fa371ee..7fbbd7e 100644 --- a/src/libdeviced/deviced-noti.c +++ b/src/libdeviced/deviced-noti.c @@ -67,7 +67,7 @@ static int dbus_proc_handler(char* type, char *buf) if (!msg) return -EBADMSG; - if (!dh_get_param_from_var(msg, "(i)", &val)) { + if (!g_variant_get_safe(msg, "(i)", &val)) { _E("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); val = -EBADMSG; goto out; @@ -121,7 +121,7 @@ static int dbus_power_handler(char* type) if (!msg) return -EBADMSG; - if (!dh_get_param_from_var(msg, "(i)", &val)) { + if (!g_variant_get_safe(msg, "(i)", &val)) { _E("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); val = -EBADMSG; goto out; @@ -165,7 +165,7 @@ static int dbus_time_handler(char* type, char* buf) if (!msg) return -EBADMSG; - if (!dh_get_param_from_var(msg, "(i)", &val)) { + if (!g_variant_get_safe(msg, "(i)", &val)) { _E("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); val = -EBADMSG; goto out; @@ -202,7 +202,7 @@ static int alarm_set_time(time_t timet) return -EBADMSG; } - if (!dh_get_param_from_var(msg, "(i)", &val)) { + if (!g_variant_get_safe(msg, "(i)", &val)) { _E("Failed to get type(%s): no message", g_variant_get_type_string(msg)); val = -EBADMSG; } @@ -243,7 +243,7 @@ static int dbus_cpu_handler(char* type, char* buf_pid, char* buf_freq) if (!msg) return -EBADMSG; - if (!dh_get_param_from_var(msg, "(i)", &val)) { + if (!g_variant_get_safe(msg, "(i)", &val)) { _E("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); val = -EBADMSG; goto out; diff --git a/src/libdeviced/display.c b/src/libdeviced/display.c index 5985d82..3247822 100644 --- a/src/libdeviced/display.c +++ b/src/libdeviced/display.c @@ -116,7 +116,7 @@ static void display_change_cb(GVariant *var, void *user_data, GError *err) if (!var) return; - if (!dh_get_param_from_var(var, "(i)", &val)) { + if (!g_variant_get_safe(var, "(i)", &val)) { _E("Failed to get(%s): no message", g_variant_get_type_string(var)); g_variant_unref(var); return; @@ -159,7 +159,7 @@ static void display_lock_cb(GVariant *var, void *user_data, GError *err) if (!var) return; - if (!dh_get_param_from_var(var, "(i)", &val)) { + if (!g_variant_get_safe(var, "(i)", &val)) { _E("Failed to get(%s): no message", g_variant_get_type_string(var)); goto out; } @@ -217,7 +217,7 @@ static void display_unlock_cb(GVariant *var, void *user_data, GError *err) if (!var) return; - if (!dh_get_param_from_var(var, "(i)", &val)) { + if (!g_variant_get_safe(var, "(i)", &val)) { _E("Failed to get(%s): no message", g_variant_get_type_string(var)); goto out; } diff --git a/src/libdeviced/led.c b/src/libdeviced/led.c index 85537b2..af43c64 100644 --- a/src/libdeviced/led.c +++ b/src/libdeviced/led.c @@ -43,7 +43,7 @@ API int led_get_brightness(void) if (!msg) return -EBADMSG; - if (!dh_get_param_from_var(msg, "(i)", &ret_val)) { + if (!g_variant_get_safe(msg, "(i)", &ret_val)) { _E("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); ret_val = -EBADMSG; } @@ -66,7 +66,7 @@ API int led_get_max_brightness(void) if (!msg) return -EBADMSG; - if (!dh_get_param_from_var(msg, "(i)", &ret_val)) { + if (!g_variant_get_safe(msg, "(i)", &ret_val)) { _E("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); ret_val = -EBADMSG; } @@ -89,7 +89,7 @@ API int led_set_brightness_with_noti(int val, bool enable) if (!msg) return -EBADMSG; - if (!dh_get_param_from_var(msg, "(i)", &ret_val)) { + if (!g_variant_get_safe(msg, "(i)", &ret_val)) { _E("Failed to get signature(%s): no message", g_variant_get_type_string(msg)); ret_val = -EBADMSG; } diff --git a/src/libdeviced/usbhost.c b/src/libdeviced/usbhost.c index 808ef1b..a813c1f 100644 --- a/src/libdeviced/usbhost.c +++ b/src/libdeviced/usbhost.c @@ -95,7 +95,7 @@ static void storage_signal_handler(GDBusConnection *conn, dd_list *elem; struct signal_handler *handler; - if (!dh_get_param_from_var(param, "(ssi)", &type, &syspath, &mount)) { + if (!g_variant_get_safe(param, "(ssi)", &type, &syspath, &mount)) { _E("failed to get params from gvariant. expected:%s, type:%s", "(ssi)", g_variant_get_type_string(param)); goto out; } @@ -135,7 +135,7 @@ static void device_signal_handler(GDBusConnection *conn, dd_list *element; memset(&device, 0, sizeof(device)); - if (!dh_get_param_from_var(param, "(isiiiiisss)", &state, + if (!g_variant_get_safe(param, "(isiiiiisss)", &state, &syspath, &device.baseclass, &device.subclass, @@ -362,7 +362,7 @@ API int open_usb_device(char *path, int *out_fd) _E("Failed to get fd list."); return -1; } - if (!dh_get_param_from_var(reply, "(i)", &ret)) { + if (!g_variant_get_safe(reply, "(i)", &ret)) { _E("Failed to get(%s): no message.", g_variant_get_type_string(reply)); ret = -1; goto out; diff --git a/src/usb-host-test/usb-host-test.c b/src/usb-host-test/usb-host-test.c index 0f2ac13..cf10da9 100644 --- a/src/usb-host-test/usb-host-test.c +++ b/src/usb-host-test/usb-host-test.c @@ -268,7 +268,7 @@ static void service_started_handler(GDBusConnection *conn, char *unit = NULL; int ret; - if (!dh_get_param_from_var(param, "(uoss)", &id, NULL, &unit, NULL)) { + if (!g_variant_get_safe(param, "(uoss)", &id, NULL, &unit, NULL)) { _E("failed to get params from gvariant. expected:%s, type:%s", "(uoss)", g_variant_get_type_string(param)); return ; } @@ -310,7 +310,7 @@ static void service_stopped_handler(GDBusConnection *conn, usbg_state *s; usbg_gadget *g; - if (!dh_get_param_from_var(param, "(uoss)", &id, NULL, &unit, NULL)) { + if (!g_variant_get_safe(param, "(uoss)", &id, NULL, &unit, NULL)) { _E("failed to get params from gvariant. expected:%s, type:%s", "(uoss)", g_variant_get_type_string(param)); return ; } diff --git a/src/usb/usb-dbus.c b/src/usb/usb-dbus.c index 5bc9a87..db428aa 100644 --- a/src/usb/usb-dbus.c +++ b/src/usb/usb-dbus.c @@ -91,7 +91,7 @@ static void change_usb_client_mode(GDBusConnection *conn, unsigned int mode; int req_vconf = -1; - if (!dh_get_param_from_var(param, "(i)", &req_vconf)) { + if (!g_variant_get_safe(param, "(i)", &req_vconf)) { _E("failed to get params from gvariant. expected:%s, type:%s", "(i)", g_variant_get_type_string(param)); return; } diff --git a/src/usb/usb-state.c b/src/usb/usb-state.c index 5e232a3..a88b5df 100644 --- a/src/usb/usb-state.c +++ b/src/usb/usb-state.c @@ -259,7 +259,7 @@ static void media_noti_cb(GVariant *var, void *user_data, GError *err) return; } - if (!dh_get_param_from_var(var, "(i)", &id)) { + if (!g_variant_get_safe(var, "(i)", &id)) { _E("Failed to get variant(%s): no USB notification message", g_variant_get_type_string(var)); goto out; } diff --git a/src/usbhost/usb-host.c b/src/usbhost/usb-host.c index 0c02247..91a5cf1 100644 --- a/src/usbhost/usb-host.c +++ b/src/usbhost/usb-host.c @@ -902,7 +902,7 @@ static void popup_result_signal_handler(GDBusConnection *conn, return; } - if (!dh_get_param_from_var(param, "(ii)", &allow, &always)) { + if (!g_variant_get_safe(param, "(ii)", &allow, &always)) { _E("failed to get params from gvariant. expected:%s, type:%s", "(ii)", g_variant_get_type_string(param)); free(req); return; -- 2.7.4 From a026a78765f1c24d9b63b52fc87147173e55791e Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Fri, 4 Sep 2020 12:10:09 +0900 Subject: [PATCH 02/16] The battery plugin is not built, when battery module is off. Change-Id: I5d3ded1a4708448c77a7bc61a31ed8d4134005ea Signed-off-by: Yunmi Ha --- CMakeLists.txt | 6 ++++-- packaging/deviced.spec | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2cda03..45d8cab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -314,8 +314,10 @@ ADD_SUBDIRECTORY(plugins/mobile/display) ADD_SUBDIRECTORY(plugins/wearable/display) ADD_SUBDIRECTORY(plugins/tv/display) ADD_SUBDIRECTORY(plugins/iot/display) -ADD_SUBDIRECTORY(plugins/mobile/battery) -ADD_SUBDIRECTORY(plugins/wearable/battery) +IF(BATTERY_MODULE STREQUAL on) + ADD_SUBDIRECTORY(plugins/mobile/battery) + ADD_SUBDIRECTORY(plugins/wearable/battery) +ENDIF() INSTALL_CONF(conf mobile-display) INSTALL_CONF(conf wearable-display) INSTALL_CONF(conf tv-display) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 34f1af3..f23b4da 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -216,13 +216,17 @@ fi mv %{_sysconfdir}/deviced/mobile-display.conf %{_sysconfdir}/deviced/display.conf mkdir -p %{_libdir}/deviced mv %{_libdir}/mobile-display.so %{_libdir}/deviced/display.so +%if %{?battery_module} == on mv %{_libdir}/mobile-battery.so %{_libdir}/deviced/battery.so +%endif %post plugin-profile-wearable mv %{_sysconfdir}/deviced/wearable-display.conf %{_sysconfdir}/deviced/display.conf mkdir -p %{_libdir}/deviced mv %{_libdir}/wearable-display.so %{_libdir}/deviced/display.so +%if %{?battery_module} == on mv %{_libdir}/wearable-battery.so %{_libdir}/deviced/battery.so +%endif %post plugin-profile-tv mv %{_sysconfdir}/deviced/tv-display.conf %{_sysconfdir}/deviced/display.conf @@ -297,7 +301,9 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so %defattr(-,root,root,-) %config %{_sysconfdir}/deviced/mobile-display.conf %{_libdir}/mobile-display.so +%if %{?battery_module} == on %{_libdir}/mobile-battery.so +%endif %{_unitdir}/rndis.service %{_bindir}/rndis.sh @@ -307,7 +313,9 @@ mv %{_libdir}/iot-display.so %{_libdir}/deviced/display.so %defattr(-,root,root,-) %config %{_sysconfdir}/deviced/wearable-display.conf %{_libdir}/wearable-display.so +%if %{?battery_module} == on %{_libdir}/wearable-battery.so +%endif %{_unitdir}/rndis.service %{_bindir}/rndis.sh -- 2.7.4 From d8702488cb1fa4cf5e8f6f85133f8bae5e0cbd26 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Thu, 10 Sep 2020 17:26:16 +0900 Subject: [PATCH 03/16] Fix battery link error when battery module is off - When battery_module option is off, there is link error about undefined function. - Get battery reference by battery plugin handle. Change-Id: I4b8649c98d52617bd98f97cfd37f52a355a1d565 Signed-off-by: Yunmi Ha --- plugins/iot/display/core.c | 20 ++++++++++++++++---- plugins/mobile/display/core.c | 20 ++++++++++++++++---- plugins/tv/display/core.c | 20 ++++++++++++++++---- plugins/wearable/display/core.c | 20 ++++++++++++++++---- plugins/wearable/display/device-interface.c | 27 ++++++++++++++++++++------- src/shared/plugin.c | 4 ++-- 6 files changed, 86 insertions(+), 25 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index b8aa6ee..f6b0c98 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -88,11 +89,12 @@ #define PM_SUSPEND 1 extern void init_pm_internal(); -extern int get_charging_status(int *val); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; static struct _backlight_ops *backlight_ops; +static struct battery_plugin *battery_plgn; +static int (*fp_get_charging_status) (int *val); static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; @@ -1768,7 +1770,7 @@ static void check_seed_status(void) int lock_state; /* Charging check */ - if ((get_charging_status(&tmp) == 0) && (tmp > 0)) + if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) set_pm_status_flag(CHRGR_FLAG); ret = get_setting_brightness(&tmp); @@ -2062,6 +2064,13 @@ static int display_probe(void *data) init_pm_internal(); disp_plgn->device_flags_to_string = __device_flags_to_string; + if (battery_plgn->handle) { + fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status"); + if (!fp_get_charging_status) + _E("Failed to obtain address of get_charging_status"); + } else + _I("There is no battery module."); + return 0; } @@ -2364,13 +2373,16 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_display_plugin(); - if (!disp_plgn) { + if (!disp_plgn) _E("Failed to get display plugin."); - } backlight_ops = get_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator."); + + battery_plgn = get_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin."); } /** * @} diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 66f7bce..f7b3b4f 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -90,11 +91,12 @@ #define PM_SUSPEND 1 extern void init_pm_internal(); -extern int get_charging_status(int *val); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; static struct _backlight_ops *backlight_ops; +static struct battery_plugin *battery_plgn; +static int (*fp_get_charging_status) (int *val); static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; @@ -1779,7 +1781,7 @@ static void check_seed_status(void) int lock_state; /* Charging check */ - if ((get_charging_status(&tmp) == 0) && (tmp > 0)) + if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) set_pm_status_flag(CHRGR_FLAG); ret = get_setting_brightness(&tmp); @@ -2073,6 +2075,13 @@ static int display_probe(void *data) init_pm_internal(); disp_plgn->device_flags_to_string = __device_flags_to_string; + if (battery_plgn->handle) { + fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status"); + if (!fp_get_charging_status) + _E("Failed to obtain address of get_charging_status"); + } else + _I("There is no battery module."); + return 0; } @@ -2380,13 +2389,16 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_display_plugin(); - if (!disp_plgn) { + if (!disp_plgn) _E("Failed to get display plugin."); - } backlight_ops = get_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator."); + + battery_plgn = get_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin."); } /** * @} diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 2db8f62..6ab5af1 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -88,11 +89,12 @@ #define PM_SUSPEND 1 extern void init_pm_internal(); -extern int get_charging_status(int *val); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; static struct _backlight_ops *backlight_ops; +static struct battery_plugin *battery_plgn; +static int (*fp_get_charging_status) (int *val); static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; @@ -1769,7 +1771,7 @@ static void check_seed_status(void) int lock_state; /* Charging check */ - if ((get_charging_status(&tmp) == 0) && (tmp > 0)) + if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) set_pm_status_flag(CHRGR_FLAG); ret = get_setting_brightness(&tmp); @@ -2064,6 +2066,13 @@ static int display_probe(void *data) init_pm_internal(); disp_plgn->device_flags_to_string = __device_flags_to_string; + if (battery_plgn->handle) { + fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status"); + if (!fp_get_charging_status) + _E("Failed to obtain address of get_charging_status"); + } else + _I("There is no battery module."); + return 0; } @@ -2366,13 +2375,16 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_display_plugin(); - if (!disp_plgn) { + if (!disp_plgn) _E("Failed to get display plugin."); - } backlight_ops = get_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator."); + + battery_plgn = get_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin."); } /** * @} diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 6ba132b..586063a 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -96,11 +97,12 @@ #define UNKNOWN_STR "unknown" extern void init_pm_internal(); -extern int get_charging_status(int *val); extern void init_save_userlock(void); static struct display_plugin *disp_plgn; static struct _backlight_ops *backlight_ops; +static struct battery_plugin *battery_plgn; +static int (*fp_get_charging_status) (int *val); static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; @@ -2050,7 +2052,7 @@ static void check_seed_status(void) int lock_state; /* Charging check */ - if ((get_charging_status(&tmp) == 0) && (tmp > 0)) + if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) set_pm_status_flag(CHRGR_FLAG); ret = get_setting_brightness(&tmp); @@ -2369,6 +2371,13 @@ static int display_probe(void *data) init_pm_internal(); disp_plgn->device_flags_to_string = __device_flags_to_string; + if (battery_plgn->handle) { + fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status"); + if (!fp_get_charging_status) + _E("Failed to obtain address of get_charging_status"); + } else + _I("There is no battery module."); + return 0; } @@ -2715,13 +2724,16 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_display_plugin(); - if (!disp_plgn) { + if (!disp_plgn) _E("Failed to get display plugin."); - } backlight_ops = get_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator."); + + battery_plgn = get_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin."); } /** diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index c803437..16f2257 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -47,6 +47,7 @@ #include "battery-monitor.h" #include "battery/power-supply.h" #include "power/power-control.h" +#include "shared/plugin.h" #define TOUCH_ON 1 #define TOUCH_OFF 0 @@ -73,6 +74,7 @@ static struct _backlight_ops backlight_ops; +static struct battery_plugin *battery_plgn; static bool custom_status; static int custom_brightness; static int force_brightness; @@ -85,6 +87,8 @@ static int aod_normal_level = -1; static int aod_min_level = -1; static int aod_charging_level = -1; static struct display_config *display_conf; +static struct battery_status *battery = NULL; +static struct battery_status* (*fp_get_var_battery_status)(void); inline struct _backlight_ops *get_backlight_ops(void) { @@ -647,11 +651,6 @@ static int backlight_transit_state(int state) int brt, val; int start, end; static int aod_brightness_level; - struct battery_status *battery = get_var_battery_status(); - if (!battery) { - _E("Failed to get battery status structure."); - return -EINVAL; - } backlight_ops.get_brightness(&brt); @@ -697,7 +696,7 @@ static int backlight_transit_state(int state) return 0; } - if (battery->charge_now == CHARGER_CHARGING) { + if (battery && battery->charge_now == CHARGER_CHARGING) { if (aod_charging_level > 0 && val >= aod_charging_level) aod_brightness_level = aod_charging_level; else if (aod_min_level > 0 && val >= aod_min_level) @@ -894,6 +893,17 @@ int init_sysfs(unsigned int flags) { register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed); + if (battery_plgn->handle) { + fp_get_var_battery_status = dlsym(battery_plgn->handle, "get_var_battery_status"); + if (fp_get_var_battery_status) { + battery = fp_get_var_battery_status(); + if (!battery) + _E("Failed to get battery status."); + } else + _E("Failed to obtain address of get_var_battery_status, %s.", dlerror()); + } else + _I("There is no battery module."); + return 0; } @@ -923,5 +933,8 @@ static void __CONSTRUCTOR__ initialize(void) display_conf = get_display_config(); if (!display_conf) _E("Failed to get display configuration."); -} + battery_plgn = get_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin."); +} diff --git a/src/shared/plugin.c b/src/shared/plugin.c index d93087c..1df0e0a 100644 --- a/src/shared/plugin.c +++ b/src/shared/plugin.c @@ -112,9 +112,9 @@ void load_plugins() if (!load_plugin(ent->d_name, &handle)) { _I("Plugin(%s) is loaded. handle=%#x", ent->d_name, (unsigned int)((intptr_t)handle)); plgn_list = g_list_append(plgn_list, handle); - if (!strcmp(ent->d_name, "display")) + if (!strcmp(ent->d_name, "display.so")) disp_plgn.handle = handle; - else if (!strcmp(ent->d_name, "battery")) + else if (!strcmp(ent->d_name, "battery.so")) battery_plgn.handle = handle; } } -- 2.7.4 From e52d0afb372cf7d1d1f6be8f58afb38fe12ab202 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Mon, 14 Sep 2020 16:11:28 +0900 Subject: [PATCH 04/16] Replace function name to get variable pointer Change-Id: I8c057e2cf393636fcf439b0a6f9d62f5e7254992 Signed-off-by: Yunmi Ha --- plugins/iot/display/core.c | 14 ++-- plugins/iot/display/device-interface.c | 6 +- plugins/iot/display/key-filter.c | 12 ++-- plugins/mobile/battery/battery-notification.c | 4 +- plugins/mobile/display/core.c | 14 ++-- plugins/mobile/display/device-interface.c | 6 +- plugins/mobile/display/key-filter.c | 12 ++-- plugins/tv/display/core.c | 14 ++-- plugins/tv/display/device-interface.c | 6 +- plugins/tv/display/key-filter.c | 12 ++-- plugins/tv/display/state-tv.c | 11 ++- .../wearable/display/auto-brightness-sensorhub.c | 15 ++--- plugins/wearable/display/bezel.c | 7 +- plugins/wearable/display/core.c | 14 ++-- plugins/wearable/display/device-interface.c | 10 +-- plugins/wearable/display/display-handler.c | 4 +- plugins/wearable/display/enhance.c | 4 +- plugins/wearable/display/key-filter.c | 15 ++--- plugins/wearable/display/lbm.c | 4 +- plugins/wearable/display/powersaver.c | 4 +- plugins/wearable/display/swim.c | 11 ++- src/apps/apps.c | 7 +- src/battery/battery-time.c | 7 +- src/battery/lowbat-handler.c | 10 +-- src/battery/power-supply.c | 15 ++--- src/display/ambient-mode.c | 11 ++- src/display/auto-brightness.c | 8 +-- src/display/core.h | 2 +- src/display/device-interface.h | 2 +- src/display/display-dbus.c | 12 ++-- src/display/display-lock.c | 8 +-- src/display/display-signal.c | 7 +- src/display/input.c | 4 +- src/display/poll.c | 7 +- src/display/setting.c | 8 +-- src/extcon/cradle.c | 7 +- src/extcon/earjack.c | 7 +- src/extcon/hdmi.c | 7 +- src/led/touch-key.c | 7 +- src/power/boot.c | 7 +- src/power/power-handler.c | 7 +- src/shared/plugin.c | 4 +- src/shared/plugin.h | 4 +- src/time/time-handler.c | 7 +- src/touchscreen/touchscreen.c | 78 +++++++++++----------- src/usb/usb.c | 7 +- src/usbhost/usb-host.c | 7 +- 47 files changed, 216 insertions(+), 240 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index f6b0c98..6929c89 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -211,7 +211,7 @@ struct display_function_info display_info = { .face_detection = NULL, }; -inline struct display_config* get_display_config() +inline struct display_config* get_var_display_config() { return &display_conf; } @@ -2372,17 +2372,17 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); } /** * @} diff --git a/plugins/iot/display/device-interface.c b/plugins/iot/display/device-interface.c index 64e4f1e..eba4550 100644 --- a/plugins/iot/display/device-interface.c +++ b/plugins/iot/display/device-interface.c @@ -78,7 +78,7 @@ static struct display_device *display_dev; static guint release_timer; static struct display_config *display_conf; -inline struct _backlight_ops *get_backlight_ops(void) +inline struct _backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -841,8 +841,8 @@ int exit_sysfs(void) static void __CONSTRUCTOR__ initialize(void) { - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); } diff --git a/plugins/iot/display/key-filter.c b/plugins/iot/display/key-filter.c index 29d7de2..11821a6 100644 --- a/plugins/iot/display/key-filter.c +++ b/plugins/iot/display/key-filter.c @@ -432,9 +432,9 @@ static int process_power_key(struct input_event *pinput) int ignore = true; static int value = KEY_RELEASED; unsigned int caps; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if (!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return ignore; } @@ -799,12 +799,12 @@ const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) { - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); } - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c index 6b9c4b4..459f455 100644 --- a/plugins/mobile/battery/battery-notification.c +++ b/plugins/mobile/battery/battery-notification.c @@ -410,9 +410,9 @@ BATTERY_OPS_REGISTER(&battery_notification_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); battery = get_var_battery_status(); if (!battery) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index f7b3b4f..7d4c64b 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -214,7 +214,7 @@ struct display_function_info display_info = { .face_detection = NULL, }; -inline struct display_config* get_display_config() +inline struct display_config* get_var_display_config() { return &display_conf; } @@ -2388,17 +2388,17 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); } /** * @} diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index 9b37f8b..80b1d01 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -77,7 +77,7 @@ static struct display_device *display_dev; static guint release_timer; static struct display_config *display_conf; -inline struct _backlight_ops *get_backlight_ops(void) +inline struct _backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -856,8 +856,8 @@ int exit_sysfs(void) static void __CONSTRUCTOR__ initialize(void) { - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); } diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 4aead39..7998b16 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -452,9 +452,9 @@ static int process_power_key(struct input_event *pinput) int ignore = true; static int value = KEY_RELEASED; unsigned int caps; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if (!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return ignore; } @@ -826,12 +826,12 @@ const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) { - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); } - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 6ab5af1..1e1c176 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -212,7 +212,7 @@ struct display_function_info display_info = { .face_detection = NULL, }; -inline struct display_config* get_display_config() +inline struct display_config* get_var_display_config() { return &display_conf; } @@ -2374,17 +2374,17 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); } /** * @} diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index 469b793..e7ab4df 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -78,7 +78,7 @@ static struct display_device *display_dev; static guint release_timer; static struct display_config *display_conf; -inline struct _backlight_ops *get_backlight_ops(void) +inline struct _backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -842,8 +842,8 @@ int exit_sysfs(void) static void __CONSTRUCTOR__ initialize(void) { - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); } diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index 24757b2..b28d7ec 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -432,9 +432,9 @@ static int process_power_key(struct input_event *pinput) int ignore = true; static int value = KEY_RELEASED; unsigned int caps; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if(!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return ignore; } @@ -793,12 +793,12 @@ const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) { - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); } - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/tv/display/state-tv.c b/plugins/tv/display/state-tv.c index 3ce57d6..ceb85d0 100644 --- a/plugins/tv/display/state-tv.c +++ b/plugins/tv/display/state-tv.c @@ -571,12 +571,11 @@ void state_tv_deinit(void) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/auto-brightness-sensorhub.c b/plugins/wearable/display/auto-brightness-sensorhub.c index e5a5004..ee7ef57 100644 --- a/plugins/wearable/display/auto-brightness-sensorhub.c +++ b/plugins/wearable/display/auto-brightness-sensorhub.c @@ -43,9 +43,9 @@ static bool lbm, hbm, hold_brt, lowdim; static void change_brightness_transit(int start, int end) { - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if(!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return ; } backlight_ops->transit_brt(start, end, @@ -373,12 +373,11 @@ void exit_level_handler(void) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/bezel.c b/plugins/wearable/display/bezel.c index bb22d8f..87bd336 100644 --- a/plugins/wearable/display/bezel.c +++ b/plugins/wearable/display/bezel.c @@ -318,8 +318,7 @@ DEVICE_OPS_REGISTER(&bezel_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 586063a..7e92237 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -234,7 +234,7 @@ struct display_function_info display_info = { .face_detection = NULL, }; -inline struct display_config *get_display_config() +inline struct display_config *get_var_display_config() { return &display_conf; } @@ -2723,17 +2723,17 @@ DEVICE_OPS_REGISTER(&display_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); } /** diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 16f2257..2e5351c 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -90,7 +90,7 @@ static struct display_config *display_conf; static struct battery_status *battery = NULL; static struct battery_status* (*fp_get_var_battery_status)(void); -inline struct _backlight_ops *get_backlight_ops(void) +inline struct _backlight_ops *get_var_backlight_ops(void) { return &backlight_ops; } @@ -930,11 +930,11 @@ int exit_sysfs(void) static void __CONSTRUCTOR__ initialize(void) { - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); } diff --git a/plugins/wearable/display/display-handler.c b/plugins/wearable/display/display-handler.c index 27b97a8..ed2e9ba 100644 --- a/plugins/wearable/display/display-handler.c +++ b/plugins/wearable/display/display-handler.c @@ -224,7 +224,7 @@ DISPLAY_OPS_REGISTER(&display_handler_ops) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/enhance.c b/plugins/wearable/display/enhance.c index 9fb32ea..0ac0b64 100644 --- a/plugins/wearable/display/enhance.c +++ b/plugins/wearable/display/enhance.c @@ -169,7 +169,7 @@ DISPLAY_OPS_REGISTER(&display_enhance_ops) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 3cf379f..32691f8 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -429,9 +429,9 @@ static int process_power_key(struct input_event *pinput) int ignore = true; static int value = KEY_RELEASED; unsigned int caps; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if (!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return ignore; } @@ -773,12 +773,11 @@ const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/lbm.c b/plugins/wearable/display/lbm.c index 79ec7cd..e10b09c 100644 --- a/plugins/wearable/display/lbm.c +++ b/plugins/wearable/display/lbm.c @@ -344,7 +344,7 @@ DISPLAY_OPS_REGISTER(&display_lbm_ops) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/powersaver.c b/plugins/wearable/display/powersaver.c index 785acfa..e4ef88b 100644 --- a/plugins/wearable/display/powersaver.c +++ b/plugins/wearable/display/powersaver.c @@ -158,7 +158,7 @@ DEVICE_OPS_REGISTER(&powersaver_device_ops) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/plugins/wearable/display/swim.c b/plugins/wearable/display/swim.c index 2b093dc..eab5f88 100644 --- a/plugins/wearable/display/swim.c +++ b/plugins/wearable/display/swim.c @@ -141,12 +141,11 @@ DEVICE_OPS_REGISTER(&swim_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/src/apps/apps.c b/src/apps/apps.c index a192797..1debfa6 100644 --- a/src/apps/apps.c +++ b/src/apps/apps.c @@ -175,8 +175,7 @@ int remove_notification(char *type, int id) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/battery/battery-time.c b/src/battery/battery-time.c index eb61816..712824a 100644 --- a/src/battery/battery-time.c +++ b/src/battery/battery-time.c @@ -441,8 +441,7 @@ DEVICE_OPS_REGISTER(&battery_time_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index e0829b4..c8bb7c1 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -780,15 +780,15 @@ DEVICE_OPS_REGISTER(&lowbat_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); - battery_plgn = get_battery_plugin(); + battery_plgn = get_var_battery_plugin(); if (!battery_plgn) - _E("Failed to get battery plugin."); + _E("Failed to get battery plugin variable."); battery = get_var_battery_status(); if (!battery) - _E("Failed to get battery status structure."); + _E("Failed to get battery status structure variable."); } diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 34722aa..c5109c5 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -1742,14 +1742,11 @@ DEVICE_OPS_REGISTER(&power_supply_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - battery_plgn = get_battery_plugin(); - if (!battery_plgn) { - _E("Failed to get battery plugin."); - } + battery_plgn = get_var_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin variable."); } - diff --git a/src/display/ambient-mode.c b/src/display/ambient-mode.c index 0e5e478..fdf58e4 100644 --- a/src/display/ambient-mode.c +++ b/src/display/ambient-mode.c @@ -307,12 +307,11 @@ DISPLAY_OPS_REGISTER(&ambient_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/src/display/auto-brightness.c b/src/display/auto-brightness.c index e8b1621..ac72807 100644 --- a/src/display/auto-brightness.c +++ b/src/display/auto-brightness.c @@ -684,11 +684,11 @@ DISPLAY_OPS_REGISTER(&display_autobrightness_ops) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); } diff --git a/src/display/core.h b/src/display/core.h index 5bfb1d1..00c3e27 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -145,7 +145,7 @@ struct display_config { * Global variables * display_conf : configuration of display */ -struct display_config* get_display_config(); +struct display_config* get_var_display_config(); /* * @brief Display Extension features diff --git a/src/display/device-interface.h b/src/display/device-interface.h index dec91c9..97121e3 100644 --- a/src/display/device-interface.h +++ b/src/display/device-interface.h @@ -91,7 +91,7 @@ struct _backlight_ops { void (*release_blink)(void); }; -struct _backlight_ops *get_backlight_ops(void); +struct _backlight_ops *get_var_backlight_ops(void); enum dpms_state { DPMS_ON, /* In use */ diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index e56c7f3..b8bf593 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -614,9 +614,9 @@ static GVariant *dbus_setrefreshrate(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int app, val, ret, control; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if (!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); ret = -EINVAL; goto error; } @@ -1307,12 +1307,12 @@ int init_pm_dbus(void) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) { - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); } - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); } diff --git a/src/display/display-lock.c b/src/display/display-lock.c index b0d2568..6f04ec6 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -399,12 +399,12 @@ dd_list *get_cond_head(enum state_t s_index) static void __CONSTRUCTOR__ initialize(void) { - backlight_ops = get_backlight_ops(); + backlight_ops = get_var_backlight_ops(); if (!backlight_ops) - _E("Failed to get backlight operator."); + _E("Failed to get backlight operator variable."); - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) { - _E("Failed to get display config."); + _E("Failed to get display config variable."); } } diff --git a/src/display/display-signal.c b/src/display/display-signal.c index cf2cf83..67c3877 100644 --- a/src/display/display-signal.c +++ b/src/display/display-signal.c @@ -176,8 +176,7 @@ void set_process_active(bool flag, pid_t pid) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/display/input.c b/src/display/input.c index b985652..e372058 100644 --- a/src/display/input.c +++ b/src/display/input.c @@ -44,9 +44,9 @@ static inline void process_event(struct libinput_event *ev) struct libinput_event_keyboard *k; unsigned int time; int fd = 0; - struct display_config *display_conf = get_display_config(); + struct display_config *display_conf = get_var_display_config(); if(!display_conf) { - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); return; } diff --git a/src/display/poll.c b/src/display/poll.c index c8a4a59..0e3ab28 100644 --- a/src/display/poll.c +++ b/src/display/poll.c @@ -184,8 +184,7 @@ void init_pm_internal() static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/display/setting.c b/src/display/setting.c index e493c7f..0b0ebb2 100644 --- a/src/display/setting.c +++ b/src/display/setting.c @@ -278,12 +278,12 @@ int exit_setting(void) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); + disp_plgn = get_var_display_plugin(); if (!disp_plgn) { - _E("Failed to get display plugin."); + _E("Failed to get display plugin variable."); } - display_conf = get_display_config(); + display_conf = get_var_display_config(); if (!display_conf) - _E("Failed to get display configuration."); + _E("Failed to get display configuration variable."); } diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c index 1eeffa1..382dcde 100644 --- a/src/extcon/cradle.c +++ b/src/extcon/cradle.c @@ -148,8 +148,7 @@ EXTCON_OPS_REGISTER(cradle_extcon_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/extcon/earjack.c b/src/extcon/earjack.c index 1fb99c2..0b89fb5 100644 --- a/src/extcon/earjack.c +++ b/src/extcon/earjack.c @@ -97,8 +97,7 @@ EXTCON_OPS_REGISTER(earjack_extcon_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/extcon/hdmi.c b/src/extcon/hdmi.c index 6f38b31..c2cc3af 100644 --- a/src/extcon/hdmi.c +++ b/src/extcon/hdmi.c @@ -196,8 +196,7 @@ EXTCON_OPS_REGISTER(hdmi_extcon_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/led/touch-key.c b/src/led/touch-key.c index 6f679be..b5a4484 100644 --- a/src/led/touch-key.c +++ b/src/led/touch-key.c @@ -330,8 +330,7 @@ DEVICE_OPS_REGISTER(&touchled_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/power/boot.c b/src/power/boot.c index 24fc3ea..e49ca75 100644 --- a/src/power/boot.c +++ b/src/power/boot.c @@ -116,8 +116,7 @@ void add_booting_done_handler(void *data) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/power/power-handler.c b/src/power/power-handler.c index c00b17f..0a672c7 100644 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -782,8 +782,7 @@ DEVICE_OPS_REGISTER(&power_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/shared/plugin.c b/src/shared/plugin.c index 1df0e0a..fc9b17b 100644 --- a/src/shared/plugin.c +++ b/src/shared/plugin.c @@ -43,12 +43,12 @@ static struct display_plugin disp_plgn; static struct battery_plugin battery_plgn; static GList *plgn_list; -inline struct display_plugin *get_display_plugin(void) +inline struct display_plugin *get_var_display_plugin(void) { return &disp_plgn; } -inline struct battery_plugin *get_battery_plugin(void) +inline struct battery_plugin *get_var_battery_plugin(void) { return &battery_plgn; } diff --git a/src/shared/plugin.h b/src/shared/plugin.h index 6eeb9d7..b79b690 100644 --- a/src/shared/plugin.h +++ b/src/shared/plugin.h @@ -22,8 +22,8 @@ #include "display/display-ops.h" #include "battery/battery-ops.h" -struct display_plugin *get_display_plugin(void); -struct battery_plugin *get_battery_plugin(void); +struct display_plugin *get_var_display_plugin(void); +struct battery_plugin *get_var_battery_plugin(void); int load_plugin(const char *id, void **h); int unload_plugin(void *h); diff --git a/src/time/time-handler.c b/src/time/time-handler.c index bac2374..9647f10 100644 --- a/src/time/time-handler.c +++ b/src/time/time-handler.c @@ -413,8 +413,7 @@ DEVICE_OPS_REGISTER(&time_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index b592bad..e3d2231 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -48,26 +48,26 @@ static int touchscreen_stop(enum device_flags flags); static int booting_done(void *data); -static struct display_config *_display_conf; -static struct _backlight_ops *_backlight_ops; +static struct display_config *display_conf; +static struct _backlight_ops *backlight_ops; static struct battery_status *battery = NULL; -static struct _backlight_ops* (*_get_var_backlight_ops)(void); -static struct display_config* (*_get_var_display_config)(void); -static struct battery_status* (*_get_var_battery_status)(void); +static struct _backlight_ops* (*fp_get_var_backlight_ops)(void); +static struct display_config* (*fp_get_var_display_config)(void); +static struct battery_status* (*fp_get_var_battery_status)(void); static void touchscreen_wakeup_status(keynode_t *key, void *data) { if (!key) return; - if (!_display_conf || !_backlight_ops) + if (!display_conf || !backlight_ops) return; - _display_conf->touch_wakeup = vconf_keynode_get_bool(key); + display_conf->touch_wakeup = vconf_keynode_get_bool(key); - if (_backlight_ops->get_lcd_power() != DPMS_ON) { - if (_display_conf->touch_wakeup) + if (backlight_ops->get_lcd_power() != DPMS_ON) { + if (display_conf->touch_wakeup) touchscreen_start(NORMAL_MODE); else touchscreen_stop(TOUCH_SCREEN_OFF_MODE); @@ -192,7 +192,7 @@ static int touchscreen_start(enum device_flags flags) if (touchscreen_enable != DEVICE_OPS_STATUS_START) return 0; - if (!_backlight_ops || !_backlight_ops->get_lcd_power) + if (!backlight_ops || !backlight_ops->get_lcd_power) return -ENOTSUP; /* Do not enable touchscreen during silent boot mode */ @@ -204,7 +204,7 @@ static int touchscreen_start(enum device_flags flags) */ ret = touchscreen_set_state(TOUCHSCREEN_ON); - state = _backlight_ops->get_lcd_power(); + state = backlight_ops->get_lcd_power(); if (state == DPMS_OFF) touchscreen_powersaving(POWERSAVING_ON); @@ -216,7 +216,7 @@ static int touchscreen_start(enum device_flags flags) static int touchscreen_stop(enum device_flags flags) { - if (!_display_conf || !_backlight_ops) { + if (!display_conf || !backlight_ops) { _I("Touchscreen is not initialized."); goto exit; } @@ -241,7 +241,7 @@ static int touchscreen_stop(enum device_flags flags) return touchscreen_powersaving(POWERSAVING_ON); } - if (_display_conf->touch_wakeup) { + if (display_conf->touch_wakeup) { _I("Touch wakeup enabled."); return touchscreen_powersaving(POWERSAVING_ON); } @@ -320,32 +320,32 @@ static void touchscreen_init(void *data) { int ret, val; - _get_var_display_config = dlsym(disp_plgn->handle, "get_display_config"); - if (_get_var_display_config) { - _display_conf = _get_var_display_config(); - if (!_display_conf) - _E("Failed to get display config."); + fp_get_var_display_config = dlsym(disp_plgn->handle, "get_var_display_config"); + if (fp_get_var_display_config) { + display_conf = fp_get_var_display_config(); + if (!display_conf) + _E("Failed to get display config variable."); } else - _E("Failed to obtain address of get_display_config, %s.", dlerror()); + _E("Failed to obtain address of get_var_display_config, %s.", dlerror()); /* 'backlight_ops' is declared static and used a lot of places with same name. * So it fails that fetching symbol directly with name 'backlight_ops'. - * To avoid this, fetches getter function 'get_backlight_ops' instead, and + * To avoid this, fetches getter function 'get_var_backlight_ops' instead, and * retrieve the 'backlight_ops' by using it */ - _get_var_backlight_ops = dlsym(disp_plgn->handle, "get_backlight_ops"); - if (_get_var_backlight_ops) { - _backlight_ops = _get_var_backlight_ops(); - if (!_backlight_ops) - _E("Failed to get backlight operator."); + fp_get_var_backlight_ops = dlsym(disp_plgn->handle, "get_var_backlight_ops"); + if (fp_get_var_backlight_ops) { + backlight_ops = fp_get_var_backlight_ops(); + if (!backlight_ops) + _E("Failed to get backlight operator variable."); } else - _E("Failed to obtain address of get_backlight_ops, %s.", dlerror()); + _E("Failed to obtain address of get_var_backlight_ops, %s.", dlerror()); if (battery_plgn->handle) { - _get_var_battery_status = dlsym(battery_plgn->handle, "get_var_battery_status"); - if (_get_var_battery_status) { - battery = _get_var_battery_status(); + fp_get_var_battery_status = dlsym(battery_plgn->handle, "get_var_battery_status"); + if (fp_get_var_battery_status) { + battery = fp_get_var_battery_status(); if (!battery) - _E("Failed to get battery status."); + _E("Failed to get battery status variable"); } else _E("Failed to obtain address of get_var_battery_status, %s.", dlerror()); } else @@ -364,8 +364,8 @@ static void touchscreen_init(void *data) vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_WAKEUP_ENABLE, touchscreen_wakeup_status, NULL); ret = vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_WAKEUP_ENABLE, &val); - if (_display_conf && ret == 0) - _display_conf->touch_wakeup = val; + if (display_conf && ret == 0) + display_conf->touch_wakeup = val; ret = dbus_handle_add_dbus_object(NULL, DEVICED_PATH_TOUCH, &dbus_interface); @@ -391,13 +391,11 @@ DEVICE_OPS_REGISTER(&touchscreen_device_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); - battery_plgn = get_battery_plugin(); - if (!battery_plgn) { - _E("Failed to get battery plugin."); - } + battery_plgn = get_var_battery_plugin(); + if (!battery_plgn) + _E("Failed to get battery plugin variable."); } diff --git a/src/usb/usb.c b/src/usb/usb.c index 0b24297..407edde 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -500,8 +500,7 @@ EXTCON_OPS_REGISTER(extcon_usb_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } diff --git a/src/usbhost/usb-host.c b/src/usbhost/usb-host.c index 91a5cf1..83dacf3 100644 --- a/src/usbhost/usb-host.c +++ b/src/usbhost/usb-host.c @@ -1207,8 +1207,7 @@ EXTCON_OPS_REGISTER(extcon_usbhost_ops) static void __CONSTRUCTOR__ initialize(void) { - disp_plgn = get_display_plugin(); - if (!disp_plgn) { - _E("Failed to get display plugin."); - } + disp_plgn = get_var_display_plugin(); + if (!disp_plgn) + _E("Failed to get display plugin variable."); } -- 2.7.4 From 07bdb759b74a30a7a2a54ce03bab638a81173a72 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 15 Sep 2020 18:52:18 +0900 Subject: [PATCH 05/16] Deduplicate below functions ex) update_lock_timer process_background process_foreground Change-Id: I396f02f04943a27134c6b7a708f65d386c97edec Signed-off-by: lokilee73 --- plugins/iot/display/core.c | 48 ----------------------------------------- plugins/mobile/display/core.c | 48 ----------------------------------------- plugins/tv/display/core.c | 48 ----------------------------------------- plugins/wearable/display/core.c | 48 ----------------------------------------- src/display/display-lock.c | 48 +++++++++++++++++++++++++++++++++++++++++ src/display/display-lock.h | 3 +++ 6 files changed, 51 insertions(+), 192 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 6929c89..66d5169 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -967,22 +967,6 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) return 0; } -/* update transition condition for application requrements */ -static void update_lock_timer(PMMsg *data, - PmLockNode *node, guint timeout_id) -{ - time_t now; - - if (data->timeout > 0) { - time(&now); - node->time = now; - } - - if (node->timeout_id) - g_source_remove(node->timeout_id); - node->timeout_id = timeout_id; -} - static void proc_condition_lock(PMMsg *data) { PmLockNode *tmp; @@ -1953,38 +1937,6 @@ static int booting_done(void *data) return done; } -static int process_background(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = true; - _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); - } - - return 0; -} - -static int process_foreground(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = false; - _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); - } - - return 0; -} - static int battery_health_changed(void *data) { int health = DATA_VALUE_INT(data); diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 7d4c64b..9ccf78b 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -979,22 +979,6 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) return 0; } -/* update transition condition for application requrements */ -static void update_lock_timer(PMMsg *data, - PmLockNode *node, guint timeout_id) -{ - time_t now; - - if (data->timeout > 0) { - time(&now); - node->time = now; - } - - if (node->timeout_id) - g_source_remove(node->timeout_id); - node->timeout_id = timeout_id; -} - static void proc_condition_lock(PMMsg *data) { PmLockNode *tmp; @@ -1964,38 +1948,6 @@ static int booting_done(void *data) return done; } -static int process_background(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = true; - _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); - } - - return 0; -} - -static int process_foreground(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = false; - _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); - } - - return 0; -} - static int battery_health_changed(void *data) { int health = DATA_VALUE_INT(data); diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 1e1c176..6f3667a 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -968,22 +968,6 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) return 0; } -/* update transition condition for application requrements */ -static void update_lock_timer(PMMsg *data, - PmLockNode *node, guint timeout_id) -{ - time_t now; - - if (data->timeout > 0) { - time(&now); - node->time = now; - } - - if (node->timeout_id) - g_source_remove(node->timeout_id); - node->timeout_id = timeout_id; -} - static void proc_condition_lock(PMMsg *data) { PmLockNode *tmp; @@ -1954,38 +1938,6 @@ static int booting_done(void *data) return done; } -static int process_background(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = true; - _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); - } - - return 0; -} - -static int process_foreground(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = false; - _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); - } - - return 0; -} - static int battery_health_changed(void *data) { int health = DATA_VALUE_INT(data); diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 7e92237..8fc8ab3 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1225,22 +1225,6 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) return 0; } -/* update transition condition for application requrements */ -static void update_lock_timer(PMMsg *data, - PmLockNode *node, guint timeout_id) -{ - time_t now; - - if (data->timeout > 0) { - time(&now); - node->time = now; - } - - if (node->timeout_id) - g_source_remove(node->timeout_id); - node->timeout_id = timeout_id; -} - static void proc_condition_lock(PMMsg *data) { PmLockNode *tmp; @@ -2239,38 +2223,6 @@ static int booting_done(void *data) return done; } -static int process_background(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = true; - _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); - } - - return 0; -} - -static int process_foreground(void *data) -{ - pid_t pid; - PmLockNode *node; - - pid = *(pid_t *)data; - - node = find_node(S_NORMAL, pid); - if (node) { - node->background = false; - _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); - } - - return 0; -} - static int battery_health_changed(void *data) { int health = DATA_VALUE_INT(data); diff --git a/src/display/display-lock.c b/src/display/display-lock.c index 6f04ec6..f97b973 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -397,6 +397,54 @@ dd_list *get_cond_head(enum state_t s_index) return cond_head[s_index]; } +int process_background(void *data) +{ + pid_t pid; + PmLockNode *node; + + pid = *(pid_t *)data; + + node = find_node(S_NORMAL, pid); + if (node) { + node->background = true; + _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); + } + + return 0; +} + +int process_foreground(void *data) +{ + pid_t pid; + PmLockNode *node; + + pid = *(pid_t *)data; + + node = find_node(S_NORMAL, pid); + if (node) { + node->background = false; + _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); + } + + return 0; +} + +/* update transition condition for application requrements */ +void update_lock_timer(PMMsg *data, + PmLockNode *node, guint timeout_id) +{ + time_t now; + + if (data->timeout > 0) { + time(&now); + node->time = now; + } + + if (node->timeout_id) + g_source_remove(node->timeout_id); + node->timeout_id = timeout_id; +} + static void __CONSTRUCTOR__ initialize(void) { backlight_ops = get_var_backlight_ops(); diff --git a/src/display/display-lock.h b/src/display/display-lock.h index c52ac84..42c1853 100644 --- a/src/display/display-lock.h +++ b/src/display/display-lock.h @@ -62,6 +62,9 @@ void makeup_trans_condition(void); int check_processes(enum state_t prohibit_state); int get_trans_condition(void); dd_list *get_cond_head(enum state_t s_index); +int process_background(void *data); +int process_foreground(void *data); +void update_lock_timer(PMMsg *data, PmLockNode *node, guint timeout_id); extern int custom_holdkey_block; -- 2.7.4 From ed7715c95e96795ae169313e01007844e7ea265e Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Wed, 16 Sep 2020 20:16:20 +0900 Subject: [PATCH 06/16] Remove unused function ciritical_log ex) CRITICAL_LOG is used instead of critical_log Change-Id: Ib47f59e9d3425cd877f978286c4da3501bdb4866 Signed-off-by: lokilee73 --- src/core/device-notifier.c | 1 - src/core/device-notifier.h | 1 - src/core/log.c | 12 ------------ src/core/log.h | 3 --- 4 files changed, 17 deletions(-) diff --git a/src/core/device-notifier.c b/src/core/device-notifier.c index db104be..3f8d1b6 100644 --- a/src/core/device-notifier.c +++ b/src/core/device-notifier.c @@ -76,7 +76,6 @@ static const char *device_notifier_type_str[DEVICE_NOTIFIER_MAX] = { NOTIFY_STR(DEVICE_NOTIFIER_UPSM_OFF), NOTIFY_STR(DEVICE_NOTIFIER_BEZEL_WAKEUP), NOTIFY_STR(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS), - NOTIFY_STR(DEVICE_NOTIFIER_CRITICAL_LOG), NOTIFY_STR(DEVICE_NOTIFIER_ULTRAPOWERSAVING), }; diff --git a/src/core/device-notifier.h b/src/core/device-notifier.h index 98fca83..6362a82 100644 --- a/src/core/device-notifier.h +++ b/src/core/device-notifier.h @@ -59,7 +59,6 @@ enum device_notifier_type { DEVICE_NOTIFIER_BEZEL_WAKEUP, DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, DEVICE_NOTIFIER_ULTRAPOWERSAVING, - DEVICE_NOTIFIER_CRITICAL_LOG, DEVICE_NOTIFIER_EXTCON_COUNT, DEVICE_NOTIFIER_MAX, }; diff --git a/src/core/log.c b/src/core/log.c index 679eee8..fe0d3bf 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -39,15 +39,3 @@ void __cyg_profile_func_exit(void *func, void *caller) g_trace_depth--; } #endif - -void critical_log_internal(const char *func, const char *fmt, ...) -{ - va_list ap; - char buf[256]; - - va_start(ap, fmt); - vsnprintf(buf, 256, fmt, ap); - va_end(ap); - _I("%s:%s", func, buf); - device_notify(DEVICE_NOTIFIER_CRITICAL_LOG, (void *)buf); -} diff --git a/src/core/log.h b/src/core/log.h index 60c363e..395ab0e 100644 --- a/src/core/log.h +++ b/src/core/log.h @@ -39,6 +39,3 @@ #define __stringify_1(x...) #x #define __stringify(x...) __stringify_1(x) -void critical_log_internal(const char *caller, const char *fmt, ...); - -#define critical_log(fmt, arg...) critical_log_internal(__func__, fmt, ##arg) -- 2.7.4 From 49cf791bc4fce10046dab4cd1819a8e089742254 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 21 Sep 2020 20:55:01 +0900 Subject: [PATCH 07/16] Add logs to get pid information for below functions. ex) dbus_changestatebyreason dbus_customlcdon dbus_customlcdoff dbus_setbrightness dbus_holdbrightness dbus_releasebrightness dbus_lcdpaneloffmode dbus_dimstay_control dbus_staytouchscreenoff Change-Id: I3e692a5b2a407df04ec6e9aeab2f596b88fb7590 Signed-off-by: lokilee73 --- src/display/display-dbus.c | 63 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index b8bf593..bd0f59d 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -418,6 +418,7 @@ static GVariant *dbus_setbrightness(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int state, brt, autobrt, ret = 0, caps; + pid_t pid; caps = display_get_caps(DISPLAY_ACTOR_API); @@ -474,7 +475,8 @@ static GVariant *dbus_setbrightness(GDBusConnection *conn, } else ret = -EINVAL; - _I("set brightness %d, %d", brt, ret); + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Set brightness pid=%d brt=%d ret=%d", pid, brt, ret); error: return g_variant_new("(i)", ret); @@ -485,6 +487,7 @@ static GVariant *dbus_holdbrightness(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int brt, autobrt, ret, caps; + pid_t pid; caps = display_get_caps(DISPLAY_ACTOR_API); @@ -527,7 +530,8 @@ static GVariant *dbus_holdbrightness(GDBusConnection *conn, _E("Failed to set vconf value for automatic brightness: %d", vconf_get_ext_errno()); } - _I("hold brightness %d, %d", brt, ret); + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Hold brightness pid=%d brt=%d ret=%d", pid, brt, ret); error: return g_variant_new("(i)", ret); @@ -538,6 +542,10 @@ static GVariant *dbus_releasebrightness(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int bat, charger, changed, setting, brt, autobrt, ret = 0; + pid_t pid; + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Release brightness pid=%d", pid); ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat); if (ret < 0) { @@ -816,6 +824,10 @@ static GVariant *dbus_customlcdon(GDBusConnection *conn, { int ret = 0; int timeout, lcdon_blocked; + pid_t pid; + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Change state to S_LCDON pid=%d", pid); g_variant_get(param, "(i)", &timeout); @@ -836,7 +848,11 @@ static GVariant *dbus_customlcdoff(GDBusConnection *conn, { int ret = 0; enum device_flags flag; - char *reason_str; + char *reason_str = NULL; + pid_t pid; + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Change state to S_LCDOFF pid=%d", pid); g_variant_get(param, "(s)", &reason_str); @@ -864,16 +880,27 @@ static GVariant *dbus_changestatebyreason(GDBusConnection *conn, { int ret = 0; int next_state, timeout; - char *reason; + char *reason = NULL, *state = NULL; + pid_t pid; g_variant_get(param, "(isi)", &next_state, &reason, &timeout); - if (next_state == DISPLAY_STATE_NORMAL) + if (next_state == DISPLAY_STATE_NORMAL) { + state = "S_LCDON"; ret = display_on_by_reason(reason, timeout); - else if (next_state == DISPLAY_STATE_SCREEN_OFF) + } else if (next_state == DISPLAY_STATE_SCREEN_OFF) { + state = "S_LCDOFF"; ret = display_off_by_reason(reason); - else + } else if (next_state == DISPLAY_STATE_SCREEN_DIM) { + state = "S_LCDDIM"; + ret = -EINVAL; + } else { + state = "unknown"; ret = -EINVAL; + } + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Change state pid=%d state=%s reason=%s ret=%d", pid, state, reason, ret); g_free(reason); return g_variant_new("(i)", ret); @@ -885,6 +912,10 @@ static GVariant *dbus_staytouchscreenoff(GDBusConnection *conn, { int ret = 0; int val; + pid_t pid; + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Stay touchscreen off pid=%d", pid); g_variant_get(param, "(i)", &val); @@ -899,6 +930,10 @@ static GVariant *dbus_lcdpaneloffmode(GDBusConnection *conn, { int ret = 0; int val; + pid_t pid; + + pid = dbus_connection_get_sender_pid(conn, sender); + _I("Set lcd panel off mode pid=%d", pid); g_variant_get(param, "(i)", &val); @@ -1145,27 +1180,31 @@ static GVariant *dbus_dimstay_control(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { - int dimstay; + int dimstay, ret = 0; + pid_t pid; g_variant_get(param, "(i)", &dimstay); if (dimstay < 0) { _E("Invalid dimstay set value %d.", dimstay); - return g_variant_new("(i)", -EINVAL); + ret = -EINVAL; + goto out; } + pid = dbus_connection_get_sender_pid(conn, sender); if (dimstay) { - _I("Set DIM_FLAG."); + _I("Set DIM_FLAG pid=%d", pid); set_pm_status_flag(DIM_FLAG); } else { - _I("Unset DIM_FLAG."); + _I("Unset DIM_FLAG pid=%d", pid); clear_pm_status_flag(DIM_FLAG); } if (get_pm_cur_state() == S_NORMAL) backlight_ops->update(); - return g_variant_new("(i)", 0); +out: + return g_variant_new("(i)", ret); } static GVariant *dbus_getbrightnessinfo(GDBusConnection *conn, -- 2.7.4 From 2b68b75d3e98c80dab1f2a8185b7bb7ce694de23 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 29 Sep 2020 16:59:38 +0900 Subject: [PATCH 08/16] Add S_LCDDIM in process_background and process_foreground S_NORMAL is affected by signal, AppStatusChange. ex) lock status of process with the signal node->background: true, LOCK is ignored node->background: false, LOCK is valid Add S_LCDDIM to make it controlled by AppStatusChange as well. Change-Id: I4f97a07c39bc58c8599a8dae68601849bff12791 Signed-off-by: lokilee73 --- src/display/display-lock.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/display/display-lock.c b/src/display/display-lock.c index f97b973..c7d88c7 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -407,7 +407,13 @@ int process_background(void *data) node = find_node(S_NORMAL, pid); if (node) { node->background = true; - _I("Process(%d) is background, then PM will be unlocked LCD_NORMAL.", pid); + _I("Process(%d) goes background. LCD_NORMAL will be unlocked.", pid); + } + + node = find_node(S_LCDDIM, pid); + if (node) { + node->background = true; + _I("Process(%d) goes background. LCD_DIM will be unlocked.", pid); } return 0; @@ -423,7 +429,13 @@ int process_foreground(void *data) node = find_node(S_NORMAL, pid); if (node) { node->background = false; - _I("Process(%d) is foreground, then PM will be locked LCD_NORMAL.", pid); + _I("Process(%d) goes foreground. LCD_NORMAL will be locked.", pid); + } + + node = find_node(S_LCDDIM, pid); + if (node) { + node->background = false; + _I("Process(%d) goes foreground. LCD_DIM will be locked.", pid); } return 0; -- 2.7.4 From f524d9027ff454858aa3c3e791cb84abc4e52a98 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 5 Oct 2020 14:03:18 +0900 Subject: [PATCH 09/16] Do not handle LCD DIM, when display.Dimming is 0 LCD DIM lock/unlock is not supported in dbus_lockstate and dbus_unlockstate. Change-Id: I51e913b66adf55bb78124185ae5aca19b46ce1a2 Signed-off-by: lokilee73 (cherry picked from commit 8dbf5cc61905833fed475ef0f3bc720ffe0ddc07) --- src/display/display-dbus.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index bd0f59d..10564f2 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -140,9 +140,14 @@ static GVariant *dbus_lockstate(GDBusConnection *conn, if (!strcmp(state_str, PM_LCDON_STR)) state = LCD_NORMAL; - else if (!strcmp(state_str, PM_LCDDIM_STR)) + else if (!strcmp(state_str, PM_LCDDIM_STR)) { + if (!display_conf.dimming) { + _E("LCD_DIM lock is not supported."); + ret = -EINVAL; + goto out; + } state = LCD_DIM; - else if (!strcmp(state_str, PM_LCDOFF_STR)) + } else if (!strcmp(state_str, PM_LCDOFF_STR)) state = LCD_OFF; else { _E("%s state is invalid, dbus ignored.", state_str); @@ -225,9 +230,14 @@ static GVariant *dbus_unlockstate(GDBusConnection *conn, if (!strcmp(state_str, PM_LCDON_STR)) state = LCD_NORMAL; - else if (!strcmp(state_str, PM_LCDDIM_STR)) + else if (!strcmp(state_str, PM_LCDDIM_STR)) { + if (!display_conf.dimming) { + _E("LCD_DIM unlock is not supported."); + ret = -EINVAL; + goto out; + } state = LCD_DIM; - else if (!strcmp(state_str, PM_LCDOFF_STR)) + } else if (!strcmp(state_str, PM_LCDOFF_STR)) state = LCD_OFF; else { _E("%s state is invalid, dbus ignored!", state_str); -- 2.7.4 From 68a02f15db7a58e845d15f9e2ad5cd99213e4d5d Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 5 Oct 2020 20:30:36 +0900 Subject: [PATCH 10/16] Fix compile error display_conf->Dimming can be obtained via get_var_display_config() Change-Id: I846084962769e2b2e6846552f8724b6bd6d221d5 Signed-off-by: lokilee73 --- src/display/display-dbus.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index 10564f2..f4f6317 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -70,6 +70,7 @@ static struct display_plugin *disp_plgn; static struct _backlight_ops *backlight_ops; +static struct display_config *display_conf; static GVariant *dbus_start(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, @@ -141,7 +142,7 @@ static GVariant *dbus_lockstate(GDBusConnection *conn, if (!strcmp(state_str, PM_LCDON_STR)) state = LCD_NORMAL; else if (!strcmp(state_str, PM_LCDDIM_STR)) { - if (!display_conf.dimming) { + if (!display_conf->dimming) { _E("LCD_DIM lock is not supported."); ret = -EINVAL; goto out; @@ -231,7 +232,7 @@ static GVariant *dbus_unlockstate(GDBusConnection *conn, if (!strcmp(state_str, PM_LCDON_STR)) state = LCD_NORMAL; else if (!strcmp(state_str, PM_LCDDIM_STR)) { - if (!display_conf.dimming) { + if (!display_conf->dimming) { _E("LCD_DIM unlock is not supported."); ret = -EINVAL; goto out; @@ -632,12 +633,6 @@ static GVariant *dbus_setrefreshrate(GDBusConnection *conn, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int app, val, ret, control; - struct display_config *display_conf = get_var_display_config(); - if (!display_conf) { - _E("Failed to get display configuration variable."); - ret = -EINVAL; - goto error; - } g_variant_get(param, "(ii)", &app, &val); @@ -1364,4 +1359,8 @@ static void __CONSTRUCTOR__ initialize(void) backlight_ops = get_var_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator variable."); + + display_conf = get_var_display_config(); + if (!display_conf) + _E("Failed to get display configuration variable."); } -- 2.7.4 From 2a6b0bfe9a7542993939ccf6173690612dd900bf Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 6 Oct 2020 20:33:36 +0900 Subject: [PATCH 11/16] Do not handle LCD DIM, when display.Dimming is 0 LCD DIM is not supported in dbus_changestate. Change-Id: Ie6d1ca66dcf5770492df3331fb71802a089df1af Signed-off-by: lokilee73 --- src/display/display-dbus.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index f4f6317..846c67e 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -301,9 +301,14 @@ static GVariant *dbus_changestate(GDBusConnection *conn, if (!strcmp(state_str, PM_LCDON_STR)) state = LCD_NORMAL; - else if (!strcmp(state_str, PM_LCDDIM_STR)) + else if (!strcmp(state_str, PM_LCDDIM_STR)) { + if (!display_conf->dimming) { + _E("LCD_DIM state is not supported."); + ret = -EINVAL; + goto out; + } state = LCD_DIM; - else if (!strcmp(state_str, PM_LCDOFF_STR)) + } else if (!strcmp(state_str, PM_LCDOFF_STR)) state = LCD_OFF; else if (!strcmp(state_str, PM_STANDBY_STR)) state = STANDBY; -- 2.7.4 From 6249588d0a71826adc34ee6585dc3a7b628009e2 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 7 Oct 2020 15:39:48 +0900 Subject: [PATCH 12/16] Add get_lcd_power_node() for direct accessing the lcd power node Change-Id: Id47db38af56b2f6b6e4be0e6b46acf79b0564d75 Signed-off-by: Hyotaek Shim --- plugins/iot/display/device-interface.c | 32 ++++++++++++++++------------- plugins/mobile/display/device-interface.c | 32 ++++++++++++++++------------- plugins/tv/display/device-interface.c | 32 ++++++++++++++++------------- plugins/wearable/display/device-interface.c | 32 ++++++++++++++++------------- 4 files changed, 72 insertions(+), 56 deletions(-) diff --git a/plugins/iot/display/device-interface.c b/plugins/iot/display/device-interface.c index eba4550..27fde01 100644 --- a/plugins/iot/display/device-interface.c +++ b/plugins/iot/display/device-interface.c @@ -124,25 +124,22 @@ static int bl_brt(int brightness, int delay) return ret; } -static int get_lcd_power(void) +static int get_lcd_power_node(void) { - enum display_state val; int ret; + enum display_state val; - if (!display_dev || !display_dev->get_state) { - return dpms_get_state(); - } else { - ret = display_dev->get_state(&val); - if (ret < 0) - return ret; + ret = display_dev->get_state(&val); + if (ret < 0) + return ret; - if (val == DISPLAY_ON && ambient_get_state()) - return DPMS_OFF; + if (val == DISPLAY_ON && ambient_get_state()) + return DPMS_OFF; - if (dpms_running_state != DPMS_SETTING_DONE) - return dpms_running_state; + if (dpms_running_state != DPMS_SETTING_DONE) + return dpms_running_state; - switch (val) { + switch (val) { case DISPLAY_ON: return DPMS_ON; case DISPLAY_STANDBY: @@ -153,10 +150,17 @@ static int get_lcd_power(void) return DPMS_OFF; default: return -EINVAL; - } } } +static int get_lcd_power(void) +{ + if (display_dev && display_dev->get_state) + return get_lcd_power_node(); + else + return dpms_get_state(); +} + bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index 80b1d01..d9b5d3b 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -123,25 +123,22 @@ static int bl_brt(int brightness, int delay) return ret; } -static int get_lcd_power(void) +static int get_lcd_power_node(void) { - enum display_state val; int ret; + enum display_state val; - if (!display_dev || !display_dev->get_state) { - return dpms_get_state(); - } else { - ret = display_dev->get_state(&val); - if (ret < 0) - return ret; + ret = display_dev->get_state(&val); + if (ret < 0) + return ret; - if (val == DISPLAY_ON && ambient_get_state()) - return DPMS_OFF; + if (val == DISPLAY_ON && ambient_get_state()) + return DPMS_OFF; - if (dpms_running_state != DPMS_SETTING_DONE) - return dpms_running_state; + if (dpms_running_state != DPMS_SETTING_DONE) + return dpms_running_state; - switch (val) { + switch (val) { case DISPLAY_ON: return DPMS_ON; case DISPLAY_STANDBY: @@ -152,10 +149,17 @@ static int get_lcd_power(void) return DPMS_OFF; default: return -EINVAL; - } } } +static int get_lcd_power(void) +{ + if (display_dev && display_dev->get_state) + return get_lcd_power_node(); + else + return dpms_get_state(); +} + bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index e7ab4df..e264290 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -124,25 +124,22 @@ static int bl_brt(int brightness, int delay) return ret; } -static int get_lcd_power(void) +static int get_lcd_power_node(void) { - enum display_state val; int ret; + enum display_state val; - if (!display_dev || !display_dev->get_state) { - return dpms_get_state(); - } else { - ret = display_dev->get_state(&val); - if (ret < 0) - return ret; + ret = display_dev->get_state(&val); + if (ret < 0) + return ret; - if (val == DISPLAY_ON && ambient_get_state()) - return DPMS_OFF; + if (val == DISPLAY_ON && ambient_get_state()) + return DPMS_OFF; - if (dpms_running_state != DPMS_SETTING_DONE) - return dpms_running_state; + if (dpms_running_state != DPMS_SETTING_DONE) + return dpms_running_state; - switch (val) { + switch (val) { case DISPLAY_ON: return DPMS_ON; case DISPLAY_STANDBY: @@ -153,10 +150,17 @@ static int get_lcd_power(void) return DPMS_OFF; default: return -EINVAL; - } } } +static int get_lcd_power(void) +{ + if (display_dev && display_dev->get_state) + return get_lcd_power_node(); + else + return dpms_get_state(); +} + bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 2e5351c..e95977b 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -136,25 +136,22 @@ static int bl_brt(int brightness, int delay) return ret; } -static int get_lcd_power(void) +static int get_lcd_power_node(void) { - enum display_state val; int ret; + enum display_state val; - if (!display_dev || !display_dev->get_state) { - return dpms_get_state(); - } else { - ret = display_dev->get_state(&val); - if (ret < 0) - return ret; + ret = display_dev->get_state(&val); + if (ret < 0) + return ret; - if (val == DISPLAY_ON && ambient_get_state()) - return DPMS_OFF; + if (val == DISPLAY_ON && ambient_get_state()) + return DPMS_OFF; - if (dpms_running_state != DPMS_SETTING_DONE) - return dpms_running_state; + if (dpms_running_state != DPMS_SETTING_DONE) + return dpms_running_state; - switch (val) { + switch (val) { case DISPLAY_ON: return DPMS_ON; case DISPLAY_STANDBY: @@ -167,10 +164,17 @@ static int get_lcd_power(void) return DPMS_DETACH; default: return -EINVAL; - } } } +static int get_lcd_power(void) +{ + if (display_dev && display_dev->get_state) + return get_lcd_power_node(); + else + return dpms_get_state(); +} + bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) -- 2.7.4 From ce51a0a20b5a136a69c412e074860dc8455bf6f8 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 8 Oct 2020 17:18:22 +0900 Subject: [PATCH 13/16] silent reboot: Fix initial DPMS contol For silent reboot, don't do DPMS_ON, which was done at the end of init_dpms(). Change-Id: I3692503aa1b7a10085dcc19408148be440f382f7 Signed-off-by: Youngjae Cho --- plugins/iot/display/core.c | 3 ++- plugins/mobile/display/core.c | 3 ++- plugins/tv/display/core.c | 3 ++- plugins/wearable/display/core.c | 3 ++- src/display/display-dpms.c | 3 --- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 66d5169..228ac67 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -2151,9 +2151,10 @@ static void display_init(void *data) * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); if (init_dpms()) { - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); + else + lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); } else { add_timer_for_init_dpms(); } diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 9ccf78b..3a3b7ce 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -2162,9 +2162,10 @@ static void display_init(void *data) * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); if (init_dpms()) { - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); + else + lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); } else { add_timer_for_init_dpms(); } diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 6f3667a..94a6503 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -2153,9 +2153,10 @@ static void display_init(void *data) * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); if (init_dpms()) { - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); + else + lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); } else { add_timer_for_init_dpms(); } diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 8fc8ab3..3d13b4c 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -2496,9 +2496,10 @@ static void display_init(void *data) * In the case, display cannot be turned on at the first booting */ // wm_ready = check_wm_ready(); if (init_dpms()) { - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); if (is_lcdon_blocked() != LCDON_BLOCK_NONE) lcd_off_procedure(LCD_OFF_BY_EVENT); + else + lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); } else { add_timer_for_init_dpms(); } diff --git a/src/display/display-dpms.c b/src/display/display-dpms.c index 81be588..265a07f 100644 --- a/src/display/display-dpms.c +++ b/src/display/display-dpms.c @@ -574,9 +574,6 @@ bool init_dpms(void) dpms_loop = g_main_loop_new(dpms_context, false); - /* Initiating enlightenment. */ - dpms_set_state(DPMS_ON); - return true; } -- 2.7.4 From cdf32833d23343df183324049c6aa49a04bc5d30 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 5 Oct 2020 17:09:04 +0900 Subject: [PATCH 14/16] Adopt a dpms cache In the previos structure, deviced sets dpms through Enlightenment, whereas gets dpms by reading the lcd power node directly. There is a possibility of a miasmatch between the actual dpms state and the lcd power node. The cached dpms value is alternatively used for this situation in replacement of the get_lcd_power(). Change-Id: Id0144cd76cb017694198856f6b40ff7162b61e64 Signed-off-by: Youngjae Cho Signed-off-by: Hyotaek Shim Signed-off-by: Youngjae Cho --- plugins/iot/display/device-interface.c | 1 + plugins/mobile/display/device-interface.c | 1 + plugins/tv/display/device-interface.c | 1 + plugins/wearable/display/device-interface.c | 1 + src/display/device-interface.h | 1 + src/display/display-dpms.c | 15 ++++++++++++++- src/display/display-dpms.h | 1 + src/touchscreen/touchscreen.c | 5 ++++- 8 files changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/iot/display/device-interface.c b/plugins/iot/display/device-interface.c index 27fde01..06ca0ad 100644 --- a/plugins/iot/display/device-interface.c +++ b/plugins/iot/display/device-interface.c @@ -741,6 +741,7 @@ static struct _backlight_ops backlight_ops = { .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, .get_lcd_power = get_lcd_power, + .get_lcd_power_cached = dpms_get_cached_state, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index d9b5d3b..b1a1356 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -740,6 +740,7 @@ static struct _backlight_ops backlight_ops = { .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, .get_lcd_power = get_lcd_power, + .get_lcd_power_cached = dpms_get_cached_state, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index e264290..9a47571 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -741,6 +741,7 @@ static struct _backlight_ops backlight_ops = { .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, .get_lcd_power = get_lcd_power, + .get_lcd_power_cached = dpms_get_cached_state, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index e95977b..d2ee406 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -806,6 +806,7 @@ static struct _backlight_ops backlight_ops = { .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, .get_lcd_power = get_lcd_power, + .get_lcd_power_cached = dpms_get_cached_state, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/src/display/device-interface.h b/src/display/device-interface.h index 97121e3..4193de8 100644 --- a/src/display/device-interface.h +++ b/src/display/device-interface.h @@ -69,6 +69,7 @@ struct _backlight_ops { int (*set_default_brt)(int level); int (*get_default_brt)(void); int (*get_lcd_power)(void); + int (*get_lcd_power_cached)(void); int (*set_custom_status)(bool on); bool (*get_custom_status)(void); int (*save_custom_brightness)(void); diff --git a/src/display/display-dpms.c b/src/display/display-dpms.c index 265a07f..418274c 100644 --- a/src/display/display-dpms.c +++ b/src/display/display-dpms.c @@ -58,6 +58,8 @@ static GMainContext *dpms_context; static bool dpms_get_state_done; static bool dpms_set_state_done; +/* deviced-managing cache value */ +static int dpms_cache = -1; static void dpms_handle_set_state(void *data, struct tizen_dpms_manager *tz_dpms, uint32_t mode, uint32_t error) { @@ -75,7 +77,6 @@ static void dpms_handle_set_state(void *data, struct tizen_dpms_manager *tz_dpms } _D("Dpms_state_cb set - mode:%u, error:%u", mode, error); - dpms_client->dpms_mode = mode; dpms_set_state_done = true; if (g_main_loop_is_running(dpms_loop)) @@ -514,6 +515,8 @@ void dpms_set_state(int on) wait_response(DPMS_RESPONSE_TIMEOUT); + dpms_cache = on; + if (!dpms_set_state_done) { _E("No response for DPMS request(%d) for %d seconds.", mode, DPMS_RESPONSE_TIMEOUT); @@ -549,6 +552,16 @@ int dpms_get_state(void) } } +int dpms_get_cached_state(void) +{ + if (!dpms_is_available()) { + _E("Dpms is not available."); + return -1; + } + + return dpms_cache; +} + bool init_dpms(void) { if (dpms_client) diff --git a/src/display/display-dpms.h b/src/display/display-dpms.h index 4a936ee..b9ac040 100644 --- a/src/display/display-dpms.h +++ b/src/display/display-dpms.h @@ -21,6 +21,7 @@ void dpms_set_state(int on); int dpms_get_state(void); +int dpms_get_cached_state(void); bool init_dpms(void); void exit_dpms(void); void __register_dpms_checklist(int mode, void (*checker)(void), const char *caller); diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index e3d2231..b2c8182 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -104,6 +104,7 @@ static int touchscreen_powersaving(enum ps_mode mode) return 0; } + static int touchscreen_probe(void *data) { int ret; @@ -204,7 +205,9 @@ static int touchscreen_start(enum device_flags flags) */ ret = touchscreen_set_state(TOUCHSCREEN_ON); - state = backlight_ops->get_lcd_power(); + state = -1; + if (backlight_ops && backlight_ops->get_lcd_power_cached) + state = backlight_ops->get_lcd_power_cached(); if (state == DPMS_OFF) touchscreen_powersaving(POWERSAVING_ON); -- 2.7.4 From a3c2a44af4d13ae1bcc3de197f189187a5fabb21 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 12 Oct 2020 14:33:32 +0900 Subject: [PATCH 15/16] Fix dbus call of default_pmlock_check() For non-killable daemons, the return of resourced's CheckAppStatus is always ignored. Therefore, fix not to call CheckAppStatus when the pmlock_check is checking non-killable daemon, not app. Change-Id: Ifeef32754c9d94a18ad302b97927407de91b83d8 Signed-off-by: Youngjae Cho Signed-off-by: lokilee73 --- src/display/display-lock.c | 48 ++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/display/display-lock.c b/src/display/display-lock.c index c7d88c7..2df1497 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -64,15 +64,34 @@ static void refresh_app_cond() trans_condition |= MASK_OFF; } +static void broadcast_pmlock_expired(pid_t pid, enum state_t state, const char* appid, time_t locktime) +{ + time_t now; + double diff; + int ret; + + time(&now); + diff = difftime(now, locktime); + + CRITICAL_LOG("%s(%d) has held %s lock for a long time(%.0f s).", + appid ? appid : "NULL", pid, state_st(state)->name + 2, diff); + + ret = dbus_handle_emit_dbus_signal(NULL, + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + "pmlock_expired", + g_variant_new("(ii)", pid, (int)diff)); + if (ret < 0) + _E("Failed to send dbus pmlock_expired"); +} + static void default_pmlock_check_cb(GVariant *var, void *user_data, GError *err) { pid_t pid = 0; - int ret, detected = 0; + int detected = 0; char *app_id = NULL; enum state_t state = (enum state_t) user_data; PmLockNode *node; - time_t now; - double diff; if (!var) return; @@ -82,26 +101,14 @@ static void default_pmlock_check_cb(GVariant *var, void *user_data, GError *err) goto out; } - if (is_app(pid) == 1 && !detected) + if (!detected) goto out; node = find_node(state, pid); if (!node) goto out; - time(&now); - diff = difftime(now, node->time); - - CRITICAL_LOG("%s(%d) has held %s lock for a long time(%.0f s).", - app_id, pid, state_st(state)->name + 2, diff); - - ret = dbus_handle_emit_dbus_signal(NULL, - DEVICED_PATH_DISPLAY, - DEVICED_INTERFACE_DISPLAY, - "pmlock_expired", - g_variant_new("(ii)", pid, (int)diff)); - if (ret < 0) - _E("Failed to send dbus pmlock_expired"); + broadcast_pmlock_expired(pid, state, app_id, node->time); out: if (app_id) @@ -140,6 +147,13 @@ static gboolean default_pmlock_check(void *data) return G_SOURCE_REMOVE; } + if (!is_app(pid)) { + /* For (non-killable) daemon, + * no need to ask resourced if it is abnormal lock */ + broadcast_pmlock_expired(pid, state, NULL, node->time); + return G_SOURCE_CONTINUE; + } + snprintf(chr_pid, sizeof(chr_pid), "%d", pid); arr[0] = chr_pid; switch (state) { -- 2.7.4 From 5fc02e79c7be0e6cf372ecf8f09ccd2f67147519 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 13 Oct 2020 12:28:30 +0900 Subject: [PATCH 16/16] Apply dpms cache globally Existing get_lcd_power() accesses to node directly, but it now uses dpms_get_cached_state() instead. Accessing to the node is separated into another function, get_lcd_power_node(). Change-Id: Ic05ce15d0fd1ec603c88db470144631a7e1b3ebd Signed-off-by: Youngjae Cho --- plugins/iot/display/device-interface.c | 14 +++----------- plugins/mobile/display/device-interface.c | 14 +++----------- plugins/tv/display/device-interface.c | 14 +++----------- plugins/wearable/display/device-interface.c | 14 +++----------- src/display/device-interface.h | 2 +- src/touchscreen/touchscreen.c | 7 ++----- 6 files changed, 15 insertions(+), 50 deletions(-) diff --git a/plugins/iot/display/device-interface.c b/plugins/iot/display/device-interface.c index 06ca0ad..ea407fb 100644 --- a/plugins/iot/display/device-interface.c +++ b/plugins/iot/display/device-interface.c @@ -153,14 +153,6 @@ static int get_lcd_power_node(void) } } -static int get_lcd_power(void) -{ - if (display_dev && display_dev->get_state) - return get_lcd_power_node(); - else - return dpms_get_state(); -} - bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) @@ -357,7 +349,7 @@ static int backlight_standby(int force) { int ret = -1; - if ((get_lcd_power() == DPMS_ON) || force) { + if ((dpms_get_cached_state() == DPMS_ON) || force) { _I("LCD standby"); ret = bl_onoff(DPMS_STANDBY, 0); } @@ -740,8 +732,8 @@ static struct _backlight_ops backlight_ops = { .standby = backlight_standby, .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, - .get_lcd_power = get_lcd_power, - .get_lcd_power_cached = dpms_get_cached_state, + .get_lcd_power = dpms_get_cached_state, + .get_lcd_power_node = get_lcd_power_node, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index b1a1356..d4ef77b 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -152,14 +152,6 @@ static int get_lcd_power_node(void) } } -static int get_lcd_power(void) -{ - if (display_dev && display_dev->get_state) - return get_lcd_power_node(); - else - return dpms_get_state(); -} - bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) @@ -356,7 +348,7 @@ static int backlight_standby(int force) { int ret = -1; - if ((get_lcd_power() == DPMS_ON) || force) { + if ((dpms_get_cached_state() == DPMS_ON) || force) { _I("LCD standby"); ret = bl_onoff(DPMS_STANDBY, 0); } @@ -739,8 +731,8 @@ static struct _backlight_ops backlight_ops = { .standby = backlight_standby, .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, - .get_lcd_power = get_lcd_power, - .get_lcd_power_cached = dpms_get_cached_state, + .get_lcd_power = dpms_get_cached_state, + .get_lcd_power_node = get_lcd_power_node, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index 9a47571..da6583c 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -153,14 +153,6 @@ static int get_lcd_power_node(void) } } -static int get_lcd_power(void) -{ - if (display_dev && display_dev->get_state) - return get_lcd_power_node(); - else - return dpms_get_state(); -} - bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) @@ -357,7 +349,7 @@ static int backlight_standby(int force) { int ret = -1; - if ((get_lcd_power() == DPMS_ON) || force) { + if ((dpms_get_cached_state() == DPMS_ON) || force) { _I("LCD standby"); ret = bl_onoff(DPMS_STANDBY, 0); } @@ -740,8 +732,8 @@ static struct _backlight_ops backlight_ops = { .standby = backlight_standby, .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, - .get_lcd_power = get_lcd_power, - .get_lcd_power_cached = dpms_get_cached_state, + .get_lcd_power = dpms_get_cached_state, + .get_lcd_power_node = get_lcd_power_node, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index d2ee406..655a102 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -167,14 +167,6 @@ static int get_lcd_power_node(void) } } -static int get_lcd_power(void) -{ - if (display_dev && display_dev->get_state) - return get_lcd_power_node(); - else - return dpms_get_state(); -} - bool display_dimstay_check(void) { if (get_pm_status_flag() & DIM_FLAG) @@ -368,7 +360,7 @@ static int backlight_standby(int force) { int ret = -1; - if ((get_lcd_power() == DPMS_ON) || force) { + if ((dpms_get_cached_state() == DPMS_ON) || force) { _I("LCD standby"); ret = bl_onoff(DPMS_STANDBY, 0); } @@ -805,8 +797,8 @@ static struct _backlight_ops backlight_ops = { .standby = backlight_standby, .set_default_brt = set_default_brt, .get_default_brt = get_default_brt, - .get_lcd_power = get_lcd_power, - .get_lcd_power_cached = dpms_get_cached_state, + .get_lcd_power = dpms_get_cached_state, + .get_lcd_power_node = get_lcd_power_node, .set_custom_status = set_custom_status, .get_custom_status = get_custom_status, .save_custom_brightness = save_custom_brightness, diff --git a/src/display/device-interface.h b/src/display/device-interface.h index 4193de8..161c528 100644 --- a/src/display/device-interface.h +++ b/src/display/device-interface.h @@ -69,7 +69,7 @@ struct _backlight_ops { int (*set_default_brt)(int level); int (*get_default_brt)(void); int (*get_lcd_power)(void); - int (*get_lcd_power_cached)(void); + int (*get_lcd_power_node)(void); int (*set_custom_status)(bool on); bool (*get_custom_status)(void); int (*save_custom_brightness)(void); diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index b2c8182..5ec95d1 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -193,9 +193,6 @@ static int touchscreen_start(enum device_flags flags) if (touchscreen_enable != DEVICE_OPS_STATUS_START) return 0; - if (!backlight_ops || !backlight_ops->get_lcd_power) - return -ENOTSUP; - /* Do not enable touchscreen during silent boot mode */ if (silent_boot && !booting_done(NULL)) return -ENOTSUP; @@ -206,8 +203,8 @@ static int touchscreen_start(enum device_flags flags) ret = touchscreen_set_state(TOUCHSCREEN_ON); state = -1; - if (backlight_ops && backlight_ops->get_lcd_power_cached) - state = backlight_ops->get_lcd_power_cached(); + if (backlight_ops && backlight_ops->get_lcd_power) + state = backlight_ops->get_lcd_power(); if (state == DPMS_OFF) touchscreen_powersaving(POWERSAVING_ON); -- 2.7.4