display: Add lockscreen attribute and replace existing plugin call 70/312270/3
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 5 Jun 2024 10:47:56 +0000 (19:47 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Wed, 12 Jun 2024 11:23:30 +0000 (20:23 +0900)
The lockscreen is solely controlled by the deviced itself, not by any of
plugins. Therefore the lockscreen getter doesn't need to call plugin
api for asking lockscreen state. Rather, display resource driver should
manage the lockscreen state, offering it via resource-manager getter to
plugins.

Change-Id: I9b956294f8e577925044cc837e1279eb843b685d
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/mobile/display/key-filter.c
plugins/tv/display/key-filter.c
src/display/display-misc.c
src/display/display-plugin.c
src/display/display-plugin.h
src/display/display-state-transition.c
src/display/resource-display.c
src/display/setting.c
src/display/setting.h
src/led/touch-key.c

index 01f787aec5d5127a462b255517918dd0ac23dd4d..0cd688b1bd6fec60232d393813b5e6917825160c 100644 (file)
@@ -574,17 +574,24 @@ static void sound_vibrate_hardkey(void)
 
 static void process_hardkey_backlight(struct input_event *pinput)
 {
-       _E("pinput->value : %d", pinput->value);
+       int lockscreen_state = VCONFKEY_IDLE_UNLOCK;
+
+       _D("pinput->value : %d", pinput->value);
+
+       syscommon_resman_get_resource_attr_int(
+               SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+               DEVICED_DISPLAY_ATTR_INT_LOCKSCREEN_STATE, &lockscreen_state);
+
        if (pinput->value == KEY_PRESSED) {
                /* Sound & Vibrate only in unlock state */
-               if (__get_lock_screen_state() == VCONFKEY_IDLE_UNLOCK
+               if (lockscreen_state == VCONFKEY_IDLE_UNLOCK
                    || get_lock_screen_bg_state())
                        sound_vibrate_hardkey();
 
                touchled_control_backlight(TOUCHLED_PRESS);
        } else if (pinput->value == KEY_RELEASED) {
                /* if lockscreen is idle lock */
-               if (__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) {
+               if (lockscreen_state == VCONFKEY_IDLE_LOCK) {
                        _D("Lock state, key backlight is off when phone is unlocked!");
                        return;
                }
index 0ec50c812dd1d15088dea70ca2df934ef47c5cd3..21883e80b2dc6a3279791bb70cd5e6ee523585ed 100644 (file)
@@ -542,17 +542,24 @@ static void sound_vibrate_hardkey(void)
 
 static void process_hardkey_backlight(struct input_event *pinput)
 {
-       _E("pinput->value : %d", pinput->value);
+       int lockscreen_state = VCONFKEY_IDLE_UNLOCK;
+
+       _D("pinput->value : %d", pinput->value);
+
+       syscommon_resman_get_resource_attr_int(
+               SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+               DEVICED_DISPLAY_ATTR_INT_LOCKSCREEN_STATE, &lockscreen_state);
+
        if (pinput->value == KEY_PRESSED) {
                /* Sound & Vibrate only in unlock state */
-               if (__get_lock_screen_state() == VCONFKEY_IDLE_UNLOCK
+               if (lockscreen_state == VCONFKEY_IDLE_UNLOCK
                    || get_lock_screen_bg_state())
                        sound_vibrate_hardkey();
 
                touchled_control_backlight(TOUCHLED_PRESS);
        } else if (pinput->value == KEY_RELEASED) {
                /* if lockscreen is idle lock */
-               if (__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) {
+               if (lockscreen_state == VCONFKEY_IDLE_LOCK) {
                        _D("Lock state, key backlight is off when phone is unlocked!");
                        return;
                }
index 4d8b6085369d2da9194f9c245e0784578275caf8..bcfbba7904a66376b94fac35918d55ccb7583549 100644 (file)
@@ -239,9 +239,8 @@ void display_misc_save_display_log(const char *path)
                if (ret < 0)
                        _E("write() failed (%d)", errno);
 
-               /* FIXME: display_plugin_get_lock_screen_state should be checked return value after modification */
                snprintf(buf, sizeof(buf), "screen lock status : %d\n",
-                       display_plugin_get_lock_screen_state());
+                       get_lock_screen_state());
                ret = write(fd, buf, strlen(buf));
                if (ret < 0)
                        _E("write() failed (%d)", errno);
index 80ab847eb97945ed7f776878b77c80430a61374c..f53190a3f9f227278e34c9324f4dcf4c3cf2c7ac 100644 (file)
 
 struct display_plugin g_display_plugin;
 
-/* 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)
-{
-       if (g_display_plugin.get_lock_screen_state)
-               return g_display_plugin.get_lock_screen_state();
-
-       return 0;
-}
-
 int display_plugin_get_system_wakeup_flag(bool *flag)
 {
        *flag = g_display_plugin.system_wakeup_flag;
index 5efce066d794ddd14271932f83356c55a1605201..c289904ff66691fd8817e5db100f388380db9787 100644 (file)
@@ -55,7 +55,6 @@ enum brightness_request_e {
 #define BR_IMPLICIT            (-1)
 
 struct display_plugin {
-       int (*get_lock_screen_state) (void);
        bool system_wakeup_flag;
        int (*auto_brightness_control) (enum brightness_request_e request, int set_brightness);
        /* FIXME: function names will be redefined */
@@ -79,7 +78,6 @@ struct display_plugin {
 };
 extern struct display_plugin g_display_plugin;
 
-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);
 int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness);
index 64176e5ffb06bb1624fb01b22e11987368d67499..0d9401d9be215003e98dfa0f4783f32cc1b24b2f 100644 (file)
@@ -454,7 +454,7 @@ void display_state_transition_update_display_state_timeout_by_priority(void)
        }
 
        /* second priority : lock state */
-       if ((__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) &&
+       if ((get_lock_screen_state() == VCONFKEY_IDLE_LOCK) &&
            !get_lock_screen_bg_state()) {
                /* timeout is different according to key or event. */
                display_plugin_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, lock_screen_timeout);
@@ -557,7 +557,7 @@ bool display_state_transition_is_possible_to_go_lcdoff(void)
        if (!dimming)
                return true;
 
-       lock = __get_lock_screen_state();
+       lock = get_lock_screen_state();
        if (lock != VCONFKEY_IDLE_LOCK)
                return false;
 
index 3945efb15fa70c02cc9fc215494d7bfd9f8d6cc0..72ee0f30b7905751a07dc9bff293700f6f2678e7 100644 (file)
@@ -329,6 +329,9 @@ static int get_display_attr_data(int resource_id,
                else
                        attr_data.i32 = g_display_plugin.config->touch_wakeup;
                break;
+       case DEVICED_DISPLAY_ATTR_INT_LOCKSCREEN_STATE:
+                       attr_data.i32 = get_lock_screen_state();
+               break;
        default:
                ret = -EINVAL;
                break;
@@ -547,6 +550,15 @@ static const struct syscommon_resman_resource_attribute display_attrs[] = {
                        .set_3_tuple = set_tuple3_display_attr_data,
                        .is_supported = syscommon_resman_resource_attr_supported_always,
                },
+       }, {
+               .name = "DEVICED_DISPLAY_ATTR_INT_LOCKSCREEN_STATE",
+               .id = DEVICED_DISPLAY_ATTR_INT_LOCKSCREEN_STATE,
+               .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+               .flag = SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC,
+               .ops = {
+                       .get = get_display_attr_data,
+                       .is_supported = syscommon_resman_resource_attr_supported_always,
+               },
        }
 };
 
index a8deaaf465dc75a0cbce25e7b7e0ad4645d9703e..b77f92d38d139d852b43a15e2866122692a5fbe7 100644 (file)
@@ -98,7 +98,7 @@ int set_force_lcdtimeout(int timeout)
        return 0;
 }
 
-int __get_lock_screen_state(void)
+int get_lock_screen_state(void)
 {
        return lock_screen_state;
 }
@@ -405,8 +405,6 @@ int init_setting(int (*func) (int key_idx, int val))
                                         (void *)((intptr_t)i));
        }
 
-       disp_plgn->get_lock_screen_state = __get_lock_screen_state;
-
        return 0;
 }
 
index 39bf8b3660bf434b7f2c8fc927763b67b972fc58..4c0f914d75d4ea4f4dc09f6b5201f97d3ae3905a 100644 (file)
@@ -110,7 +110,7 @@ extern int set_setting_pmstate(int val);
 extern int get_lowbatt_status(int *val);
 
 //FIXME
-int __get_lock_screen_state(void);
+int get_lock_screen_state(void);
 
 /*
  * @}
index c6195a90804323318ba0afceaa25ab906729257b..b6f7f8eb06f910aa9693dbb81538fe6568244ee1 100644 (file)
@@ -21,6 +21,8 @@
 #include <vconf.h>
 #include <hal/device/hal-led.h>
 #include <libsyscommon/libgdbus.h>
+#include <libsyscommon/resource-manager.h>
+#include <system/syscommon-plugin-deviced-display-interface.h>
 
 #include "core/log.h"
 #include "shared/devices.h"
@@ -125,6 +127,8 @@ static void process_touchkey_release(void)
 
 static void process_touchkey_enable(bool enable)
 {
+       int lockscreen_state = VCONFKEY_IDLE_UNLOCK;
+
        /* release existing timer */
        if (hardkey_timeout_id > 0) {
                g_source_remove(hardkey_timeout_id);
@@ -141,7 +145,10 @@ static void process_touchkey_enable(bool enable)
                touchled_set_state(true);
 
                /* do not create turnoff timer in case of idle lock state */
-               if (display_plugin_get_lock_screen_state() == VCONFKEY_IDLE_LOCK)
+               syscommon_resman_get_resource_attr_int(
+                       SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+                       DEVICED_DISPLAY_ATTR_INT_LOCKSCREEN_STATE, &lockscreen_state);
+               if (lockscreen_state == VCONFKEY_IDLE_LOCK)
                        return;
 
                /* start timer */