shared: Replace is_emulator() with syscommon_is_emulator() 83/296283/2
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 24 Jul 2023 12:43:36 +0000 (21:43 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 25 Jul 2023 01:42:29 +0000 (10:42 +0900)
Change-Id: I4ee8746942fbc9f3a223bb5d3867f774a2ce5a52
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/wearable/display/core.c
src/battery/lowbat-handler.c
src/display/ambient-mode.c
src/display/display-state-transition.c
src/shared/common.c
src/shared/common.h
src/usb-gadget/usb-gadget-ops.c

index 7f8b507..53a183e 100644 (file)
@@ -40,6 +40,7 @@
 #include <vconf-keys.h>
 #include <sys/time.h>
 #include <libsyscommon/list.h>
+#include <libsyscommon/common.h>
 #include <hal/device/hal-device-power.h>
 
 #include "shared/log.h"
@@ -641,7 +642,7 @@ static int default_trans(int evt)
                        states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
                } else {
                        if ((get_pm_cur_state() == S_SLEEP)
-                       && (is_emulator() == true || timeout_sleep_support == false))
+                       && (syscommon_is_emulator() == true || timeout_sleep_support == false))
                                return 0;
 
                        st->action(st->timeout);
index 0e2bec2..9010c68 100644 (file)
@@ -27,6 +27,7 @@
 #include <hal/device/hal-battery.h>
 #include <libsyscommon/libgdbus.h>
 #include <libsyscommon/list.h>
+#include <libsyscommon/common.h>
 
 #include "lowbat-handler.h"
 #include "battery-ops.h"
@@ -152,7 +153,7 @@ static int lowbat_add_scenario(int old, int now, int (*func)(void *data))
 
 static int power_execute(int state)
 {
-       if (is_emulator()) {
+       if (syscommon_is_emulator()) {
                CRITICAL_LOG("Poweroff by lowbattery is disabled at emulator.");
                return 0;
        }
index 7c56b8a..8c99049 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdbool.h>
 #include <fcntl.h>
 #include <libsyscommon/libgdbus.h>
+#include <libsyscommon/common.h>
 
 #include "core.h"
 #include "display.h"
@@ -137,7 +138,7 @@ void ambient_check_invalid_state(pid_t pid)
        if (pid != INTERNAL_LOCK_AMBIENT)
                return;
 
-       if (is_emulator()) {
+       if (syscommon_is_emulator()) {
                /* In emulator, deviced does not turn off the display. */
                if (display_panel_get_dpms_cached_state() == DPMS_ON)
                        return;
index 83a4c26..5cd94c7 100644 (file)
@@ -21,6 +21,7 @@
  * @brief      This file has functions related to display state transition
  */
 
+#include <libsyscommon/common.h>
 #include "shared/log.h"
 #include "core/udev.h"
 #include "device-interface.h"
@@ -111,7 +112,7 @@ int display_state_transition_reset_state_transition_timeout(int timeout)
                return -EPERM;
 
        if ((get_pm_cur_state() == S_LCDOFF)
-       && (is_emulator() == true || timeout_sleep_support == false))
+       && (syscommon_is_emulator() == true || timeout_sleep_support == false))
                return -EPERM;
 
        _I("Reset timeout(%d ms) pm_cur_state(%d).", timeout, get_pm_cur_state());
@@ -382,7 +383,7 @@ int display_state_transition_do_state_transition(enum state_t state, int evt_typ
                        display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_TIMEOUT);
                } else {
                        if ((get_pm_cur_state() == S_SLEEP) &&
-                       (is_emulator() == true || timeout_sleep_support == false))
+                       (syscommon_is_emulator() == true || timeout_sleep_support == false))
                                return 0;
 
                        display_plugin_state_get_timeout(get_pm_cur_state(), &timeout);
@@ -663,4 +664,4 @@ int display_state_transition_request_state_transition_with_option(pid_t pid, int
        display_state_transition_do_state_transition_by_pm_control_event(&recv_data);
 
        return 0;
-}
\ No newline at end of file
+}
index 314b510..fc4846e 100644 (file)
@@ -33,7 +33,6 @@
 #include <stdarg.h>
 #include <errno.h>
 #include <poll.h>
-#include <system_info.h>
 #include "log.h"
 #include "common.h"
 
@@ -53,34 +52,6 @@ int get_systemd_reboot_param(char *buf, unsigned bufsize)
        return r;
 }
 
-#define MODEL_NAME      "http://tizen.org/system/model_name"
-#define MODEL_EMULATOR  "Emulator"
-
-bool is_emulator(void)
-{
-       int ret;
-       char *model_name = NULL;
-       static bool emul = false;
-       static int set = 0;
-
-       if (set)
-               return emul;
-
-       ret = system_info_get_platform_string(MODEL_NAME, &model_name);
-       if (ret < 0) {
-               _E("Cannot get model name: %d", ret);
-               return emul;
-       }
-
-       if (!strncmp(MODEL_EMULATOR, model_name, strlen(model_name) + 1))
-               emul = true;
-
-       set = 1;
-       free(model_name);
-
-       return emul;
-}
-
 int do_mkdir(const char *path, mode_t mode)
 {
        char d[PATH_MAX];
index f617b27..6c80016 100644 (file)
@@ -197,7 +197,6 @@ static inline void __cleanup_fclose_func(FILE **f) {
 #endif
 
 int get_systemd_reboot_param(char *buf, unsigned bufsize);
-bool is_emulator(void);
 int do_mkdir(const char *path, mode_t mode);
 int do_copy_force(const char *src, const char *dst);
 void watchdog_notify(void);
index 1c91f59..f34083e 100644 (file)
@@ -5,6 +5,7 @@
 #include <libsyscommon/libsystemd.h>
 #include <libsyscommon/list.h>
 #include <libsyscommon/ini-parser.h>
+#include <libsyscommon/common.h>
 #include <hal/device/hal-board.h>
 
 #include <shared/log.h>
@@ -494,7 +495,7 @@ int usb_gadget_ops_init(void)
 
        syscommon_config_parse_by_section(PATH_USB_GADGET_CONF, load_usb_gadget_config, NULL);
 
-       if (is_emulator()) {
+       if (syscommon_is_emulator()) {
                __usb_gadget_open = dummy_usb_gadget_open;
                __usb_gadget_close = dummy_usb_gadget_close;
                __usb_gadget_enable = dummy_usb_gadget_enable;