2 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <Elementary.h>
20 #include <sys/types.h>
25 #include <Ecore_Wayland.h>
35 #include "process_mgr.h"
40 #define LOCKSCREEN_ENABLE 0
42 #define PWLOCK_LITE_PKG_NAME "org.tizen.pwlock-lite"
44 #define DATA_UNENCRYPTED "unencrypted"
45 #define DATA_MOUNTED "mounted"
46 #define SD_DATA_ENCRYPTED "encrypted"
47 #define SD_CRYPT_META_FILE ".MetaEcfsFile"
48 #define MMC_MOUNT_POINT "/opt/storage/sdcard"
52 static void _hide_home(void)
54 int seq = status_active_get()->starter_sequence;
57 vconf_set_int(VCONFKEY_STARTER_SEQUENCE, 0);
62 static void _show_home(void)
66 if (status_active_get()->starter_sequence || !show_menu) {
67 vconf_set_int(VCONFKEY_STARTER_SEQUENCE, 1);
74 static Eina_Bool _finish_boot_animation(void *data)
76 if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0) {
77 _E("Failed to set boot animation finished set");
81 return ECORE_CALLBACK_CANCEL;
86 static int _fail_to_launch_pwlock(const char *appid, const char *key, const char *value, void *cfn, void *afn)
88 _finish_boot_animation(NULL);
94 static void _after_launch_pwlock(int pid)
96 process_mgr_set_pwlock_priority(pid);
97 ecore_timer_add(0.5, _finish_boot_animation, NULL);
103 static void _signal_handler(int signum, siginfo_t *info, void *unused)
105 _D("_signal_handler : Terminated...");
111 static int _power_off_cb(status_active_key_e key, void *data)
113 int val = status_active_get()->sysman_power_off_status;
115 if (val == VCONFKEY_SYSMAN_POWER_OFF_DIRECT
116 || val == VCONFKEY_SYSMAN_POWER_OFF_RESTART)
118 _D("_power_off_cb : Terminated...");
127 static int _boot_animation_finished_cb(status_active_key_e key, void *data)
129 int val = status_active_get()->boot_animation_finished;
130 _D("boot animation finished : %d", val);
133 #if LOCKSCREEN_ENABLE
134 lock_mgr_daemon_start();
144 static void _language_changed_cb(keynode_t *node, void *data)
150 lang = vconf_keynode_get_str(node);
153 _D("language is changed : %s", lang);
155 elm_language_set(lang);
160 static int _set_i18n(const char *domain, const char *dir)
164 if (domain == NULL) {
169 char *lang = vconf_get_str(VCONFKEY_LANGSET);
170 r = setlocale(LC_ALL, lang);
172 _E("setlocale() error");
178 r = bindtextdomain(domain, dir);
180 _E("bindtextdomain() error");
183 r = textdomain(domain);
185 _E("textdomain() error");
188 if (vconf_notify_key_changed(VCONFKEY_LANGSET, _language_changed_cb, NULL) < 0) {
189 _E("Failed to register changed cb : %s", VCONFKEY_LANGSET);
197 static int _check_dead_signal(int pid, void *data)
200 #if LOCKSCREEN_ENABLE
205 _D("Process %d is termianted", pid);
212 home_pid = home_mgr_get_home_pid();
213 #if LOCKSCREEN_ENABLE
214 volume_pid = home_mgr_get_volume_pid();
215 lock_pid = lock_mgr_get_lock_pid();
218 if (pid == home_pid) {
219 _D("Homescreen is dead");
220 home_mgr_relaunch_homescreen();
221 #if LOCKSCREEN_ENABLE
222 } else if (pid == volume_pid) {
223 _D("volume is dead");
224 home_mgr_relaunch_volume();
225 } else if (pid == lock_pid) {
226 _D("lockscreen is dead");
230 _D("Unknown process, ignore it");
238 static void _init(struct appdata *ad)
240 struct sigaction act;
241 char err_buf[128] = {0,};
243 memset(&act,0x00,sizeof(struct sigaction));
244 act.sa_sigaction = _signal_handler;
245 act.sa_flags = SA_SIGINFO;
247 int ret = sigemptyset(&act.sa_mask);
249 strerror_r(errno, err_buf, sizeof(err_buf));
250 _E("Failed to sigemptyset[%d / %s]", errno, err_buf);
252 ret = sigaddset(&act.sa_mask, SIGTERM);
254 strerror_r(errno, err_buf, sizeof(err_buf));
255 _E("Failed to sigaddset[%d / %s]", errno, err_buf);
257 ret = sigaction(SIGTERM, &act, NULL);
259 strerror_r(errno, err_buf, sizeof(err_buf));
260 _E("Failed to sigaction[%d / %s]", errno, err_buf);
263 _set_i18n(PACKAGE, LOCALEDIR);
266 status_active_register_cb(STATUS_ACTIVE_KEY_SYSMAN_POWER_OFF_STATUS, _power_off_cb, NULL);
267 status_active_register_cb(STATUS_ACTIVE_KEY_BOOT_ANIMATION_FINISHED, _boot_animation_finished_cb, NULL);
269 /* Ordering : _hide_home -> process_mgr_must_launch(pwlock) -> _show_home */
272 process_mgr_must_launch(PWLOCK_LITE_PKG_NAME, NULL, NULL, _fail_to_launch_pwlock, _after_launch_pwlock);
275 hw_key_create_window();
278 aul_listen_app_dead_signal(_check_dead_signal, NULL);
283 static void _fini(struct appdata *ad)
286 hw_key_destroy_window();
287 #if LOCKSCREEN_ENABLE
288 lock_mgr_daemon_end();
291 status_active_unregister_cb(STATUS_ACTIVE_KEY_SYSMAN_POWER_OFF_STATUS, _power_off_cb);
292 status_active_unregister_cb(STATUS_ACTIVE_KEY_BOOT_ANIMATION_FINISHED, _boot_animation_finished_cb);
295 if (vconf_ignore_key_changed(VCONFKEY_LANGSET, _language_changed_cb) < 0) {
296 _E("Failed to unregister changed cb : %s", VCONFKEY_LANGSET);
302 int main(int argc, char *argv[])
307 _D("starter is launched..!!");
309 ret = elm_init(argc, argv);
311 _E("elm_init() failed : %d", ret);
315 ret = ecore_wl_init(NULL);
317 _E("ecore_wl_init() failed : %d", ret);