From 65f766d7131344ac95cfb53360ea20ea98bfe89e Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 27 Aug 2020 14:35:56 +0900 Subject: [PATCH 01/16] Dosen't lock becasue it could prevent Suspend-to-RAM If internal lock by USB-HOST is on, it can prevent going to suspend-to-ram. So, remove it. Change-Id: I87852664313d662cf38af120383506bd2116932f Signed-off-by: lokilee73 --- src/usbhost/usb-host.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/usbhost/usb-host.c b/src/usbhost/usb-host.c index fd076fe..c3b5750 100644 --- a/src/usbhost/usb-host.c +++ b/src/usbhost/usb-host.c @@ -1190,15 +1190,11 @@ DEVICE_OPS_REGISTER(&usbhost_device_ops) static int extcon_usbhost_state_changed(int status) { - if (status == USBHOST_DISCONNECTED) { + if (status == USBHOST_DISCONNECTED) _I("USB host connector disconnected."); - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_USB_HOST, LCD_OFF, STAY_CUR_STATE); - } else { + else _I("USB host connector connected."); - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_USB_HOST, LCD_OFF, STAY_CUR_STATE, 0); - } + return 0; } -- 2.7.4 From e9731fde6488fd49dbeb937f280d5769886eef76 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 1 Sep 2020 11:12:49 +0900 Subject: [PATCH 02/16] Return errno for failing fopen in config_parse Change-Id: I23c0e54128f59c9a3b3e533add1670cfb74bf9df Signed-off-by: Youngjae Cho --- src/core/config-parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/config-parser.c b/src/core/config-parser.c index 02f07d0..68b9f76 100644 --- a/src/core/config-parser.c +++ b/src/core/config-parser.c @@ -61,8 +61,8 @@ int config_parse(const char *file_name, int cb(struct parse_result *result, /* open conf file */ f = fopen(file_name, "r"); if (!f) { + ret = -errno; _E("Failed to open file '%s'.", file_name); - ret = -EIO; goto error; } -- 2.7.4 From b8087749b614f5460bec2a321756c661cbd86310 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 31 Aug 2020 11:38:10 +0900 Subject: [PATCH 03/16] Enhance display/power lock managemenent Summary: - Detect someone who holds lock longer than 30 minutes. - If a general application is detected, deviced generates signal with time information in addtion to pid. - If a specific daemon is detected, deviced tries to kill it directly. For general applications: Added an addition information, lock holding time in second, to the signal "pmlock_expired". This makes someone, who is in charge of application lifecycle and notification, possible to determine whether to kill that application or not. For some specific killable daemon: Added list of killable daemon to conf file and deviced loads that list. If a killable daemon holds lock longer than 30 minutes, deviced directly sends SIGTERM to that daemon, releasing lock. After for a while, deviced checks once more, if the daemon is still alive then, sends SIGKILL. Change-Id: Ia0d433facdcc7814e19278619a58a111ff7ff7c3 Signed-off-by: Youngjae Cho --- plugins/wearable/display/core.c | 231 +++++++++++++++++++++++++++++++++++++++- src/display/core.h | 7 ++ src/display/display-lock.c | 62 ++++++----- src/display/display-lock.h | 13 +++ 4 files changed, 279 insertions(+), 34 deletions(-) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 4a5c8e0..6f3bb43 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -69,6 +69,7 @@ #include "shared/plugin.h" #define DISPLAY_CONF_FILE "/etc/deviced/display.conf" +#define POWERLOCK_CONF_FILE "/etc/deviced/powerlock.conf" #ifndef VCONFKEY_HOMESCREEN_TUTORIAL_OOBE_ENABLED #define VCONFKEY_HOMESCREEN_TUTORIAL_OOBE_ENABLED "db/private/com.samsung.w-home/tutorial_oobe_enabled" @@ -189,6 +190,19 @@ static int trans_table[S_END][EVENT_END] = { (b.tv_sec * 1000000 + b.tv_usec)) \ / 1000) +#define KILLABLE_DAEMON_LOCK_LIMIT 1800 /* seconds, 30min */ +#define FORCE_RELEASE_LOCK_INTERVAL 5 /* seconds */ + +static void get_comm(pid_t pid, char *comm); +static bool is_killable_daemon(pid_t pid); +static gboolean pmlock_terminate_daemon_to_release_lock(gpointer data); +static int pmlock_check(void *data); +static int powerlock_load_config(struct parse_result *result, void *user_data); +static void free_killable_daemon_list(void); + +static dd_list *display_lock_killable_daemon; +static bool initialized_killable_daemon_list; + static struct display_config display_conf = { .lock_wait_time = LOCK_SCREEN_WATING_TIME, .longpress_interval = LONG_PRESS_INTERVAL, @@ -206,6 +220,7 @@ static struct display_config display_conf = { .timeout_enable = true, .input_support = true, .lockcheck_timeout = 600, + .pmlock_check = pmlock_check, .aod_enter_level = 40, .aod_tsp = true, .touch_wakeup = false, @@ -319,6 +334,181 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } +static void get_comm(pid_t pid, char *comm) +{ + char buf[PATH_MAX]; + int fd, r; + + if (pid >= INTERNAL_LOCK_BASE) + snprintf(buf, PATH_MAX, "/proc/%d/comm", getpid()); + else + snprintf(buf, PATH_MAX, "/proc/%d/comm", pid); + + fd = open(buf, O_RDONLY); + if (fd < 0) { + comm[0] = '\0'; + _E("Process(%d) does not exist now(may be dead without unlock).", pid); + return; + } + + r = read(fd, comm, PATH_MAX); + if ((r > 0) && (r < PATH_MAX)) { + if (comm[r - 1] == '\n') + comm[r - 1] = '\0'; + else + comm[r] = '\0'; + } else + comm[0] = '\0'; + + close(fd); +} + +static bool is_killable_daemon(pid_t pid) +{ + char pname[PATH_MAX] = {0, }; + const char *blacklist; + dd_list *l; + + get_comm(pid, pname); + if (!(*pname)) + return false; + + DD_LIST_FOREACH(display_lock_killable_daemon, l, blacklist) { + if (MATCH(pname, blacklist)) + return true; + } + + return false; +} + +static gboolean pmlock_terminate_daemon_to_release_lock(gpointer data) +{ + pid_t pid; + PmLockNode *node; + enum state_t state; + int ret; + bool pid_exist; + char pname[PATH_MAX] = {0, }; + + if (!data) { + _E("Invalid parameter."); + return G_SOURCE_REMOVE; + } + + node = (PmLockNode *) data; + state = node->state; + pid = node->pid; + + if (pid <= 0) { + _E("Invalid lock pid."); + del_node(state, node); + return G_SOURCE_REMOVE; + } + + if (!node->killable_daemon) { + _E("Incorrect checker, this is not a killable daemon. Stop checking lock."); + return G_SOURCE_REMOVE; + } + + pid_exist = (kill(pid, 0) == 0); + if (pid_exist) + get_comm(pid, pname); + + if (node->force_release == false) { + /* Stop checking lock if process had been terminated */ + if (!pid_exist) { + del_node(state, node); + _I("Process %d not found. Stop checking lock.", pid); + return G_SOURCE_REMOVE; + } + + /* KILLABLE_DAEMON_LOCK_LIMIT is expired. Kill the daemon */ + CRITICAL_LOG("%s(%d) holds %s lock for %ds. kill SIGTERM.", + *pname ? pname : "Unknown", pid, states[state].name, KILLABLE_DAEMON_LOCK_LIMIT); + ret = kill(pid, SIGTERM); + if (ret < 0) + CRITICAL_LOG("Failed to send SIGTERM to process %s(%d), %d.", + *pname ? pname : "Unknown", pid, errno); + + node->force_release = true; + g_timeout_add_seconds(FORCE_RELEASE_LOCK_INTERVAL, + pmlock_terminate_daemon_to_release_lock, (gpointer)node); + } else if (node->force_release == true) { + /* kill confirmation */ + if (pid_exist) { + CRITICAL_LOG("%s(%d) is still alive, kill SIGKILL.", + *pname ? pname : "Unknown", pid); + + ret = kill(pid, SIGKILL); + if (ret < 0) + CRITICAL_LOG("Failed to kill process %s(%d), %d.", + *pname ? pname : "Unknown", pid, errno); + } + + /* release lock */ + CRITICAL_LOG("Release %s lock occupied by PID %d.", states[state].name, pid); + del_node(state, node); + set_unlock_time(pid, state); + + if (!timeout_src_id) + states[get_pm_cur_state()].trans(EVENT_TIMEOUT); + } + + return G_SOURCE_REMOVE; +} + +static int pmlock_check(void *data) +{ + PmLockNode *node; + int ret; + + assert(data); + node = (PmLockNode *) data; + + if (!initialized_killable_daemon_list) { + ret = config_parse(POWERLOCK_CONF_FILE, powerlock_load_config, NULL); + /* config file may not exist */ + if (ret < 0 && ret != -ENOENT) + _W("Failed to load %s, %d.", POWERLOCK_CONF_FILE, ret); + + if (status == DEVICE_OPS_STATUS_UNINIT) { + _W("Lock request before display init. Preloaded killable list."); + initialized_killable_daemon_list = true; + } else if (status == DEVICE_OPS_STATUS_STOP) { + _W("Lock request after display stop. Loaded list will be freed immediately."); + node->killable_daemon = is_killable_daemon(node->pid); + free_killable_daemon_list(); + goto killable_marked; + } + } + + node->killable_daemon = is_killable_daemon(node->pid); + +killable_marked: + /* use default lock checker */ + if (!node->killable_daemon) + return 0; + + return g_timeout_add_seconds(KILLABLE_DAEMON_LOCK_LIMIT, + pmlock_terminate_daemon_to_release_lock, (gpointer)node); +} + +static void free_killable_daemon_list(void) +{ + dd_list *l, *l_next; + char *blacklist; + + if (!display_lock_killable_daemon) + return; + + DD_LIST_FOREACH_SAFE(display_lock_killable_daemon, l, l_next, blacklist) { + DD_LIST_REMOVE(display_lock_killable_daemon, blacklist); + free(blacklist); + } + display_lock_killable_daemon = NULL; + initialized_killable_daemon_list = false; +} + static unsigned long get_lcd_on_flags(void) { unsigned long flags = NORMAL_MODE; @@ -1089,9 +1279,13 @@ static void proc_condition_lock(PMMsg *data) holdkey_block = GET_COND_FLAG(data->cond) & PM_FLAG_BLOCK_HOLDKEY; tmp = find_node(state, pid); - if (!tmp) - add_node(state, pid, cond_timeout_id, holdkey_block); - else { + if (!tmp) { + tmp = add_node(state, pid, cond_timeout_id, holdkey_block); + if (!tmp) { + _E("Failed to acquire lock, state: %d, pid: %d.", state, pid); + return; + } + } else { update_lock_timer(data, tmp, cond_timeout_id); tmp->holdkey_block = holdkey_block; } @@ -1122,8 +1316,8 @@ static void proc_condition_lock(PMMsg *data) } } - _SD("be requested LOCK info pname(%s), holdkeyblock(%d) flags(%d)", - pname, holdkey_block, flags); + _SD("be requested LOCK info pname(%s), holdkeyblock(%d) flags(%d) killable_daemon(%d)", + pname, holdkey_block, flags, tmp->killable_daemon); set_lock_time(pid, pname, state); device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)&value); @@ -2172,6 +2366,26 @@ static int display_load_config(struct parse_result *result, void *user_data) return 0; } +static int powerlock_load_config(struct parse_result *result, void *user_data) +{ + char *name = NULL; + + _D("powerlock_load_config: section=%s name=%s value=%s", result->section, result->name, result->value); + + if (MATCH(result->section, "KillableDaemon") && MATCH(result->name, "KillableList")) { + name = strndup(result->value, PATH_MAX - 1); + if (!name) { + _E("Not enough memory."); + return -ENOMEM; + } + + CRITICAL_LOG("Add %s to killable daemon list.", name); + DD_LIST_APPEND(display_lock_killable_daemon, name); + } + + return 0; +} + static gboolean delayed_init_dpms(gpointer data) { int timeout; @@ -2331,6 +2545,12 @@ static void display_init(void *data) _W("Failed to load '%s', use default value: %d", DISPLAY_CONF_FILE, ret); + ret = config_parse(POWERLOCK_CONF_FILE, powerlock_load_config, NULL); + /* config file may not exist */ + if (ret < 0 && ret != -ENOENT) + _W("Failed to load %s, %d.", POWERLOCK_CONF_FILE, ret); + initialized_killable_daemon_list = true; + register_kernel_uevent_control(&lcd_uevent_ops); register_kernel_uevent_control(&sec_dsim_uevent_ops); @@ -2489,6 +2709,7 @@ static void display_exit(void *data) exit_lcd_operation(); free_lock_info_list(); + free_killable_daemon_list(); /* free display service */ display_service_free(); diff --git a/src/display/core.h b/src/display/core.h index caa97dc..5bfb1d1 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -126,6 +126,13 @@ struct display_config { int accel_sensor_on; int continuous_sampling; int lockcheck_timeout; + + /* Define pmlock checker. + * Return id of the lock checker. + * + * Returning 0 will use default lock checker */ + int (*pmlock_check) (void *data); + int aod_enter_level; bool aod_tsp; bool timeout_enable; diff --git a/src/display/display-lock.c b/src/display/display-lock.c index 4450a76..b1e08d4 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -37,6 +37,8 @@ static struct _backlight_ops *backlight_ops; static dd_list *cond_head[S_END]; static int trans_condition; +static struct display_config *display_conf; + bool check_lock_state(int state) { dd_list *elem; @@ -62,7 +64,7 @@ static void refresh_app_cond() trans_condition |= MASK_OFF; } -static void pmlock_check_cb(GVariant *var, void *user_data, GError *err) +static void default_pmlock_check_cb(GVariant *var, void *user_data, GError *err) { pid_t pid = 0; int ret, detected = 0; @@ -97,7 +99,7 @@ static void pmlock_check_cb(GVariant *var, void *user_data, GError *err) DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, "pmlock_expired", - g_variant_new("(i)", pid)); + g_variant_new("(ii)", pid, (int)diff)); if (ret < 0) _E("Failed to send dbus pmlock_expired"); @@ -107,12 +109,11 @@ out: g_variant_unref(var); } -static gboolean pmlock_check(void *data) +static gboolean default_pmlock_check(void *data) { const char *arr[2]; char chr_pid[PID_MAX]; PmLockNode *node; - GVariant *v; enum state_t state; pid_t pid; int ret; @@ -122,8 +123,9 @@ static gboolean pmlock_check(void *data) return G_SOURCE_REMOVE; } - v = (GVariant*)data; - g_variant_get(v, "(ii)", &state, &pid); + node = (PmLockNode *) data; + state = node->state; + pid = node->pid; if (state == S_LCDOFF && backlight_ops->get_lcd_power() == DPMS_ON) { _D("Lcd state is PM_LCD_POWER_ON"); @@ -152,7 +154,6 @@ static gboolean pmlock_check(void *data) break; default: _E("Invalid state."); - g_variant_unref(v); return G_SOURCE_REMOVE; } @@ -160,7 +161,7 @@ static gboolean pmlock_check(void *data) RESOURCED_PATH_PROCESS, RESOURCED_INTERFACE_PROCESS, METHOD_APP_STATUS, - "is", arr, pmlock_check_cb, -1, (void *)(intptr_t)state); + "is", arr, default_pmlock_check_cb, -1, (void *)(intptr_t)state); if (ret < 0) _E("Failed to call dbus method"); @@ -184,41 +185,39 @@ PmLockNode *find_node(enum state_t s_index, pid_t pid) PmLockNode *add_node(enum state_t s_index, pid_t pid, guint timeout_id, bool holdkey_block) { - guint warning_id = 0; PmLockNode *n; - GVariant *v = NULL; time_t now; - struct display_config *display_conf = get_display_config(); - if (!display_conf) { - _E("Failed to get display configuration."); - return NULL; - } - n = (PmLockNode *) malloc(sizeof(PmLockNode)); + assert(display_conf); + + n = (PmLockNode *) calloc(1, sizeof(PmLockNode)); if (n == NULL) { - _E("Not enough memory, add cond. fail"); + _E("Not enough memory, failed to alloc lock node."); return NULL; } - if (pid < INTERNAL_LOCK_BASE) { - v = g_variant_new("(ii)", s_index, pid); - if (v) { - warning_id = g_timeout_add_seconds(display_conf->lockcheck_timeout, - pmlock_check, (void *)v); - } else { - _E("Failed to make GVariant."); - } - } - time(&now); + n->state = s_index; n->pid = pid; n->timeout_id = timeout_id; - n->warning_id = warning_id; - n->warning_param = v; n->time = now; n->holdkey_block = holdkey_block; n->background = false; n->broadcast_warning = true; + + if (pid < INTERNAL_LOCK_BASE) { + /* check if this lock node needs custom-defined lock checker. + * n->warning_id would be 0 if fails to register the checker, + * or there is no need to use that checker */ + if (display_conf->pmlock_check) + n->warning_id = display_conf->pmlock_check(n); + + /* use default lock checker */ + if (!n->warning_id) + n->warning_id = g_timeout_add_seconds(display_conf->lockcheck_timeout, + default_pmlock_check, (gpointer)n); + } + DD_LIST_APPEND(cond_head[s_index], n); refresh_app_cond(); @@ -403,4 +402,9 @@ static void __CONSTRUCTOR__ initialize(void) backlight_ops = get_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator."); + + display_conf = get_display_config(); + if (!display_conf) { + _E("Failed to get display config."); + } } diff --git a/src/display/display-lock.h b/src/display/display-lock.h index bde19db..c52ac84 100644 --- a/src/display/display-lock.h +++ b/src/display/display-lock.h @@ -27,6 +27,7 @@ #include "core.h" typedef struct _pm_lock_node { + enum state_t state; pid_t pid; guint timeout_id; guint warning_id; @@ -35,6 +36,18 @@ typedef struct _pm_lock_node { bool holdkey_block; bool background; bool broadcast_warning; + + /* Set true when the lock holder is an entry of + * the list display_lock_killable_daemon. + * If true, deviced tries to kill this lock holder when + * the holder holds lock longer than KILLABLE_DAEMON_LOCK_LIMIT */ + bool killable_daemon; + + /* Set true when the lock holder holds lock + * longer than KILLABLE_DAEMON_LOCK_LIMIT. + * After a while, FORCE_RELEASE_LOCK_INTERVAL, + * this lock will be released. */ + bool force_release; } PmLockNode; bool check_lock_state(int state); -- 2.7.4 From 55798963183d65a4e2a1b50deed79ca90888abe4 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Fri, 28 Aug 2020 17:41:33 +0900 Subject: [PATCH 04/16] Fix dlsym() caller for get_display_conf Change-Id: If9eac834f99620e52807881c321d2f08e4a6e194 --- src/touchscreen/touchscreen.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index adc244c..44ad171 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -51,6 +51,7 @@ static struct display_config *_display_conf; static struct _backlight_ops *_backlight_ops; static struct _backlight_ops* (*_get_backlight_ops)(void); +static struct display_config* (*_get_display_config)(void); static void touchscreen_wakeup_status(keynode_t *key, void *data) { @@ -318,9 +319,13 @@ static void touchscreen_init(void *data) { int ret, val; - _display_conf = dlsym(disp_plgn->handle, "display_conf"); - if (!_display_conf) - _E("Failed to obtain address of display_conf, %s.", dlerror()); + _get_display_config = dlsym(disp_plgn->handle, "get_display_config"); + if (_get_display_config) { + _display_conf = _get_display_config(); + if (!_display_conf) + _E("Failed to get display config."); + } else + _E("Failed to obtain address of get_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'. -- 2.7.4 From 1105b08b7f9e98a06a1c8b9b72193554ed0f7730 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Sat, 29 Aug 2020 17:13:31 +0900 Subject: [PATCH 05/16] Support multi HDMI + Svace fix 1) Support multi HDMI There are two HDMI ports in RPI4 target and it can be increased in the future. So, make a bitmap table for HDMI. Supported MAX HDMI number is 64 for now. Below data is listed up. extcon# : 1 is shifted by # ex) type value bitmap extcon1 1/0 0x10/0x00 extcon2 1/0 0x100/0x000 extcon3 1/0 0x1000/0x0000 If one of them is 1, then 1(connected) is broadcasted. Otherwise, 0(disconnected) is broadcasted. 2) Svace fix src/power/power-control.c Below condition is removed, because .log_type is same or bigger than PM_LOG_MIN pm_history_log[index].log_type < PM_LOG_MIN Change-Id: Ib9dbaa374cc5ccbbde1ebac45840befe1fb786d2 Signed-off-by: lokilee73 --- src/core/common.h | 1 + src/extcon/cradle.c | 2 +- src/extcon/earjack.c | 2 +- src/extcon/extcon.c | 37 +++++++++++++++------------- src/extcon/extcon.h | 3 ++- src/extcon/hdmi.c | 63 +++++++++++++++++++++++++++++++++++++++++++---- src/power/power-control.c | 3 +-- src/usb/usb.c | 2 +- src/usbhost/usb-host.c | 2 +- 9 files changed, 86 insertions(+), 29 deletions(-) diff --git a/src/core/common.h b/src/core/common.h index 3f53d1e..b49e52b 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -29,6 +29,7 @@ #define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0])) #define BITS_PER_LONG (sizeof(long) * 8) +#define BITS_PER_CHAR (sizeof(char) * 8) #define OFFSET(x) ((x) & (BITS_PER_LONG - 1)) #define BIT(x) (1UL << OFFSET(x)) #define LONG(x) ((x) / BITS_PER_LONG) diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c index 72e368c..1eeffa1 100644 --- a/src/extcon/cradle.c +++ b/src/extcon/cradle.c @@ -55,7 +55,7 @@ static void cradle_send_broadcast(int status) _E("Failed to send dbus signal(%s)", SIGNAL_CRADLE_STATE); } -static int cradle_update(int status) +static int cradle_update(const char *index, int status) { int ret; diff --git a/src/extcon/earjack.c b/src/extcon/earjack.c index 003b7bb..1fb99c2 100644 --- a/src/extcon/earjack.c +++ b/src/extcon/earjack.c @@ -68,7 +68,7 @@ static void earjack_send_system_event(int status) bundle_free(b); } -static int earjack_update(int status) +static int earjack_update(const char *index, int status) { int ret; diff --git a/src/extcon/extcon.c b/src/extcon/extcon.c index a0c06f5..9bb0118 100644 --- a/src/extcon/extcon.c +++ b/src/extcon/extcon.c @@ -22,7 +22,6 @@ #include #include "core/log.h" -#include "core/list.h" #include "core/common.h" #include "core/devices.h" #include "core/config-parser.h" @@ -32,6 +31,7 @@ #define EXTCON_PATH "/sys/class/extcon" #define STATE_NAME "STATE" +#define DEVICE_TYPE "DEVTYPE" #define METHOD_SYSPOPUP_SHOW "show" @@ -92,7 +92,7 @@ void extcon_update_count(extcon_index_type_e index, unsigned long count) device_notify(DEVICE_NOTIFIER_EXTCON_COUNT, (void *)&extcon); } -static int extcon_update(const char *name, const char *value) +static int extcon_update(const char *name, const char *index, const char *value) { struct extcon_ops *dev; char buf[BUF_MAX]; @@ -109,7 +109,7 @@ static int extcon_update(const char *name, const char *value) status = atoi(value); /* Do not invoke update func. if it's the same value */ - if (dev->status == status) + if (dev->status == status && !index) return 0; _I("Changed %s device: (%d) to (%d).", name, dev->status, status); @@ -132,7 +132,7 @@ static int extcon_update(const char *name, const char *value) } if (dev->update) - dev->update(status); + dev->update(index, status); return 0; } @@ -155,11 +155,11 @@ int extcon_enable_device(const char *name) dev->enabled = true; if (strncmp(name, "USB", strlen("USB")) == 0) { - ret = extcon_update("USB", "0"); + ret = extcon_update("USB", NULL, "0"); if (ret != 0) _E("Failed to disconnect USB."); - ret = extcon_update("USB", "1"); + ret = extcon_update("USB", NULL, "1"); if (ret != 0) _E("Failed to connect USB."); } @@ -200,12 +200,13 @@ int extcon_disable_device(const char *name) return 0; } -static int extcon_parsing_value(const char *value) + +static int extcon_parsing_value(const char *index, const char *value) { char *s, *p; char name[NAME_MAX]; - if (!value) + if (!value || !index) return -EINVAL; s = (char*)value; @@ -216,7 +217,7 @@ static int extcon_parsing_value(const char *value) memset(name, 0, sizeof(name)); memcpy(name, s, p-s); /* name is env_name and p+1 is env_value */ - extcon_update(name, p+1); + extcon_update(name, index, p+1); s = strchr(p, '\n'); if (!s) break; @@ -229,26 +230,28 @@ static int extcon_parsing_value(const char *value) static void uevent_extcon_handler(struct udev_device *dev) { const char *env_value; + const char *dev_index; int ret; env_value = udev_device_get_property_value(dev, STATE_NAME); - if (!env_value) - return; + dev_index = udev_device_get_property_value(dev, DEVICE_TYPE); - ret = extcon_parsing_value(env_value); + ret = extcon_parsing_value(dev_index, env_value); if (ret < 0) _E("Failed to parse extcon value: %d", ret); } static int extcon_load_uevent(struct parse_result *result, void *user_data) { + char *index = user_data; + if (!result) return 0; if (!result->name || !result->value) return 0; - extcon_update(result->name, result->value); + extcon_update(result->name, index, result->value); return 0; } @@ -277,7 +280,7 @@ static int get_extcon_init_state(void) if (access(node, F_OK) != 0) continue; - ret = config_parse(node, extcon_load_uevent, NULL); + ret = config_parse(node, extcon_load_uevent, result->d_name); if (ret < 0) _E("Failed to parse %s data: %d", node, ret); } @@ -322,7 +325,7 @@ static GVariant *dbus_enable_device(GDBusConnection *conn, g_variant_get(param, "(s)", &device); - ret = extcon_update(device, "1"); + ret = extcon_update(device, NULL, "1"); g_free(device); return g_variant_new("(i)", ret); @@ -337,7 +340,7 @@ static GVariant *dbus_disable_device(GDBusConnection *conn, g_variant_get(param, "(s)", &device); - ret = extcon_update(device, "0"); + ret = extcon_update(device, NULL, "0"); g_free(device); return g_variant_new("(i)", ret); @@ -373,7 +376,7 @@ static void extcon_changed(struct connection_info *info, void *data) return; /* call to update */ - extcon_update(info->name, info->state); + extcon_update(info->name, NULL, info->state); } static int extcon_probe(void *data) diff --git a/src/extcon/extcon.h b/src/extcon/extcon.h index 7369fb0..4148096 100644 --- a/src/extcon/extcon.h +++ b/src/extcon/extcon.h @@ -21,6 +21,7 @@ #define __EXTCON_H__ #include "core/common.h" +#include "core/list.h" #include #include "extcon-count.h" @@ -42,7 +43,7 @@ struct extcon_ops { int enabled; void (*init)(void *data); void (*exit)(void *data); - int (*update)(int status); + int (*update)(const char *index, int status); }; /* Status for External Connectors */ diff --git a/src/extcon/hdmi.c b/src/extcon/hdmi.c index 9eac710..6f38b31 100644 --- a/src/extcon/hdmi.c +++ b/src/extcon/hdmi.c @@ -20,6 +20,7 @@ #include #include #include "core/log.h" +#include "core/list.h" #include "core/device-notifier.h" #include "display/core.h" #include "display/display-ops.h" @@ -29,6 +30,16 @@ #define METHOD_GET_HDMI "GetHDMI" #define SIGNAL_HDMI_STATE "ChangedHDMI" +#define HDMI_NUMBER_MAX (64) // max number of supported hdmi +#define HDMI_BITMAP_T (sizeof(hdmi_bitmap_t) * BITS_PER_CHAR) // size of hdmi_bitmap_t + +/* macro to set/unset bit */ +#define HDMI_SET_BIT(num) (hdmi_bitmap |= (1ULL << ((num) % HDMI_BITMAP_T))) +#define HDMI_UNSET_BIT(num) (hdmi_bitmap &= ~(1ULL << ((num) % HDMI_BITMAP_T))) + +typedef unsigned long long hdmi_bitmap_t; + +static hdmi_bitmap_t hdmi_bitmap; static struct display_plugin *disp_plgn; static struct extcon_ops hdmi_extcon_ops; @@ -52,20 +63,62 @@ static void hdmi_send_broadcast(int status) _E("Failed to send dbus signal(%s)", SIGNAL_HDMI_STATE); } -static int hdmi_update(int status) +/* if hdmi_bitmap is bigger than 0, we assume hdmi is connected */ +static int get_hdmi_status(void) +{ + if (hdmi_bitmap > 0) + return HDMI_CONNECTED; + + return HDMI_DISCONNECTED; +} + + +static void update_hdmi_bitmap(int index, int status) +{ + if (status == HDMI_CONNECTED) + HDMI_SET_BIT(index); + else + HDMI_UNSET_BIT(index); +} + +static void update_all_hdmi_bitmap(int status) +{ + if (status == HDMI_CONNECTED) + hdmi_bitmap = ULLONG_MAX; + else + hdmi_bitmap = 0; +} + +static int hdmi_update(const char *index, int status) { int ret; + int num = -1; + int hdmi_status; - _I("Hdmi changed. status=%d", status); + _I("Hdmi changed"); if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_HDMI, LCD_NORMAL); - ret = vconf_set_int(VCONFKEY_SYSMAN_HDMI, status); + + if (!index) + update_all_hdmi_bitmap(status); + else { + sscanf(index, "extcon%d", &num); + if (num < 0 || num >= HDMI_NUMBER_MAX) { + _E("Invalid HDMI number: %d", num); + return -EINVAL; + } + update_hdmi_bitmap(num, status); + } + + hdmi_status = get_hdmi_status(); + ret = vconf_set_int(VCONFKEY_SYSMAN_HDMI, hdmi_status); if (ret < 0) _E("Failed to set vconf value for hdmi: %d", vconf_get_ext_errno()); - hdmi_send_broadcast(status); + hdmi_extcon_ops.status = hdmi_status; + hdmi_send_broadcast(hdmi_status); - if (status == HDMI_CONNECTED) { + if (hdmi_status == HDMI_CONNECTED) { if (disp_plgn->pm_lock_internal) disp_plgn->pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0); } else { diff --git a/src/power/power-control.c b/src/power/power-control.c index e133c55..fbb6b9f 100644 --- a/src/power/power-control.c +++ b/src/power/power-control.c @@ -105,8 +105,7 @@ void pm_history_print(int fd, int count) if (pm_history_log[index].time == 0) continue; - if (pm_history_log[index].log_type < PM_LOG_MIN || - pm_history_log[index].log_type >= PM_LOG_MAX) + if (pm_history_log[index].log_type >= PM_LOG_MAX) continue; ctime_r(&pm_history_log[index].time, time_buf); time_buf[strlen(time_buf) - 1] = 0; diff --git a/src/usb/usb.c b/src/usb/usb.c index 691d0c3..0b24297 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -383,7 +383,7 @@ int usb_change_mode(unsigned int new_mode, bool change_debug_mode) } /* Called by extcon udev event */ -static int usb_state_changed(int new_status) +static int usb_state_changed(const char *index, int new_status) { int ret = -1; static int old_status = -1; diff --git a/src/usbhost/usb-host.c b/src/usbhost/usb-host.c index c3b5750..0c02247 100644 --- a/src/usbhost/usb-host.c +++ b/src/usbhost/usb-host.c @@ -1188,7 +1188,7 @@ static const struct device_ops usbhost_device_ops = { DEVICE_OPS_REGISTER(&usbhost_device_ops) -static int extcon_usbhost_state_changed(int status) +static int extcon_usbhost_state_changed(const char *index, int status) { if (status == USBHOST_DISCONNECTED) _I("USB host connector disconnected."); -- 2.7.4 From fe0822e49485931c831440b7f3e8fcf538f62b94 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Tue, 8 Sep 2020 11:05:37 +0900 Subject: [PATCH 06/16] Deduplicate display_load_config Change-Id: I450a89b1e115a0302101aae95cfd643eb651ff6b Signed-off-by: lokilee73 --- plugins/iot/display/core.c | 76 ----------------------------------------- plugins/mobile/display/core.c | 76 ----------------------------------------- plugins/tv/display/core.c | 76 ----------------------------------------- plugins/wearable/display/core.c | 76 ----------------------------------------- src/display/display.c | 75 ++++++++++++++++++++++++++++++++++++++++ src/display/display.h | 2 ++ 6 files changed, 77 insertions(+), 304 deletions(-) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 7495514..b8aa6ee 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -50,7 +50,6 @@ #include "core/udev.h" #include "core/list.h" #include "core/common.h" -#include "core/config-parser.h" #include "core/launch.h" #include "apps/apps.h" #include "extcon/extcon.h" @@ -59,7 +58,6 @@ #include "power/power-control.h" #include "power/boot.h" #include "power/doze.h" -#include "dd-display.h" #include "display-dpms.h" #include "display-signal.h" #include "display-lock.h" @@ -2005,80 +2003,6 @@ static int battery_health_changed(void *data) return 0; } -static int display_load_config(struct parse_result *result, void *user_data) -{ - struct display_config *c = user_data; - - _D("display_load_config: section=%s name=%s value=%s", result->section, result->name, result->value); - - if (!c) - return -EINVAL; - - if (!MATCH(result->section, "Display")) - return 0; - - if (MATCH(result->name, "LockScreenWaitingTime")) { - SET_CONF(c->lock_wait_time, atof(result->value)); - _D("lock wait time is %.3f", c->lock_wait_time); - } else if (MATCH(result->name, "LongPressInterval")) { - SET_CONF(c->longpress_interval, atof(result->value)); - _D("long press interval is %.3f", c->longpress_interval); - } else if (MATCH(result->name, "LightSensorSamplingInterval")) { - SET_CONF(c->lightsensor_interval, atof(result->value)); - _D("lightsensor interval is %.3f", c->lightsensor_interval); - } else if (MATCH(result->name, "LCDOffTimeout")) { - SET_CONF(c->lcdoff_timeout, atoi(result->value)); - _D("lcdoff timeout is %d ms", c->lcdoff_timeout); - } else if (MATCH(result->name, "BrightnessChangeStep")) { - SET_CONF(c->brightness_change_step, atoi(result->value)); - _D("brightness change step is %d", c->brightness_change_step); - } else if (MATCH(result->name, "LCDAlwaysOn")) { - c->lcd_always_on = (MATCH(result->value, "yes") ? 1 : 0); - _D("LCD always on is %d", c->lcd_always_on); - } else if (MATCH(result->name, "Dimming")) { - c->dimming = (MATCH(result->value, "yes") ? 1 : 0); - _D("Dimming is %d", c->dimming); - } else if (MATCH(result->name, "ChangedFrameRateAllowed")) { - if (strstr(result->value, "setting")) { - c->framerate_app[REFRESH_SETTING] = 1; - _D("framerate app is Setting"); - } - if (strstr(result->value, "all")) { - memset(c->framerate_app, 1, sizeof(c->framerate_app)); - _D("framerate app is All"); - } - } else if (MATCH(result->name, "ControlDisplay")) { - c->control_display = (MATCH(result->value, "yes") ? 1 : 0); - _D("ControlDisplay is %d", c->control_display); - } else if (MATCH(result->name, "PowerKeyDoublePressSupport")) { - c->powerkey_doublepress = (MATCH(result->value, "yes") ? 1 : 0); - _D("PowerKeyDoublePressSupport is %d", c->powerkey_doublepress); - } else if (MATCH(result->name, "AccelSensorOn")) { - c->accel_sensor_on = (MATCH(result->value, "yes") ? 1 : 0); - _D("AccelSensorOn is %d", c->accel_sensor_on); - } else if (MATCH(result->name, "ContinuousSampling")) { - c->continuous_sampling = (MATCH(result->value, "yes") ? 1 : 0); - _D("ContinuousSampling is %d", c->continuous_sampling); - } else if (MATCH(result->name, "TimeoutEnable")) { - c->timeout_enable = (MATCH(result->value, "yes") ? true : false); - _D("Timeout is %s", c->timeout_enable ? "enalbed" : "disabled"); - } else if (MATCH(result->name, "InputSupport")) { - c->input_support = (MATCH(result->value, "yes") ? true : false); - _D("Input is %s", c->input_support ? "supported" : "NOT supported"); - } else if (MATCH(result->name, "LockCheckTimeout")) { - SET_CONF(c->lockcheck_timeout, atoi(result->value)); - _D("LockCheckTimeout is %d", c->lockcheck_timeout); - } else if (MATCH(result->name, "AODTSP")) { - c->aod_tsp = (MATCH(result->value, "yes") ? true : false); - _D("TSP control at is %d at aod", c->aod_tsp); - } else if (MATCH(result->name, "SleepSupport")) { - c->sleep_support = (MATCH(result->value, "yes") ? true : false); - _D("SleepSupport is %d", c->sleep_support); - } - - return 0; -} - static gboolean delayed_init_dpms(gpointer data) { int timeout; diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 1826433..66f7bce 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -50,7 +50,6 @@ #include "core/udev.h" #include "core/list.h" #include "core/common.h" -#include "core/config-parser.h" #include "core/launch.h" #include "apps/apps.h" #include "extcon/extcon.h" @@ -59,7 +58,6 @@ #include "power/power-control.h" #include "power/boot.h" #include "power/doze.h" -#include "dd-display.h" #include "display/display-dpms.h" #include "proximity.h" #include "display-info.h" @@ -2016,80 +2014,6 @@ static int battery_health_changed(void *data) return 0; } -static int display_load_config(struct parse_result *result, void *user_data) -{ - struct display_config *c = user_data; - - _D("display_load_config: section=%s name=%s value=%s", result->section, result->name, result->value); - - if (!c) - return -EINVAL; - - if (!MATCH(result->section, "Display")) - return 0; - - if (MATCH(result->name, "LockScreenWaitingTime")) { - SET_CONF(c->lock_wait_time, atof(result->value)); - _D("lock wait time is %.3f", c->lock_wait_time); - } else if (MATCH(result->name, "LongPressInterval")) { - SET_CONF(c->longpress_interval, atof(result->value)); - _D("long press interval is %.3f", c->longpress_interval); - } else if (MATCH(result->name, "LightSensorSamplingInterval")) { - SET_CONF(c->lightsensor_interval, atof(result->value)); - _D("lightsensor interval is %.3f", c->lightsensor_interval); - } else if (MATCH(result->name, "LCDOffTimeout")) { - SET_CONF(c->lcdoff_timeout, atoi(result->value)); - _D("lcdoff timeout is %d ms", c->lcdoff_timeout); - } else if (MATCH(result->name, "BrightnessChangeStep")) { - SET_CONF(c->brightness_change_step, atoi(result->value)); - _D("brightness change step is %d", c->brightness_change_step); - } else if (MATCH(result->name, "LCDAlwaysOn")) { - c->lcd_always_on = (MATCH(result->value, "yes") ? 1 : 0); - _D("LCD always on is %d", c->lcd_always_on); - } else if (MATCH(result->name, "Dimming")) { - c->dimming = (MATCH(result->value, "yes") ? 1 : 0); - _D("Dimming is %d", c->dimming); - } else if (MATCH(result->name, "ChangedFrameRateAllowed")) { - if (strstr(result->value, "setting")) { - c->framerate_app[REFRESH_SETTING] = 1; - _D("framerate app is Setting"); - } - if (strstr(result->value, "all")) { - memset(c->framerate_app, 1, sizeof(c->framerate_app)); - _D("framerate app is All"); - } - } else if (MATCH(result->name, "ControlDisplay")) { - c->control_display = (MATCH(result->value, "yes") ? 1 : 0); - _D("ControlDisplay is %d", c->control_display); - } else if (MATCH(result->name, "PowerKeyDoublePressSupport")) { - c->powerkey_doublepress = (MATCH(result->value, "yes") ? 1 : 0); - _D("PowerKeyDoublePressSupport is %d", c->powerkey_doublepress); - } else if (MATCH(result->name, "AccelSensorOn")) { - c->accel_sensor_on = (MATCH(result->value, "yes") ? 1 : 0); - _D("AccelSensorOn is %d", c->accel_sensor_on); - } else if (MATCH(result->name, "ContinuousSampling")) { - c->continuous_sampling = (MATCH(result->value, "yes") ? 1 : 0); - _D("ContinuousSampling is %d", c->continuous_sampling); - } else if (MATCH(result->name, "TimeoutEnable")) { - c->timeout_enable = (MATCH(result->value, "yes") ? true : false); - _D("Timeout is %s", c->timeout_enable ? "enalbed" : "disabled"); - } else if (MATCH(result->name, "InputSupport")) { - c->input_support = (MATCH(result->value, "yes") ? true : false); - _D("Input is %s", c->input_support ? "supported" : "NOT supported"); - } else if (MATCH(result->name, "LockCheckTimeout")) { - SET_CONF(c->lockcheck_timeout, atoi(result->value)); - _D("LockCheckTimeout is %d", c->lockcheck_timeout); - } else if (MATCH(result->name, "AODTSP")) { - c->aod_tsp = (MATCH(result->value, "yes") ? true : false); - _D("TSP control at is %d at aod", c->aod_tsp); - } else if (MATCH(result->name, "SleepSupport")) { - c->sleep_support = (MATCH(result->value, "yes") ? true : false); - _D("SleepSupport is %d", c->sleep_support); - } - - return 0; -} - static gboolean delayed_init_dpms(gpointer data) { int timeout; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 665df86..2db8f62 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -50,7 +50,6 @@ #include "core/udev.h" #include "core/list.h" #include "core/common.h" -#include "core/config-parser.h" #include "core/launch.h" #include "apps/apps.h" #include "extcon/extcon.h" @@ -59,7 +58,6 @@ #include "power/power-control.h" #include "power/boot.h" #include "power/doze.h" -#include "dd-display.h" #include "display-dpms.h" #include "display-signal.h" #include "display-lock.h" @@ -2006,80 +2004,6 @@ static int battery_health_changed(void *data) return 0; } -static int display_load_config(struct parse_result *result, void *user_data) -{ - struct display_config *c = user_data; - - _D("display_load_config: section=%s name=%s value=%s", result->section, result->name, result->value); - - if (!c) - return -EINVAL; - - if (!MATCH(result->section, "Display")) - return 0; - - if (MATCH(result->name, "LockScreenWaitingTime")) { - SET_CONF(c->lock_wait_time, atof(result->value)); - _D("lock wait time is %.3f", c->lock_wait_time); - } else if (MATCH(result->name, "LongPressInterval")) { - SET_CONF(c->longpress_interval, atof(result->value)); - _D("long press interval is %.3f", c->longpress_interval); - } else if (MATCH(result->name, "LightSensorSamplingInterval")) { - SET_CONF(c->lightsensor_interval, atof(result->value)); - _D("lightsensor interval is %.3f", c->lightsensor_interval); - } else if (MATCH(result->name, "LCDOffTimeout")) { - SET_CONF(c->lcdoff_timeout, atoi(result->value)); - _D("lcdoff timeout is %d ms", c->lcdoff_timeout); - } else if (MATCH(result->name, "BrightnessChangeStep")) { - SET_CONF(c->brightness_change_step, atoi(result->value)); - _D("brightness change step is %d", c->brightness_change_step); - } else if (MATCH(result->name, "LCDAlwaysOn")) { - c->lcd_always_on = (MATCH(result->value, "yes") ? 1 : 0); - _D("LCD always on is %d", c->lcd_always_on); - } else if (MATCH(result->name, "Dimming")) { - c->dimming = (MATCH(result->value, "yes") ? 1 : 0); - _D("Dimming is %d", c->dimming); - } else if (MATCH(result->name, "ChangedFrameRateAllowed")) { - if (strstr(result->value, "setting")) { - c->framerate_app[REFRESH_SETTING] = 1; - _D("framerate app is Setting"); - } - if (strstr(result->value, "all")) { - memset(c->framerate_app, 1, sizeof(c->framerate_app)); - _D("framerate app is All"); - } - } else if (MATCH(result->name, "ControlDisplay")) { - c->control_display = (MATCH(result->value, "yes") ? 1 : 0); - _D("ControlDisplay is %d", c->control_display); - } else if (MATCH(result->name, "PowerKeyDoublePressSupport")) { - c->powerkey_doublepress = (MATCH(result->value, "yes") ? 1 : 0); - _D("PowerKeyDoublePressSupport is %d", c->powerkey_doublepress); - } else if (MATCH(result->name, "AccelSensorOn")) { - c->accel_sensor_on = (MATCH(result->value, "yes") ? 1 : 0); - _D("AccelSensorOn is %d", c->accel_sensor_on); - } else if (MATCH(result->name, "ContinuousSampling")) { - c->continuous_sampling = (MATCH(result->value, "yes") ? 1 : 0); - _D("ContinuousSampling is %d", c->continuous_sampling); - } else if (MATCH(result->name, "TimeoutEnable")) { - c->timeout_enable = (MATCH(result->value, "yes") ? true : false); - _D("Timeout is %s", c->timeout_enable ? "enalbed" : "disabled"); - } else if (MATCH(result->name, "InputSupport")) { - c->input_support = (MATCH(result->value, "yes") ? true : false); - _D("Input is %s", c->input_support ? "supported" : "NOT supported"); - } else if (MATCH(result->name, "LockCheckTimeout")) { - SET_CONF(c->lockcheck_timeout, atoi(result->value)); - _D("LockCheckTimeout is %d", c->lockcheck_timeout); - } else if (MATCH(result->name, "AODTSP")) { - c->aod_tsp = (MATCH(result->value, "yes") ? true : false); - _D("TSP control at is %d at aod", c->aod_tsp); - } else if (MATCH(result->name, "SleepSupport")) { - c->sleep_support = (MATCH(result->value, "yes") ? true : false); - _D("SleepSupport is %d", c->sleep_support); - } - - return 0; -} - static gboolean delayed_init_dpms(gpointer data) { int timeout; diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 6f3bb43..33907f1 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -51,7 +51,6 @@ #include "core/udev.h" #include "core/list.h" #include "core/common.h" -#include "core/config-parser.h" #include "core/launch.h" #include "apps/apps.h" #include "extcon/extcon.h" @@ -60,7 +59,6 @@ #include "power/power-control.h" #include "power/boot.h" #include "power/doze.h" -#include "dd-display.h" #include "display/display-dpms.h" #include "display-info.h" #include "battery-monitor.h" @@ -2292,80 +2290,6 @@ static int battery_health_changed(void *data) return 0; } -static int display_load_config(struct parse_result *result, void *user_data) -{ - struct display_config *c = user_data; - - _D("display_load_config: section=%s name=%s value=%s", result->section, result->name, result->value); - - if (!c) - return -EINVAL; - - if (!MATCH(result->section, "Display")) - return 0; - - if (MATCH(result->name, "LockScreenWaitingTime")) { - SET_CONF(c->lock_wait_time, atof(result->value)); - _D("lock wait time is %.3f", c->lock_wait_time); - } else if (MATCH(result->name, "LongPressInterval")) { - SET_CONF(c->longpress_interval, atof(result->value)); - _D("long press interval is %.3f", c->longpress_interval); - } else if (MATCH(result->name, "LightSensorSamplingInterval")) { - SET_CONF(c->lightsensor_interval, atof(result->value)); - _D("lightsensor interval is %.3f", c->lightsensor_interval); - } else if (MATCH(result->name, "LCDOffTimeout")) { - SET_CONF(c->lcdoff_timeout, atoi(result->value)); - _D("lcdoff timeout is %d ms", c->lcdoff_timeout); - } else if (MATCH(result->name, "BrightnessChangeStep")) { - SET_CONF(c->brightness_change_step, atoi(result->value)); - _D("brightness change step is %d", c->brightness_change_step); - } else if (MATCH(result->name, "LCDAlwaysOn")) { - c->lcd_always_on = (MATCH(result->value, "yes") ? 1 : 0); - _D("LCD always on is %d", c->lcd_always_on); - } else if (MATCH(result->name, "Dimming")) { - c->dimming = (MATCH(result->value, "yes") ? 1 : 0); - _D("Dimming is %d", c->dimming); - } else if (MATCH(result->name, "ChangedFrameRateAllowed")) { - if (strstr(result->value, "setting")) { - c->framerate_app[REFRESH_SETTING] = 1; - _D("framerate app is Setting"); - } - if (strstr(result->value, "all")) { - memset(c->framerate_app, 1, sizeof(c->framerate_app)); - _D("framerate app is All"); - } - } else if (MATCH(result->name, "ControlDisplay")) { - c->control_display = (MATCH(result->value, "yes") ? 1 : 0); - _D("ControlDisplay is %d", c->control_display); - } else if (MATCH(result->name, "PowerKeyDoublePressSupport")) { - c->powerkey_doublepress = (MATCH(result->value, "yes") ? 1 : 0); - _D("PowerKeyDoublePressSupport is %d", c->powerkey_doublepress); - } else if (MATCH(result->name, "AccelSensorOn")) { - c->accel_sensor_on = (MATCH(result->value, "yes") ? 1 : 0); - _D("AccelSensorOn is %d", c->accel_sensor_on); - } else if (MATCH(result->name, "ContinuousSampling")) { - c->continuous_sampling = (MATCH(result->value, "yes") ? 1 : 0); - _D("ContinuousSampling is %d", c->continuous_sampling); - } else if (MATCH(result->name, "TimeoutEnable")) { - c->timeout_enable = (MATCH(result->value, "yes") ? true : false); - _D("Timeout is %s", c->timeout_enable ? "enalbed" : "disabled"); - } else if (MATCH(result->name, "InputSupport")) { - c->input_support = (MATCH(result->value, "yes") ? true : false); - _D("Input is %s", c->input_support ? "supported" : "NOT supported"); - } else if (MATCH(result->name, "LockCheckTimeout")) { - SET_CONF(c->lockcheck_timeout, atoi(result->value)); - _D("LockCheckTimeout is %d", c->lockcheck_timeout); - } else if (MATCH(result->name, "AODTSP")) { - c->aod_tsp = (MATCH(result->value, "yes") ? true : false); - _D("TSP control at is %d at aod", c->aod_tsp); - } else if (MATCH(result->name, "SleepSupport")) { - c->sleep_support = (MATCH(result->value, "yes") ? true : false); - _D("SleepSupport is %d", c->sleep_support); - } - - return 0; -} - static int powerlock_load_config(struct parse_result *result, void *user_data) { char *name = NULL; diff --git a/src/display/display.c b/src/display/display.c index e4de7d3..7ee2523 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -22,8 +22,10 @@ #include "util.h" #include "core.h" #include "display-ops.h" +#include "dd-display.h" #include "core/list.h" #include "core/common.h" +#include "core/config-parser.h" static int pm_cur_state; static int pm_old_state; @@ -84,3 +86,76 @@ void lcd_direct_control(enum dpms_state state, int flags) } } +int display_load_config(struct parse_result *result, void *user_data) +{ + struct display_config *c = user_data; + + _D("display_load_config: section=%s name=%s value=%s", result->section, result->name, result->value); + + if (!c) + return -EINVAL; + + if (!MATCH(result->section, "Display")) + return 0; + + if (MATCH(result->name, "LockScreenWaitingTime")) { + SET_CONF(c->lock_wait_time, atof(result->value)); + _D("lock wait time is %.3f", c->lock_wait_time); + } else if (MATCH(result->name, "LongPressInterval")) { + SET_CONF(c->longpress_interval, atof(result->value)); + _D("long press interval is %.3f", c->longpress_interval); + } else if (MATCH(result->name, "LightSensorSamplingInterval")) { + SET_CONF(c->lightsensor_interval, atof(result->value)); + _D("lightsensor interval is %.3f", c->lightsensor_interval); + } else if (MATCH(result->name, "LCDOffTimeout")) { + SET_CONF(c->lcdoff_timeout, atoi(result->value)); + _D("lcdoff timeout is %d ms", c->lcdoff_timeout); + } else if (MATCH(result->name, "BrightnessChangeStep")) { + SET_CONF(c->brightness_change_step, atoi(result->value)); + _D("brightness change step is %d", c->brightness_change_step); + } else if (MATCH(result->name, "LCDAlwaysOn")) { + c->lcd_always_on = (MATCH(result->value, "yes") ? 1 : 0); + _D("LCD always on is %d", c->lcd_always_on); + } else if (MATCH(result->name, "Dimming")) { + c->dimming = (MATCH(result->value, "yes") ? 1 : 0); + _D("Dimming is %d", c->dimming); + } else if (MATCH(result->name, "ChangedFrameRateAllowed")) { + if (strstr(result->value, "setting")) { + c->framerate_app[REFRESH_SETTING] = 1; + _D("framerate app is Setting"); + } + if (strstr(result->value, "all")) { + memset(c->framerate_app, 1, sizeof(c->framerate_app)); + _D("framerate app is All"); + } + } else if (MATCH(result->name, "ControlDisplay")) { + c->control_display = (MATCH(result->value, "yes") ? 1 : 0); + _D("ControlDisplay is %d", c->control_display); + } else if (MATCH(result->name, "PowerKeyDoublePressSupport")) { + c->powerkey_doublepress = (MATCH(result->value, "yes") ? 1 : 0); + _D("PowerKeyDoublePressSupport is %d", c->powerkey_doublepress); + } else if (MATCH(result->name, "AccelSensorOn")) { + c->accel_sensor_on = (MATCH(result->value, "yes") ? 1 : 0); + _D("AccelSensorOn is %d", c->accel_sensor_on); + } else if (MATCH(result->name, "ContinuousSampling")) { + c->continuous_sampling = (MATCH(result->value, "yes") ? 1 : 0); + _D("ContinuousSampling is %d", c->continuous_sampling); + } else if (MATCH(result->name, "TimeoutEnable")) { + c->timeout_enable = (MATCH(result->value, "yes") ? true : false); + _D("Timeout is %s", c->timeout_enable ? "enalbed" : "disabled"); + } else if (MATCH(result->name, "InputSupport")) { + c->input_support = (MATCH(result->value, "yes") ? true : false); + _D("Input is %s", c->input_support ? "supported" : "NOT supported"); + } else if (MATCH(result->name, "LockCheckTimeout")) { + SET_CONF(c->lockcheck_timeout, atoi(result->value)); + _D("LockCheckTimeout is %d", c->lockcheck_timeout); + } else if (MATCH(result->name, "AODTSP")) { + c->aod_tsp = (MATCH(result->value, "yes") ? true : false); + _D("TSP control at is %d at aod", c->aod_tsp); + } else if (MATCH(result->name, "SleepSupport")) { + c->sleep_support = (MATCH(result->value, "yes") ? true : false); + _D("SleepSupport is %d", c->sleep_support); + } + + return 0; +} diff --git a/src/display/display.h b/src/display/display.h index 4acb2ea..c87c06e 100644 --- a/src/display/display.h +++ b/src/display/display.h @@ -21,6 +21,7 @@ #define __DISPLAY_H__ #include "device-interface.h" +#include "core/config-parser.h" void lcd_direct_control(enum dpms_state state, int flags); int get_pm_cur_state(void); @@ -30,6 +31,7 @@ void set_pm_old_state(int old_state); unsigned int get_pm_status_flag(void); void set_pm_status_flag(unsigned int status_flag); void clear_pm_status_flag(unsigned int status_flag); +int display_load_config(struct parse_result *result, void *user_data); enum brightness_request_e { BR_MIN = 0, -- 2.7.4 From e94b9e4520e5c1a16b8d9a8424a1014cfabb5e49 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Fri, 4 Sep 2020 11:57:18 +0900 Subject: [PATCH 07/16] Get battery status from battery plugin. - When battery_module option is off, there is link error about undefined function. - Change battery reference to battery plugin same as display. Change-Id: I75924fd15f81e2485463f0d3eca3f8e798ecaec6 Signed-off-by: Yunmi Ha --- plugins/mobile/battery/battery-notification.c | 2 +- plugins/wearable/battery/battery-notification.c | 2 +- plugins/wearable/display/device-interface.c | 2 +- src/battery/battery-time.c | 2 +- src/battery/lowbat-handler.c | 2 +- src/battery/power-supply.c | 2 +- src/battery/power-supply.h | 2 +- src/touchscreen/touchscreen.c | 39 ++++++++++++++++++------- 8 files changed, 35 insertions(+), 18 deletions(-) diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c index c3fe9f1..11cd6d7 100644 --- a/plugins/mobile/battery/battery-notification.c +++ b/plugins/mobile/battery/battery-notification.c @@ -414,7 +414,7 @@ static void __CONSTRUCTOR__ initialize(void) if (!disp_plgn) _E("Failed to get display plugin."); - battery = get_battery_status(); + battery = get_var_battery_status(); if (!battery) _E("Failed to get battery status structure."); } diff --git a/plugins/wearable/battery/battery-notification.c b/plugins/wearable/battery/battery-notification.c index 0d8e1e0..84ad217 100644 --- a/plugins/wearable/battery/battery-notification.c +++ b/plugins/wearable/battery/battery-notification.c @@ -102,7 +102,7 @@ BATTERY_OPS_REGISTER(&battery_notification_ops) static void __CONSTRUCTOR__ initialize(void) { - battery = get_battery_status(); + battery = get_var_battery_status(); if (!battery) _E("Failed to get battery status structure."); } diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 83dcb2c..c803437 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -647,7 +647,7 @@ static int backlight_transit_state(int state) int brt, val; int start, end; static int aod_brightness_level; - struct battery_status *battery = get_battery_status(); + struct battery_status *battery = get_var_battery_status(); if (!battery) { _E("Failed to get battery status structure."); return -EINVAL; diff --git a/src/battery/battery-time.c b/src/battery/battery-time.c index f557448..eb61816 100644 --- a/src/battery/battery-time.c +++ b/src/battery/battery-time.c @@ -265,7 +265,7 @@ static int battinfo_calculation(void) int tmp = 0; struct battery_status *battery; - battery = get_battery_status(); + battery = get_var_battery_status(); if (!battery) { _E("Failed to get battery status structure."); return -EINVAL; diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index c25523c..e0829b4 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -788,7 +788,7 @@ static void __CONSTRUCTOR__ initialize(void) if (!battery_plgn) _E("Failed to get battery plugin."); - battery = get_battery_status(); + battery = get_var_battery_status(); if (!battery) _E("Failed to get battery status structure."); } diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index c7e3203..06b2ed7 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -113,7 +113,7 @@ static struct battery_device *battery_dev; static int load_uevent(struct parse_result *result, void *user_data); static int event_handler_state_changed(void *data); -inline struct battery_status *get_battery_status() +inline struct battery_status *get_var_battery_status(void) { return &battery; } diff --git a/src/battery/power-supply.h b/src/battery/power-supply.h index ebc050b..84c459c 100644 --- a/src/battery/power-supply.h +++ b/src/battery/power-supply.h @@ -118,7 +118,7 @@ struct battery_status { char power_source_s[32]; }; -struct battery_status *get_battery_status(); +struct battery_status *get_var_battery_status(void); extern struct battery_status old_battery; extern bool battery_initialized; diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index 44ad171..b592bad 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -38,6 +38,7 @@ enum ps_mode { }; static struct display_plugin *disp_plgn; +static struct battery_plugin *battery_plgn; static struct touchscreen_device *touchscreen_dev; static int touchscreen_enable = DEVICE_OPS_STATUS_START; static int powersaving_support = true; @@ -49,9 +50,11 @@ static int booting_done(void *data); static struct display_config *_display_conf; static struct _backlight_ops *_backlight_ops; +static struct battery_status *battery = NULL; -static struct _backlight_ops* (*_get_backlight_ops)(void); -static struct display_config* (*_get_display_config)(void); +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 void touchscreen_wakeup_status(keynode_t *key, void *data) { @@ -213,9 +216,7 @@ static int touchscreen_start(enum device_flags flags) static int touchscreen_stop(enum device_flags flags) { - struct battery_status *battery = get_battery_status(); - - if (!_display_conf || !_backlight_ops || !battery) { + if (!_display_conf || !_backlight_ops) { _I("Touchscreen is not initialized."); goto exit; } @@ -319,9 +320,9 @@ static void touchscreen_init(void *data) { int ret, val; - _get_display_config = dlsym(disp_plgn->handle, "get_display_config"); - if (_get_display_config) { - _display_conf = _get_display_config(); + _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."); } else @@ -331,14 +332,25 @@ static void touchscreen_init(void *data) * So it fails that fetching symbol directly with name 'backlight_ops'. * To avoid this, fetches getter function 'get_backlight_ops' instead, and * retrieve the 'backlight_ops' by using it */ - _get_backlight_ops = dlsym(disp_plgn->handle, "get_backlight_ops"); - if (_get_backlight_ops) { - _backlight_ops = _get_backlight_ops(); + _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."); } else _E("Failed to obtain address of get_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(); + 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."); + if (touchscreen_dev && touchscreen_dev->set_powersaving) { ret = touchscreen_dev->set_powersaving(0); if (ret < 0) @@ -383,4 +395,9 @@ static void __CONSTRUCTOR__ initialize(void) if (!disp_plgn) { _E("Failed to get display plugin."); } + + battery_plgn = get_battery_plugin(); + if (!battery_plgn) { + _E("Failed to get battery plugin."); + } } -- 2.7.4 From 7fed44c306a8b81560694e64286c756db3110b2a Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 10 Sep 2020 13:36:35 +0900 Subject: [PATCH 08/16] Update warning_id when registering lockcheck timer Segfault occurs when the lock node had been deleted during FORCE_RELEASE_LOCK_INTERVAL and accessed by lockcheck timer callback. Change-Id: I8defd4fa15a3276588286ef6ae7811d34433241b Signed-off-by: Youngjae Cho (cherry picked from commit dd12492f83aa2a72e1f580569b81c594e72e042c) --- plugins/wearable/display/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 33907f1..6ba132b 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -429,7 +429,7 @@ static gboolean pmlock_terminate_daemon_to_release_lock(gpointer data) *pname ? pname : "Unknown", pid, errno); node->force_release = true; - g_timeout_add_seconds(FORCE_RELEASE_LOCK_INTERVAL, + node->warning_id = g_timeout_add_seconds(FORCE_RELEASE_LOCK_INTERVAL, pmlock_terminate_daemon_to_release_lock, (gpointer)node); } else if (node->force_release == true) { /* kill confirmation */ -- 2.7.4 From d2ec47c434e5dfe9433358ef11e34eeed859583d Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 10 Sep 2020 16:14:30 +0900 Subject: [PATCH 09/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 10/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 11/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 12/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 13/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 14/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 15/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 16/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