From 42e274e13e70d96b2645939bca83a29c7e0226bb Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Wed, 24 Apr 2019 18:56:03 +0900 Subject: [PATCH 01/16] Remove power off related code in lowbat_popup power off by low battery is executed without popup. So, power off related code in lowbat_popup is useless. Change-Id: Ia2443aa3ea8e2a3b964286c085234921cb1cd0b4 Signed-off-by: lokilee73 --- src/battery/battery.h | 1 - src/battery/lowbat-handler.c | 18 ------------------ 2 files changed, 19 deletions(-) diff --git a/src/battery/battery.h b/src/battery/battery.h index 0b0f7b8..5c38207 100644 --- a/src/battery/battery.h +++ b/src/battery/battery.h @@ -26,7 +26,6 @@ #define BATTERY_LEVEL_CHECK_CRITICAL 1 #define LOWBAT_OPT_WARNING 1 -#define LOWBAT_OPT_POWEROFF 2 #define LOWBAT_OPT_CHARGEERR 3 #define LOWBAT_OPT_CHECK 4 diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 1d8cfa1..9f37f39 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -55,7 +55,6 @@ #define WARNING_LOW_BAT_ACT "warning_low_bat_act" #define CRITICAL_LOW_BAT_ACT "critical_low_bat_act" -#define POWER_OFF_BAT_ACT "power_off_bat_act" #define CHARGE_BAT_ACT "charge_bat_act" #define CHARGE_CHECK_ACT "charge_check_act" #define CHARGE_ERROR_ACT "charge_error_act" @@ -300,7 +299,6 @@ out: int lowbat_popup(char *option) { - static int launched_poweroff; static int lowbat_popup_option; int ret; int power_source = 1; @@ -316,18 +314,12 @@ int lowbat_popup(char *option) goto direct_launch; } - if (strcmp(option, POWER_OFF_BAT_ACT)) - launched_poweroff = 0; - if (!strcmp(option, WARNING_LOW_BAT_ACT)) { power_source = get_lowbat_noti_value(LOW_BATTERY, &active_noti, &event_noti); lowbat_popup_option = LOWBAT_OPT_CHECK; } else if (!strcmp(option, CRITICAL_LOW_BAT_ACT)) { power_source = get_lowbat_noti_value(CRITICAL_BATTERY, &active_noti, &event_noti); lowbat_popup_option = LOWBAT_OPT_WARNING; - } else if (!strcmp(option, POWER_OFF_BAT_ACT)) { - value = "poweroff"; - lowbat_popup_option = LOWBAT_OPT_POWEROFF; } else if (!strcmp(option, CHARGE_ERROR_ACT)) { value = "chargeerr"; lowbat_popup_option = LOWBAT_OPT_CHARGEERR; @@ -346,21 +338,11 @@ int lowbat_popup(char *option) direct_launch: _D("Popup value=%s", value); if (booting_done(NULL)) { - - if (launched_poweroff == 1) { - _I("Will be foreced power off."); - power_execute(POWER_POWEROFF); - return 0; - } - if (battery.charge_now) { _I("Skip low battery popup during charging."); return 0; } - if (lowbat_popup_option == LOWBAT_OPT_POWEROFF) - launched_poweroff = 1; - r_disturb = vconf_get_int("memory/shealth/sleep/do_not_disturb", &s_disturb); if (r_disturb < 0) _E("Failed to get vconf value for do not disturb: %d", vconf_get_ext_errno()); -- 2.7.4 From 6b1f9e092a2312710df0a129a251168b3cd6ee3e Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Fri, 26 Apr 2019 14:34:05 +0900 Subject: [PATCH 02/16] Fix misused function of g_timeout_add_seconds Input value of g_timeout_add_seconds() should be integer. But the input is float in some cases. So, change g_timeout_add_seconds to g_timeout_add on this cases. Change-Id: I95b843b46e13c078398f39bac374f7faa5d03917 Signed-off-by: lokilee73 --- plugins/iot/display/auto-brightness.c | 4 ++-- plugins/iot/display/core.c | 4 ++-- plugins/mobile/display/auto-brightness.c | 4 ++-- plugins/mobile/display/core.c | 4 ++-- plugins/tv/display/auto-brightness.c | 4 ++-- plugins/tv/display/core.c | 4 ++-- plugins/wearable/display/auto-brightness.c | 4 ++-- plugins/wearable/display/core.c | 4 ++-- src/led/touch-key.c | 14 +++++++++----- 9 files changed, 25 insertions(+), 21 deletions(-) mode change 100755 => 100644 plugins/iot/display/auto-brightness.c mode change 100755 => 100644 plugins/iot/display/core.c mode change 100755 => 100644 plugins/mobile/display/auto-brightness.c mode change 100755 => 100644 plugins/mobile/display/core.c mode change 100755 => 100644 plugins/tv/display/auto-brightness.c mode change 100755 => 100644 plugins/tv/display/core.c mode change 100755 => 100644 plugins/wearable/display/auto-brightness.c mode change 100755 => 100644 plugins/wearable/display/core.c diff --git a/plugins/iot/display/auto-brightness.c b/plugins/iot/display/auto-brightness.c old mode 100755 new mode 100644 index d49c463..88ff66a --- a/plugins/iot/display/auto-brightness.c +++ b/plugins/iot/display/auto-brightness.c @@ -47,7 +47,7 @@ #define MAX_FAULT 5 #define DEFAULT_AUTOMATIC_BRT 5 #define AUTOMATIC_DEVIDE_VAL 10 -#define AUTOMATIC_DELAY_TIME 0.5 /* 0.5 sec */ +#define AUTOMATIC_DELAY_TIME 500 /* 0.5 sec */ #define RADIAN_VALUE (57.2957) #define ROTATION_90 90 @@ -513,7 +513,7 @@ static void update_auto_brightness(bool update) } if (update) { - update_timeout = g_timeout_add_seconds(AUTOMATIC_DELAY_TIME, + update_timeout = g_timeout_add(AUTOMATIC_DELAY_TIME, update_handler, NULL); } } diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c old mode 100755 new mode 100644 index dcddfc6..6333b08 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -174,7 +174,7 @@ static const char *lcdoff_sig_lookup[SIGNAL_MAX] = { #define ACTIVE_ACT "active" #define INACTIVE_ACT "inactive" -#define LOCK_SCREEN_WATING_TIME 0.3 /* 0.3 second */ +#define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ #define LONG_PRESS_INTERVAL 2 /* 2 seconds */ #define SAMPLING_INTERVAL 1 /* 1 sec */ #define BRIGHTNESS_CHANGE_STEP 10 @@ -1498,7 +1498,7 @@ static void check_lock_screen(void) } /* Use time to check lock is done. */ - lock_timeout_id = g_timeout_add_seconds(display_conf.lock_wait_time, + lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, lcd_on_expired, NULL); return; diff --git a/plugins/mobile/display/auto-brightness.c b/plugins/mobile/display/auto-brightness.c old mode 100755 new mode 100644 index 73597f1..a9d4100 --- a/plugins/mobile/display/auto-brightness.c +++ b/plugins/mobile/display/auto-brightness.c @@ -47,7 +47,7 @@ #define MAX_FAULT 5 #define DEFAULT_AUTOMATIC_BRT 5 #define AUTOMATIC_DEVIDE_VAL 10 -#define AUTOMATIC_DELAY_TIME 0.5 /* 0.5 sec */ +#define AUTOMATIC_DELAY_TIME 500 /* 0.5 sec */ #define RADIAN_VALUE (57.2957) #define ROTATION_90 90 @@ -513,7 +513,7 @@ static void update_auto_brightness(bool update) } if (update) { - update_timeout = g_timeout_add_seconds(AUTOMATIC_DELAY_TIME, + update_timeout = g_timeout_add(AUTOMATIC_DELAY_TIME, update_handler, NULL); } } diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c old mode 100755 new mode 100644 index dcddfc6..6333b08 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -174,7 +174,7 @@ static const char *lcdoff_sig_lookup[SIGNAL_MAX] = { #define ACTIVE_ACT "active" #define INACTIVE_ACT "inactive" -#define LOCK_SCREEN_WATING_TIME 0.3 /* 0.3 second */ +#define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ #define LONG_PRESS_INTERVAL 2 /* 2 seconds */ #define SAMPLING_INTERVAL 1 /* 1 sec */ #define BRIGHTNESS_CHANGE_STEP 10 @@ -1498,7 +1498,7 @@ static void check_lock_screen(void) } /* Use time to check lock is done. */ - lock_timeout_id = g_timeout_add_seconds(display_conf.lock_wait_time, + lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, lcd_on_expired, NULL); return; diff --git a/plugins/tv/display/auto-brightness.c b/plugins/tv/display/auto-brightness.c old mode 100755 new mode 100644 index c32306f..ed957cd --- a/plugins/tv/display/auto-brightness.c +++ b/plugins/tv/display/auto-brightness.c @@ -47,7 +47,7 @@ #define MAX_FAULT 5 #define DEFAULT_AUTOMATIC_BRT 5 #define AUTOMATIC_DEVIDE_VAL 10 -#define AUTOMATIC_DELAY_TIME 0.5 /* 0.5 sec */ +#define AUTOMATIC_DELAY_TIME 500 /* 0.5 sec */ #define RADIAN_VALUE (57.2957) #define ROTATION_90 90 @@ -513,7 +513,7 @@ static void update_auto_brightness(bool update) } if (update) { - update_timeout = g_timeout_add_seconds(AUTOMATIC_DELAY_TIME, + update_timeout = g_timeout_add(AUTOMATIC_DELAY_TIME, update_handler, NULL); } } diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c old mode 100755 new mode 100644 index 869b398..4a6d3ce --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -176,7 +176,7 @@ static const char *lcdoff_sig_lookup[SIGNAL_MAX] = { #define ACTIVE_ACT "active" #define INACTIVE_ACT "inactive" -#define LOCK_SCREEN_WATING_TIME 0.3 /* 0.3 second */ +#define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ #define LONG_PRESS_INTERVAL 2 /* 2 seconds */ #define SAMPLING_INTERVAL 1 /* 1 sec */ #define BRIGHTNESS_CHANGE_STEP 10 @@ -1499,7 +1499,7 @@ static void check_lock_screen(void) } /* Use time to check lock is done. */ - lock_timeout_id = g_timeout_add_seconds(display_conf.lock_wait_time, + lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, lcd_on_expired, NULL); return; diff --git a/plugins/wearable/display/auto-brightness.c b/plugins/wearable/display/auto-brightness.c old mode 100755 new mode 100644 index d85fd8c..efc415c --- a/plugins/wearable/display/auto-brightness.c +++ b/plugins/wearable/display/auto-brightness.c @@ -47,7 +47,7 @@ #define MAX_FAULT 5 #define DEFAULT_AUTOMATIC_BRT 5 #define AUTOMATIC_DEVIDE_VAL 10 -#define AUTOMATIC_DELAY_TIME 0.5 /* 0.5 sec */ +#define AUTOMATIC_DELAY_TIME 500 /* 0.5 sec */ #define RADIAN_VALUE (57.2957) #define ROTATION_90 90 @@ -513,7 +513,7 @@ static void update_auto_brightness(bool update) } if (update) { - update_timeout = g_timeout_add_seconds(AUTOMATIC_DELAY_TIME, + update_timeout = g_timeout_add(AUTOMATIC_DELAY_TIME, update_handler, NULL); } } diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c old mode 100755 new mode 100644 index c446ac8..211ea08 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -174,7 +174,7 @@ static const char *lcdoff_sig_lookup[SIGNAL_MAX] = { #define ACTIVE_ACT "active" #define INACTIVE_ACT "inactive" -#define LOCK_SCREEN_WATING_TIME 0.3 /* 0.3 second */ +#define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ #define LONG_PRESS_INTERVAL 2 /* 2 seconds */ #define SAMPLING_INTERVAL 1 /* 1 sec */ #define BRIGHTNESS_CHANGE_STEP 10 @@ -1497,7 +1497,7 @@ static void check_lock_screen(void) } /* Use time to check lock is done. */ - lock_timeout_id = g_timeout_add_seconds(display_conf.lock_wait_time, + lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, lcd_on_expired, NULL); return; diff --git a/src/led/touch-key.c b/src/led/touch-key.c index 7b18984..2852ac2 100644 --- a/src/led/touch-key.c +++ b/src/led/touch-key.c @@ -102,6 +102,7 @@ static void process_touchkey_press(void) static void process_touchkey_release(void) { float fduration; + int duration; /* release existing timer */ if (hardkey_timeout_id > 0) { @@ -114,8 +115,9 @@ static void process_touchkey_release(void) return; /* start timer */ fduration = (float)hardkey_duration / KEYBACKLIGHT_BASE_TIME; - hardkey_timeout_id = g_timeout_add_seconds( - fduration, + duration = (int)(fduration * 1000); + hardkey_timeout_id = g_timeout_add( + duration, key_backlight_expired, NULL); } @@ -156,7 +158,8 @@ static void process_touchkey_enable(bool enable) static void hardkey_duration_cb(keynode_t *key, void *data) { - float duration; + float fduration; + int duration; hardkey_duration = vconf_keynode_get_int(key); @@ -181,8 +184,9 @@ static void hardkey_duration_cb(keynode_t *key, void *data) return; /* start timer */ - duration = (float)hardkey_duration / KEYBACKLIGHT_BASE_TIME; - hardkey_timeout_id = g_timeout_add_seconds( + fduration = (float)hardkey_duration / KEYBACKLIGHT_BASE_TIME; + duration = (int)(fduration * 1000); + hardkey_timeout_id = g_timeout_add( duration, key_backlight_expired, NULL); } -- 2.7.4 From 931a972438a6099c98d012c46997001d60ef8a69 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 29 Apr 2019 15:40:27 +0900 Subject: [PATCH 03/16] Modify check_power_supply_noti to refer to blockmode_wearable only Below vconf is not used anymore. ex) memory/shealth/sleep/do_not_disturb So, change check_power_supply_noti to refer to db/setting/blockmode_wearable only. Basically, battery full notification policy is different according to profiles. - Wearable : refers to vconf value called blockmode_wearable ex) db/setting/blockmode_wearable if it's true, notification is blocked, false, notification is allowed. - iot, tv : don't care - mobile : not decided yet, so apply default value as tv and iot We can keep the policy by setting default value of blockmode_wearable to false. It can be changed via setting menu. And Setting menu for blockmode_wearable is only available on wearable profile. Change-Id: I981a31e70cba59ccd544f6fce8a784de601f339d Signed-off-by: lokilee73 --- src/battery/power-supply.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 2ab1914..5c55ecf 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -60,7 +60,7 @@ #define METHOD_CHARGE_NOTI_ON "BatteryChargeNotiOn" #define RETRY_MAX 5 -#define BATTERY_CHECK_TIMER_INTERVAL (0.5) +#define BATTERY_CHECK_TIMER_INTERVAL 500 /* 0.5 second */ enum power_supply_init_type { POWER_SUPPLY_NOT_READY = 0, @@ -209,24 +209,16 @@ out: static int check_power_supply_noti(void) { -#ifdef MICRO_DD - int r_disturb, s_disturb, r_block, s_block; - r_disturb = vconf_get_int("memory/shealth/sleep/do_not_disturb", &s_disturb); - r_block = vconf_get_bool("db/setting/blockmode_wearable", &s_block); - - if (r_disturb < 0) - _E("Failed to get vconf value for do not disturb: %d", vconf_get_ext_errno()); - if (r_block < 0) - _E("Failed to get vconf value for blockmode wearable: %d", vconf_get_ext_errno()); + int block, ret; - if ((r_disturb != 0 && r_block != 0) || - (s_disturb == 0 && s_block == 0)) { - return 1; + ret = vconf_get_bool("db/setting/blockmode_wearable", &block); + if (ret < 0) { + _E("Failed to get vconf value for blockmode wearable: %d", vconf_get_ext_errno()); + return 1; } + if (block == 0) + return 1; return 0; -#else - return 1; -#endif } static int send_full_noti(enum charge_full_type state) @@ -849,7 +841,7 @@ static gboolean power_supply_update(void *data) static void power_supply_timer_start(void) { _D("Battery init timer during booting."); - power_timer = g_timeout_add_seconds(BATTERY_CHECK_TIMER_INTERVAL, + power_timer = g_timeout_add(BATTERY_CHECK_TIMER_INTERVAL, power_supply_update, NULL); if (power_timer == 0) _E("Failed to add battery init timer during booting."); -- 2.7.4 From bd62d7bfa6d8eeff44ae30abf6a6afce276a9900 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 29 Apr 2019 20:01:54 +0900 Subject: [PATCH 04/16] Unify ovp_type and temp_type to health_type and add temperature in battery_status 1. Ovp_type and temp type is a kind of battery health_type. So, unify ovp_type and temp_type to health_type 2. Remove temp in battery_status. Because it is unified to health_type. Instead, add temperature for value in celsius. Change-Id: Ie595c4154530f7a187de7d25481562689170764e Signed-off-by: lokilee73 --- src/battery/power-supply.c | 74 +++++++++++++++++++--------------------------- src/battery/power-supply.h | 22 +++++--------- 2 files changed, 39 insertions(+), 57 deletions(-) diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 5c55ecf..9cede4f 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -45,6 +45,7 @@ #define OVERHEAT_NAME "Overheat" #define TEMPCOLD_NAME "Cold" #define OVERVOLT_NAME "Over voltage" +#define GOOD_NAME "Good" #define REMOVE_POPUP "remove_battery_popups" @@ -134,7 +135,7 @@ static void health_timer_reset(void) static gboolean health_timer_cb(void *data) { - int value = HEALTH_BAD; + int value = HEALTH_DEAD; health_timer_reset(); @@ -147,9 +148,9 @@ static gboolean health_timer_cb(void *data) disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); if (disp_plgn.pm_lock_internal) disp_plgn.pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); - if (battery.temp == TEMP_LOW) + if (battery.health == HEALTH_LOW) battery_charge_err_low_act(NULL); - else if (battery.temp == TEMP_HIGH) + else if (battery.health == HEALTH_HIGH) battery_charge_err_high_act(NULL); return G_SOURCE_REMOVE; } @@ -464,9 +465,9 @@ static void update_health(enum battery_noti_status status) if (disp_plgn.pm_lock_internal) disp_plgn.pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); - if (battery.temp == TEMP_LOW) + if (battery.health == HEALTH_LOW) battery_charge_err_low_act(NULL); - else if (battery.temp == TEMP_HIGH) + else if (battery.health == HEALTH_HIGH) battery_charge_err_high_act(NULL); } else { if (disp_plgn.pm_unlock_internal) @@ -484,14 +485,14 @@ static void update_ovp(enum battery_noti_status status) if (old == status) return; - _I("charge=%d ovp=%d", battery.charge_now, battery.ovp); + _I("charge=%d ovp=%d", battery.charge_now, battery.health); old = status; if (disp_plgn.pm_change_internal) disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); if (status == DEVICE_NOTI_ON) - value = OVP_ABNORMAL; + value = HEALTH_OVP; else - value = OVP_NORMAL; + value = HEALTH_GOOD; device_notify(DEVICE_NOTIFIER_BATTERY_OVP, (void *)&value); } @@ -501,9 +502,9 @@ static void check_battery_status(void) int status; if (battery.charge_now == CHARGER_ABNORMAL && - (battery.health == HEALTH_BAD || battery.present == PRESENT_ABNORMAL)) + (battery.health == HEALTH_DEAD || battery.present == PRESENT_ABNORMAL)) status = DEVICE_CHANGE_ABNORMAL; - else if (battery.ovp == OVP_ABNORMAL) + else if (battery.health == HEALTH_OVP) status = DEVICE_CHANGE_ABNORMAL; else status = DEVICE_CHANGE_NORMAL; @@ -512,7 +513,7 @@ static void check_battery_status(void) old = status; if (battery.charge_now == CHARGER_ABNORMAL) { - if (battery.health == HEALTH_BAD) { + if (battery.health == HEALTH_DEAD) { device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health); #ifdef TIZEN_FEATURE_BATTERY_OVER_TEMPERATURE update_health(DEVICE_NOTI_ON); @@ -523,7 +524,7 @@ static void check_battery_status(void) return; } } - if (battery.ovp == OVP_ABNORMAL) { + if (battery.health == HEALTH_OVP) { update_ovp(DEVICE_NOTI_ON); return; } @@ -627,30 +628,22 @@ static void check_health_status(const char *env_value) { if (env_value == NULL) { battery.health = HEALTH_GOOD; - battery.temp = TEMP_LOW; - battery.ovp = OVP_NORMAL; return; } if (strncmp(env_value, OVERHEAT_NAME, - sizeof(OVERHEAT_NAME)) == 0) { - battery.health = HEALTH_BAD; - battery.temp = TEMP_HIGH; - battery.ovp = OVP_NORMAL; - } else if (strncmp(env_value, TEMPCOLD_NAME, - sizeof(TEMPCOLD_NAME)) == 0) { - battery.health = HEALTH_BAD; - battery.temp = TEMP_LOW; - battery.ovp = OVP_NORMAL; - } else if (strncmp(env_value, OVERVOLT_NAME, - sizeof(OVERVOLT_NAME)) == 0) { + sizeof(OVERHEAT_NAME)) == 0) + battery.health = HEALTH_HIGH; + else if (strncmp(env_value, TEMPCOLD_NAME, + sizeof(TEMPCOLD_NAME)) == 0) + battery.health = HEALTH_LOW; + else if (strncmp(env_value, OVERVOLT_NAME, + sizeof(OVERVOLT_NAME)) == 0) + battery.health = HEALTH_OVP; + else if (strncmp(env_value, GOOD_NAME, + sizeof(GOOD_NAME)) == 0) battery.health = HEALTH_GOOD; - battery.temp = TEMP_LOW; - battery.ovp = OVP_ABNORMAL; - } else { - battery.health = HEALTH_GOOD; - battery.temp = TEMP_LOW; - battery.ovp = OVP_NORMAL; - } + else + battery.health = HEALTH_NO_OPT; } static void check_online_status(const char *env_value) @@ -710,7 +703,7 @@ static void battery_state(struct battery_info *info) if (!info) return; - _I("status=%s(%s) power_source=%s(%d) capa=%d health=%s(%s) present=%d OVP=%s current=%d(%d) volt=%d(%d) temp=%d", + _I("status=%s(%s) power_source=%s(%d) capa=%d health=%s present=%d current=%d(%d) volt=%d(%d) temp=%d", info->status, battery.charge_now == CHARGER_CHARGING ? "Charging" : (battery.charge_now == CHARGER_DISCHARGING ? "Discharging" : "Abnormal"), @@ -718,9 +711,7 @@ static void battery_state(struct battery_info *info) info->online, info->capacity, info->health, - battery.temp == TEMP_LOW ? "Low" : "High", info->present, - battery.ovp == OVP_NORMAL ? "X" : "O", info->current_now, info->current_average, info->voltage_now, @@ -762,7 +753,7 @@ static void battery_changed(struct battery_info *info, void *data) battery.current_average = info->current_average; battery.voltage_now = info->voltage_now; battery.voltage_average = info->voltage_average; - battery.temp = info->temperature; + battery.temperature = info->temperature; battery_state(info); @@ -803,9 +794,7 @@ static void power_supply_status_init(void) battery.capacity = pct; battery.health = HEALTH_GOOD; - battery.ovp = OVP_NORMAL; battery.present = PRESENT_NORMAL; - battery.temp = TEMP_LOW; if (charge_now == battery.charge_now && charge_full == battery.charge_full && @@ -975,15 +964,14 @@ static GVariant *dbus_power_supply_handler(GDBusConnection *conn, check_health_status(argv[2]); check_online_status(argv[3]); check_present_status(argv[4]); - _I("capa=%d full=%d now=%d health=%d online=%d ovp=%d present=%d temp=%d", + _I("capa=%d full=%d now=%d health=%d online=%d present=%d temp=%d", battery.capacity, battery.charge_full, battery.charge_now, battery.health, battery.online, - battery.ovp, battery.present, - battery.temp); + battery.temperature); if (battery.online > POWER_SUPPLY_TYPE_BATTERY) power_supply_noti(DEVICE_NOTI_BATT_CHARGE, DEVICE_NOTI_ON); @@ -1049,7 +1037,7 @@ static GVariant *dbus_get_battery_info(GDBusConnection *conn, battery.current_average, battery.voltage_now, battery.voltage_average, - battery.temp); + battery.temperature); } static const dbus_method_s dbus_methods[] = { @@ -1097,7 +1085,7 @@ static int display_changed(void *data) { if (battery.charge_now != CHARGER_ABNORMAL) return 0; - if (battery.health != HEALTH_BAD && battery.present != PRESENT_ABNORMAL) + if (battery.health != HEALTH_DEAD && battery.present != PRESENT_ABNORMAL) return 0; if (disp_plgn.pm_lock_internal) diff --git a/src/battery/power-supply.h b/src/battery/power-supply.h index 8ff0ae6..3f529ae 100644 --- a/src/battery/power-supply.h +++ b/src/battery/power-supply.h @@ -43,14 +43,14 @@ enum charge_now_type { CHARGER_DISCHARGING = 0, CHARGER_CHARGING = 1, }; -enum health_type { - HEALTH_BAD = 0, - HEALTH_GOOD = 1, -}; -enum temp_type { - TEMP_LOW = 0, - TEMP_HIGH = 1, +enum health_type { + HEALTH_NO_OPT = -1, + HEALTH_GOOD, + HEALTH_LOW, + HEALTH_DEAD, + HEALTH_HIGH, + HEALTH_OVP, }; enum present_type { @@ -58,11 +58,6 @@ enum present_type { PRESENT_NORMAL = 1, }; -enum ovp_type { - OVP_NORMAL = 0, - OVP_ABNORMAL = 1, -}; - enum battery_noti_type { DEVICE_NOTI_BATT_CHARGE = 0, DEVICE_NOTI_BATT_LOW, @@ -83,8 +78,7 @@ struct battery_status { int health; int present; int online; - int temp; - int ovp; + int temperature; int current_now; int current_average; int voltage_now; -- 2.7.4 From 683d4d2e2bd17719fc5bab0cd54eb2f6d4bf09b6 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 2 May 2019 14:18:09 +0900 Subject: [PATCH 05/16] Change condition to return and notifying input in health_timer_cb 1. Change condition to take actions in case of HEALTH_LOW and HEALTH_HIGH 2. Fix a bug to take over battery.health with an input instead of value Change-Id: Ia491a08e7184b60c788276a51dee0d1aa67aac80 Signed-off-by: lokilee73 --- src/battery/power-supply.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 9cede4f..67ddf6f 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -135,15 +135,13 @@ static void health_timer_reset(void) static gboolean health_timer_cb(void *data) { - int value = HEALTH_DEAD; - health_timer_reset(); - if (battery.health == HEALTH_GOOD) + if (battery.health != HEALTH_LOW && battery.health != HEALTH_HIGH) return G_SOURCE_REMOVE; _I("Popup: Battery health status is not good."); - device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&value); + device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health); if (disp_plgn.pm_change_internal) disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); if (disp_plgn.pm_lock_internal) -- 2.7.4 From e6210917f33b004e1cd5df8347266efe0892a6c3 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 2 May 2019 20:59:25 +0900 Subject: [PATCH 06/16] Add variable ret for dbus_handle_broadcast_dbus_signal_var eturned value of dbus_handle_broadcast_dbus_signal_var is integer. So, add ret to print error log when it fails. Change-Id: I6bc57894bed68fdeedc92a19a2de9e7b090e6874 Signed-off-by: lokilee73 --- plugins/iot/display/ambient-mode.c | 6 +++++- plugins/iot/display/core.c | 10 ++++++++-- plugins/mobile/display/ambient-mode.c | 6 +++++- plugins/mobile/display/core.c | 10 ++++++++-- plugins/tv/display/ambient-mode.c | 6 +++++- plugins/tv/display/core.c | 10 ++++++++-- plugins/tv/display/state-tv.c | 27 ++++++++++++++++++++++----- plugins/wearable/display/ambient-mode.c | 6 +++++- plugins/wearable/display/core.c | 10 ++++++++-- src/battery/battery-time.c | 6 +++++- src/extcon/cradle.c | 5 ++++- src/extcon/earjack.c | 5 ++++- src/extcon/hdmi.c | 5 ++++- src/led/torch.c | 6 +++++- src/power/power-handler.c | 5 ++++- src/usb/usb-dbus.c | 2 +- src/usbhost/usb-host.c | 5 ++++- 17 files changed, 105 insertions(+), 25 deletions(-) mode change 100755 => 100644 plugins/mobile/display/ambient-mode.c mode change 100755 => 100644 plugins/tv/display/ambient-mode.c mode change 100755 => 100644 plugins/wearable/display/ambient-mode.c diff --git a/plugins/iot/display/ambient-mode.c b/plugins/iot/display/ambient-mode.c index bc482f5..b15fd56 100644 --- a/plugins/iot/display/ambient-mode.c +++ b/plugins/iot/display/ambient-mode.c @@ -43,10 +43,14 @@ static unsigned int update_count; void broadcast_ambient_state(int state) { - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + int ret; + + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, SIGNAL_AMBIENT_MODE, g_variant_new("(i)", (state == 0 ? 0 : 1))); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_AMBIENT_MODE); } int ambient_get_condition(void) diff --git a/plugins/iot/display/core.c b/plugins/iot/display/core.c index 6333b08..7f26941 100644 --- a/plugins/iot/display/core.c +++ b/plugins/iot/display/core.c @@ -290,6 +290,7 @@ static void broadcast_lcd_on(enum signal_type type, enum device_flags flags) { const char *str; const char *signal; + int ret; if (type <= SIGNAL_INVALID || type >= SIGNAL_MAX) { _E("Invalid signal type(%d).", type); @@ -309,16 +310,19 @@ static void broadcast_lcd_on(enum signal_type type, enum device_flags flags) signal = lcdon_sig_lookup[type]; _I("lcdstep : Broadcast signal(%s:%s).", signal, str); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, signal, g_variant_new("(s)", str)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", signal); } static void broadcast_lcd_off(enum signal_type type, enum device_flags flags) { const char *str; const char *signal; + int ret; if (type <= SIGNAL_INVALID || type >= SIGNAL_MAX) { _E("Invalid signal type(%d).", type); @@ -337,10 +341,12 @@ static void broadcast_lcd_off(enum signal_type type, enum device_flags flags) str = UNKNOWN_STR; _I("lcdstep : Broadcast signal(%s).", signal); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, signal, g_variant_new("(s)", str)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", signal); } void broadcast_lcd_off_late(enum device_flags flags) diff --git a/plugins/mobile/display/ambient-mode.c b/plugins/mobile/display/ambient-mode.c old mode 100755 new mode 100644 index bc482f5..b15fd56 --- a/plugins/mobile/display/ambient-mode.c +++ b/plugins/mobile/display/ambient-mode.c @@ -43,10 +43,14 @@ static unsigned int update_count; void broadcast_ambient_state(int state) { - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + int ret; + + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, SIGNAL_AMBIENT_MODE, g_variant_new("(i)", (state == 0 ? 0 : 1))); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_AMBIENT_MODE); } int ambient_get_condition(void) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 6333b08..7f26941 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -290,6 +290,7 @@ static void broadcast_lcd_on(enum signal_type type, enum device_flags flags) { const char *str; const char *signal; + int ret; if (type <= SIGNAL_INVALID || type >= SIGNAL_MAX) { _E("Invalid signal type(%d).", type); @@ -309,16 +310,19 @@ static void broadcast_lcd_on(enum signal_type type, enum device_flags flags) signal = lcdon_sig_lookup[type]; _I("lcdstep : Broadcast signal(%s:%s).", signal, str); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, signal, g_variant_new("(s)", str)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", signal); } static void broadcast_lcd_off(enum signal_type type, enum device_flags flags) { const char *str; const char *signal; + int ret; if (type <= SIGNAL_INVALID || type >= SIGNAL_MAX) { _E("Invalid signal type(%d).", type); @@ -337,10 +341,12 @@ static void broadcast_lcd_off(enum signal_type type, enum device_flags flags) str = UNKNOWN_STR; _I("lcdstep : Broadcast signal(%s).", signal); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, signal, g_variant_new("(s)", str)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", signal); } void broadcast_lcd_off_late(enum device_flags flags) diff --git a/plugins/tv/display/ambient-mode.c b/plugins/tv/display/ambient-mode.c old mode 100755 new mode 100644 index bc482f5..b15fd56 --- a/plugins/tv/display/ambient-mode.c +++ b/plugins/tv/display/ambient-mode.c @@ -43,10 +43,14 @@ static unsigned int update_count; void broadcast_ambient_state(int state) { - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + int ret; + + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, SIGNAL_AMBIENT_MODE, g_variant_new("(i)", (state == 0 ? 0 : 1))); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_AMBIENT_MODE); } int ambient_get_condition(void) diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 4a6d3ce..95ebe4f 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -292,6 +292,7 @@ static void broadcast_lcd_on(enum signal_type type, enum device_flags flags) { const char *str; const char *signal; + int ret; if (type <= SIGNAL_INVALID || type >= SIGNAL_MAX) { _E("Invalid signal type(%d).", type); @@ -311,16 +312,19 @@ static void broadcast_lcd_on(enum signal_type type, enum device_flags flags) signal = lcdon_sig_lookup[type]; _I("lcdstep : Broadcast signal(%s:%s).", signal, str); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, signal, g_variant_new("(s)", str)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", signal); } static void broadcast_lcd_off(enum signal_type type, enum device_flags flags) { const char *str; const char *signal; + int ret; if (type <= SIGNAL_INVALID || type >= SIGNAL_MAX) { _E("Invalid signal type(%d).", type); @@ -339,10 +343,12 @@ static void broadcast_lcd_off(enum signal_type type, enum device_flags flags) str = UNKNOWN_STR; _I("lcdstep : Broadcast signal(%s).", signal); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, signal, g_variant_new("(s)", str)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", signal); } void broadcast_lcd_off_late(enum device_flags flags) diff --git a/plugins/tv/display/state-tv.c b/plugins/tv/display/state-tv.c index 7a6173d..8753a8d 100644 --- a/plugins/tv/display/state-tv.c +++ b/plugins/tv/display/state-tv.c @@ -117,6 +117,7 @@ static int lcdon_check(int curr, int next) static int lcdon_pre(void *data) { + int ret; /* TODO: cancel suspend */ /* That will unlock callback registration in case of getting back to normal @@ -128,10 +129,12 @@ static int lcdon_pre(void *data) if (pm_cur_state == S_STANDBY) { _I("send pre state change NORMAL"); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, SIGNAL_PRE_CHANGE_STATE, g_variant_new("(s)", states[S_LCDON].name)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_PRE_CHANGE_STATE); /*Give time to process callback */ usleep(PRE_STATE_CHANGE_TIMEOUT); } @@ -141,10 +144,14 @@ static int lcdon_pre(void *data) static int lcdon_post(void *data) { - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + int ret; + + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, SIGNAL_CHANGE_STATE, g_variant_new("(s)", states[S_LCDON].name)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_CHANGE_STATE); /* TODO: set_power */ @@ -209,11 +216,15 @@ static int lcdoff_pre(void *data) static int lcdoff_post(void *data) { + int ret; + /* broadcast to other application */ - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, SIGNAL_CHANGE_STATE, g_variant_new("(s)", states[S_LCDOFF].name)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_CHANGE_STATE); return 0; } @@ -284,11 +295,15 @@ static int standby_pre(void *data) static int standby_post(void *data) { + int ret; + /* broadcast to other application */ - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, SIGNAL_CHANGE_STATE, g_variant_new("(s)", states[S_STANDBY].name)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_CHANGE_STATE); backlight_ops.off(0); @@ -384,10 +399,12 @@ static int suspend_post(void *data) _E("Fail to change state to next_state(%s)", states[cond].name); /* Broadcast pre-wakeup signal */ - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_POWER, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER, SIGNAL_PRE_WAKEUP, g_variant_new("(i)", 0)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_PRE_WAKEUP); /* Notify resume state */ device_notify(DEVICE_NOTIFIER_POWER_RESUME, NULL); diff --git a/plugins/wearable/display/ambient-mode.c b/plugins/wearable/display/ambient-mode.c old mode 100755 new mode 100644 index bc482f5..b15fd56 --- a/plugins/wearable/display/ambient-mode.c +++ b/plugins/wearable/display/ambient-mode.c @@ -43,10 +43,14 @@ static unsigned int update_count; void broadcast_ambient_state(int state) { - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + int ret; + + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, SIGNAL_AMBIENT_MODE, g_variant_new("(i)", (state == 0 ? 0 : 1))); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_AMBIENT_MODE); } int ambient_get_condition(void) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 211ea08..4fe0fc7 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -290,6 +290,7 @@ static void broadcast_lcd_on(enum signal_type type, enum device_flags flags) { const char *str; const char *signal; + int ret; if (type <= SIGNAL_INVALID || type >= SIGNAL_MAX) { _E("Invalid signal type(%d).", type); @@ -309,16 +310,19 @@ static void broadcast_lcd_on(enum signal_type type, enum device_flags flags) signal = lcdon_sig_lookup[type]; _I("lcdstep : Broadcast signal(%s:%s).", signal, str); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, signal, g_variant_new("(s)", str)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", signal); } static void broadcast_lcd_off(enum signal_type type, enum device_flags flags) { const char *str; const char *signal; + int ret; if (type <= SIGNAL_INVALID || type >= SIGNAL_MAX) { _E("Invalid signal type(%d).", type); @@ -337,10 +341,12 @@ static void broadcast_lcd_off(enum signal_type type, enum device_flags flags) str = UNKNOWN_STR; _I("lcdstep : Broadcast signal(%s).", signal); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, signal, g_variant_new("(s)", str)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", signal); } void broadcast_lcd_off_late(enum device_flags flags) diff --git a/src/battery/battery-time.c b/src/battery/battery-time.c index 88cc071..75db00d 100644 --- a/src/battery/battery-time.c +++ b/src/battery/battery-time.c @@ -220,11 +220,15 @@ static float update_factor(enum state_b b_index) static void broadcast_battery_time(char *signal, int time) { + int ret; + if (!signal) return; - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY, signal, g_variant_new("(i)", time)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", signal); } static void update_time(enum state_a a_index, int seconds) diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c index d60dde0..282cd79 100644 --- a/src/extcon/cradle.c +++ b/src/extcon/cradle.c @@ -36,6 +36,7 @@ static struct extcon_ops cradle_extcon_ops; static void cradle_send_broadcast(int status) { static int old; + int ret; if (old == status) return; @@ -43,10 +44,12 @@ static void cradle_send_broadcast(int status) _I("Broadcast cradle status(%d).", status); old = status; - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, SIGNAL_CRADLE_STATE, g_variant_new("(i)", status)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_CRADLE_STATE); } static int cradle_update(int status) diff --git a/src/extcon/earjack.c b/src/extcon/earjack.c index 0b6235d..d02aeb0 100644 --- a/src/extcon/earjack.c +++ b/src/extcon/earjack.c @@ -33,6 +33,7 @@ static void earjack_send_broadcast(int status) { static int old = 0; + int ret; if (old == status) return; @@ -40,10 +41,12 @@ static void earjack_send_broadcast(int status) _I("Broadcast earjack status(%d).", status); old = status; - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, SIGNAL_EARJACK_STATE, g_variant_new("(i)", status)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_EARJACK_STATE); } static void earjack_send_system_event(int status) diff --git a/src/extcon/hdmi.c b/src/extcon/hdmi.c index 4283ac5..8ab10e5 100644 --- a/src/extcon/hdmi.c +++ b/src/extcon/hdmi.c @@ -33,6 +33,7 @@ static struct extcon_ops hdmi_extcon_ops; static void hdmi_send_broadcast(int status) { static int old; + int ret; if (old == status) return; @@ -40,10 +41,12 @@ static void hdmi_send_broadcast(int status) _I("Broadcast hdmi status(%d)", status); old = status; - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, SIGNAL_HDMI_STATE, g_variant_new("(i)", status)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_HDMI_STATE); } static int hdmi_update(int status) diff --git a/src/led/torch.c b/src/led/torch.c index 71d329f..94acf50 100644 --- a/src/led/torch.c +++ b/src/led/torch.c @@ -44,10 +44,14 @@ static struct led_state led_state = { static void flash_state_broadcast(int val) { - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_LED, + int ret; + + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_LED, DEVICED_INTERFACE_LED, SIGNAL_FLASH_STATE, g_variant_new("(i)", val)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_FLASH_STATE); } static GVariant *dbus_get_brightness(GDBusConnection *conn, diff --git a/src/power/power-handler.c b/src/power/power-handler.c index 277da74..222eeeb 100644 --- a/src/power/power-handler.c +++ b/src/power/power-handler.c @@ -446,6 +446,7 @@ static int poweroff_option_valid(enum poweroff_type type_e, const char *option) static void poweroff_send_broadcast(int status) { static int old = 0; + int ret; if (old == status) return; @@ -455,10 +456,12 @@ static void poweroff_send_broadcast(int status) old = status; /* Need to notify to deviced-vibrator. deviced-vibrator receives ChangeState signal for POWEROFF_TYPE_DIRECT and POWEROFF_TYPE_RESTART */ - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_POWEROFF, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_POWEROFF, DEVICED_INTERFACE_POWEROFF, SIGNAL_POWEROFF_STATE, g_variant_new("(i)", status)); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_POWEROFF_STATE); } static int power_execute_pid(const char *typename, const char *option) diff --git a/src/usb/usb-dbus.c b/src/usb/usb-dbus.c index c28870e..fcd9068 100644 --- a/src/usb/usb-dbus.c +++ b/src/usb/usb-dbus.c @@ -120,7 +120,7 @@ void broadcast_usb_mode_changed(void) DEVICED_INTERFACE_USB, SIGNAL_MODE_CHANGED, g_variant_new("(u)", mode)); if (ret < 0) - _E("Failed to send dbus signal."); + _E("Failed to send dbus signal(%s)", SIGNAL_MODE_CHANGED); } static void change_usb_client_mode(GDBusConnection *conn, diff --git a/src/usbhost/usb-host.c b/src/usbhost/usb-host.c index 56e681e..6ef9bfe 100644 --- a/src/usbhost/usb-host.c +++ b/src/usbhost/usb-host.c @@ -172,6 +172,7 @@ static void print_usbhost(struct usbhost_device *usbhost) static void broadcast_usbhost_signal(enum usbhost_state state, struct usbhost_device *usbhost) { + int ret; GVariant *param; if (!usbhost) @@ -188,10 +189,12 @@ static void broadcast_usbhost_signal(enum usbhost_state state, (usbhost->product ? usbhost->product : ""), (usbhost->serial ? usbhost->serial : "")); - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_USBHOST, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_USBHOST, DEVICED_INTERFACE_USBHOST, SIGNAL_USB_HOST_CHANGED, param); + if (ret < 0) + _E("Failed to send dbus signal(%s)", SIGNAL_USB_HOST_CHANGED); } static int add_usbhost_list(struct udev_device *dev, const char *devpath) -- 2.7.4 From ae3bce6e00c2a14c84aedfd0c9b87793f95e0111 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Fri, 3 May 2019 11:53:45 +0900 Subject: [PATCH 07/16] Change battery_state to prevent duplicated work Usage of battery_state was to print battery information. But change it to prevent duplicated work in battery_changed. Battery related information will be printed in process_power_supply. Change-Id: I313fd6c2ecad348b7ce228b20592b09ab1f9c09d Signed-off-by: lokilee73 --- src/battery/power-supply.c | 50 ++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 67ddf6f..f602701 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -696,33 +696,43 @@ static void process_power_supply(void *data) device_notify(DEVICE_NOTIFIER_BATTERY_CHARGING, &battery.charge_now); } -static void battery_state(struct battery_info *info) +static int battery_state(struct battery_info *info) { - if (!info) - return; + static struct battery_status prev_status; - _I("status=%s(%s) power_source=%s(%d) capa=%d health=%s present=%d current=%d(%d) volt=%d(%d) temp=%d", - info->status, - battery.charge_now == CHARGER_CHARGING ? "Charging" - : (battery.charge_now == CHARGER_DISCHARGING ? "Discharging" : "Abnormal"), - info->power_source, - info->online, - info->capacity, - info->health, - info->present, - info->current_now, - info->current_average, - info->voltage_now, - info->voltage_average, - info->temperature); + if (!info) { + memcpy(&prev_status, &battery, sizeof(battery)); + return 0; + } + + if (prev_status.capacity == battery.capacity && + prev_status.charge_status == battery.charge_status && + prev_status.charge_full == battery.charge_full && + prev_status.charge_now == battery.charge_now && + prev_status.health == battery.health && + prev_status.present == battery.present && + prev_status.online == battery.online) + return 0; + + prev_status.capacity = battery.capacity; + prev_status.charge_status = battery.charge_status; + prev_status.charge_full = battery.charge_full; + prev_status.charge_now = battery.charge_now; + prev_status.health = battery.health; + prev_status.present = battery.present; + prev_status.online = battery.online; + + return 1; } static void battery_changed(struct battery_info *info, void *data) { int ret; - if (!info) + if (!info) { + (void)battery_state(NULL); return; + } if (info->status) { snprintf(battery.status_s, sizeof(battery.status_s), @@ -753,7 +763,9 @@ static void battery_changed(struct battery_info *info, void *data) battery.voltage_average = info->voltage_average; battery.temperature = info->temperature; - battery_state(info); + ret = battery_state(info); + if (ret != 1) + return; ret = booting_done(NULL); if (ret) { -- 2.7.4 From ae64acacab6214db043428af4b842c4453981662 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Fri, 3 May 2019 17:28:15 +0900 Subject: [PATCH 08/16] Change power_supply_status_init Add battery_changed in power_supply_status_init, because previous code is too complicated. Battery_changed can replace it. Change-Id: Id06d3b9d9db391040b5fe176e421e1c322b92aea Signed-off-by: lokilee73 --- src/battery/power-supply.c | 57 ++++++++-------------------------------------- 1 file changed, 10 insertions(+), 47 deletions(-) mode change 100644 => 100755 src/battery/power-supply.c diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c old mode 100644 new mode 100755 index f602701..0c50aa2 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -336,6 +336,7 @@ void power_supply_broadcast(char *sig, int status) { static int old; static char sig_old[32]; + int ret; if (strcmp(sig_old, sig) == 0 && old == status) return; @@ -347,11 +348,12 @@ void power_supply_broadcast(char *sig, int status) /*snprintf(str_status, sizeof(str_status), "%d", status); arr[0] = str_status;*/ - dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_BATTERY, + ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY, sig, g_variant_new("(i)", status)); - + if (ret < 0) + _E("Failed to send dbus signal(%s)", sig); } static void noti_batt_full(void) @@ -779,56 +781,17 @@ static void battery_changed(struct battery_info *info, void *data) } -static void battery_get_capacity(struct battery_info *info, void *data) -{ - int *capa = data; - - if (info && info->capacity >= 0) - *capa = info->capacity; -} - static void power_supply_status_init(void) { - static int charge_now = -1; - static int charge_full = -1; - static int capacity = -1; - int pct; int r; - pct = -1; - r = battery_dev->get_current_state(battery_get_capacity, &pct); - if (r < 0 || pct < 0) { - _E("Failed to get battery capacity. capa=%d: %d", pct, r); - return; - } - - battery.capacity = pct; - battery.health = HEALTH_GOOD; - battery.present = PRESENT_NORMAL; - - if (charge_now == battery.charge_now && - charge_full == battery.charge_full && - capacity == battery.capacity) - return; - - _I("charging=%d full=%d capacity=%d", battery.charge_now, battery.charge_full, battery.capacity); - - if (charge_now != battery.charge_now) { - r = vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, battery.charge_now); - if (r < 0) - _E("Failed to set vconf value for battery charge now: %d", vconf_get_ext_errno()); - power_supply_broadcast(CHARGE_NOW_SIGNAL, battery.charge_now); - } - if (capacity != battery.capacity) { - r = vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, battery.capacity); - if (r < 0) - _E("Failed to set vconf value for battery capacity: %d", vconf_get_ext_errno()); - power_supply_broadcast(CHARGE_CAPACITY_SIGNAL, battery.capacity); + if (battery_dev && battery_dev->get_current_state) { + r = battery_dev->get_current_state(battery_changed, NULL); + if (r < 0 || battery.capacity < 0) { + _E("Failed to get battery capacity (capa: %d, ret: %d)", battery.capacity, r); + return; + } } - - charge_now = battery.charge_now; - charge_full = battery.charge_full; - capacity = battery.capacity; } static gboolean power_supply_update(void *data) -- 2.7.4 From 8818b2349f19a42c73cda9fe35859b32f7c1a3f2 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Wed, 8 May 2019 17:53:51 +0900 Subject: [PATCH 09/16] Add protection code and insert a log for broadcasting same signal and status Change-Id: I67dd7f9f0660bc432cc3cc193328c46fb1d132e1 Signed-off-by: lokilee73 --- src/battery/power-supply.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) mode change 100755 => 100644 src/battery/power-supply.c diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c old mode 100755 new mode 100644 index 0c50aa2..9e0d54b --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -338,8 +338,14 @@ void power_supply_broadcast(char *sig, int status) static char sig_old[32]; int ret; - if (strcmp(sig_old, sig) == 0 && old == status) + if (!sig) { + _E("there is no signal name"); return; + } + if (strncmp(sig_old, sig, strlen(sig)) == 0 && old == status) { + _D("Skip broadcasting same signal and status: %s %d", sig, status); + return; + } _D("signal=%s status=%d", sig, status); -- 2.7.4 From 6b27a38449547be0b64a521120e7012c0f35b0c7 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 9 May 2019 11:17:07 +0900 Subject: [PATCH 10/16] Remove unused function print_lowbat_state Change-Id: I43419bc75a0f3b7d2cc06592dce3fabb0585459b Signed-off-by: lokilee73 --- src/battery/lowbat-handler.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 9f37f39..21b51e5 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -162,15 +162,6 @@ static int lowbat_add_scenario(int old, int now, int (*func)(void *data)) return 0; } -static void print_lowbat_state(unsigned int bat_percent) -{ -#if 0 - int i; - for (i = 0; i < BAT_MON_SAMPLES; i++) - _D("\t%d", recent_bat_percent[i]); -#endif -} - static int power_execute(void *data) { static const struct device_ops *ops; @@ -733,7 +724,6 @@ static void lowbat_monitor(void *data) return; } else bat_percent = *(int *)data; - print_lowbat_state(bat_percent); lowbat_process(bat_percent, NULL); } -- 2.7.4 From c7081697c0a0469d75cb819e8465bdce9e92f143 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 9 May 2019 12:14:29 +0900 Subject: [PATCH 11/16] Move vconf setting for capacity from lowbat_process to process_power_supply Lowbat_process has to deal with low battery related parameters. It's better to set capcity related vconf in process_power_supply. Change-Id: I46d3feb977824e90bc32f74050382637af8b63d6 Signed-off-by: lokilee73 --- src/battery/lowbat-handler.c | 11 +---------- src/battery/power-supply.c | 7 +++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 21b51e5..354bbb6 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -585,16 +585,7 @@ static int lowbat_process(int bat_percent, void *ad) change_lowbat_level(new_bat_capacity); battery_level_send_system_event(new_bat_capacity); - if (new_bat_capacity != cur_bat_capacity) { - _D("[BAT_MON] cur=%d new=%d", cur_bat_capacity, new_bat_capacity); - ret = vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, new_bat_capacity); - if (ret == 0) - cur_bat_capacity = new_bat_capacity; - else - _E("Failed to set vconf value for battery capacity: %d", vconf_get_ext_errno()); - - power_supply_broadcast(CHARGE_CAPACITY_SIGNAL, new_bat_capacity); - } + cur_bat_capacity = new_bat_capacity; ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &vconf_state); if (ret < 0) { diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 9e0d54b..710599d 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -688,6 +688,13 @@ static void process_power_supply(void *data) power_supply_broadcast(CHARGE_NOW_SIGNAL, battery.charge_now); } + if (old_battery.capacity != battery.capacity) { + ret = vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, battery.capacity); + if (ret < 0) + _E("Failed to set vconf value for battery capacity: %d", vconf_get_ext_errno()); + power_supply_broadcast(CHARGE_CAPACITY_SIGNAL, battery.capacity); + } + lowbat_execute(data); check_online(); if (old_battery.charge_full != battery.charge_full) -- 2.7.4 From 67d5f7157d53d6adcf73aa4a53dcc1e85ee52a50 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 9 May 2019 14:57:01 +0900 Subject: [PATCH 12/16] Change function name dbus_get_charge_level is used to get vconf value of VCONFKEY_SYSMAN_BATTERY_STATUS_LOW. It's not intuitive. So, change it. Change-Id: Ieb62b6fcd9baabbb7a746782f2146bc397d80432 Signed-off-by: lokilee73 --- src/battery/power-supply.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 710599d..c4eb7c8 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -856,7 +856,7 @@ static GVariant *dbus_get_charge_now(GDBusConnection *conn, return g_variant_new("(i)", ret); } -static GVariant *dbus_get_charge_level(GDBusConnection *conn, +static GVariant *dbus_get_status_low(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -1029,7 +1029,7 @@ static GVariant *dbus_get_battery_info(GDBusConnection *conn, static const dbus_method_s dbus_methods[] = { { CHARGER_STATUS_SIGNAL, NULL, "i", dbus_get_charger_status }, { CHARGE_NOW_SIGNAL, NULL, "i", dbus_get_charge_now }, - { CHARGE_LEVEL_SIGNAL, NULL, "i", dbus_get_charge_level }, + { CHARGE_LEVEL_SIGNAL, NULL, "i", dbus_get_status_low }, { CHARGE_CAPACITY_SIGNAL, NULL, "i", dbus_get_percent }, { CHARGE_CAPACITY_LAW_SIGNAL, NULL, "i", dbus_get_percent_raw }, { CHARGE_FULL_SIGNAL, NULL, "i", dbus_is_full }, -- 2.7.4 From 2633e05005bb79a9c5665781c84d68b63022831b Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 9 May 2019 17:00:27 +0900 Subject: [PATCH 13/16] Add low_bat_old to nofify when low_bat changes Currently, DEVICE_NOTIFIER_LOWBAT is notified periodically. So, add low_bat_old to notify when low_bat is changed. Change-Id: I70b1730a993f4f1783e20c719970223901b752b4 Signed-off-by: lokilee73 --- src/battery/lowbat-handler.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 354bbb6..0ba1ae1 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -570,6 +570,7 @@ static void change_lowbat_level(int bat_percent) static int lowbat_process(int bat_percent, void *ad) { static int online; + static bool low_bat_old; int new_bat_capacity; int new_bat_state; int vconf_state = -1; @@ -652,7 +653,10 @@ static int lowbat_process(int bat_percent, void *ad) if (new_bat_capacity <= battery_info.warning) low_bat = true; - device_notify(DEVICE_NOTIFIER_LOWBAT, (void *)low_bat); + if (low_bat_old != low_bat) { + device_notify(DEVICE_NOTIFIER_LOWBAT, (void *)&low_bat); + low_bat_old = low_bat; + } if (battery.online == POWER_SUPPLY_TYPE_UNKNOWN) { _E("Battery online is not initialized."); -- 2.7.4 From 15e715b79359974582b6e96338e922451fe2ff79 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Fri, 10 May 2019 14:20:03 +0900 Subject: [PATCH 14/16] Fix invalid return value of dbus Return value in dbus_locktimeout_expired has to be integer. So, fix it. Change-Id: Ie34853948852bca28f87bf0c984c59ea07a86fdd Signed-off-by: lokilee73 --- plugins/iot/display/display-dbus.c | 2 +- plugins/mobile/display/display-dbus.c | 2 +- plugins/tv/display/display-dbus.c | 2 +- plugins/wearable/display/display-dbus.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/iot/display/display-dbus.c b/plugins/iot/display/display-dbus.c index 12e1d0a..69ef153 100644 --- a/plugins/iot/display/display-dbus.c +++ b/plugins/iot/display/display-dbus.c @@ -963,7 +963,7 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, return NULL; out: - gvar = g_variant_new("(si)", req_id, ret); + gvar = g_variant_new("(i)", ret); g_free(req_id); if (ex) free(ex); diff --git a/plugins/mobile/display/display-dbus.c b/plugins/mobile/display/display-dbus.c index 12e1d0a..69ef153 100644 --- a/plugins/mobile/display/display-dbus.c +++ b/plugins/mobile/display/display-dbus.c @@ -963,7 +963,7 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, return NULL; out: - gvar = g_variant_new("(si)", req_id, ret); + gvar = g_variant_new("(i)", ret); g_free(req_id); if (ex) free(ex); diff --git a/plugins/tv/display/display-dbus.c b/plugins/tv/display/display-dbus.c index 12e1d0a..69ef153 100644 --- a/plugins/tv/display/display-dbus.c +++ b/plugins/tv/display/display-dbus.c @@ -963,7 +963,7 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, return NULL; out: - gvar = g_variant_new("(si)", req_id, ret); + gvar = g_variant_new("(i)", ret); g_free(req_id); if (ex) free(ex); diff --git a/plugins/wearable/display/display-dbus.c b/plugins/wearable/display/display-dbus.c index 12e1d0a..69ef153 100644 --- a/plugins/wearable/display/display-dbus.c +++ b/plugins/wearable/display/display-dbus.c @@ -963,7 +963,7 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, return NULL; out: - gvar = g_variant_new("(si)", req_id, ret); + gvar = g_variant_new("(i)", ret); g_free(req_id); if (ex) free(ex); -- 2.7.4 From 5d18bc167445fd3f238ff13421963bbd4db393bd Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 13 May 2019 11:16:51 +0900 Subject: [PATCH 15/16] Fix dbus error by no reply timeout There is a dbus error, when dbus_lockTimeoutExpired is called. So, change it to reply. Change-Id: Ica0dda733d5b8e8da6fa45cc6328a6a1a2f5cd60 Signed-off-by: lokilee73 --- plugins/iot/display/display-dbus.c | 9 ++------- plugins/mobile/display/display-dbus.c | 9 ++------- plugins/tv/display/display-dbus.c | 9 ++------- plugins/wearable/display/display-dbus.c | 9 ++------- 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/plugins/iot/display/display-dbus.c b/plugins/iot/display/display-dbus.c index 69ef153..382dbed 100644 --- a/plugins/iot/display/display-dbus.c +++ b/plugins/iot/display/display-dbus.c @@ -911,7 +911,6 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, char pid_str[16]; char comm[NAME_MAX]; struct pmlock_expired_s *ex = NULL; - GVariant *gvar = NULL; CHECK_POWEROFF(); @@ -959,15 +958,11 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, DD_LIST_APPEND(expired_req_list, ex); - g_free(req_id); - return NULL; - out: - gvar = g_variant_new("(i)", ret); g_free(req_id); - if (ex) + if (ex && ret < 0) free(ex); - return gvar; + return g_variant_new("(i)", ret); } static gboolean app_term(gpointer data) diff --git a/plugins/mobile/display/display-dbus.c b/plugins/mobile/display/display-dbus.c index 69ef153..382dbed 100644 --- a/plugins/mobile/display/display-dbus.c +++ b/plugins/mobile/display/display-dbus.c @@ -911,7 +911,6 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, char pid_str[16]; char comm[NAME_MAX]; struct pmlock_expired_s *ex = NULL; - GVariant *gvar = NULL; CHECK_POWEROFF(); @@ -959,15 +958,11 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, DD_LIST_APPEND(expired_req_list, ex); - g_free(req_id); - return NULL; - out: - gvar = g_variant_new("(i)", ret); g_free(req_id); - if (ex) + if (ex && ret < 0) free(ex); - return gvar; + return g_variant_new("(i)", ret); } static gboolean app_term(gpointer data) diff --git a/plugins/tv/display/display-dbus.c b/plugins/tv/display/display-dbus.c index 69ef153..382dbed 100644 --- a/plugins/tv/display/display-dbus.c +++ b/plugins/tv/display/display-dbus.c @@ -911,7 +911,6 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, char pid_str[16]; char comm[NAME_MAX]; struct pmlock_expired_s *ex = NULL; - GVariant *gvar = NULL; CHECK_POWEROFF(); @@ -959,15 +958,11 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, DD_LIST_APPEND(expired_req_list, ex); - g_free(req_id); - return NULL; - out: - gvar = g_variant_new("(i)", ret); g_free(req_id); - if (ex) + if (ex && ret < 0) free(ex); - return gvar; + return g_variant_new("(i)", ret); } static gboolean app_term(gpointer data) diff --git a/plugins/wearable/display/display-dbus.c b/plugins/wearable/display/display-dbus.c index 69ef153..382dbed 100644 --- a/plugins/wearable/display/display-dbus.c +++ b/plugins/wearable/display/display-dbus.c @@ -911,7 +911,6 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, char pid_str[16]; char comm[NAME_MAX]; struct pmlock_expired_s *ex = NULL; - GVariant *gvar = NULL; CHECK_POWEROFF(); @@ -959,15 +958,11 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, DD_LIST_APPEND(expired_req_list, ex); - g_free(req_id); - return NULL; - out: - gvar = g_variant_new("(i)", ret); g_free(req_id); - if (ex) + if (ex && ret < 0) free(ex); - return gvar; + return g_variant_new("(i)", ret); } static gboolean app_term(gpointer data) -- 2.7.4 From 0f59b98e8eae8cbf6b1f4e83228fb2f0c5c4d39c Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 13 May 2019 08:53:01 +0000 Subject: [PATCH 16/16] Revert "Fix dbus error by no reply timeout" This reverts commit 5d18bc167445fd3f238ff13421963bbd4db393bd. Change-Id: Ieb797fecd0230dea2d4558dd7ea629fdfded2ccb --- plugins/iot/display/display-dbus.c | 9 +++++++-- plugins/mobile/display/display-dbus.c | 9 +++++++-- plugins/tv/display/display-dbus.c | 9 +++++++-- plugins/wearable/display/display-dbus.c | 9 +++++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/plugins/iot/display/display-dbus.c b/plugins/iot/display/display-dbus.c index 382dbed..69ef153 100644 --- a/plugins/iot/display/display-dbus.c +++ b/plugins/iot/display/display-dbus.c @@ -911,6 +911,7 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, char pid_str[16]; char comm[NAME_MAX]; struct pmlock_expired_s *ex = NULL; + GVariant *gvar = NULL; CHECK_POWEROFF(); @@ -958,11 +959,15 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, DD_LIST_APPEND(expired_req_list, ex); + g_free(req_id); + return NULL; + out: + gvar = g_variant_new("(i)", ret); g_free(req_id); - if (ex && ret < 0) + if (ex) free(ex); - return g_variant_new("(i)", ret); + return gvar; } static gboolean app_term(gpointer data) diff --git a/plugins/mobile/display/display-dbus.c b/plugins/mobile/display/display-dbus.c index 382dbed..69ef153 100644 --- a/plugins/mobile/display/display-dbus.c +++ b/plugins/mobile/display/display-dbus.c @@ -911,6 +911,7 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, char pid_str[16]; char comm[NAME_MAX]; struct pmlock_expired_s *ex = NULL; + GVariant *gvar = NULL; CHECK_POWEROFF(); @@ -958,11 +959,15 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, DD_LIST_APPEND(expired_req_list, ex); + g_free(req_id); + return NULL; + out: + gvar = g_variant_new("(i)", ret); g_free(req_id); - if (ex && ret < 0) + if (ex) free(ex); - return g_variant_new("(i)", ret); + return gvar; } static gboolean app_term(gpointer data) diff --git a/plugins/tv/display/display-dbus.c b/plugins/tv/display/display-dbus.c index 382dbed..69ef153 100644 --- a/plugins/tv/display/display-dbus.c +++ b/plugins/tv/display/display-dbus.c @@ -911,6 +911,7 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, char pid_str[16]; char comm[NAME_MAX]; struct pmlock_expired_s *ex = NULL; + GVariant *gvar = NULL; CHECK_POWEROFF(); @@ -958,11 +959,15 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, DD_LIST_APPEND(expired_req_list, ex); + g_free(req_id); + return NULL; + out: + gvar = g_variant_new("(i)", ret); g_free(req_id); - if (ex && ret < 0) + if (ex) free(ex); - return g_variant_new("(i)", ret); + return gvar; } static gboolean app_term(gpointer data) diff --git a/plugins/wearable/display/display-dbus.c b/plugins/wearable/display/display-dbus.c index 382dbed..69ef153 100644 --- a/plugins/wearable/display/display-dbus.c +++ b/plugins/wearable/display/display-dbus.c @@ -911,6 +911,7 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, char pid_str[16]; char comm[NAME_MAX]; struct pmlock_expired_s *ex = NULL; + GVariant *gvar = NULL; CHECK_POWEROFF(); @@ -958,11 +959,15 @@ GVariant *dbus_locktimeout_expired(GDBusConnection *conn, DD_LIST_APPEND(expired_req_list, ex); + g_free(req_id); + return NULL; + out: + gvar = g_variant_new("(i)", ret); g_free(req_id); - if (ex && ret < 0) + if (ex) free(ex); - return g_variant_new("(i)", ret); + return gvar; } static gboolean app_term(gpointer data) -- 2.7.4