power: Move convert_action_string_to_power_state() to plugin-api-deviced 73/297373/3
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 17 Aug 2023 10:46:28 +0000 (19:46 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 18 Aug 2023 00:59:21 +0000 (09:59 +0900)
convert_action_string_to_power_state() is used on both deviced
and deviced-plugin-backend. So that move it to plugin-api-deviced
package in libsyscommon.

Change-Id: I2809e7a85a51339beb673782c0aae12e8f2e3da6
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
plugins/iot-headless/input/input-config.c
src/power/power-boot.c
src/power/power.h

index edbcfd5..2e7f753 100644 (file)
@@ -25,6 +25,7 @@
 #include <libsyscommon/list.h>
 #include <libsyscommon/log.h>
 #include <system/syscommon-plugin-deviced-common-interface.h>
+#include <system/syscommon-plugin-deviced-power-interface.h>
 
 #include <linux/input.h>
 
@@ -137,8 +138,8 @@ static void add_action_transition_info(struct input_event_unit *ieu, char *curr,
         * Otherwise, ieu->id won't be defined at this point.*/
        ti->reason = ieu->id;
 
-       ti->curr = convert_action_string_to_power_state(curr);
-       ti->next = convert_action_string_to_power_state(next);
+       ti->curr = syscommon_plugin_deviced_power_convert_to_power_state(curr);
+       ti->next = syscommon_plugin_deviced_power_convert_to_power_state(next);
 
        SYS_G_LIST_APPEND(*action_list, ti);
 }
index 6bbceab..c59edd4 100644 (file)
@@ -25,6 +25,7 @@
 #include <libsyscommon/list.h>
 #include <libsyscommon/file.h>
 #include <libsyscommon/ini-parser.h>
+#include <system/syscommon-plugin-deviced-power-interface.h>
 #include <hal/device/hal-board.h>
 
 #include "core/log.h"
@@ -130,8 +131,8 @@ static void parse_transition_info(const char *action)
        char next[16] = { 0, };
 
        if (sscanf(action, "%15[^,],%15s", curr, next) == 2) {
-               init_ti.curr = convert_action_string_to_power_state(curr);
-               init_ti.next = convert_action_string_to_power_state(next);
+               init_ti.curr = syscommon_plugin_deviced_power_convert_to_power_state(curr);
+               init_ti.next = syscommon_plugin_deviced_power_convert_to_power_state(next);
        }
 }
 
index b174d5a..640ed43 100644 (file)
@@ -37,26 +37,6 @@ struct trans_info {
 
 void power_state_manager_init(void *data);
 
-static inline uint64_t convert_action_string_to_power_state(const char *str)
-{
-       if (MATCH(str, "start"))
-               return DEVICED_POWER_STATE_START;
-       else if (MATCH(str, "sleep"))
-               return DEVICED_POWER_STATE_SLEEP;
-       else if (MATCH(str, "normal"))
-               return DEVICED_POWER_STATE_NORMAL;
-       else if (MATCH(str, "poweroff"))
-               return DEVICED_POWER_STATE_POWEROFF;
-       else if (MATCH(str, "reboot"))
-               return DEVICED_POWER_STATE_REBOOT;
-       else if (MATCH(str, "exit"))
-               return DEVICED_POWER_STATE_EXIT;
-       else if (MATCH(str, "current"))
-               return DEVICED_POWER_STATE_ALL;
-
-       return DEVICED_POWER_STATE_UNDEFINED;
-}
-
 static inline const char *state_name(uint64_t state)
 {
        if (state == DEVICED_POWER_STATE_START)