2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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.
20 #include <vconf-keys.h>
24 #include "lockd-debug.h"
25 #include "lockd-process-mgr.h"
26 #include "starter-vconf.h"
28 #define LOCKD_DEFAULT_PKG_NAME "org.tizen.livebox-lock"
29 #define LOCKD_DEFAULT_LOCKSCREEN "org.tizen.draglock"
30 #define LOCKD_PHONE_LOCK_PKG_NAME "org.tizen.phone-lock"
31 #define RETRY_MAXCOUNT 30
32 #define RELAUNCH_INTERVAL 100*1000
34 static char *_lockd_process_mgr_get_pkgname(void)
38 pkgname = vconf_get_str(VCONF_PRIVATE_LOCKSCREEN_PKGNAME);
40 LOCKD_DBG("pkg name is %s", pkgname);
42 if (pkgname == NULL) {
43 return LOCKD_DEFAULT_PKG_NAME;
49 int lockd_process_mgr_restart_lock(int phone_lock_state)
51 char *lock_app_path = NULL;
55 lock_app_path = _lockd_process_mgr_get_pkgname();
59 if (phone_lock_state == 1)
60 bundle_add(b, "mode", "lock");
62 bundle_add(b, "mode", "normal");
64 pid = aul_launch_app(lock_app_path, b);
66 LOCKD_DBG("Reset : aul_launch_app(%s, NULL), pid = %d", lock_app_path,
76 lockd_process_mgr_start_lock(void *data, int (*dead_cb) (int, void *),
79 char *lock_app_path = NULL;
83 lock_app_path = _lockd_process_mgr_get_pkgname();
87 if (phone_lock_state == 1)
88 bundle_add(b, "mode", "lock");
90 bundle_add(b, "mode", "normal");
93 for (i=0; i<RETRY_MAXCOUNT; i++)
95 pid = aul_launch_app(lock_app_path, b);
97 LOCKD_DBG("aul_launch_app(%s), pid = %d", lock_app_path, pid);
99 if (pid == AUL_R_ECOMM) {
100 LOCKD_DBG("Relaunch lock application [%d]times", i);
101 usleep(RELAUNCH_INTERVAL);
102 } else if (pid == AUL_R_ERROR) {
103 LOCKD_DBG("launch[%s] is failed, launch default lock screen", lock_app_path);
104 pid = aul_launch_app(LOCKD_DEFAULT_LOCKSCREEN, b);
116 LOCKD_DBG("Relaunch lock application failed..!!");
120 int lockd_process_mgr_start_normal_lock(void *data, int (*dead_cb) (int, void *))
125 for (i=0; i<RETRY_MAXCOUNT; i++)
127 pid = aul_launch_app(LOCKD_DEFAULT_PKG_NAME, NULL);
129 LOCKD_DBG("aul_launch_app(%s), pid = %d", LOCKD_DEFAULT_PKG_NAME, pid);
131 if (pid == AUL_R_ECOMM) {
132 LOCKD_DBG("Relaunch lock application [%d]times", i);
133 usleep(RELAUNCH_INTERVAL);
134 } else if (pid == AUL_R_ERROR) {
135 LOCKD_DBG("launch[%s] is failed, launch default lock screen", LOCKD_DEFAULT_PKG_NAME);
136 pid = aul_launch_app(LOCKD_DEFAULT_LOCKSCREEN, NULL);
144 LOCKD_DBG("Relaunch lock application failed..!!");
148 int lockd_process_mgr_start_phone_lock(void)
156 bundle_add(b, "pwlock_type", "running_lock");
157 bundle_add(b, "window_type", "alpha");
159 pid = aul_launch_app(LOCKD_PHONE_LOCK_PKG_NAME, b);
160 LOCKD_DBG("aul_launch_app(%s, b), pid = %d", LOCKD_PHONE_LOCK_PKG_NAME,
163 bundle_add(b, "mode", "lock");
165 pid = aul_launch_app(LOCKD_DEFAULT_PKG_NAME, b);
167 LOCKD_DBG("aul_launch_app(%s, NULL), pid = %d", LOCKD_DEFAULT_PKG_NAME,
176 int lockd_process_mgr_start_recovery_lock(void)
183 bundle_add(b, "pwlock_type", "recovery_lock");
184 bundle_add(b, "window_type", "alpha");
186 pid = aul_launch_app(LOCKD_PHONE_LOCK_PKG_NAME, b);
187 LOCKD_DBG("aul_launch_app(%s, b), pid = %d", LOCKD_PHONE_LOCK_PKG_NAME,
196 lockd_process_mgr_terminate_lock_app(int lock_app_pid, int state)
199 ("lockd_process_mgr_terminate_lock_app, state:%d\n",
203 if (lock_app_pid != 0) {
204 LOCKD_DBG("Terminate Lock app(pid : %d)", lock_app_pid);
205 aul_terminate_pid(lock_app_pid);
210 void lockd_process_mgr_terminate_phone_lock(int phone_lock_pid)
212 LOCKD_DBG("Terminate Phone Lock(pid : %d)", phone_lock_pid);
213 aul_terminate_pid(phone_lock_pid);
216 int lockd_process_mgr_check_lock(int pid)
219 LOCKD_DBG("%s, %d", __func__, __LINE__);
220 /* Check pid is invalid. */
221 if (aul_app_get_pkgname_bypid(pid, buf, sizeof(buf)) < 0) {
222 LOCKD_DBG("no such pkg by pid %d\n", pid);
224 LOCKD_DBG("app pkgname = %s, pid = %d\n", buf, pid);
225 if (aul_app_is_running(buf) == TRUE) {
226 LOCKD_DBG("%s [pid = %d] is running\n", buf, pid);
229 LOCKD_DBG("[pid = %d] is exist but %s is not running\n",