4 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 #include <eventsystem.h>
23 #include <libsyscommon/libgdbus.h>
24 #include <libsyscommon/libsystemd.h>
27 #include "shared/device-notifier.h"
28 #include "shared/common.h"
29 #include "display/poll.h"
30 #include "display/display-ops.h"
31 #include "shared/plugin.h"
34 #define SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED "StartupFinished"
35 #define SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED "UserSessionStartupFinished"
37 static struct display_plugin *disp_plgn;
38 static guint sig_id[2] = {0, 0};
40 void remove_delayed_init_done_handler(void *data)
42 gdbus_signal_unsubscribe(NULL, sig_id[0]);
43 gdbus_signal_unsubscribe(NULL, sig_id[1]);
46 static void delayed_init_done_received(GDBusConnection *conn,
54 static int system_done = 0;
55 static int user_done = 0;
57 if (strcmp(name, SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED) == 0) {
61 system_done = check_system_boot_finished();
62 if (system_done == 0) {
63 _E("System session is not ready yet.");
66 CRITICAL_LOG("System session is ready.");
67 device_notify_once(DEVICE_NOTIFIER_DELAYED_INIT, &system_done);
69 } else if (strcmp(name, SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED) == 0) {
73 _I("User session is ready.");
76 if (!system_done || !user_done)
79 remove_delayed_init_done_handler(NULL);
81 _I("Real booting done. Unlock LCD_OFF.");
82 if (disp_plgn->pm_unlock_internal)
83 disp_plgn->pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN);
85 _I("Signal booting done.");
90 void add_delayed_init_done_handler(void *data)
92 /* System Session is loaded completely */
94 sig_id[0] = gdbus_signal_subscribe(NULL,
96 SYSTEMD_DBUS_IFACE_MANAGER,
97 SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED,
98 delayed_init_done_received,
102 _E("Failed to init dbus signal(%s).", SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED);
104 /* User Session is loaded completely */
105 sig_id[1] = gdbus_signal_subscribe(NULL,
107 SYSTEMD_DBUS_IFACE_MANAGER,
108 SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED,
109 delayed_init_done_received,
113 _E("Failed to init dbus signal(%s).", SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED);
116 static void __CONSTRUCTOR__ initialize(void)
118 disp_plgn = get_var_display_plugin();
120 _E("Failed to get display plugin variable.");