display: headed: Add set_lcdoff_reason() 15/297515/2
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 21 Aug 2023 07:45:30 +0000 (16:45 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 21 Aug 2023 07:50:50 +0000 (16:50 +0900)
It is copy of display_state_transition_update_lcdoff_reason() of the
src/display/display-state-transition.c. Its operation is not related
to the display core but just related to vconf API. It remove dependency
to the core display-state-transition.h.

Change-Id: I26e630ca7e61d8dcb8f45b48715d0170fc8684fb
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/iot-headed/display/key-filter.c

index ef86c4ff0b5ee88bba54df5527b50fedd601ee45..b011d5afb58973021998c439602f23d344831ff8 100644 (file)
@@ -34,7 +34,6 @@
 #include "display-actor.h"
 #include "display-config.h"
 #include "display-misc.h"
-#include "display-state-transition.h"
 #include <libsyscommon/log.h>
 #include "display-lock.h"
 #include "input/input.h"
@@ -118,6 +117,29 @@ static inline void restore_custom_brightness(void)
                        DEVICED_DISPLAY_ATTR_INT_CUSTOM_BRIGHTNESS, true);
 }
 
+static int set_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;
+}
+
 static void pwroff_popup(void)
 {
        int ret;
@@ -417,7 +439,7 @@ static int lcdoff_powerkey(void)
                switch_off_lcd();
                display_lock_release_lock_all(SYSCOMMON_DEVICED_DISPLAY_STATE_ON);
                display_lock_release_lock_all(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM);
-               display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY);
+               set_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY);
                syscommon_resman_set_resource_attr_uint64_2(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
                        DEVICED_DISPLAY_ATTR_TUPLE2_SET_CURRENT_STATE,
                        SYSCOMMON_DEVICED_DISPLAY_STATE_OFF, DEVICED_EVENT_INPUT_POWERKEY);
@@ -527,7 +549,7 @@ static int process_screenlock_key(struct input_event *pinput)
 
        display_lock_release_lock_all(SYSCOMMON_DEVICED_DISPLAY_STATE_ON);
        display_lock_release_lock_all(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM);
-       display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY);
+       set_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY);
 
        /* LCD off forcly */
        syscommon_resman_set_resource_attr_uint64_2(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),