*/
#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;
}