4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 #include <Ecore_Input.h>
28 #include <Ecore_Evas.h>
37 #include <sys/types.h>
40 #include <sys/prctl.h>
41 #include <pkgmgr-info.h>
43 #ifdef WEARABLE_PROFILE
44 #include <proc_stat.h>
47 #include <privacy_manager_client.h>
49 #include "amd_config.h"
50 #include "amd_launch.h"
51 #include "amd_appinfo.h"
52 #include "amd_status.h"
54 #include "simple_util.h"
55 #include "amd_cgutil.h"
57 #include "app_signal.h"
61 #include "access_control.h"
63 #ifdef WEARABLE_PROFILE
64 #include "dd-display.h"
67 #define TERM_WAIT_SEC 3
70 #define AUL_PR_NAME 16
71 #define PATH_APP_ROOT "/opt/usr/apps"
72 #define PATH_DATA "/data"
73 #define SDK_CODE_COVERAGE "CODE_COVERAGE"
74 #define SDK_DYNAMIC_ANALYSIS "DYNAMIC_ANALYSIS"
75 #define PATH_DA_SO "/home/developer/sdk_tools/da/da_probe.so"
77 #define PHONE_ORIENTATION_MODE "memory/private/sensor/10001"
78 #define AMD_EFFECT_IMAGE_ENABLE "db/setting/effect_image"
79 #define PHONE_ROTATE_LOCK "db/setting/auto_rotate_screen"
81 #define SYS_MIN_CPU_LOCK_FILE "/sys/devices/system/cpu/cpufreq/slp/min_cpu_lock"
82 #define MIN_CPU_LCK_CNT 0
83 #define MAX_CPU_LCK_CNT 2
85 #define HIDE_INDICATOR 0
86 #define SHOW_INDICATOR 1
88 struct appinfomgr *_laf;
94 /*Unused data structure. Will be removed*/
96 char *pkg_name; /* package */
97 char *app_path; /* exec */
98 char *original_app_path; /* exec */
99 int multiple; /* x_slp_multiple */
101 } app_info_from_pkgmgr;
104 static GList *_kill_list;
109 guint tid; /* timer ID */
113 static const char *atom_name = "_E_COMP_FAKE_LAUNCH_IMAGE"; // Atomic ID string
114 static Ecore_X_Atom ATOM_IMAGE_EFFECT; //Atomic ID
115 static void __amd_effect_image_file_set(char *image_file);
116 static void __amd_send_message_to_e17(int screenmode, const char * indicator);
117 static int __amd_change_min_cpulock_count(int value);
118 static Eina_Bool __amd_restore_min_cpulock_count_cb(void *data);
120 static void _set_sdk_env(const char* appid, char* str) {
121 char buf[MAX_LOCAL_BUFSZ];
124 _D("key : %s / value : %s", AUL_K_SDK, str);
125 /* http://gcc.gnu.org/onlinedocs/gcc/Cross_002dprofiling.html*/
126 /* GCOV_PREFIX contains the prefix to add to the absolute paths in the object file. */
127 /* Prefix can be absolute, or relative. The default is no prefix. */
128 /* GCOV_PREFIX_STRIP indicates the how many initial directory names */
129 /* to stripoff the hardwired absolute paths. Default value is 0. */
130 if (strncmp(str, SDK_CODE_COVERAGE, strlen(str)) == 0) {
131 snprintf(buf, MAX_LOCAL_BUFSZ, PATH_APP_ROOT"/%s"PATH_DATA, appid);
132 ret = setenv("GCOV_PREFIX", buf, 1);
133 _D("GCOV_PREFIX : %d", ret);
134 ret = setenv("GCOV_PREFIX_STRIP", "4096", 1);
135 _D("GCOV_PREFIX_STRIP : %d", ret);
136 } else if (strncmp(str, SDK_DYNAMIC_ANALYSIS, strlen(str)) == 0) {
137 ret = setenv("LD_PRELOAD", PATH_DA_SO, 1);
138 _D("LD_PRELOAD : %d", ret);
142 #define USE_ENGINE(engine) setenv("ELM_ENGINE", engine, 1);
144 static void _set_env(const char *appid, bundle * kb, const char *hwacc)
147 const char **str_array;
151 setenv("PKG_NAME", appid, 1);
155 str = bundle_get_val(kb, AUL_K_STARTTIME);
157 setenv("APP_START_TIME", str, 1);
159 if(bundle_get_type(kb, AUL_K_SDK) & BUNDLE_TYPE_ARRAY) {
160 str_array = bundle_get_str_array(kb, AUL_K_SDK, &len);
161 if(str_array != NULL) {
162 for (i = 0; i < len; i++) {
163 _D("index : [%d]", i);
164 _set_sdk_env(appid, (char *)str_array[i]);
168 str = bundle_get_val(kb, AUL_K_SDK);
170 _set_sdk_env(appid, (char *)str);
174 setenv("HWACC", hwacc, 1);
177 static void _prepare_exec(const char *appid, bundle *kb)
179 const struct appinfo *ai;
180 const char *app_path = NULL;
181 const char *pkg_type = NULL;
183 char process_name[AUL_PR_NAME];
189 signal(SIGINT, SIG_DFL);
190 signal(SIGTERM, SIG_DFL);
191 signal(SIGCHLD, SIG_DFL);
193 ai = appinfo_find(_laf, appid);
195 app_path = appinfo_get_value(ai, AIT_EXEC);
196 pkg_type = appinfo_get_value(ai, AIT_TYPE);
197 hwacc = appinfo_get_value(ai, AIT_HWACC);
200 _D("appid : %s / pkg_type : %s / app_path : %s ", appid, pkg_type, app_path);
201 if ((ret = __set_access(appid, pkg_type, app_path)) < 0) {
202 _D("fail to set privileges - check your package's credential : %d\n", ret);
206 /* SET DUMPABLE - for coredump*/
207 prctl(PR_SET_DUMPABLE, 1);
209 /* SET PROCESS NAME*/
210 if (app_path == NULL) {
211 _D("app_path should not be NULL - check menu db");
214 file_name = strrchr(app_path, '/') + 1;
215 if (file_name == NULL) {
216 _D("can't locate file name to execute");
219 memset(process_name, '\0', AUL_PR_NAME);
220 snprintf(process_name, AUL_PR_NAME, "%s", file_name);
221 prctl(PR_SET_NAME, process_name);
224 _set_env(appid, kb, hwacc);
226 /* TODO: do security job */
230 static int _add_cgroup(struct cginfo *cg, const char *group, int pid)
234 r = cgutil_exist_group(cg, CTRL_MGR, group);
236 _E("exist check error: %s", strerror(errno));
240 if (r == 0) { /* not exist */
241 r = cgutil_create_group(cg, CTRL_MGR, group);
243 _E("create group error");
248 r = cgutil_group_add_pid(cg, CTRL_MGR, group, pid);
250 _E("add pid to group error");
251 cgutil_remove_group(cg, CTRL_MGR, group);
258 static char **__create_argc_argv(bundle * kb, int *margc)
263 argc = bundle_export_to_argv(kb, &argv);
268 static void _do_exec(struct cginfo *cg, const char *cmd, const char *group, bundle *kb)
277 r = _add_cgroup(cg, group, getpid());
281 b = g_shell_parse_argv(cmd, &argc, &argv, NULL);
284 b_argv = __create_argc_argv(kb, &b_argc);
285 b_argv[0] = strdup(argv[0]);
286 _prepare_exec(group, kb);
287 execv(b_argv[0], b_argv);
291 _prepare_exec(group, kb);
292 execv(argv[0], argv);
295 _E("exec error: %s", strerror(errno));
299 int service_start(struct cginfo *cg, const char *group, const char *cmd, bundle *kb)
304 if (!cg || !group || !*group || !cmd || !*cmd) {
306 _E("service start: %s", strerror(errno));
312 case 0: /* child process */
314 _do_exec(cg, cmd, group, kb);
320 _E("service start: fork: %s", strerror(errno));
323 default: /* parent process */
324 _D("child process: %d", p);
332 int _start_srv(const struct appinfo *ai, bundle *kb)
338 group = appinfo_get_filename(ai);
340 cmd = appinfo_get_value(ai, AIT_EXEC);
342 _E("start service: '%s' has no exec", group);
346 r = service_start(_lcg, group, cmd, kb);
348 _E("start service: '%s': failed", group);
355 static void _free_kt(struct ktimer *kt)
360 cgutil_unref(&kt->cg);
365 static void _kill_pid(struct cginfo *cg, const char *group, pid_t pid)
369 if (pid <= INIT_PID) /* block sending to all process or init */
372 r = cgutil_exist_group(cg, CTRL_MGR, group);
374 _E("send SIGKILL: exist: %s", strerror(errno));
378 _D("send SIGKILL: '%s' not exist", group);
382 /* TODO: check pid exist in group */
386 _D("send SIGKILL: pid %d not exist", pid);
390 r = kill(pid, SIGKILL);
392 _E("send SIGKILL: %s", strerror(errno));
395 static gboolean _ktimer_cb(gpointer data)
397 struct ktimer *kt = data;
399 _kill_pid(kt->cg, kt->group, kt->pid);
400 _kill_list = g_list_remove(_kill_list, kt);
406 static void _add_list(struct cginfo *cg, const char *group, pid_t pid)
410 kt = calloc(1, sizeof(*kt));
415 kt->group = strdup(group);
421 kt->cg = cgutil_ref(cg);
422 kt->tid = g_timeout_add_seconds(TERM_WAIT_SEC, _ktimer_cb, kt);
424 _kill_list = g_list_append(_kill_list, kt);
427 static inline void _del_list(GList *l)
436 g_source_remove(kt->tid);
438 _kill_list = g_list_delete_link(_kill_list, l);
441 static int _kill_pid_cb(void *user_data, const char *group, pid_t pid)
445 if (pid <= INIT_PID) /* block sending to all process or init */
448 r = kill(pid, SIGTERM);
450 _E("send SIGTERM: %s", strerror(errno));
452 _add_list(user_data, group, pid);
457 int service_stop(struct cginfo *cg, const char *group)
459 if (!cg || !group || !*group) {
464 return cgutil_group_foreach_pid(cg, CTRL_MGR, FILENAME(group),
468 void service_release(const char *group)
473 if (!group || !*group)
476 group = FILENAME(group);
479 for (l = _kill_list; l; l = g_list_next(l)) {
480 struct ktimer *k = l->data;
484 if (k->group && !strcmp(k->group, group))
491 int _send_to_sigkill(int pid)
499 if (killpg(pgid, SIGKILL) < 0)
504 int _resume_app(int pid)
509 __app_send_raw_with_delay_reply(pid, APP_RESUME_BY_PID, (unsigned char *)&dummy,
512 _E("resume packet timeout error");
514 _E("raise failed - %d resume fail\n", pid);
515 _E("we will term the app - %d\n", pid);
516 _send_to_sigkill(pid);
524 int _fake_launch_app(int cmd, int pid, bundle * kb)
530 bundle_encode(kb, &kb_data, &datalen);
531 if ((ret = __app_send_raw_with_delay_reply(pid, cmd, kb_data, datalen)) < 0)
532 _E("error request fake launch - error code = %d", ret);
537 static void __real_send(int clifd, int ret)
539 if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
540 if (errno == EPIPE) {
541 _E("send failed due to EPIPE.\n");
543 _E("send fail to client");
549 static gboolean __au_glib_check(GSource *src)
554 fd_list = src->poll_fds;
556 tmp = (GPollFD *) fd_list->data;
557 if ((tmp->revents & (POLLIN | POLLPRI)))
559 fd_list = fd_list->next;
565 static gboolean __au_glib_dispatch(GSource *src, GSourceFunc callback,
572 static gboolean __au_glib_prepare(GSource *src, gint *timeout)
577 static GSourceFuncs funcs = {
578 .prepare = __au_glib_prepare,
579 .check = __au_glib_check,
580 .dispatch = __au_glib_dispatch,
593 static gboolean __reply_handler(gpointer data)
595 struct reply_info *r_info = (struct reply_info *) data;;
596 int fd = r_info->gpollfd->fd;
599 int clifd = r_info->clifd;
600 int pid = r_info->pid;
601 int cmd = r_info->cmd;
603 len = recv(fd, &res, sizeof(int), 0);
605 if (errno == EAGAIN) {
606 _E("recv timeout : %s", strerror(errno));
609 _E("recv error : %s", strerror(errno));
616 if ( cmd == APP_TERM_BY_PID ) {
617 __real_send(clifd, -1);
618 } else if ( cmd == APP_START_ASYNC ) {
621 __real_send(clifd, res);
624 if ( cmd == APP_TERM_BY_PID ) {
625 __real_send(clifd, 0);
626 } else if ( cmd == APP_START_ASYNC ) {
629 __real_send(clifd, pid);
633 _D("listen fd(%d) , send fd(%d), pid(%d), cmd(%d)", fd, clifd, pid, cmd);
635 g_source_remove(r_info->timer_id);
636 g_source_remove_poll(r_info->src, r_info->gpollfd);
637 g_source_destroy(r_info->src);
638 g_free(r_info->gpollfd);
644 static gboolean __recv_timeout_handler(gpointer data)
646 struct reply_info *r_info = (struct reply_info *) data;
647 int fd = r_info->gpollfd->fd;
649 _E("application is not responding : pid(%d) cmd(%d)", r_info->pid, r_info->cmd);
653 if( r_info->cmd == APP_TERM_BY_PID ) {
654 if (_send_to_sigkill(r_info->pid) < 0) {
655 _E("fail to killing - %d\n", r_info->pid);
656 __real_send(r_info->clifd, -1);
659 __real_send(r_info->clifd, 0);
662 g_source_remove_poll(r_info->src, r_info->gpollfd);
663 g_source_destroy(r_info->src);
664 g_free(r_info->gpollfd);
670 _term_app(int pid, int clifd)
677 struct reply_info *r_info;
679 if ( (ret = __app_send_raw_with_delay_reply
680 (pid, APP_TERM_BY_PID, (unsigned char *)&dummy, sizeof(int))) < 0) {
681 _D("terminate packet send error - use SIGKILL");
682 if (_send_to_sigkill(pid) < 0) {
683 _E("fail to killing - %d\n", pid);
684 __real_send(clifd, -1);
687 __real_send(clifd, 0);
691 src = g_source_new(&funcs, sizeof(GSource));
693 gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
694 gpollfd->events = POLLIN;
697 r_info = malloc(sizeof(*r_info));
698 r_info->clifd = clifd;
701 r_info->gpollfd = gpollfd;
702 r_info->cmd = APP_TERM_BY_PID;
704 _D("listen fd : %d, send fd : %d", ret, clifd);
706 r_info->timer_id = g_timeout_add(5000, __recv_timeout_handler, (gpointer) r_info);
707 g_source_add_poll(src, gpollfd);
708 g_source_set_callback(src, (GSourceFunc) __reply_handler,
709 (gpointer) r_info, NULL);
710 g_source_set_priority(src, G_PRIORITY_DEFAULT);
711 r = g_source_attach(src, NULL);
716 static int __nofork_processing(int cmd, int pid, bundle * kb, int clifd)
722 struct reply_info *r_info;
723 const char *operation;
725 operation = bundle_get_val(kb, "__APP_SVC_OP_TYPE__");
727 if ( cmd == APP_OPEN ||
728 (operation != NULL && strncmp(operation, "http://tizen.org/appcontrol/operation/main", 512) == 0)){
731 snprintf(val, sizeof(val), "%d", 800);
734 ret = invoke_dbus_method_sync(SYSTEM_BUS_NAME, SYSTEM_OBJECT_PATH,
735 SYSTEM_INTERFACE_NAME, SYSTEM_METHOD_NAME, "i", arr);
736 _D("%s-%s : %d", SYSTEM_INTERFACE_NAME, SYSTEM_METHOD_NAME, ret);
742 _D("resume app's pid : %d\n", pid);
743 if ((ret = _resume_app(pid)) < 0)
744 _E("__resume_app failed. error code = %d", ret);
745 _D("resume app done");
750 case APP_START_ASYNC:
751 _D("fake launch pid : %d\n", pid);
752 if ((ret = _fake_launch_app(cmd, pid, kb)) < 0)
753 _E("fake_launch failed. error code = %d", ret);
754 _D("fake launch done");
759 src = g_source_new(&funcs, sizeof(GSource));
761 gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
762 gpollfd->events = POLLIN;
765 r_info = malloc(sizeof(*r_info));
766 r_info->clifd = clifd;
769 r_info->gpollfd = gpollfd;
772 _D("listen fd : %d, send fd : %d", ret, clifd);
774 r_info->timer_id = g_timeout_add(5200, __recv_timeout_handler, (gpointer) r_info);
775 g_source_add_poll(src, gpollfd);
776 g_source_set_callback(src, (GSourceFunc) __reply_handler,
777 (gpointer) r_info, NULL);
778 g_source_set_priority(src, G_PRIORITY_DEFAULT);
779 r = g_source_attach(src, NULL);
788 __amd_sysman_restore_hz_timer_cb(void *data)
790 struct context *ctxt = data;
795 sysman_release_cpu_min_frequency ();
797 _D("*******[1.6MHZ Support] Released\n " );
799 return ECORE_CALLBACK_CANCEL; // same as EINA_FALSE
807 static int __amd_change_min_cpulock_count(int value)
811 fd = open(SYS_MIN_CPU_LOCK_FILE, O_WRONLY);
814 snprintf(buf, sizeof(buf), "%d", value);
815 if (write(fd, buf, strlen(buf)) < 0) {
816 _E("[AMD]: Unable to change min_cpu_lock value!, err: %s\n",strerror(errno));
821 _D("[AMD]: Succesfully changed min cpu value to %d\n", value);
825 static Eina_Bool __amd_restore_min_cpulock_count_cb(void *data)
827 struct context *ctxt = data;
830 __amd_change_min_cpulock_count(MIN_CPU_LCK_CNT);
831 return ECORE_CALLBACK_CANCEL;
834 static void __amd_effect_image_file_set(char *image_file)
836 Ecore_X_Window root_win;
837 root_win = ecore_x_window_root_first_get();
838 ecore_x_window_prop_string_set(root_win, ATOM_IMAGE_EFFECT,image_file);
842 static void __amd_send_message_to_e17(int screenmode, const char * indicator)
844 Ecore_X_Window root_win;
846 root_win = ecore_x_window_root_first_get();
847 _D("root win : %x",root_win);
848 int screen_orientation[5]={0,270,0,180,90};
849 if (screenmode > 4 || screenmode < 0)
852 if (strncmp(indicator, "true", 4) == 0){
853 _D("[LAUNCHING EFFECT]: screen mode is %d, indicator show\n", screen_orientation[screenmode] );
854 ret = ecore_x_client_message32_send (root_win, ATOM_IMAGE_EFFECT,
855 ECORE_X_EVENT_MASK_WINDOW_PROPERTY, 1,
856 screen_orientation[screenmode],
857 SHOW_INDICATOR, 0, 0);
860 _D("[LAUNCHING EFFECT]: screen mode is %d, indicator hide\n", screen_orientation[screenmode] );
861 ret = ecore_x_client_message32_send (root_win, ATOM_IMAGE_EFFECT,
862 ECORE_X_EVENT_MASK_WINDOW_PROPERTY, 1,
863 screen_orientation[screenmode],
864 HIDE_INDICATOR, 0, 0);
867 _D("ecore_x_client_message32_send : %d",ret);
872 static int append_variant(DBusMessageIter *iter, const char *sig, char *param[])
882 for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) {
885 int_type = atoi(param[i]);
886 dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &int_type);
889 int_type = atoi(param[i]);
890 dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &int_type);
893 int64_type = atoi(param[i]);
894 dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &int64_type);
897 dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, param[i]);
907 int invoke_dbus_method_sync(const char *dest, const char *path,
908 const char *interface, const char *method,
909 const char *sig, char *param[])
912 DBusMessageIter iter;
917 msg = dbus_message_new_method_call(dest, path, interface, method);
919 _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
923 dbus_message_iter_init_append(msg, &iter);
924 r = append_variant(&iter, sig, param);
926 _E("append_variant error(%d)", r);
927 dbus_message_unref(msg);
931 dbus_error_init(&err);
933 reply = dbus_connection_send_with_reply_and_block(conn, msg, 500, &err);
934 dbus_message_unref(msg);
936 _E("dbus_connection_send error(%s:%s)", err.name, err.message);
937 dbus_error_free(&err);
941 r = dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
942 dbus_message_unref(reply);
944 _E("no message : [%s:%s]", err.name, err.message);
945 dbus_error_free(&err);
952 int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_uid, int fd)
954 const struct appinfo *ai;
956 const char *multiple = NULL;
957 const char *app_path = NULL;
958 const char *pkg_type = NULL;
959 const char *component_type = NULL;
961 char tmp_pid[MAX_PID_STR_BUFSZ];
963 const char *permission;
965 const char *taskmanage;
967 const char *pkg_status;
968 const char *operation;
969 char caller_appid[256];
971 pkgmgrinfo_cert_compare_result_type_e compare_result;
973 int pad_pid = LAUNCHPAD_PID;
976 char trm_buf[MAX_PACKAGE_STR_SIZE];
977 bool consented = true;
980 #ifdef WEARABLE_PROFILE
981 int wmanager_connected = 0;
984 snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", caller_pid);
985 bundle_add(kb, AUL_K_CALLER_PID, tmp_pid);
987 if (cmd == APP_START_RES)
988 bundle_add(kb, AUL_K_WAIT_RESULT, "1");
990 caller = _status_app_get_appid_bypid(caller_pid);
992 ret = aul_app_get_appid_bypid(caller_pid, caller_appid, sizeof(caller_appid));
994 bundle_add(kb, AUL_K_CALLER_APPID, caller_appid);
997 bundle_add(kb, AUL_K_CALLER_APPID, caller);
999 SECURE_LOGD("caller : %s", bundle_get_val(kb,AUL_K_CALLER_APPID));
1001 ai = appinfo_find(_laf, appid);
1005 __real_send(fd, -1);
1008 pkg_status = appinfo_get_value(ai, AIT_STATUS);
1009 if(pkg_status && strncmp(pkg_status, "upgrading", 9) == 0 ) {
1011 __real_send(fd, -1);
1013 } else if(pkg_status && strncmp(pkg_status, "unmounted", 9) == 0 ) {
1015 __real_send(fd, -1);
1020 pkgid = appinfo_get_value(ai, AIT_PKGID);
1022 if(bundle_get_val(kb, AUL_K_PRIVACY_APPID)){
1023 bundle_del(kb, AUL_K_PRIVACY_APPID);
1025 privacy_manager_client_check_user_consented(pkgid, &consented);
1027 _D("consented : %d", consented);
1029 if(consented == false && bundle_get_val(kb, AUL_K_SDK) == NULL) {
1030 _D("appid : %s", appid);
1031 bundle_add(kb, AUL_K_PRIVACY_APPID, appid);
1032 appid = PRIVACY_POPUP;
1033 bundle_del(kb, AUL_K_PKG_NAME);
1034 bundle_add(kb, AUL_K_PKG_NAME, appid);
1035 ai = appinfo_find(_laf, appid);
1039 app_path = appinfo_get_value(ai, AIT_EXEC);
1040 pkg_type = appinfo_get_value(ai, AIT_TYPE);
1041 permission = appinfo_get_value(ai, AIT_PERM);
1042 pkgid = appinfo_get_value(ai, AIT_PKGID);
1043 component_type = appinfo_get_value(ai, AIT_COMPTYPE);
1045 if(permission && strncmp(permission, "signature", 9) == 0 ) {
1046 if(caller_uid != 0 && (cmd == APP_START || cmd == APP_START_RES || cmd == APP_START_ASYNC)){
1047 const struct appinfo *caller_ai;
1048 caller_ai = appinfo_find(_laf, caller_appid);
1049 preload = appinfo_get_value(caller_ai, AIT_PRELOAD);
1050 if( preload && strncmp(preload, "true", 4) != 0 ) {
1051 pkgmgrinfo_pkginfo_compare_app_cert_info(caller_appid, appid, &compare_result);
1052 if(compare_result != PMINFO_CERT_COMPARE_MATCH) {
1053 pid = -EILLEGALACCESS;
1054 __real_send(fd, pid);
1061 pkgmgrinfo_client_request_enable_external_pkg(pkgid);
1063 if (component_type && strncmp(component_type, "uiapp", 5) == 0) {
1064 multiple = appinfo_get_value(ai, AIT_MULTI);
1065 if (!multiple || strncmp(multiple, "false", 5) == 0) {
1066 pid = _status_app_is_running_v2(appid);
1069 status = _status_get_app_info_status(pid);
1070 if (pid > 0 && status != STATUS_DYING) {
1071 if (caller_pid == pid) {
1072 SECURE_LOGD("caller process & callee process is same.[%s:%d]", appid, pid);
1073 pid = -ELOCALLAUNCH_ID;
1075 #ifdef WEARABLE_PROFILE
1076 proc_group_change_status(PROC_CGROUP_SET_RESUME_REQUEST, pid, appid);
1078 if ((ret = __nofork_processing(cmd, pid, kb, fd)) < 0) {
1084 } else if (cmd != APP_RESUME) {
1085 if(status == STATUS_DYING && pid > 0) {
1086 r = kill(pid, SIGKILL);
1088 _D("send SIGKILL: %s", strerror(errno));
1090 hwacc = appinfo_get_value(ai, AIT_HWACC);
1091 bundle_add(kb, AUL_K_HWACC, hwacc);
1092 taskmanage = appinfo_get_value(ai, AIT_TASKMANAGE);
1093 bundle_add(kb, AUL_K_TASKMANAGE, taskmanage);
1094 operation = bundle_get_val(kb, "__APP_SVC_OP_TYPE__");
1096 if ( cmd == APP_OPEN ||
1097 (operation != NULL && strncmp(operation, "http://tizen.org/appcontrol/operation/main", 512) == 0) ||
1098 (caller != NULL && strcmp(caller, "com.samsung.wnotification2") == 0) ){
1101 snprintf(val, sizeof(val), "%d", 1200);
1104 ret = invoke_dbus_method_sync(SYSTEM_BUS_NAME, SYSTEM_OBJECT_PATH,
1105 SYSTEM_INTERFACE_NAME, SYSTEM_METHOD_NAME, "i", arr);
1106 _D("%s-%s : %d", SYSTEM_INTERFACE_NAME, SYSTEM_METHOD_NAME, ret);
1111 * default mode : fake effect off, 1.6 MHZ off
1113 * full mode : fake effect on, 1.6 MHZ on
1115 * fake effect mode : fake effect on, 1.6 MHZ off
1117 * 1.6 MHZ mode : faek effect off, 1.6MHZ on
1120 vconf_get_int(AMD_EFFECT_IMAGE_ENABLE, &effect_mode);
1121 #ifdef WEARABLE_PROFILE
1122 vconf_get_bool(VCONFKEY_WMS_WMANAGER_CONNECTED, &wmanager_connected);
1123 //_D("*******[effect_mode] Mode : %d\n ", effect_mode );
1125 if ( ( cmd == APP_OPEN || (operation != NULL && strncmp(operation, "http://tizen.org/appcontrol/operation/main", 512) == 0) )
1126 && (effect_mode == 1 || effect_mode == 2) && wmanager_connected == true){
1128 if ( ( cmd == APP_OPEN || (operation != NULL && strncmp(operation, "http://tizen.org/appcontrol/operation/main", 512) == 0) )
1129 && (effect_mode == 1 || effect_mode == 2)){
1131 char image_filename[256] = {0,};
1132 const char *portraitimg = NULL;
1133 const char *indicator = NULL;
1134 bool rotate_allowed = false;
1136 vconf_get_bool(PHONE_ROTATE_LOCK, &rotate_allowed); /*TODO: use vconf_notify_key_changed()*/
1137 portraitimg = appinfo_get_value(ai, AIT_EFFECTIMAGEPORT);
1138 indicator = appinfo_get_value(ai, AIT_INDICATOR_DISP);
1139 /*Currently we assume apps supporting launching effect supports portrait mode*/
1141 snprintf(image_filename, 255, "%s", portraitimg);
1142 if (access(image_filename, R_OK) == 0){
1143 __amd_effect_image_file_set("/usr/share/splash_images/type0_portrait.bmp");
1144 __amd_send_message_to_e17(0, indicator);
1149 bundle_add(kb, AUL_K_EXEC, app_path);
1150 bundle_add(kb, AUL_K_PACKAGETYPE, pkg_type);
1151 if(bundle_get_type(kb, AUL_K_SDK) != BUNDLE_TYPE_NONE) {
1152 pad_pid = DEBUG_LAUNCHPAD_PID;
1153 } else if(strncmp(pkg_type, "wgt", 3) == 0) {
1154 pad_pid = WEB_LAUNCHPAD_PID;
1156 #ifdef PROCESS_POOL_ENABLE
1158 const char *process_pool = appinfo_get_value(ai, AIT_POOL);
1159 _D("process_pool: %s\n", process_pool);
1161 if (strncmp(process_pool, "true", 4) == 0)
1163 pad_pid = PROCESS_POOL_LAUNCHPAD_PID;
1168 pid = app_send_cmd(pad_pid, cmd, kb);
1170 pid = -ENOLAUNCHPAD;
1172 //_add_cgroup(_lcg, appid, pid);
1173 #ifdef WEARABLE_PROFILE
1174 proc_group_change_status(PROC_CGROUP_SET_LAUNCH_REQUEST, pid, appid);
1175 snprintf(trm_buf, MAX_PACKAGE_STR_SIZE, "appinfo_launch:%s[PID]%d", appid, pid);
1176 __trm_app_info_send_socket(trm_buf);
1180 else if (component_type && strncmp(component_type, "svcapp", 6) == 0) {
1181 pid = _status_app_is_running_v2(appid);
1183 if ((ret = __nofork_processing(cmd, pid, kb, fd)) < 0) {
1186 } else if (cmd != APP_RESUME) {
1187 pid = service_start(_lcg, appid, app_path, kb);
1188 #ifdef WEARABLE_PROFILE
1189 proc_group_change_status(PROC_CGROUP_SET_SERVICE_REQUEST, pid, appid);
1193 _E("unkown application");
1197 if(cmd == APP_START_ASYNC)
1200 __real_send(fd, pid);
1204 _status_add_app_info_list(appid, app_path, pid, pad_pid);
1207 #ifdef WEARABLE_PROFILE
1208 display_lock_state(LCD_OFF, STAY_CUR_STATE, 1000);
1215 int _launch_init(struct amdmgr* amd)
1219 conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
1221 _E("dbus_bus_get error");
1227 void _set_atom_effect(void)
1229 ATOM_IMAGE_EFFECT = ecore_x_atom_get(atom_name);