display: Use plugin-api on detecting setting value update 56/312256/3
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 5 Jun 2024 06:55:19 +0000 (15:55 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Wed, 12 Jun 2024 11:23:27 +0000 (20:23 +0900)
Plugin can now receive occurance of setting value change via plugin
interface operation, on_changed_setting_value(), so the plugin can
hook the event and handle it based on its own policy. If the plugin
haven't implemented the operation, deviced handle it in a default way.

Change-Id: I3bc4b3bd3fe35a78b2c29a9603f3040b103e0c99
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/wearable/display/core.c
src/display/display-plugin.c
src/display/display-plugin.h
src/display/setting.c

index 508ffe91617d4d3209d34508a143b243bb7b3801..564b556b2c8b6d0a4feb46a206b40e89609daddc 100644 (file)
@@ -806,6 +806,12 @@ static void default_saving_mode(int onoff)
        }
 }
 
+/**
+ * FIXME: It is currently not being used.
+ *   Move it to plugin git, platform/core/system/plugin/deviced-wearable,
+ *   and register it as plugin operation through plugin interface. Or remove it
+ *   if it won't be used anymore.
+ */
 static int update_setting(int key_idx, int val)
 {
        int ret;
index 8f65f35acb081fe5c286199bde3839f4deb51def..80ab847eb97945ed7f776878b77c80430a61374c 100644 (file)
 
 struct display_plugin g_display_plugin;
 
-int display_plugin_update_pm_setting(int key_idx, int val)
-{
-       if (g_display_plugin.update_pm_setting)
-               return g_display_plugin.update_pm_setting(key_idx, 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)
 {
index ea3856d7462b9e0a3044735d6ec6b6859b11d227..5efce066d794ddd14271932f83356c55a1605201 100644 (file)
@@ -55,7 +55,6 @@ enum brightness_request_e {
 #define BR_IMPLICIT            (-1)
 
 struct display_plugin {
-       int (*update_pm_setting) (int key_idx, int val);
        int (*get_lock_screen_state) (void);
        bool system_wakeup_flag;
        int (*auto_brightness_control) (enum brightness_request_e request, int set_brightness);
@@ -80,8 +79,6 @@ struct display_plugin {
 };
 extern struct display_plugin g_display_plugin;
 
-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);
index 04a31aa165556554c8c24823b6617e83c4351dbb..a8deaaf465dc75a0cbce25e7b7e0ad4645d9703e 100644 (file)
@@ -57,8 +57,6 @@ static int custom_normal_timeout = 0;
 static int custom_dim_timeout = 0;
 static int exclusive_dim_timeout = EXCLUSIVE_DIM_TIMEOUT_UNSET;
 
-int (*update_pm_setting) (int key_idx, int val);
-
 static gboolean display_state_send_system_event(gpointer data)
 {
        const char *str;
@@ -280,13 +278,23 @@ static int setting_cb(keynode_t *key_nodes, void *data)
        return 0;
 }
 
+/**
+ * FIXME:
+ *  Those key_idx not related to setting app should be removed
+ *  and be handled in another function. This function is only for
+ *  detecting events controlling device from setting app.
+ */
 int display_setting_update_pm_setting(int key_idx, int val)
 {
        int ret;
        enum syscommon_deviced_display_state current;
 
-       if (display_plugin_is_there_update_pm_setting())
-               return display_plugin_update_pm_setting(key_idx, val);
+       ret = syscommon_plugin_deviced_display_notify_setting_value_changed(key_idx, val);
+       if (ret == 0)
+               return 0;
+
+       if (ret != -EOPNOTSUPP)
+               return ret;
 
        ret = display_state_get_current(&current);
        if (ret < 0)
@@ -383,14 +391,10 @@ int display_setting_update_pm_setting(int key_idx, int val)
        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;
 
-       if (func != NULL)
-               disp_plgn->update_pm_setting = func;
-
        for (i = SETTING_BEGIN; i < SETTING_GET_END; i++) {
                /*
                 * To pass an index data through the vconf infratstructure