From 84ed104e0aa96dd633440ffe4bb0934c836022a8 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Thu, 22 Dec 2016 20:47:25 +0900 Subject: [PATCH] Make esd broadcast boot_complete once. boot_complete system-event will be emitted after system-session finished. Change-Id: Ifb604a813d5f4c2339c17252ddabf14c079308c6 Signed-off-by: jongmyeongko --- include/eventsystem_daemon.h | 1 - src/esd_main.c | 91 +++----------------------------------------- 2 files changed, 6 insertions(+), 86 deletions(-) diff --git a/include/eventsystem_daemon.h b/include/eventsystem_daemon.h index a5aaa8f..56f44a0 100644 --- a/include/eventsystem_daemon.h +++ b/include/eventsystem_daemon.h @@ -46,7 +46,6 @@ extern "C" { #define SYSTEMD_DBUS_IFACE_MANAGER SYSTEMD_DBUS_DEST ".Manager" #define SYSTEMD_DBUS_PATH "/org/freedesktop/systemd1" #define SYSTEMD_DBUS_SIGNAL_STARTUP_FINISHED "StartupFinished" -#define SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED "UserSessionStartupFinished" int __esd_register_vconf_callbacks(void); diff --git a/src/esd_main.c b/src/esd_main.c index 1bbe29d..93e096a 100644 --- a/src/esd_main.c +++ b/src/esd_main.c @@ -70,8 +70,6 @@ typedef struct __earlier_table_item { } earlier_item; #endif -static bool system_bootcompleted; -static bool user_bootcompleted; static GHashTable *user_last_event_table; /* table of user events for last data */ @@ -1035,62 +1033,6 @@ static int __esd_get_user_items(void) return ES_R_OK; } -static int __esd_send_bootcomplete(GDBusConnection *conn, const char *list_name) -{ - GVariant *result; - GError *error = NULL; - GVariantIter *iter; - gchar *str; - GVariant *gv; - bundle *b; - bundle_raw *raw; - int len; - gboolean ret; - - result = g_dbus_connection_call_sync(conn, - "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", - list_name, NULL, G_VARIANT_TYPE("(as)"), G_DBUS_CALL_FLAGS_NONE, - -1, NULL, &error); - - if (result == NULL) { - _E("get (%s) error(%s)", list_name, error->message); - g_error_free(error); - return ES_R_ERROR; - } - - b = bundle_create(); - bundle_add_str(b, EVT_KEY_BOOT_COMPLETED, - EVT_VAL_BOOT_COMPLETED_TRUE); - - bundle_encode(b, &raw, &len); - - g_variant_get(result, "(as)", &iter); - while (g_variant_iter_loop(iter, "s", &str)) { - if (!strstr((const char *)str, "event.busname")) - continue; - - gv = g_variant_new("(us)", (unsigned int)len, raw); - ret = g_dbus_connection_emit_signal(conn, - str, - SYS_EVENT_OBJ_PATH, - SYS_EVENT_NAME_PREFIX, - EVT_KEY_BOOT_COMPLETED, - gv, - &error); - if (ret == FALSE) { - _E("Unable to emit signal: %s", error->message); - g_error_free(error); - } - } - - g_variant_iter_free(iter); - g_variant_unref(result); - bundle_free_encoded_rawdata(&raw); - bundle_free(b); - - return ES_R_OK; -} - static void __esd_signal_handler(GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, @@ -1100,21 +1042,17 @@ static void __esd_signal_handler(GDBusConnection *connection, gpointer user_data) { int handle; + bundle *b; if (!g_strcmp0(signal_name, SYSTEMD_DBUS_SIGNAL_STARTUP_FINISHED)) { _I("System session finished"); - system_bootcompleted = true; - } else if (!g_strcmp0(signal_name, - SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED)) { - _I("User session finished"); - __esd_get_user_items(); - user_bootcompleted = true; - } - if (system_bootcompleted && user_bootcompleted) { - __esd_send_bootcomplete(connection, "ListNames"); - __esd_send_bootcomplete(connection, "ListActivatableNames"); + b = bundle_create(); + bundle_add_str(b, EVT_KEY_BOOT_COMPLETED, + EVT_VAL_BOOT_COMPLETED_TRUE); + eventsystem_send_system_event(SYS_EVENT_BOOT_COMPLETED, b); + bundle_free(b); handle = creat(ESD_BOOT_COMPLETED, 0640); if (handle != -1) @@ -1714,7 +1652,6 @@ static void __esd_on_bus_acquired(GDBusConnection *connection, guint reg_id = 0; guint boot_id = 0; - guint user_boot_id = 0; GError *error = NULL; reg_id = g_dbus_connection_register_object(connection, @@ -1742,22 +1679,6 @@ static void __esd_on_bus_acquired(GDBusConnection *connection, _E("g_dbus_connection_signal_subscribe() is failed."); g_object_unref(connection); } - - user_boot_id = g_dbus_connection_signal_subscribe(connection, - NULL, - SYSTEMD_DBUS_IFACE_MANAGER, - SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED, - SYSTEMD_DBUS_PATH, - NULL, - G_DBUS_SIGNAL_FLAGS_NONE, - __esd_signal_handler, - NULL, - NULL); - - if (user_boot_id == 0) { - _E("g_dbus_connection_signal_subscribe() is failed."); - g_object_unref(connection); - } } static void __esd_on_name_acquired(GDBusConnection *connection, -- 2.7.4