edbus
capi-network-connection
eventsystem
+ libxml-2.0
)
pkg_check_modules(PKGS REQUIRED ${PKG_MODULE})
#define DBUS_PATH_BOOT_DONE "/Org/Tizen/System/DeviceD/Core"
#define DBUS_IFACE_BOOT_DONE "org.tizen.system.deviced.core"
-// Network
-#define MAX_CLIENT 10000
-#define TID_NETWORK 1
-void* register_connection(void *data);
-void destroy_connection(void);
-extern pthread_t tid[MAX_CLIENT+1];
-
// Common
#define DEFAULT_MSGPROC "default"
#define HDS_DEFAULT_ID "fsdef0"
#define GROUP_MEMORY 30
#define STATUS 15
-#define TID_NETWORK 1
-#define TID_LOCATION 3
-#define TID_HDS_ATTACH 4
-#define TID_HDS_DETACH 5
-#define TID_SENSOR 6
-#define TID_VCONF 7
+enum tid_list {
+ TID_NETWORK = 1,
+ TID_LOCATION = 3,
+ TID_HDS_ATTACH = 4,
+ TID_HDS_DETACH = 5,
+ TID_SENSOR = 6,
+ TID_VCONF = 7,
+ TID_CAPABILITY = 8,
+ TID_MAX
+};
+
+extern pthread_t tid[TID_MAX + 1];
/* common vconf keys */
#define VCONF_LOW_MEMORY "memory/sysman/low_memory"
char type_cmd[ID_SIZE];
};
+// Helper
+int parse_val(char *buff, unsigned char data, char *parsbuf);
+
+// Network
+void * register_connection(void *data);
+void destroy_connection(void);
+
+// Checking capabilities
+void * check_capabilities(void *data);
+
+// Vconf
+void set_vconf_cb(void);
void add_vconf_map_common(void);
void add_vconf_map_profile(void);
-void send_default_suspend_req(void);
+
+// HDS
void send_default_mount_req(void);
-bool valid_hds_path(char* path);
-int try_mount(char* tag, char* path);
+bool valid_hds_path(char *path);
+int try_mount(char *tag, char *path);
void hds_unmount_all(void);
-void set_vconf_cb(void);
+
+// Guest condition
+void send_default_suspend_req(void);
void send_emuld_connection(void);
+
+// Dbus
+void dbus_send(const char *device, const char * target, const char * option);
+void dbus_send_signal(const char *device, const char *target, const char *option);
+
+// Message proc
void add_msg_proc_common(void);
void add_msg_proc_ext(void);
-void dbus_send(const char* device, const char* target, const char* option);
-void dbus_send_signal(const char* device, const char* target, const char* option);
-int parse_val(char *buff, unsigned char data, char *parsbuf);
-bool msgproc_hds(ijcommand* ijcmd);
-bool msgproc_cmd(ijcommand* ijcmd);
-bool msgproc_suspend(ijcommand* ijcmd);
-bool msgproc_system(ijcommand* ijcmd);
-bool msgproc_package(ijcommand* ijcmd);
-bool msgproc_vconf(ijcommand* ijcmd);
-bool msgproc_location(ijcommand* ijcmd);
+// Message proc handling
+bool msgproc_hds(ijcommand *ijcmd);
+bool msgproc_cmd(ijcommand *ijcmd);
+bool msgproc_suspend(ijcommand *ijcmd);
+bool msgproc_system(ijcommand *ijcmd);
+bool msgproc_package(ijcommand *ijcmd);
+bool msgproc_vconf(ijcommand *ijcmd);
+bool msgproc_location(ijcommand *ijcmd);
#endif // __EMULD_H__
#define IJTYPE_BOOT "boot"
#define IJTYPE_VCONF "vconf"
#define IJTYPE_LOCATION "location"
+#define IJTYPE_CAP "cap"
// struct
struct fd_info
Group: SDK/Other
BuildRequires: cmake
+BuildRequires: libxml2-devel
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(deviced)
BuildRequires: pkgconfig(dlog)
#include <stdlib.h>
#include <mntent.h>
+#include <libxml/xmlreader.h>
+
#include "emuld.h"
#define CMD_BUF 1024
#define MKDIR_MODE (S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
#define MAX_DIGITS_INT 10 // in decimal
+#define PATH_MODEL_CONFIG "/etc/config/model-config.xml"
+#define NUM_CHECK_LIST 13
+
unsigned int msize = MAX_PAYLOAD_SIZE;
void add_vconf_map_common(void)
send_to_ecs(IJTYPE_HDS, 0, 0, NULL);
}
+static const xmlChar* cap_check_list[] = {
+ (const xmlChar*)"tizen.org/feature/battery",
+ (const xmlChar*)"tizen.org/feature/location",
+ (const xmlChar*)"tizen.org/feature/network.nfc",
+ (const xmlChar*)"tizen.org/feature/network.telephony",
+ (const xmlChar*)"tizen.org/feature/sensor.accelerometer",
+ (const xmlChar*)"tizen.org/feature/sensor.gyroscope",
+ (const xmlChar*)"tizen.org/feature/sensor.magnetometer",
+ (const xmlChar*)"tizen.org/feature/sensor.proximity",
+ (const xmlChar*)"tizen.org/feature/sensor.photometer",
+ (const xmlChar*)"tizen.org/feature/sensor.barometer",
+ (const xmlChar*)"tizen.org/feature/sensor.heart_rate_monitor",
+ (const xmlChar*)"tizen.org/feature/sensor.ultraviolet",
+ (const xmlChar*)"tizen.org/feature/sensor.pedometer"
+};
+
+static int cap_device_list[] = {
+ 0x0001, // Battery
+ 0x0002, // Location
+ 0x0004, // NFC
+ 0x0008, // Telephony
+ 0x0010, // Accelerometer
+ 0x0020, // Gyroscope
+ 0x0040, // Magnetometer
+ 0x0080, // Proximity
+ 0x0100, // Light
+ 0x0200, // Pressure
+ 0x0400, // HeartRate
+ 0x0800, // Ultraviolet
+ 0x1000, // Pedometer
+};
+
+static void search_xml(xmlTextReaderPtr reader, int *list)
+{
+ const xmlChar** cap_list = cap_check_list;
+ const xmlChar *attr, *value;
+ int ret;
+
+ attr = xmlTextReaderGetAttribute(reader, (const xmlChar*)"name");
+
+ for (unsigned int i = 0; i < NUM_CHECK_LIST; i++) {
+ if (list[i] == 0 && xmlStrEqual(attr, cap_list[i])) {
+ ret = xmlTextReaderRead(reader);
+ if (ret == 1 && xmlTextReaderHasValue(reader)) {
+ value = xmlTextReaderConstValue(reader);
+ if (xmlStrEqual(value, (const xmlChar*)"true")) {
+ list[i] = 1;
+ }
+ }
+ LOGINFO("Found: %s, value: %d", attr, list[i]);
+ }
+ }
+}
+
+static int check_model_config(int* data)
+{
+ xmlTextReaderPtr reader = NULL;
+ int ret;
+ int cap_result_list [NUM_CHECK_LIST];
+ const char* path = PATH_MODEL_CONFIG;
+
+ reader = xmlReaderForFile(path, NULL, 0);
+ if (reader == NULL) {
+ LOGERR("Could not parse file %s", path);
+ return -1;
+ }
+
+ memset(cap_result_list, 0, sizeof(cap_result_list));
+
+ ret = xmlTextReaderRead(reader);
+ while (ret == 1) {
+ search_xml(reader, cap_result_list);
+ ret = xmlTextReaderRead(reader);
+ }
+
+ xmlFreeTextReader(reader);
+
+ if (ret != 0) {
+ LOGERR("Failed to parse : %d", ret);
+ return -1;
+ }
+
+ for (int i = 0; i < NUM_CHECK_LIST; i++) {
+ if (cap_result_list[i] == 1) {
+ *data |= cap_device_list[i];
+ }
+ }
+
+ return 0;
+}
+
+void* check_capabilities(void *data)
+{
+ int ret;
+ int cap_check = 0;
+
+ usleep(1000000); // XXX: wait 1 sec to be ready the networking
+
+ ret = check_model_config(&cap_check);
+ if (ret < 0) {
+ LOGERR("Failed to check model config.");
+ return NULL;
+ }
+
+ LOGINFO("Check capability: %x, %d", cap_check, cap_check);
+
+ char *buf = (char*)malloc(MAX_DIGITS_INT + 1);
+ if (!buf) {
+ LOGERR("insufficient memory available");
+ return NULL;
+ }
+
+ snprintf(buf, MAX_DIGITS_INT + 1, "%d", cap_check);
+ send_to_ecs(IJTYPE_CAP, 0, 0, buf);
+
+ free(buf);
+
+ return NULL;
+}
+
static void low_memory_cb(keynode_t* pKey, void* pData)
{
switch (vconf_keynode_get_type(pKey)) {
#include "emuld.h"
-pthread_t tid[MAX_CLIENT + 1];
+pthread_t tid[TID_MAX + 1];
int g_epoll_fd;
struct epoll_event g_events[MAX_EVENTS];
void* dl_handles[MAX_PLUGINS];
init_plugins();
if (pthread_create(&conn_thread_t, NULL, register_connection, NULL) < 0) {
- LOGERR("network connection pthread create fail!");
+ LOGERR("network connection thread is failed to create!");
return -1;
}
- if (pthread_create(&tid[TID_NETWORK], NULL, handling_network, NULL) != 0)
- {
- LOGERR("boot noti pthread create fail!");
+ if (pthread_create(&tid[TID_NETWORK], NULL, handling_network, NULL) != 0) {
+ LOGERR("boot notification thread is failed to create!");
+ return -1;
+ }
+
+ if (pthread_create(&tid[TID_CAPABILITY], NULL, check_capabilities, NULL) != 0) {
+ LOGERR("checking capabilities thread is failed to create!");
return -1;
}
ret = pthread_join(tid[TID_NETWORK], &retval);
if (ret < 0) {
- LOGERR("message loop pthread join is failed.");
+ LOGERR("message loop thread is failed to join.");
}
ret = pthread_join(conn_thread_t, &retval);
if (ret < 0) {
- LOGERR("network connection pthread join is failed.");
+ LOGERR("network connection thread is failed to join.");
+ }
+
+ ret = pthread_join(tid[TID_CAPABILITY], &retval);
+ if (ret < 0) {
+ LOGERR("checking capabilities thread is failed to join.");
}
emuld_exit();