From 7d3f027182f795dbc873da074252de81099e45ab Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Fri, 16 Jun 2023 12:41:49 +0900 Subject: [PATCH] display: Relocate update_setting() from plugins to core update_setting() is called from display init() and it updates pm related setting. Actually, this function does a lot of work according to the incoming key value. Also, it is necessary to change the initialization way, so it will be refactored after relocation. To relocate, wrapper functions are added below display-plugin. - bool display_plugin_is_there_update_pm_setting(void); - int display_plugin_is_lcd_on_blocked(void); - int display_plugin_set_power_save_mode_flag(int onoff); -> This wrapper is added for wearable plugin. New function is added below display/setting - int display_setting_update_pm_setting(int key_idx, int val); -> This is temporary function, it will be refactored. Change-Id: I90564168f72df733e887e231fa8262a7a83f86ac Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 95 +--------------------------- plugins/mobile/display/core.c | 95 +--------------------------- plugins/tv/display/core.c | 95 +--------------------------- plugins/wearable/display/core.c | 15 +++-- src/battery/lowbat-handler.c | 2 +- src/battery/power-supply.c | 2 +- src/display/display-plugin.c | 29 +++++++++ src/display/display-plugin.h | 5 ++ src/display/display.c | 3 + src/display/plugin-common/display-dbus.c | 12 ++-- src/display/setting.c | 104 ++++++++++++++++++++++++++++++- src/display/setting.h | 2 +- 12 files changed, 163 insertions(+), 296 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index b144e11..1ab9da5 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -420,97 +420,6 @@ int poll_callback(int condition, PMMsg *data) return 0; } -static int update_setting(int key_idx, int val) -{ - int ret; - - switch (key_idx) { - case SETTING_TO_NORMAL: - display_state_transition_update_display_state_timeout_by_priority(); - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - break; - case SETTING_LOW_BATT: - if (display_misc_is_low_battery_state(val)) { - if (!(get_pm_status_flag() & CHRGR_FLAG)) - display_set_power_save_mode_flag(true); - set_pm_status_flag(LOWBT_FLAG); - } else { - if (get_pm_status_flag() & PWRSV_FLAG) - display_set_power_save_mode_flag(false); - clear_pm_status_flag(LOWBT_FLAG); - clear_pm_status_flag(BRTCH_FLAG); - ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, false); - if (ret < 0) - _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno()); - } - break; - case SETTING_CHARGING: - if (val) { - if (get_pm_status_flag() & LOWBT_FLAG) { - display_set_power_save_mode_flag(false); - clear_pm_status_flag(LOWBT_FLAG); - } - set_pm_status_flag(CHRGR_FLAG); - } else { - int bat_state; - ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, - &bat_state); - if (ret < 0) { - bat_state = VCONFKEY_SYSMAN_BAT_NORMAL; - _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno()); - } - if (display_misc_is_low_battery_state(bat_state)) { - display_set_power_save_mode_flag(true); - set_pm_status_flag(LOWBT_FLAG); - } - clear_pm_status_flag(CHRGR_FLAG); - } - break; - case SETTING_BRT_LEVEL: - if (get_pm_status_flag() & PWRSV_FLAG) { - set_pm_status_flag(BRTCH_FLAG); - ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, true); - if (ret < 0) - _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno()); - _I("Brightness changed in low battery," - "escape dim state."); - } - display_backlight_set_default_brightness(val); - break; - case SETTING_LOCK_SCREEN: - set_lock_screen_state(val); - if (val == VCONFKEY_IDLE_UNLOCK) - touchled_control_backlight(TOUCHLED_DIRECT_OFF); - - /* LCD on if lock screen show before waiting time */ - if ((get_pm_cur_state() == S_NORMAL) && - val == VCONFKEY_IDLE_LOCK && - display_panel_get_dpms_cached_state() != DPMS_ON && - is_lcdon_blocked() == LCDON_BLOCK_NONE) - display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - break; - case SETTING_LOCK_SCREEN_BG: - set_lock_screen_bg_state(val); - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - break; - case SETTING_POWER_CUSTOM_BRIGHTNESS: - if (val == VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON) - display_backlight_set_custom_status(true); - else - display_backlight_set_custom_status(false); - break; - - default: - return -1; - } - return 0; -} - static void check_seed_status(void) { int ret = -1; @@ -654,6 +563,8 @@ static int display_probe(void *data) dp->custom_lcd_off = NULL; dp->display_on_by_reason = NULL; dp->display_off_by_reason = NULL; + dp->default_saving_mode = NULL; + dp->is_lcdon_blocked = is_lcdon_blocked; setup_display_plugin_backlight_ops(dp); /* check display feature */ @@ -757,7 +668,7 @@ static void display_init(void *data) for (i = INIT_SETTING; i < INIT_END; i++) { switch (i) { case INIT_SETTING: - ret = init_setting(update_setting); + ret = init_setting(NULL); break; case INIT_INTERFACE: if (display_conf.timeout_enable) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index f0ff545..47cf451 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -429,97 +429,6 @@ int poll_callback(int condition, PMMsg *data) return 0; } -static int update_setting(int key_idx, int val) -{ - int ret; - - switch (key_idx) { - case SETTING_TO_NORMAL: - display_state_transition_update_display_state_timeout_by_priority(); - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - break; - case SETTING_LOW_BATT: - if (display_misc_is_low_battery_state(val)) { - if (!(get_pm_status_flag() & CHRGR_FLAG)) - display_set_power_save_mode_flag(true); - set_pm_status_flag(LOWBT_FLAG); - } else { - if (get_pm_status_flag() & PWRSV_FLAG) - display_set_power_save_mode_flag(false); - clear_pm_status_flag(LOWBT_FLAG); - clear_pm_status_flag(BRTCH_FLAG); - ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, false); - if (ret < 0) - _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno()); - } - break; - case SETTING_CHARGING: - if (val) { - if (get_pm_status_flag() & LOWBT_FLAG) { - display_set_power_save_mode_flag(false); - clear_pm_status_flag(LOWBT_FLAG); - } - set_pm_status_flag(CHRGR_FLAG); - } else { - int bat_state; - ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, - &bat_state); - if (ret < 0) { - bat_state = VCONFKEY_SYSMAN_BAT_NORMAL; - _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno()); - } - if (display_misc_is_low_battery_state(bat_state)) { - display_set_power_save_mode_flag(true); - set_pm_status_flag(LOWBT_FLAG); - } - clear_pm_status_flag(CHRGR_FLAG); - } - break; - case SETTING_BRT_LEVEL: - if (get_pm_status_flag() & PWRSV_FLAG) { - set_pm_status_flag(BRTCH_FLAG); - ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, true); - if (ret < 0) - _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno()); - _I("Brightness changed in low battery," - "escape dim state."); - } - display_backlight_set_default_brightness(val); - break; - case SETTING_LOCK_SCREEN: - set_lock_screen_state(val); - if (val == VCONFKEY_IDLE_UNLOCK) - touchled_control_backlight(TOUCHLED_DIRECT_OFF); - - /* LCD on if lock screen show before waiting time */ - if ((get_pm_cur_state() == S_NORMAL) && - val == VCONFKEY_IDLE_LOCK && - display_panel_get_dpms_cached_state() != DPMS_ON && - is_lcdon_blocked() == LCDON_BLOCK_NONE) - display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - break; - case SETTING_LOCK_SCREEN_BG: - set_lock_screen_bg_state(val); - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - break; - case SETTING_POWER_CUSTOM_BRIGHTNESS: - if (val == VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON) - display_backlight_set_custom_status(true); - else - display_backlight_set_custom_status(false); - break; - - default: - return -1; - } - return 0; -} - static void check_seed_status(void) { int ret = -1; @@ -663,6 +572,8 @@ static int display_probe(void *data) dp->custom_lcd_off = NULL; dp->display_on_by_reason = NULL; dp->display_off_by_reason = NULL; + dp->default_saving_mode = NULL; + dp->is_lcdon_blocked = is_lcdon_blocked; setup_display_plugin_backlight_ops(dp); /** @@ -762,7 +673,7 @@ static void display_init(void *data) for (i = INIT_SETTING; i < INIT_END; i++) { switch (i) { case INIT_SETTING: - ret = init_setting(update_setting); + ret = init_setting(NULL); break; case INIT_INTERFACE: if (display_conf.timeout_enable) diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 65f76e7..e16cd09 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -419,97 +419,6 @@ int poll_callback(int condition, PMMsg *data) return 0; } -static int update_setting(int key_idx, int val) -{ - int ret; - - switch (key_idx) { - case SETTING_TO_NORMAL: - display_state_transition_update_display_state_timeout_by_priority(); - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - break; - case SETTING_LOW_BATT: - if (display_misc_is_low_battery_state(val)) { - if (!(get_pm_status_flag() & CHRGR_FLAG)) - display_set_power_save_mode_flag(true); - set_pm_status_flag(LOWBT_FLAG); - } else { - if (get_pm_status_flag() & PWRSV_FLAG) - display_set_power_save_mode_flag(false); - clear_pm_status_flag(LOWBT_FLAG); - clear_pm_status_flag(BRTCH_FLAG); - ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, false); - if (ret < 0) - _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno()); - } - break; - case SETTING_CHARGING: - if (val) { - if (get_pm_status_flag() & LOWBT_FLAG) { - display_set_power_save_mode_flag(false); - clear_pm_status_flag(LOWBT_FLAG); - } - set_pm_status_flag(CHRGR_FLAG); - } else { - int bat_state; - ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, - &bat_state); - if (ret < 0) { - bat_state = VCONFKEY_SYSMAN_BAT_NORMAL; - _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno()); - } - if (display_misc_is_low_battery_state(bat_state)) { - display_set_power_save_mode_flag(true); - set_pm_status_flag(LOWBT_FLAG); - } - clear_pm_status_flag(CHRGR_FLAG); - } - break; - case SETTING_BRT_LEVEL: - if (get_pm_status_flag() & PWRSV_FLAG) { - set_pm_status_flag(BRTCH_FLAG); - ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, true); - if (ret < 0) - _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno()); - _I("Brightness changed in low battery," - "escape dim state."); - } - display_backlight_set_default_brightness(val); - break; - case SETTING_LOCK_SCREEN: - set_lock_screen_state(val); - if (val == VCONFKEY_IDLE_UNLOCK) - touchled_control_backlight(TOUCHLED_DIRECT_OFF); - - /* LCD on if lock screen show before waiting time */ - if ((get_pm_cur_state() == S_NORMAL) && - val == VCONFKEY_IDLE_LOCK && - display_panel_get_dpms_cached_state() != DPMS_ON && - is_lcdon_blocked() == LCDON_BLOCK_NONE) - display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - break; - case SETTING_LOCK_SCREEN_BG: - set_lock_screen_bg_state(val); - display_state_transition_update_display_state_timeout_by_priority(); - if (get_pm_cur_state() == S_NORMAL) - display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); - break; - case SETTING_POWER_CUSTOM_BRIGHTNESS: - if (val == VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON) - display_backlight_set_custom_status(true); - else - display_backlight_set_custom_status(false); - break; - - default: - return -1; - } - return 0; -} - static void check_seed_status(void) { int ret = -1; @@ -654,6 +563,8 @@ static int display_probe(void *data) dp->custom_lcd_off = NULL; dp->display_on_by_reason = NULL; dp->display_off_by_reason = NULL; + dp->default_saving_mode = NULL; + dp->is_lcdon_blocked = is_lcdon_blocked; setup_display_plugin_backlight_ops(dp); /** @@ -753,7 +664,7 @@ static void display_init(void *data) for (i = INIT_SETTING; i < INIT_END; i++) { switch (i) { case INIT_SETTING: - ret = init_setting(update_setting); + ret = init_setting(NULL); break; case INIT_INTERFACE: if (display_conf.timeout_enable) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 3662293..150dc3f 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -95,7 +95,6 @@ static struct display_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; static guint transit_timer; @@ -1065,11 +1064,11 @@ static int update_setting(int key_idx, int val) case SETTING_LOW_BATT: if (display_misc_is_low_battery_state(val)) { if (!(get_pm_status_flag() & CHRGR_FLAG)) - power_saving_func(true); + default_saving_mode(true); set_pm_status_flag(LOWBT_FLAG); } else { if (get_pm_status_flag() & PWRSV_FLAG) - power_saving_func(false); + default_saving_mode(false); clear_pm_status_flag(LOWBT_FLAG); clear_pm_status_flag(BRTCH_FLAG); ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, false); @@ -1080,7 +1079,7 @@ static int update_setting(int key_idx, int val) case SETTING_CHARGING: if (val) { if (get_pm_status_flag() & LOWBT_FLAG) { - power_saving_func(false); + default_saving_mode(false); clear_pm_status_flag(LOWBT_FLAG); } set_pm_status_flag(CHRGR_FLAG); @@ -1093,7 +1092,7 @@ static int update_setting(int key_idx, int val) _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno()); } if (display_misc_is_low_battery_state(bat_state)) { - power_saving_func(true); + default_saving_mode(true); set_pm_status_flag(LOWBT_FLAG); } clear_pm_status_flag(CHRGR_FLAG); @@ -1177,7 +1176,7 @@ static void check_seed_status(void) } if (display_misc_is_low_battery_state(bat_state)) { if (!(get_pm_status_flag() & CHRGR_FLAG)) { - power_saving_func(true); + default_saving_mode(true); set_pm_status_flag(LOWBT_FLAG); } } @@ -1285,6 +1284,8 @@ static int display_probe(void *data) dp->custom_lcd_off = custom_lcdoff; dp->display_on_by_reason = display_on_by_reason; dp->display_off_by_reason = display_off_by_reason; + dp->default_saving_mode = default_saving_mode; + dp->is_lcdon_blocked = is_lcdon_blocked; setup_display_plugin_backlight_ops(dp); /** @@ -1397,8 +1398,6 @@ static void display_init(void *data) signal(SIGHUP, sig_hup); - power_saving_func = default_saving_mode; - /* load configutation */ ret = display_load_config(&display_conf); if (ret < 0) diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 3d294ab..b67e6dd 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -533,7 +533,7 @@ static int lowbat_process(int bat_percent, void *ad) if (status != -1) { result = status; - display_plugin_update_pm_setting(SETTING_LOW_BATT, status); + display_setting_update_pm_setting(SETTING_LOW_BATT, status); } else result = vconf_state; diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index 1f63c8a..c9c4c21 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -377,7 +377,7 @@ static void noti_batt_full(void) static void check_power_supply(int state) { pm_check_and_change(state); - display_plugin_update_pm_setting(SETTING_CHARGING, state); + display_setting_update_pm_setting(SETTING_CHARGING, state); } static void charger_state_send_system_event(int state) diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index 5ce4b5e..e5df386 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -60,6 +60,14 @@ int display_plugin_update_pm_setting(int key_idx, int val) return 0; } +bool display_plugin_is_there_update_pm_setting(void) +{ + if (g_display_plugin.update_pm_setting) + return true; + + return false; +} + /* FIXME: return 0 can be value of get_lock_screen_state, it is hard to distinguish error or not */ int display_plugin_get_lock_screen_state(void) { @@ -159,6 +167,27 @@ int display_plugin_display_off_by_reason(const char *reason) return -EOPNOTSUPP; } +int display_plugin_set_power_save_mode_flag(int onoff) +{ + if (g_display_plugin.default_saving_mode) { + g_display_plugin.default_saving_mode(onoff); + return 0; + } + + return -EOPNOTSUPP; +} + +/** FIXME: is_lcdon_blocked() should be moved or refactored after plugin relocation + * Also, this is temporary wrapper function. It should be removed. + */ +int display_plugin_is_lcd_on_blocked(void) +{ + if (g_display_plugin.is_lcdon_blocked) + return g_display_plugin.is_lcdon_blocked(); + + return -EOPNOTSUPP; +} + int display_plugin_backlight_get_lcd_power(void) { if (g_display_plugin.backlight && g_display_plugin.backlight->get_lcd_power) diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h index 95470d0..b2f3478 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -73,6 +73,8 @@ struct display_plugin { int (*custom_lcd_off) (enum device_flags flag); int (*display_on_by_reason) (const char *reason, int timeout); int (*display_off_by_reason) (const char *reason); + void (*default_saving_mode) (int onoff); + int (*is_lcdon_blocked) (void); struct display_config *config; struct display_backlight_ops *backlight; @@ -85,6 +87,7 @@ int display_plugin_pm_lock_internal(pid_t pid, int s_bits, int flags, int timeou int display_plugin_pm_unlock_internal(pid_t pid, int s_bits, int flags); int display_plugin_pm_change_internal(pid_t pid, int s_bits); int display_plugin_update_pm_setting(int key_idx, int val); +bool display_plugin_is_there_update_pm_setting(void); int display_plugin_get_lock_screen_state(void); int display_plugin_get_system_wakeup_flag(bool *flag); int display_plugin_set_system_wakeup_flag(bool flag); @@ -98,6 +101,8 @@ int display_plugin_custom_lcd_on(int timeout); int display_plugin_custom_lcd_off(enum device_flags flag); int dipslay_plugin_display_on_by_reason(const char *reason, int timeout); int display_plugin_display_off_by_reason(const char *reason); +int display_plugin_set_power_save_mode_flag(int onoff); +int display_plugin_is_lcd_on_blocked(void); int display_plugin_backlight_get_lcd_power(void); int display_plugin_backlight_set_brightness(int brightness); diff --git a/src/display/display.c b/src/display/display.c index 157da0f..561571a 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -215,6 +215,9 @@ int display_get_display_ops_status(enum device_ops_status *dev_ops_status) void display_set_power_save_mode_flag(int onoff) { + if (display_plugin_set_power_save_mode_flag(onoff) == 0) + return; + if (onoff) set_pm_status_flag(PWRSV_FLAG); else diff --git a/src/display/plugin-common/display-dbus.c b/src/display/plugin-common/display-dbus.c index 69840fa..42c07f1 100644 --- a/src/display/plugin-common/display-dbus.c +++ b/src/display/plugin-common/display-dbus.c @@ -827,13 +827,11 @@ static GVariant *dbus_lockscreenbgon(GDBusConnection *conn, g_variant_get(param, "(s)", &on); - if (!strcmp(on, "true")) { - if (disp_plgn->update_pm_setting) - disp_plgn->update_pm_setting(SETTING_LOCK_SCREEN_BG, true); - } else if (!strcmp(on, "false")) { - if (disp_plgn->update_pm_setting) - disp_plgn->update_pm_setting(SETTING_LOCK_SCREEN_BG, false); - } else + if (!strcmp(on, "true")) + display_setting_update_pm_setting(SETTING_LOCK_SCREEN_BG, true); + else if (!strcmp(on, "false")) + display_setting_update_pm_setting(SETTING_LOCK_SCREEN_BG, false); + else ret = -EINVAL; g_free(on); diff --git a/src/display/setting.c b/src/display/setting.c index e652a9c..d697d2a 100644 --- a/src/display/setting.c +++ b/src/display/setting.c @@ -24,9 +24,14 @@ #include "ambient-mode.h" #include "core.h" +#include "device-interface.h" #include "util.h" #include "setting.h" +#include "display-misc.h" #include "display-ops.h" +#include "display-plugin.h" +#include "display-state-transition.h" +#include "led/touch-key.h" #include "shared/eventsystem.h" #include "shared/plugin.h" @@ -240,12 +245,107 @@ static int setting_cb(keynode_t *key_nodes, void *data) vconf_keynode_get_name(tmp), index); return -1; } - if (disp_plgn->update_pm_setting) - disp_plgn->update_pm_setting(index, vconf_keynode_get_int(tmp)); + display_setting_update_pm_setting(index, vconf_keynode_get_int(tmp)); + + return 0; +} + +int display_setting_update_pm_setting(int key_idx, int val) +{ + int ret; + + if (display_plugin_is_there_update_pm_setting()) + return display_plugin_update_pm_setting(key_idx, val); + + switch (key_idx) { + case SETTING_TO_NORMAL: + display_state_transition_update_display_state_timeout_by_priority(); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); + break; + case SETTING_LOW_BATT: + if (display_misc_is_low_battery_state(val)) { + if (!(get_pm_status_flag() & CHRGR_FLAG)) + display_set_power_save_mode_flag(true); + set_pm_status_flag(LOWBT_FLAG); + } else { + if (get_pm_status_flag() & PWRSV_FLAG) + display_set_power_save_mode_flag(false); + clear_pm_status_flag(LOWBT_FLAG); + clear_pm_status_flag(BRTCH_FLAG); + ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, false); + if (ret < 0) + _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno()); + } + break; + case SETTING_CHARGING: + if (val) { + if (get_pm_status_flag() & LOWBT_FLAG) { + display_set_power_save_mode_flag(false); + clear_pm_status_flag(LOWBT_FLAG); + } + set_pm_status_flag(CHRGR_FLAG); + } else { + int bat_state; + ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, + &bat_state); + if (ret < 0) { + bat_state = VCONFKEY_SYSMAN_BAT_NORMAL; + _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno()); + } + if (display_misc_is_low_battery_state(bat_state)) { + display_set_power_save_mode_flag(true); + set_pm_status_flag(LOWBT_FLAG); + } + clear_pm_status_flag(CHRGR_FLAG); + } + break; + case SETTING_BRT_LEVEL: + if (get_pm_status_flag() & PWRSV_FLAG) { + set_pm_status_flag(BRTCH_FLAG); + ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, true); + if (ret < 0) + _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno()); + _I("Brightness changed in low battery," + "escape dim state."); + } + display_backlight_set_default_brightness(val); + break; + case SETTING_LOCK_SCREEN: + set_lock_screen_state(val); + if (val == VCONFKEY_IDLE_UNLOCK) + touchled_control_backlight(TOUCHLED_DIRECT_OFF); + + /* LCD on if lock screen show before waiting time */ + if ((get_pm_cur_state() == S_NORMAL) && + val == VCONFKEY_IDLE_LOCK && + display_panel_get_dpms_cached_state() != DPMS_ON && + display_plugin_is_lcd_on_blocked() == LCDON_BLOCK_NONE) + display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); + display_state_transition_update_display_state_timeout_by_priority(); + if (get_pm_cur_state() == S_NORMAL) + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); + break; + case SETTING_LOCK_SCREEN_BG: + set_lock_screen_bg_state(val); + display_state_transition_update_display_state_timeout_by_priority(); + if (get_pm_cur_state() == S_NORMAL) + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); + break; + case SETTING_POWER_CUSTOM_BRIGHTNESS: + if (val == VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON) + display_backlight_set_custom_status(true); + else + display_backlight_set_custom_status(false); + break; + + default: + return -1; + } return 0; } +/* FIXME: update_pm_setting functions initalization should be changed after relocation work */ int init_setting(int (*func) (int key_idx, int val)) { int i; diff --git a/src/display/setting.h b/src/display/setting.h index 077f505..e8e5ab7 100644 --- a/src/display/setting.h +++ b/src/display/setting.h @@ -46,7 +46,7 @@ enum { SETTING_END }; -extern int (*update_pm_setting) (int key_idx, int val); +int display_setting_update_pm_setting(int key_idx, int val); int set_force_lcdtimeout(int timeout); int get_setting_brightness(int *level); -- 2.7.4