From: Jinhyung Choi Date: Thu, 8 Jan 2015 06:07:21 +0000 (+0900) Subject: deviced: booting done notification handling X-Git-Tag: submit/tizen/20150527.025434~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4390db195ea16f85feba44538d194b40f92d4cb8;p=platform%2Fadaptation%2Femulator%2Femulator-daemon.git deviced: booting done notification handling - leaving kernel log by evdi Change-Id: I7ff6b05c3eeea307217e23cfd484530675483895 Signed-off-by: Jinhyung Choi --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4680ba4..eeb7a9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,34 +13,34 @@ set(PROJECT_RELEASE_VERSION "0") set(CMAKE_VERBOSE_MAKEFILE OFF) IF("$ENV{CFLAGS}" MATCHES "-DMOBILE") - OPTION(USE_D_MOBILE "Use Mobile Def" ON) + OPTION(USE_D_MOBILE "Use Mobile Def" ON) ENDIF() IF("$ENV{CFLAGS}" MATCHES "-DWEARABLE") - OPTION(USE_D_WEARABLE "Use Wearable Def" ON) + OPTION(USE_D_WEARABLE "Use Wearable Def" ON) ENDIF() SET(SRCS - src/emuld.cpp - src/evdi.cpp - src/client.cpp - src/common.cpp + src/emuld.cpp + src/evdi.cpp + src/client.cpp + src/common.cpp ) IF(USE_D_MOBILE) - SET(SRCS ${SRCS} - src/mobile.cpp - src/mobile_dev.cpp - src/common_dev.cpp - ) + SET(SRCS ${SRCS} + src/mobile.cpp + src/mobile_dev.cpp + src/common_dev.cpp + ) ENDIF(USE_D_MOBILE) IF(USE_D_WEARABLE) - SET(SRCS ${SRCS} - src/wearable.cpp - src/wearable_dev.cpp - src/common_dev.cpp - ) + SET(SRCS ${SRCS} + src/wearable.cpp + src/wearable_dev.cpp + src/common_dev.cpp + ) ENDIF(USE_D_WEARABLE) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) @@ -48,9 +48,11 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) INCLUDE(FindPkgConfig) SET(PKG_MODULE - vconf - deviced - dlog + vconf + deviced + dlog + ecore + edbus ) pkg_check_modules(PKGS REQUIRED ${PKG_MODULE}) diff --git a/include/emuld.h b/include/emuld.h index 95c2f3d..25ce7bd 100644 --- a/include/emuld.h +++ b/include/emuld.h @@ -57,9 +57,10 @@ enum #define HEADER_SIZE 4 // Thread TID profile uses >= 5 -#define TID_SDCARD 1 -#define TID_LOCATION 2 -#define TID_HDS 3 +#define TID_BOOT 1 +#define TID_SDCARD 2 +#define TID_LOCATION 3 +#define TID_HDS 4 extern pthread_t tid[MAX_CLIENT + 1]; extern int g_fd[fdtype_max]; @@ -182,12 +183,14 @@ bool accept_proc(const int server_fd); void send_to_ecs(const char* cat, int group, int action, char* data); void send_emuld_connection(void); void send_default_suspend_req(void); +void* dbus_booting_done_check(void* data); void systemcall(const char* param); int parse_val(char *buff, unsigned char data, char *parsbuf); #define IJTYPE_SUSPEND "suspend" #define IJTYPE_GUEST "guest" #define IJTYPE_PACKAGE "package" +#define IJTYPE_BOOT "boot" void msgproc_suspend(ijcommand* ijcmd); void msgproc_system(ijcommand* ijcmd); diff --git a/packaging/emuld.spec b/packaging/emuld.spec index 2a8bd15..910a06d 100644 --- a/packaging/emuld.spec +++ b/packaging/emuld.spec @@ -11,6 +11,9 @@ BuildRequires: cmake BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(deviced) BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(edbus) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(dbus-glib-1) %description A emulator daemon is used for communication between guest and host diff --git a/src/common.cpp b/src/common.cpp index 9ef00b5..cb3da76 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -29,12 +29,16 @@ #include #include +#include #include #include #include "emuld.h" //#include "deviced/dd-display.h" +#include +#include + #define PMAPI_RETRY_COUNT 3 #define POWEROFF_DURATION 2 @@ -161,9 +165,7 @@ void send_to_ecs(const char* cat, int group, int action, char* data) if (!tmp) return; - if (data != NULL) { - memcpy(tmp, &datalen, 2); - } + memcpy(tmp, &datalen, 2); memcpy(tmp + 2, &group, 1); memcpy(tmp + 3, &action, 1); if (data != NULL) { @@ -374,3 +376,74 @@ void msgproc_package(ijcommand* ijcmd) } } +enum ioctl_cmd { + IOCTL_CMD_BOOT_DONE, +}; + +void send_to_kernel(void) +{ + if(ioctl(g_fd[fdtype_device], IOCTL_CMD_BOOT_DONE, NULL) == -1) { + LOGERR("Failed to send ioctl to kernel"); + return; + } + LOGINFO("[DBUS] sent booting done to kernel"); +} + +#define DBUS_PATH_BOOT_DONE "/Org/Tizen/System/DeviceD/Core" +#define DBUS_IFACE_BOOT_DONE "org.tizen.system.deviced.core" +#define BOOT_DONE_SIGNAL "BootingDone" + +static void boot_done(void *data, DBusMessage *msg) +{ + if (dbus_message_is_signal(msg, + DBUS_IFACE_BOOT_DONE, + BOOT_DONE_SIGNAL) != 0) { + LOGINFO("[DBUS] sending booting done to ecs."); + send_to_ecs(IJTYPE_BOOT, 0, 0, NULL); + LOGINFO("[DBUS] sending booting done to kernel for log."); + send_to_kernel(); + } +} + +void* dbus_booting_done_check(void* data) +{ + E_DBus_Connection *connection; + E_DBus_Signal_Handler *boot_handler = NULL; + + ecore_init(); + e_dbus_init(); + + connection = e_dbus_bus_get(DBUS_BUS_SYSTEM); + if (!connection) { + LOGERR("[DBUS] Failed to get dbus bus."); + e_dbus_shutdown(); + ecore_shutdown(); + return NULL; + } + + boot_handler = e_dbus_signal_handler_add( + connection, + NULL, + DBUS_PATH_BOOT_DONE, + DBUS_IFACE_BOOT_DONE, + BOOT_DONE_SIGNAL, + boot_done, + NULL); + if (!boot_handler) { + LOGERR("[DBUS] Failed to register handler"); + e_dbus_signal_handler_del(connection, boot_handler); + e_dbus_shutdown(); + ecore_shutdown(); + return NULL; + } + LOGINFO("[DBUS] signal handler is added."); + + ecore_main_loop_begin(); + + e_dbus_signal_handler_del(connection, boot_handler); + e_dbus_shutdown(); + ecore_shutdown(); + + return NULL; +} + diff --git a/src/emuld.cpp b/src/emuld.cpp index ba059af..c07213e 100644 --- a/src/emuld.cpp +++ b/src/emuld.cpp @@ -292,6 +292,12 @@ int main( int argc , char *argv[]) exit(0); } + if (pthread_create(&tid[TID_BOOT], NULL, dbus_booting_done_check, NULL) != 0) + { + LOGERR("boot noti pthread create fail!"); + return -1; + } + LOGINFO("[START] epoll & device init success"); init_profile();