update boilerplate
[apps/home/starter.git] / lock-mgr / src / lockd-process-mgr.c
1 /*
2  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved 
3  *
4  * This file is part of <starter>
5  * Written by <Seungtaek Chung> <seungtaek.chung@samsung.com>, <Mi-Ju Lee> <miju52.lee@samsung.com>, <Xi Zhichan> <zhichan.xi@samsung.com>
6  *
7  * PROPRIETARY/CONFIDENTIAL
8  *
9  * This software is the confidential and proprietary information of SAMSUNG ELECTRONICS ("Confidential Information").
10  * You shall not disclose such Confidential Information and shall use it only in accordance
11  * with the terms of the license agreement you entered into with SAMSUNG ELECTRONICS.
12  * SAMSUNG make no representations or warranties about the suitability of the software,
13  * either express or implied, including but not limited to the implied warranties of merchantability,
14  * fitness for a particular purpose, or non-infringement.
15  * SAMSUNG shall not be liable for any damages suffered by licensee as a result of using,
16  * modifying or distributing this software or its derivatives.
17  *
18  */
19
20 #include <vconf.h>
21 #include <vconf-keys.h>
22
23 #include <aul.h>
24
25 #include "lockd-debug.h"
26 #include "lockd-process-mgr.h"
27
28 #define LOCKD_PHONE_LOCK_PKG_NAME "org.tizen.phone-lock"
29
30 int lockd_process_mgr_start_phone_lock(void)
31 {
32         int pid = 0;
33         bundle *b = NULL;
34
35         b = bundle_create();
36
37         bundle_add(b, "pwlock_type", "running_lock");
38         bundle_add(b, "window_type", "alpha");
39
40         pid = aul_launch_app(LOCKD_PHONE_LOCK_PKG_NAME, b);
41         LOCKD_DBG("aul_launch_app(%s, b), pid = %d", LOCKD_PHONE_LOCK_PKG_NAME,
42                   pid);
43         if (b)
44                 bundle_free(b);
45
46         return pid;
47 }
48
49 void lockd_process_mgr_terminate_phone_lock(int phone_lock_pid)
50 {
51         LOCKD_DBG("Terminate Phone Lock(pid : %d)", phone_lock_pid);
52         aul_terminate_pid(phone_lock_pid);
53 }
54
55 int lockd_process_mgr_check_lock(int pid)
56 {
57         char buf[128];
58         LOCKD_DBG("%s, %d", __func__, __LINE__);
59         if (aul_app_get_pkgname_bypid(pid, buf, sizeof(buf)) < 0) {
60                 LOCKD_DBG("no such pkg by pid %d\n", pid);
61         } else {
62                 LOCKD_DBG("lock screen pkgname = %s, pid = %d\n", buf, pid);
63                 if (aul_app_is_running(buf) == TRUE) {
64                         LOCKD_DBG("%s [pid = %d] is running\n", buf, pid);
65                         return TRUE;
66                 } else {
67                         LOCKD_DBG("[pid = %d] is exist but %s is not running\n",
68                                   pid, buf);
69                 }
70         }
71         return FALSE;
72 }