display: state-transition: Relocate update_lcdoff_source() 78/293878/4
authorYunhee Seo <yuni.seo@samsung.com>
Wed, 7 Jun 2023 08:34:39 +0000 (17:34 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Thu, 8 Jun 2023 08:25:45 +0000 (17:25 +0900)
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 <yuni.seo@samsung.com>
12 files changed:
plugins/iot-headed/display/core.c
plugins/iot-headed/display/key-filter.c
plugins/mobile/display/core.c
plugins/mobile/display/key-filter.c
plugins/tv/display/core.c
plugins/tv/display/key-filter.c
plugins/wearable/display/core.c
plugins/wearable/display/key-filter.c
src/display/core.h
src/display/display-state-transition.c
src/display/display-state-transition.h
src/display/plugin-common/display-dbus.c

index fcbafea..b1c68b1 100644 (file)
@@ -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)
index b8ef405..5361e0e 100644 (file)
@@ -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)
index 9545fac..464d3d4 100644 (file)
@@ -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)
index 180262d..65a0de2 100644 (file)
@@ -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)
index 49e70e3..b986639 100644 (file)
@@ -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)
index 64628d6..6a44187 100644 (file)
@@ -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)
index b0a7d33..9e61e52 100644 (file)
@@ -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)
index 8c1bd60..2658612 100644 (file)
@@ -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)
index ae7ea33..6a11082 100644 (file)
@@ -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);
index 126d77b..bc06af4 100644 (file)
@@ -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
index caed462..7193a7f 100644 (file)
@@ -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
index 78fb314..24eb2ff 100644 (file)
@@ -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);