From: Yunhee Seo Date: Wed, 7 Jun 2023 08:34:39 +0000 (+0900) Subject: display: state-transition: Relocate update_lcdoff_source() X-Git-Tag: accepted/tizen/unified/dev/20230726.115933~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78d970139203c91f225e2afcc52151777fab6136;p=platform%2Fcore%2Fsystem%2Fdeviced.git display: state-transition: Relocate update_lcdoff_source() update_lcdoff_source() is used for setting lcdoff reason. This function is called when the display state goes to lcdoff state. Same code was copied and used in all plugins. Thus, this function is added below display-state-transition int display_state_transition_update_lcdoff_reason(int source); -> This function sets the lcdoff reason to VCONFKEY_PM_LCDOFF_SOURCE. Change-Id: Idc857d4b52502612eaccb01373d984815806a153 Signed-off-by: Yunhee Seo --- diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index fcbafea..b1c68b1 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -714,26 +714,6 @@ static int proc_condition(PMMsg *data) return 0; } -void update_lcdoff_source(int source) -{ - int ret; - - switch (source) { - case VCONFKEY_PM_LCDOFF_BY_TIMEOUT: - _I("LCD OFF by timeout."); - break; - case VCONFKEY_PM_LCDOFF_BY_POWERKEY: - _I("LCD OFF by powerkey."); - break; - default: - _E("Invalid value(%d).", source); - return; - } - ret = vconf_set_int(VCONFKEY_PM_LCDOFF_SOURCE, source); - if (ret < 0) - _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno()); -} - /* SIGHUP signal handler * For debug... print info to syslog */ @@ -808,7 +788,7 @@ static int default_trans(int evt) /* enter action */ if (st->action) { if (get_pm_cur_state() == S_LCDOFF) - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index b8ef405..5361e0e 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" +#include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" #include "shared/device-notifier.h" @@ -394,7 +395,7 @@ static int lcdoff_powerkey(void) switch_off_lcd(); delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); } @@ -508,7 +509,7 @@ static int process_screenlock_key(struct input_event *pinput) if (!check_holdkey_block(S_NORMAL) && !check_holdkey_block(S_LCDDIM)) { delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ if (disp_plgn->pm_change_internal) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 9545fac..464d3d4 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -724,26 +724,6 @@ static int proc_condition(PMMsg *data) return 0; } -void update_lcdoff_source(int source) -{ - int ret; - - switch (source) { - case VCONFKEY_PM_LCDOFF_BY_TIMEOUT: - _I("LCD OFF by timeout."); - break; - case VCONFKEY_PM_LCDOFF_BY_POWERKEY: - _I("LCD OFF by powerkey."); - break; - default: - _E("Invalid value(%d).", source); - return; - } - ret = vconf_set_int(VCONFKEY_PM_LCDOFF_SOURCE, source); - if (ret < 0) - _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno()); -} - /* SIGHUP signal handler * For debug... print info to syslog */ @@ -818,7 +798,7 @@ static int default_trans(int evt) /* enter action */ if (st->action) { if (get_pm_cur_state() == S_LCDOFF) - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 180262d..65a0de2 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" +#include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" #include "shared/device-notifier.h" @@ -384,7 +385,7 @@ static int lcdoff_powerkey(void) switch_off_lcd(); delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); } @@ -541,7 +542,7 @@ static int process_screenlock_key(struct input_event *pinput) if (!check_holdkey_block(S_NORMAL) && !check_holdkey_block(S_LCDDIM)) { delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ if (disp_plgn->pm_change_internal) diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 49e70e3..b986639 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -714,26 +714,6 @@ static int proc_condition(PMMsg *data) return 0; } -void update_lcdoff_source(int source) -{ - int ret; - - switch (source) { - case VCONFKEY_PM_LCDOFF_BY_TIMEOUT: - _I("LCD OFF by timeout."); - break; - case VCONFKEY_PM_LCDOFF_BY_POWERKEY: - _I("LCD OFF by powerkey."); - break; - default: - _E("Invalid value(%d).", source); - return; - } - ret = vconf_set_int(VCONFKEY_PM_LCDOFF_SOURCE, source); - if (ret < 0) - _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno()); -} - /* SIGHUP signal handler * For debug... print info to syslog */ @@ -808,7 +788,7 @@ static int default_trans(int evt) /* enter action */ if (st->action) { if (get_pm_cur_state() == S_LCDOFF) - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index 64628d6..6a44187 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" +#include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" #include "shared/device-notifier.h" @@ -394,7 +395,7 @@ static int lcdoff_powerkey(void) switch_off_lcd(); delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); } @@ -508,7 +509,7 @@ static int process_screenlock_key(struct input_event *pinput) if (!check_holdkey_block(S_NORMAL) && !check_holdkey_block(S_LCDDIM)) { delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ if (disp_plgn->pm_change_internal) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index b0a7d33..9e61e52 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1049,26 +1049,6 @@ static int proc_condition(PMMsg *data) return 0; } -void update_lcdoff_source(int source) -{ - int ret; - - switch (source) { - case VCONFKEY_PM_LCDOFF_BY_TIMEOUT: - _I("LCD OFF by timeout."); - break; - case VCONFKEY_PM_LCDOFF_BY_POWERKEY: - _I("LCD OFF by powerkey."); - break; - default: - _E("Invalid value(%d).", source); - return; - } - ret = vconf_set_int(VCONFKEY_PM_LCDOFF_SOURCE, source); - if (ret < 0) - _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno()); -} - /* SIGHUP signal handler * For debug... print info to syslog */ @@ -1151,7 +1131,7 @@ static int default_trans(int evt) /* enter action */ if (st->action) { if (get_pm_cur_state() == S_LCDOFF) - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 8c1bd60..2658612 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-panel.h" #include "display-backlight.h" #include "display-config.h" +#include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" #include "shared/device-notifier.h" @@ -391,7 +392,7 @@ static int lcdoff_powerkey(void) switch_off_lcd(); delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); } @@ -505,7 +506,7 @@ static int process_screenlock_key(struct input_event *pinput) if (!check_holdkey_block(S_NORMAL) && !check_holdkey_block(S_LCDDIM)) { delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ if (disp_plgn->pm_change_internal) diff --git a/src/display/core.h b/src/display/core.h index ae7ea33..6a11082 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -125,7 +125,6 @@ int delete_condition(enum state_t state); int custom_lcdoff(enum device_flags flag); int display_on_by_reason(const char *reason, int timeout); int display_off_by_reason(const char *reason); -void update_lcdoff_source(int source); int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name); int custom_lcdon(int timeout); void lcd_on_direct(enum device_flags flags); diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index 126d77b..bc06af4 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -280,4 +280,28 @@ int display_state_transition_check_state_transition_condition(enum state_t cur_s } return 0; /* transitable */ +} + +int display_state_transition_update_lcdoff_reason(int source) +{ + int ret; + + switch (source) { + case VCONFKEY_PM_LCDOFF_BY_TIMEOUT: + _I("LCD OFF by timeout."); + break; + case VCONFKEY_PM_LCDOFF_BY_POWERKEY: + _I("LCD OFF by powerkey."); + break; + default: + _E("Invalid value(%d).", source); + return -EINVAL; + } + ret = vconf_set_int(VCONFKEY_PM_LCDOFF_SOURCE, source); + if (ret < 0) { + _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno()); + return -EPERM; + } + + return 0; } \ No newline at end of file diff --git a/src/display/display-state-transition.h b/src/display/display-state-transition.h index caed462..7193a7f 100644 --- a/src/display/display-state-transition.h +++ b/src/display/display-state-transition.h @@ -38,5 +38,6 @@ int display_state_transition_set_lock_screen_timeout(int timeout); int display_state_transition_get_lock_screen_timeout(int *timeout); void display_state_transition_update_display_state_timeout_by_priority(void); int display_state_transition_check_state_transition_condition(enum state_t cur_state, enum state_t next_state); +int display_state_transition_update_lcdoff_reason(int source); #endif /* __DISPLAY_STATE_TRANSITION_H__ */ \ No newline at end of file diff --git a/src/display/plugin-common/display-dbus.c b/src/display/plugin-common/display-dbus.c index 78fb314..24eb2ff 100644 --- a/src/display/plugin-common/display-dbus.c +++ b/src/display/plugin-common/display-dbus.c @@ -47,6 +47,7 @@ #include "display-lock.h" #include "display-panel.h" #include "display-config.h" +#include "display-state-transition.h" //#include "display/display.h" #include "display-backlight.h" #include "display-misc.h" @@ -361,7 +362,7 @@ static GVariant *dbus_changestate(GDBusConnection *conn, ret = disp_plgn->pm_change_internal(pid, state); if (!ret && state == LCD_OFF) - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); out: g_free(state_str); return g_variant_new("(i)", ret);