#define AUL_K_PKGID "__AUL_PKGID_"
#define AUL_K_DEBUG "__AUL_DEBUG__"
#define AUL_K_PRIVACY_APPID "__AUL_PRIVACY_APPID__"
+#define AUL_K_COMP_TYPE "__AUL_COMP_TYPE__"
#ifdef __cplusplus
}
#include <bundle_internal.h>
#include <sys/socket.h>
-#include "menu_db_util.h"
-
#ifdef LAUNCHPAD_LOG
#undef LOG_TAG
#define LOG_TAG "LAUNCHPAD"
#define MAX_LOCAL_BUFSZ 128
#define AUL_SOCK_MAXBUFF 65535
+#define PAD_CMD_LAUNCH 0
+#define PAD_CMD_VISIBILITY 10
+
#define _E(fmt, arg...) LOGE(fmt, ##arg)
#define _D(fmt, arg...) LOGD(fmt, ##arg)
#define _W(fmt, arg...) LOGW(fmt, ##arg)
unsigned char data[1];
} app_pkt_t;
+typedef struct {
+ char *appid;
+ char *app_path;
+ char *original_app_path;
+ char *pkg_type;
+ char *hwacc;
+ char *taskmanage;
+ char *pkgid;
+ char *comp_type;
+ char *internal_pool;
+} appinfo_t;
+
char *_proc_get_cmdline_bypid(int pid);
-app_info_from_db *_get_app_info_from_bundle_by_pkgname(const char *pkgname, bundle *kb);
-void _modify_bundle(bundle * kb, int caller_pid, app_info_from_db * menu_info, int cmd);
+void _modify_bundle(bundle * kb, int caller_pid, appinfo_t *menu_info, int cmd);
int _create_server_sock(const char *name);
app_pkt_t *_recv_pkt_raw(int fd, int *clifd, struct ucred *cr);
int _send_pkt_raw(int client_fd, app_pkt_t *pkt);
int _connect_to_launchpad(int type);
-void _set_env(app_info_from_db * menu_info, bundle * kb);
+void _set_env(appinfo_t *menu_info, bundle * kb);
char** _create_argc_argv(bundle * kb, int *margc);
+appinfo_t* _appinfo_create(bundle *kb);
+void _appinfo_free(appinfo_t *menu_info);
+char *_appinfo_get_app_path(appinfo_t *menu_info);
+
#endif
+++ /dev/null
-/*
- * Copyright (c) 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.
- */
-
-#ifndef __MENU_DB_UTIL_H_
-#define __MENU_DB_UTIL_H_
-
-#include <string.h>
-#include <stdio.h>
-#include <malloc.h>
-
-#define MAX_PATH_LEN 1024
-
-typedef struct {
- char *pkg_name; /* appid */
- char *app_path; /* exec */
- char *original_app_path; /* exec */
- char *pkg_type; /* x_slp_packagetype */
- char *hwacc; /* hwacceleration */
- char *taskmanage; /* taskmanage */
- char *pkg_id;
-} app_info_from_db;
-
-static inline char *_get_pkgname(app_info_from_db *menu_info)
-{
- return menu_info ? menu_info->pkg_name : NULL;
-}
-
-static inline char *_get_pkgid(app_info_from_db *menu_info)
-{
- return menu_info ? menu_info->pkg_id : NULL;
-}
-
-static inline char *_get_app_path(app_info_from_db *menu_info)
-{
- int i = 0;
- int path_len = -1;
-
- if (!menu_info || menu_info->app_path == NULL)
- return NULL;
-
- while (menu_info->app_path[i] != 0) {
- if (menu_info->app_path[i] == ' '
- || menu_info->app_path[i] == '\t') {
- path_len = i;
- break;
- }
- i++;
- }
-
- if (path_len == 0) {
- free(menu_info->app_path);
- menu_info->app_path = NULL;
- } else if (path_len > 0) {
- char *tmp_app_path = malloc(sizeof(char) * (path_len + 1));
- if(tmp_app_path == NULL)
- return NULL;
- snprintf(tmp_app_path, path_len + 1, "%s", menu_info->app_path);
- free(menu_info->app_path);
- menu_info->app_path = tmp_app_path;
- }
-
- return menu_info->app_path;
-}
-
-static inline char *_get_original_app_path(app_info_from_db *menu_info)
-{
- return menu_info ? menu_info->original_app_path : NULL;
-}
-
-static inline void _free_app_info_from_db(app_info_from_db *menu_info)
-{
- if (menu_info != NULL) {
- if (menu_info->pkg_name != NULL)
- free(menu_info->pkg_name);
- if (menu_info->app_path != NULL)
- free(menu_info->app_path);
- if (menu_info->original_app_path != NULL)
- free(menu_info->original_app_path);
- if (menu_info->pkg_type != NULL)
- free(menu_info->pkg_type);
- if (menu_info->hwacc != NULL)
- free(menu_info->hwacc);
- if (menu_info->taskmanage != NULL)
- free(menu_info->taskmanage);
- if (menu_info->pkg_id != NULL)
- free(menu_info->pkg_id);
- free(menu_info);
- }
-}
-
-#endif
#include "launchpad.h"
#define AUL_PR_NAME 16
-#define AUL_POLL_CNT 15
#define EXEC_CANDIDATE_EXPIRED 5
#define EXEC_CANDIDATE_WAIT 1
#define DIFF(a,b) (((a)>(b))?(a)-(b):(b)-(a))
int send_fd;
int last_exec_time;
guint source;
+ guint timer;
} candidate;
typedef struct {
} loader_context_t;
static candidate __candidate[LAUNCHPAD_TYPE_MAX] = {
- { CANDIDATE_NONE, CANDIDATE_NONE, -1, 0, 0 },
- { CANDIDATE_NONE, CANDIDATE_NONE, -1, 0, 0 },
- { CANDIDATE_NONE, CANDIDATE_NONE, -1, 0, 0 }
+ { CANDIDATE_NONE, CANDIDATE_NONE, -1, 0, 0, 0 },
+ { CANDIDATE_NONE, CANDIDATE_NONE, -1, 0, 0, 0 },
+ { CANDIDATE_NONE, CANDIDATE_NONE, -1, 0, 0, 0 }
};
static void __refuse_candidate_process(int server_fd)
}
static int __send_launchpad_loader(int type, app_pkt_t *pkt,
- const char *app_path, int clifd)
+ const char *app_path, int clifd, const char *comp_type)
{
char sock_path[PATH_MAX];
int pid = -1;
__send_result_to_caller(clifd, pid, app_path); //to AMD
- g_timeout_add(1000, __handle_preparing_candidate_process, GINT_TO_POINTER(type));
+ if (strcmp("uiapp", comp_type) == 0)
+ __candidate[type].timer = g_timeout_add(5000, __handle_preparing_candidate_process, GINT_TO_POINTER(type));
+ else
+ __candidate[type].timer = g_timeout_add(2000, __handle_preparing_candidate_process, GINT_TO_POINTER(type));
return pid;
}
}
static int __prepare_exec(const char *appId, const char *app_path,
- app_info_from_db * menu_info, bundle * kb)
+ appinfo_t *menu_info, bundle * kb)
{
char *file_name;
char process_name[AUL_PR_NAME];
}
static int __launch_directly(const char *appid, const char *app_path, int clifd,
- bundle* kb, app_info_from_db *menu_info)
+ bundle* kb, appinfo_t *menu_info)
{
char sock_path[PATH_MAX];
int pid = fork();
{
int i;
- for (i = 0; i < LAUNCHPAD_TYPE_MAX; ++i)
- __prepare_candidate_process(i);
+ for (i = 0; i < LAUNCHPAD_TYPE_MAX; ++i) {
+ if (__candidate[i].effective_pid == CANDIDATE_NONE) {
+ __prepare_candidate_process(i);
+ if (__candidate[i].timer > 0) {
+ g_source_remove(__candidate[i].timer);
+ __candidate[i].timer = 0;
+ }
+ }
+ }
}
static void __destroy_poll_data(gpointer data)
int fd = lc->gpollfd->fd;
bundle *kb = NULL;
app_pkt_t *pkt = NULL;
- app_info_from_db *menu_info = NULL;
+ appinfo_t *menu_info = NULL;
- const char *pkg_name = NULL;
- const char *internal_pool = NULL;
const char *app_path = NULL;
int pid = -1;
int clifd = -1;
goto end;
}
+ if (pkt->cmd == PAD_CMD_VISIBILITY) {
+ _W("cmd visibility");
+ __preload_candidate_process();
+ __real_send(clifd, 0);
+ clifd = -1;
+ goto end;
+ }
+
INIT_PERF(kb);
PERF("packet processing start");
- pkg_name = bundle_get_val(kb, AUL_K_APPID);
- SECURE_LOGD("pkg name : %s\n", pkg_name);
-
- menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb);
+ menu_info = _appinfo_create(kb);
if (menu_info == NULL) {
_E("such pkg no found");
goto end;
}
- app_path = _get_app_path(menu_info);
+ app_path = _appinfo_get_app_path(menu_info);
if (app_path == NULL) {
_E("app_path is NULL");
goto end;
goto end;
}
- internal_pool = bundle_get_val(kb, AUL_K_EXEC);
- SECURE_LOGD("exec : %s\n", internal_pool);
- internal_pool = bundle_get_val(kb, AUL_K_INTERNAL_POOL);
-
- SECURE_LOGD("internal pool : %s\n", internal_pool);
+ SECURE_LOGD("exec : %s\n", menu_info->app_path);
+ SECURE_LOGD("comp_type : %s\n", menu_info->comp_type);
+ SECURE_LOGD("internal pool : %s\n", menu_info->internal_pool);
SECURE_LOGD("hwacc : %s\n", menu_info->hwacc);
- type = __get_launchpad_type(internal_pool, menu_info->hwacc);
+ type = __get_launchpad_type(menu_info->internal_pool, menu_info->hwacc);
if (type < 0) {
_E("failed to get launchpad type");
goto end;
}
_modify_bundle(kb, cr.pid, menu_info, pkt->cmd);
- pkg_name = _get_pkgname(menu_info);
- if (pkg_name == NULL) {
- _E("unable to get pkg_name from menu_info");
+ if (menu_info->appid == NULL) {
+ _E("unable to get appid from menu_info");
goto end;
}
&& (__candidate[type].pid != CANDIDATE_NONE)
&& (DIFF(__candidate[type].last_exec_time, time(NULL)) > EXEC_CANDIDATE_WAIT)) {
_W("Launch on type-based process-pool");
- pid = __send_launchpad_loader(type, pkt, app_path, clifd);
+ pid = __send_launchpad_loader(type, pkt, app_path, clifd, menu_info->comp_type);
} else if ((__candidate[LAUNCHPAD_TYPE_COMMON].pid != CANDIDATE_NONE)
&& (DIFF(__candidate[LAUNCHPAD_TYPE_COMMON].last_exec_time,
time(NULL)) > EXEC_CANDIDATE_WAIT)) {
_W("Launch on common type process-pool");
- pid = __send_launchpad_loader(LAUNCHPAD_TYPE_COMMON, pkt, app_path, clifd);
+ pid = __send_launchpad_loader(LAUNCHPAD_TYPE_COMMON, pkt, app_path, clifd, menu_info->comp_type);
} else {
_W("Candidate is not prepared");
- pid = __launch_directly(pkg_name, app_path, clifd, kb, menu_info);
+ pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info);
__send_result_to_caller(clifd, pid, app_path);
}
clifd = -1;
if (clifd != -1)
close(clifd);
- if (pid > 0) {
+ if (pid > 0)
__send_app_launch_signal_dbus(pid);
- }
if (menu_info != NULL)
- _free_app_info_from_db(menu_info);
+ _appinfo_free(menu_info);
if (kb != NULL)
bundle_free(kb);
#include "launchpad_common.h"
#include "key.h"
+#define MAX_PATH_LEN 1024
#define BINSH_NAME "/bin/sh"
#define BINSH_SIZE 7
#define VALGRIND_NAME "/home/developer/sdk_tools/valgrind/usr/bin/valgrind"
#define CONNECT_RETRY_COUNT 3
#define AUL_PKT_HEADER_SIZE (sizeof(int) + sizeof(int))
-#define APP_START 0
-#define APP_OPEN 1
-#define APP_RESUME 2
-#define APP_START_RES 3
-
static int __read_proc(const char *path, char *buf, int size)
{
int fd;
return strdup(buf);
}
-app_info_from_db *_get_app_info_from_bundle_by_pkgname(const char *pkgname, bundle *kb)
+appinfo_t* _appinfo_create(bundle *kb)
{
- app_info_from_db *menu_info;
+ appinfo_t *menu_info;
const char *ptr = NULL;
- menu_info = calloc(1, sizeof(app_info_from_db));
+ menu_info = calloc(1, sizeof(appinfo_t));
if (menu_info == NULL)
return NULL;
- menu_info->pkg_name = strdup(pkgname);
+ ptr = bundle_get_val(kb, AUL_K_APPID);
+ if (ptr)
+ menu_info->appid = strdup(ptr);
ptr = bundle_get_val(kb, AUL_K_EXEC);
if (ptr)
menu_info->app_path = strdup(ptr);
menu_info->taskmanage = strdup(ptr);
ptr = bundle_get_val(kb, AUL_K_PKGID);
if (ptr)
- menu_info->pkg_id = strdup(ptr);
+ menu_info->pkgid = strdup(ptr);
+ ptr = bundle_get_val(kb, AUL_K_COMP_TYPE);
+ if (ptr)
+ menu_info->comp_type = strdup(ptr);
+ ptr = bundle_get_val(kb, AUL_K_INTERNAL_POOL);
+ if (ptr)
+ menu_info->internal_pool = strdup(ptr);
- if (!_get_app_path(menu_info)) {
- _free_app_info_from_db(menu_info);
+ if (!_appinfo_get_app_path(menu_info)) {
+ _appinfo_free(menu_info);
return NULL;
}
return menu_info;
}
-void _modify_bundle(bundle * kb, int caller_pid, app_info_from_db * menu_info, int cmd)
+char *_appinfo_get_app_path(appinfo_t *menu_info)
+{
+ int i = 0;
+ int path_len = -1;
+
+ if (!menu_info || menu_info->app_path == NULL)
+ return NULL;
+
+ while (menu_info->app_path[i] != 0) {
+ if (menu_info->app_path[i] == ' '
+ || menu_info->app_path[i] == '\t') {
+ path_len = i;
+ break;
+ }
+ i++;
+ }
+
+ if (path_len == 0) {
+ free(menu_info->app_path);
+ menu_info->app_path = NULL;
+ } else if (path_len > 0) {
+ char *tmp_app_path = malloc(sizeof(char) * (path_len + 1));
+ if(tmp_app_path == NULL)
+ return NULL;
+ snprintf(tmp_app_path, path_len + 1, "%s", menu_info->app_path);
+ free(menu_info->app_path);
+ menu_info->app_path = tmp_app_path;
+ }
+
+ return menu_info->app_path;
+}
+
+void _appinfo_free(appinfo_t *menu_info)
+{
+ if (menu_info != NULL) {
+ if (menu_info->appid != NULL)
+ free(menu_info->appid);
+ if (menu_info->app_path != NULL)
+ free(menu_info->app_path);
+ if (menu_info->original_app_path != NULL)
+ free(menu_info->original_app_path);
+ if (menu_info->pkg_type != NULL)
+ free(menu_info->pkg_type);
+ if (menu_info->hwacc != NULL)
+ free(menu_info->hwacc);
+ if (menu_info->taskmanage != NULL)
+ free(menu_info->taskmanage);
+ if (menu_info->pkgid != NULL)
+ free(menu_info->pkgid);
+ if (menu_info->comp_type != NULL)
+ free(menu_info->comp_type);
+ if (menu_info->internal_pool != NULL)
+ free(menu_info->internal_pool);
+
+ free(menu_info);
+ }
+}
+
+void _modify_bundle(bundle * kb, int caller_pid, appinfo_t *menu_info, int cmd)
{
bundle_del(kb, AUL_K_APPID);
bundle_del(kb, AUL_K_EXEC);
bundle_del(kb, AUL_K_HWACC);
bundle_del(kb, AUL_K_TASKMANAGE);
bundle_del(kb, AUL_K_PKGID);
+ bundle_del(kb, AUL_K_COMP_TYPE);
+ bundle_del(kb, AUL_K_INTERNAL_POOL);
/* Parse app_path to retrieve default bundle*/
- if (cmd == APP_START || cmd == APP_START_RES || cmd == APP_OPEN
- || cmd == APP_RESUME) {
+ if (cmd == PAD_CMD_LAUNCH) {
char *ptr;
char exe[MAX_PATH_LEN];
int flag;
- ptr = _get_original_app_path(menu_info);
+ ptr = menu_info->original_app_path;
flag = __parse_app_path(ptr, exe, sizeof(exe));
if (flag > 0) {
return -1;
}
-void _set_env(app_info_from_db * menu_info, bundle * kb)
+void _set_env(appinfo_t *menu_info, bundle * kb)
{
const char *str;
char* out_app_path, int* out_argc, char ***out_argv, int type)
{
bundle *kb = NULL;
- app_info_from_db *menu_info = NULL;
- const char *app_id = NULL;
+ appinfo_t *menu_info = NULL;
const char *app_path = NULL;
- const char *pkg_id = NULL;
int tmp_argc = 0;
char **tmp_argv = NULL;
int ret = -1;
__bundle = kb;
atexit(__at_exit_to_release_bundle);
- app_id = bundle_get_val(kb, AUL_K_APPID);
- if (app_id == NULL) {
- _E("Unable to get app_id");
+ menu_info = _appinfo_create(kb);
+ if (menu_info == NULL) {
+ _D("such pkg no found");
exit(-1);
}
- menu_info = _get_app_info_from_bundle_by_pkgname(app_id, kb);
- if (menu_info == NULL) {
- _D("such pkg no found");
+ if (menu_info->appid == NULL) {
+ _E("Unable to get app_id");
exit(-1);
}
exit(-1);
}
- SECURE_LOGD("app id: %s, launchpad type: %d", app_id, type);
+ SECURE_LOGD("app id: %s, launchpad type: %d", menu_info->appid, type);
- app_path = _get_app_path(menu_info);
+ app_path = _appinfo_get_app_path(menu_info);
if (app_path == NULL) {
_E("app_path is NULL");
exit(-1);
_modify_bundle(kb, /*cr.pid - unused parameter*/ 0, menu_info, pkt->cmd);
- app_id = _get_pkgname(menu_info);
- if (app_id == NULL) {
- _E("unable to get app_id from menu_info");
- exit(-1);
- }
- SECURE_LOGD("app id: %s", app_id);
- __appid = strdup(app_id);
+ __appid = strdup(menu_info->appid);
if (__appid == NULL) {
_E("Out of memory");
exit(-1);
}
aul_set_preinit_appid(__appid);
- pkg_id = _get_pkgid(menu_info);
- if (pkg_id == NULL) {
+ if (menu_info->pkgid == NULL) {
_E("unable to get pkg_id from menu_info");
exit(-1);
}
- SECURE_LOGD("pkg id: %s", pkg_id);
+ SECURE_LOGD("pkg id: %s", menu_info->pkgid);
- __pkgid = strdup(pkg_id);
+ __pkgid = strdup(menu_info->pkgid);
if (__pkgid == NULL) {
_E("Out of memory");
exit(-1);
exit(-1);
if (menu_info != NULL)
- _free_app_info_from_db(menu_info);
+ _appinfo_free(menu_info);
return ret;
}
__argc = argc;
__argv = argv;
- //temp - this requires some optimization.
- sleep(1);
- _D("sleeping 1 sec...");
-
if (__before_loop(argc, argv) != 0)
return -1;
#include <bundle_internal.h>
#include <aul.h>
-#include "menu_db_util.h"
#include "launchpad_common.h"
#include "preload.h"
#include "process_pool_preload.h"