#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <stdlib.h>
+#include <system_info.h>
#include "common.h"
#define MAX_LINE 128
#define NEWLINE "\n\r"
#define COMMENT '#'
+#define MODEL_NAME "http://tizen.org/system/model_name"
+#define MODEL_EMULATOR "Emulator"
+
static inline char *trim_str(char *s)
{
char *t;
_E("Failed to read %s:%d!", file_name, lineno);
return ret;
}
+
+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;
+}
if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
- DD_LIST_FOREACH(handle_list, elem, temp) {
- if (temp->handle == ret) {
- found = true;
- temp->index = device_index;
- break;
+ if (!is_emulator()) {
+ DD_LIST_FOREACH(handle_list, elem, temp) {
+ if (temp->handle == ret) {
+ found = true;
+ temp->index = device_index;
+ break;
+ }
}
}
DD_LIST_APPEND(handle_list, handle);
*device_handle = (haptic_device_h)handle;
}
+
if (DD_LIST_LENGTH(handle_list) == 1) {
ret = register_signal_handler();
if (ret < 0)
if (!device_handle)
return DEVICE_ERROR_INVALID_PARAMETER;
- DD_LIST_FOREACH(handle_list, elem, temp) {
- if (temp->handle != handle->handle)
- continue;
- found = true;
- break;
+ if (!is_emulator()) {
+
+ DD_LIST_FOREACH(handle_list, elem, temp) {
+ if (temp->handle != handle->handle)
+ continue;
+ found = true;
+ break;
+ }
+
+ if (!found)
+ return DEVICE_ERROR_OPERATION_FAILED;
}
- if (!found)
- return DEVICE_ERROR_OPERATION_FAILED;
DD_LIST_REMOVE(handle_list, handle);
snprintf(str_handle, sizeof(str_handle), "%u", (unsigned int)handle->handle);
free(handle);