/* * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include #include #include #include "lockd-debug.h" #include "lockd-process-mgr.h" #include "starter-vconf.h" #define LOCKD_DEFAULT_PKG_NAME "org.tizen.lockscreen" #define LOCKD_DRAG_LOCKSCREEN "com.samsung.draglock" #define LOCKD_PHONE_LOCK_PKG_NAME LOCKD_DEFAULT_PKG_NAME #define RETRY_MAXCOUNT 30 #define RELAUNCH_INTERVAL 100*1000 #define LOCKD_VOICE_CALL_PKG_NAME "com.samsung.call" #define LOCKD_VIDEO_CALL_PKG_NAME "com.samsung.vtmain" #define NICE_VALUE_PWLOCK -5 #define NICE_VALUE_LOCKSCREEN -20 static char *default_lockscreen_pkg = NULL; static bool _lockd_exist_package(char *pkgid) { int ret = 0; pkgmgrinfo_appinfo_h handle = NULL; ret = pkgmgrinfo_appinfo_get_appinfo(pkgid, &handle); if (PMINFO_R_OK != ret || NULL == handle) { LOCKD_SECURE_DBG("%s doesn't exist in this binary", pkgid); return false; } pkgmgrinfo_appinfo_destroy_appinfo(handle); return true; } void lockd_process_mgr_init(void) { default_lockscreen_pkg = vconf_get_str(VCONF_PRIVATE_LOCKSCREEN_DEFAULT_PKGNAME); LOCKD_SECURE_DBG("default lock screen pkg name is %s", default_lockscreen_pkg); if (default_lockscreen_pkg == NULL) { default_lockscreen_pkg = LOCKD_DEFAULT_PKG_NAME; } if (!_lockd_exist_package(default_lockscreen_pkg)) { LOCKD_SECURE_ERR("%s is not exist, default lock screen pkg name is set to %s", default_lockscreen_pkg, LOCKD_DRAG_LOCKSCREEN); default_lockscreen_pkg = LOCKD_DRAG_LOCKSCREEN; if (vconf_set_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, default_lockscreen_pkg) != 0) { LOCKD_SECURE_ERR("vconf key [%s] set [%s] is failed", VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, default_lockscreen_pkg); } } } static char *_lockd_process_mgr_get_pkgname(int lock_type) { char *pkgname = NULL; if (lock_type > 1) { pkgname = vconf_get_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR); LOCKD_SECURE_DBG("pkg name is %s", pkgname); if (pkgname == NULL) { pkgname = default_lockscreen_pkg; } else if (_lockd_exist_package(pkgname) == FALSE) { pkgname = default_lockscreen_pkg; } } else { pkgname = default_lockscreen_pkg; } return pkgname; } int lockd_process_mgr_restart_lock(int lock_type) { char *lock_app_path = NULL; int pid; int i; LOCKD_DBG("%s, %d", __func__, __LINE__); lock_app_path = _lockd_process_mgr_get_pkgname(lock_type); for (i=0; i0) { if (vconf_set_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, LOCKD_DRAG_LOCKSCREEN) != 0) { LOCKD_SECURE_ERR("vconf key [%s] set [%s] is failed", VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, LOCKD_DRAG_LOCKSCREEN); } return pid; } } else { return pid; } } else { return pid; } } LOCKD_ERR("Relaunch lock application failed..!!"); return pid; } int lockd_process_mgr_start_normal_lock(void *data, int (*dead_cb) (int, void *)) { int pid = 0; int i; for (i=0; i