pkg_check_modules(syscommon REQUIRED
glib-2.0
gio-2.0
+ gio-unix-2.0
dlog
- gio-unix-2.0)
+ capi-system-info)
FOREACH(flag ${syscommon_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
Source: %{name}-%{version}.tar.gz
Source1001: %{name}.manifest
+BuildRequires: cmake
+BuildRequires: pkgconfig(cmocka)
BuildRequires: pkgconfig(glib-2.0) >= 2.44
BuildRequires: pkgconfig(gio-2.0) >= 2.44
BuildRequires: pkgconfig(gio-unix-2.0)
BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(cmocka)
-BuildRequires: cmake
-
-Requires: /bin/cp
+BuildRequires: pkgconfig(capi-system-info)
-Requires(post): /sbin/ldconfig
+Requires: /bin/cp
+Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
%description
+++ /dev/null
-/Makefile
-/test-*
\ No newline at end of file
*/
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
#include <unistd.h>
+#include <system/system_info.h>
+#include "shared/log.h"
#include "common.h"
-#define CONTAINER_FILE_PATH "/run/systemd/container"
+#define FEATURE_MODEL_NAME "http://tizen.org/system/model_name"
+#define FEATURE_MODEL_NAME_EMULATOR "Emulator"
+#define CONTAINER_FILE_PATH "/run/systemd/container"
-bool is_container()
+bool libsys_is_emulator(void)
{
+ int ret = 0;
+ char *model_name = NULL;
+ static bool is_emul = false;
+ static bool is_cached = false;
+
+ if (is_cached)
+ return is_emul;
+
+ ret = system_info_get_platform_string(FEATURE_MODEL_NAME, &model_name);
+ if (ret < 0) {
+ _E("Cannot get model name: %d, libsys_is_emulator() returns false on operation failure", ret);
+ return false;
+ }
+
+ if (!strncmp(FEATURE_MODEL_NAME_EMULATOR, model_name, strlen(model_name) + 1))
+ is_emul = true;
+
+ is_cached = true;
+ free(model_name);
+
+ return is_emul;
+}
+
+bool libsys_is_container(void)
+{
+ static bool is_container = false;
+ static bool is_cached = false;
+
+ if (is_cached)
+ return is_container;
+
if (access(CONTAINER_FILE_PATH, F_OK) == 0)
- return true;
+ is_container = true;
+
+ is_cached = true;
- return false;
+ return is_container;
}
#include <stdbool.h>
-bool is_container();
+/**
+ * @brief Check if running on emulator
+ *
+ * @return true if running on emulator, otherwise false even on operation failure
+ */
+bool libsys_is_emulator(void);
+
+/**
+ * @brief Check if running on container
+ *
+ * @return true if running on container, otherwise false even on operation failure
+ */
+bool libsys_is_container(void);
#endif /* __LIBCOMMON_COMMON_H__ */