2 * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __LAUNCHPAD_COMMON_H__
18 #define __LAUNCHPAD_COMMON_H__
27 #include <bundle_internal.h>
28 #include <sys/socket.h>
31 #include <tzplatform_config.h>
35 #define LOG_TAG "LAUNCHPAD"
38 #define MAX_PENDING_CONNECTIONS 10
39 #define MAX_LOCAL_BUFSZ 128
40 #define AUL_SOCK_MAXBUFF 131071
41 #define LOADER_ARG_LEN 1024
43 #define PAD_CMD_LAUNCH 0
44 #define PAD_CMD_VISIBILITY 10
45 #define PAD_CMD_ADD_LOADER 11
46 #define PAD_CMD_REMOVE_LOADER 12
47 #define PAD_CMD_MAKE_DEFAULT_SLOTS 13
48 #define PAD_CMD_DEMAND 14
49 #define PAD_CMD_PING 15
50 #define PAD_CMD_UPDATE_APP_TYPE 16
51 #define PAD_CMD_PREPARE_APP_DEFINED_LOADER 17
53 #define LAUNCHPAD_LAUNCH_SIGNAL 83
54 #define LAUNCHPAD_DEAD_SIGNAL 61
55 #define APP_STARTUP_SIGNAL 89
57 #define PAD_LOADER_ID_STATIC 0
58 #define PAD_LOADER_ID_DIRECT 1
59 #define PAD_LOADER_ID_DYNAMIC_BASE 10
61 #define KEY_LOADER_TYPE "loader_type"
62 #define LOADER_TYPE_COMMON "common-loader"
63 #define LOADER_TYPE_HW "hw-loader"
64 #define LOADER_TYPE_SW "sw-loader"
66 #define _E(fmt, arg...) LOGE(fmt, ##arg)
67 #define _D(fmt, arg...) LOGD(fmt, ##arg)
68 #define _W(fmt, arg...) LOGW(fmt, ##arg)
69 #define _I(fmt, arg...) LOGI(fmt, ##arg)
71 #define FREE_AND_NULL(x) do { \
78 #define ARRAY_SIZE(x) ((sizeof(x)) / sizeof(x[0]))
79 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
85 typedef struct _app_pkt_t {
89 unsigned char data[1];
95 char *original_app_path;
108 void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd);
110 int _send_message_to_logger(const char *tag, const char *format, ...);
111 int _send_cmd_to_amd(int cmd);
112 int _create_server_sock(const char *name);
113 app_pkt_t *_recv_pkt_raw(int fd);
114 app_pkt_t *_accept_recv_pkt_raw(int fd, int *clifd, struct ucred *cr);
115 int _send_pkt_raw(int client_fd, app_pkt_t *pkt);
116 int _connect_to_launchpad(int type, int id);
117 int _set_sock_option(int fd, int cli);
118 void _set_env(appinfo_t *menu_info, bundle *kb);
119 char **_create_argc_argv(bundle *kb, int *margc);
120 char *_get_libdir(const char *path);
121 int _delete_sock_path(int pid, uid_t uid);
123 appinfo_t *_appinfo_create(bundle *kb);
124 void _appinfo_free(appinfo_t *menu_info);
125 char *_appinfo_get_app_path(appinfo_t *menu_info);
126 int _close_all_fds(void);
127 void _get_cpu_idle(unsigned long long *total, unsigned long long *idle);
128 int _setup_stdio(const char *ident);
129 int _set_priority(int prio);
130 int _wait_tep_mount(bundle *b);
131 int _prepare_app_socket(void);
132 int _enable_external_pkg(bundle *b, const char *pkgid, uid_t pkg_uid);
133 int _verify_proc_caps(void);
134 int _prepare_id_file(void);
135 void _print_hwc_log(const char *format, ...);
140 #endif /* __LAUNCHPAD_COMMON_H__ */