diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2015-12-10 18:05:49 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.vlan103.tizen.org> | 2015-12-10 18:05:49 -0800 |
commit | 6707c39e23ead9c697e22d901c811b0a4e4285df (patch) | |
tree | 12a8263ae349855b87aaa24bc06304f0ef52027b | |
parent | 84e940e56d169cbba8c4b281656541ff752a6a84 (diff) | |
parent | 8327b344ca9dc7e755ff8fbdcad599d5f5cad272 (diff) | |
download | aul-1-6707c39e23ead9c697e22d901c811b0a4e4285df.tar.gz aul-1-6707c39e23ead9c697e22d901c811b0a4e4285df.tar.bz2 aul-1-6707c39e23ead9c697e22d901c811b0a4e4285df.zip |
Merge "support debug-launchpad" into tizensubmit/tizen/20151211.044548accepted/tizen/wearable/20151212.072919accepted/tizen/tv/20151212.072423accepted/tizen/mobile/20151212.070857
-rw-r--r-- | am_daemon/amd_launch.c | 10 | ||||
-rw-r--r-- | am_daemon/amd_request.c | 6 | ||||
-rw-r--r-- | include/app_launchpad_types.h | 23 | ||||
-rw-r--r-- | include/app_sock.h | 6 | ||||
-rw-r--r-- | include/launch.h | 6 | ||||
-rw-r--r-- | packaging/aul.manifest | 2 | ||||
-rw-r--r-- | packaging/aul.spec | 2 | ||||
-rw-r--r-- | src/app_sock.c | 14 | ||||
-rw-r--r-- | src/launch.c | 13 | ||||
-rw-r--r-- | test/CMakeLists.txt | 10 | ||||
-rw-r--r-- | test/appid2pid.c | 33 | ||||
-rw-r--r-- | test/launch_debug.c | 103 |
12 files changed, 207 insertions, 21 deletions
diff --git a/am_daemon/amd_launch.c b/am_daemon/amd_launch.c index 3b31686a..6b993236 100644 --- a/am_daemon/amd_launch.c +++ b/am_daemon/amd_launch.c @@ -702,7 +702,8 @@ int _send_hint_for_visibility(uid_t uid) b = bundle_create(); - ret = app_agent_send_cmd(uid, PAD_CMD_VISIBILITY, b); + ret = app_agent_send_cmd(uid, LAUNCHPAD_PROCESS_POOL_SOCK, + PAD_CMD_VISIBILITY, b); if (b) bundle_free(b); @@ -740,6 +741,7 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid, gboolean can_attach = FALSE; gboolean new_process = FALSE; app_group_launch_mode launch_mode; + const char *pad_type = LAUNCHPAD_PROCESS_POOL_SOCK; snprintf(tmpbuf, MAX_PID_STR_BUFSZ, "%d", caller_pid); bundle_add(kb, AUL_K_CALLER_PID, tmpbuf); @@ -842,7 +844,11 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid, bundle_add(kb, AUL_K_PKGID, pkg_id); bundle_add(kb, AUL_K_INTERNAL_POOL, process_pool); bundle_add(kb, AUL_K_COMP_TYPE, component_type); - pid = app_agent_send_cmd(caller_uid, PAD_CMD_LAUNCH, kb); + + if (bundle_get_type(kb, AUL_K_SDK) != BUNDLE_TYPE_NONE) + pad_type = DEBUG_LAUNCHPAD_SOCK; + + pid = app_agent_send_cmd(caller_uid, pad_type, PAD_CMD_LAUNCH, kb); if (pid > 0) aul_send_app_launch_request_signal(pid, appid, pkg_id, component_type); } diff --git a/am_daemon/amd_request.c b/am_daemon/amd_request.c index d3dcdae1..6f016710 100644 --- a/am_daemon/amd_request.c +++ b/am_daemon/amd_request.c @@ -950,7 +950,8 @@ static int __dispatch_app_add_loader(int clifd, const app_pkt_t *pkt, struct ucr snprintf(tmpbuf, sizeof(tmpbuf), "%d", getpgid(cr->pid)); bundle_add(kb, AUL_K_CALLER_PID, tmpbuf); - ret = app_agent_send_cmd(cr->uid, PAD_CMD_ADD_LOADER, kb); + ret = app_agent_send_cmd(cr->uid, LAUNCHPAD_PROCESS_POOL_SOCK, + PAD_CMD_ADD_LOADER, kb); bundle_free(kb); __send_result_to_client(clifd, ret); @@ -968,7 +969,8 @@ static int __dispatch_app_remove_loader(int clifd, const app_pkt_t *pkt, struct return -1; } - ret = app_agent_send_cmd(cr->uid, PAD_CMD_REMOVE_LOADER, kb); + ret = app_agent_send_cmd(cr->uid, LAUNCHPAD_PROCESS_POOL_SOCK, + PAD_CMD_REMOVE_LOADER, kb); bundle_free(kb); __send_result_to_client(clifd, ret); diff --git a/include/app_launchpad_types.h b/include/app_launchpad_types.h new file mode 100644 index 00000000..c566d852 --- /dev/null +++ b/include/app_launchpad_types.h @@ -0,0 +1,23 @@ +/* + * 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 __APP_LAUNCHPAD_TYPES_H__ +#define __APP_LAUNCHPAD_TYPES_H__ + +#define LAUNCHPAD_PROCESS_POOL_SOCK ".launchpad-process-pool-sock" +#define DEBUG_LAUNCHPAD_SOCK ".debug-launchpad-sock" + +#endif /* __APP_LAUNCHPAD_TYPES_H__ */ diff --git a/include/app_sock.h b/include/app_sock.h index 68bbf68a..42da81ff 100644 --- a/include/app_sock.h +++ b/include/app_sock.h @@ -116,12 +116,12 @@ int __app_send_raw_with_noreply_for_uid(int pid, uid_t uid, int cmd, unsigned ch int __app_send_raw_with_delay_reply(int pid, int cmd, unsigned char *kb_data, int datalen); int __app_send_raw_with_delay_reply_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen); int __app_send_raw_with_fd_reply(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen, int *ret_fd); -int __app_agent_send_raw(int uid, int cmd, unsigned char *kb_data, int datalen); -int __app_agent_send_raw_with_noreply(int uid, int cmd, unsigned char *kb_data, int datalen); +int __app_agent_send_raw(int uid, const char *pad_type, int cmd, unsigned char *kb_data, int datalen); +int __app_agent_send_raw_with_noreply(int uid, const char *pad_type, int cmd, unsigned char *kb_data, int datalen); app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr); app_pkt_t *__app_send_cmd_with_result(int pid, int cmd, unsigned char *kb_data, int datalen); app_pkt_t *__app_send_cmd_with_result_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen); -int __create_agent_client_sock(int uid); +int __create_agent_client_sock(int uid, const char *pad_type); int __create_server_sock_by_path(char *path); int __create_sock_activation(void); #endif diff --git a/include/launch.h b/include/launch.h index c38f6bb5..4b34e6da 100644 --- a/include/launch.h +++ b/include/launch.h @@ -25,6 +25,8 @@ #include <glib.h> +#include "app_launchpad_types.h" + int aul_initialize(); int aul_register_init_callback( int (*aul_handler)(aul_type type, bundle *, void *), void *data); @@ -46,8 +48,8 @@ int aul_launch_app_with_result(const char *pkgname, bundle *kb, void (*cbfunc) (bundle *, int, void *), void *data); -int app_agent_send_cmd(int uid, int cmd, bundle *kb); -int app_agent_send_cmd_with_noreply(int uid, int cmd, bundle *kb); +int app_agent_send_cmd(int uid, const char *pad_type, int cmd, bundle *kb); +int app_agent_send_cmd_with_noreply(int uid, const char *pad_type, int cmd, bundle *kb); int app_subapp_terminate_request(void); int __call_aul_handler(aul_type type, bundle *kb); gboolean __aul_glib_handler(gpointer data); diff --git a/packaging/aul.manifest b/packaging/aul.manifest index 425b26a8..2c90873e 100644 --- a/packaging/aul.manifest +++ b/packaging/aul.manifest @@ -7,5 +7,7 @@ <filesystem path="/usr/bin/aul_test" exec_label="User" /> <filesystem path="/usr/bin/open_app" exec_label="User" /> <filesystem path="/usr/bin/launch_app" exec_label="User" /> + <filesystem path="/usr/bin/launch_debug" exec_label="User" /> + <filesystem path="/usr/bin/appid2pid" exec_label="User" /> </assign> </manifest> diff --git a/packaging/aul.spec b/packaging/aul.spec index 38bb9414..4f39cde1 100644 --- a/packaging/aul.spec +++ b/packaging/aul.spec @@ -135,6 +135,8 @@ systemctl daemon-reload %{_bindir}/app_launcher %{_bindir}/appgroup_info %{_bindir}/launch_app +%{_bindir}/appid2pid +%{_bindir}/launch_debug %{_datadir}/aul/miregex/* %{_datadir}/aul/preload_list.txt %{_datadir}/aul/preexec_list.txt diff --git a/src/app_sock.c b/src/app_sock.c index db9d7d68..31c50363 100644 --- a/src/app_sock.c +++ b/src/app_sock.c @@ -200,7 +200,7 @@ int __create_sock_activation(void) return -1; } -int __create_agent_client_sock(int uid) +int __create_agent_client_sock(int uid, const char *pad_type) { int fd = -1; struct sockaddr_un saddr = { 0, }; @@ -223,7 +223,7 @@ int __create_agent_client_sock(int uid) } saddr.sun_family = AF_UNIX; - snprintf(saddr.sun_path, UNIX_PATH_MAX, "/run/user/%d/.launchpad-process-pool-sock", uid); + snprintf(saddr.sun_path, UNIX_PATH_MAX, "/run/user/%d/%s", uid, pad_type); retry_con: ret = __connect_client_sock(fd, (struct sockaddr *)&saddr, sizeof(saddr), 100 * 1000); @@ -604,7 +604,8 @@ retry_recv: return res; } -int __app_agent_send_raw(int uid, int cmd, unsigned char *kb_data, int datalen) +int __app_agent_send_raw(int uid, const char *pad_type, + int cmd, unsigned char *kb_data, int datalen) { int fd; int len; @@ -619,7 +620,7 @@ int __app_agent_send_raw(int uid, int cmd, unsigned char *kb_data, int datalen) _D("uid(%d) : cmd(%d)", uid, cmd); - fd = __create_agent_client_sock(uid); + fd = __create_agent_client_sock(uid, pad_type); if (fd < 0) return -ECOMM; @@ -666,7 +667,8 @@ retry_recv: } -int __app_agent_send_raw_with_noreply(int uid, int cmd, unsigned char *kb_data, int datalen) +int __app_agent_send_raw_with_noreply(int uid, const char *pad_type, + int cmd, unsigned char *kb_data, int datalen) { int fd; int len; @@ -681,7 +683,7 @@ int __app_agent_send_raw_with_noreply(int uid, int cmd, unsigned char *kb_data, _D("uid(%d) : cmd(%d)", uid, cmd); - fd = __create_agent_client_sock(uid); + fd = __create_agent_client_sock(uid, pad_type); if (fd < 0) return -ECOMM; diff --git a/src/launch.c b/src/launch.c index fe79d807..d136b7f9 100644 --- a/src/launch.c +++ b/src/launch.c @@ -207,33 +207,34 @@ static int __app_send_cmd_with_fd(int pid, int uid, int cmd, bundle *kb, int *re } /** - * @brief encode kb and send it to 'pid' - * @param[in] pid receiver's pid + * @brief encode kb and send it to launchpad + * @param[in] uid receiver's uid + * @param[in] pad_type launchpad type * @param[in] cmd message's status (APP_START | APP_RESULT) * @param[in] kb data */ -SLPAPI int app_agent_send_cmd(int uid, int cmd, bundle *kb) +SLPAPI int app_agent_send_cmd(int uid, const char *pad_type, int cmd, bundle *kb) { int datalen; bundle_raw *kb_data; int res; bundle_encode(kb, &kb_data, &datalen); - if ((res = __app_agent_send_raw(uid, cmd, kb_data, datalen)) < 0) + if ((res = __app_agent_send_raw(uid, pad_type, cmd, kb_data, datalen)) < 0) res = __get_aul_error(res); free(kb_data); return res; } -SLPAPI int app_agent_send_cmd_with_noreply(int uid, int cmd, bundle *kb) +SLPAPI int app_agent_send_cmd_with_noreply(int uid, const char *pad_type, int cmd, bundle *kb) { int datalen; bundle_raw *kb_data; int res; bundle_encode(kb, &kb_data, &datalen); - if ((res = __app_send_raw_with_noreply(uid, cmd, kb_data, datalen)) < 0) + if ((res = __app_agent_send_raw_with_noreply(uid, pad_type, cmd, kb_data, datalen)) < 0) res = __get_aul_error(res); free(kb_data); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 899820f5..40e302ca 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,3 +16,13 @@ add_executable(open_app open_app.c) target_link_libraries(open_app aul ${pkgs_LDFLAGS} "-pie") INSTALL(TARGETS open_app DESTINATION bin) + +add_executable(appid2pid + appid2pid.c) +target_link_libraries(appid2pid aul ${pkgs_LDFLAGS} "-pie") +INSTALL(TARGETS appid2pid DESTINATION bin) + +add_executable(launch_debug + launch_debug.c) +target_link_libraries(launch_debug aul ${pkgs_LDFLAGS} "-pie") +INSTALL(TARGETS launch_debug DESTINATION bin) diff --git a/test/appid2pid.c b/test/appid2pid.c new file mode 100644 index 00000000..97f205ea --- /dev/null +++ b/test/appid2pid.c @@ -0,0 +1,33 @@ +/* + * 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. + */ + +#include <stdio.h> +#include <stdlib.h> + +#include "aul.h" + +int main(int argc, char **argv) +{ + if (argc < 2) { + printf("[usage] %s <appid>\n", argv[0]); + exit(EXIT_FAILURE); + } + + /* get pid by appid */ + printf("%d\n", aul_app_get_pid(argv[1])); + + return 0; +} diff --git a/test/launch_debug.c b/test/launch_debug.c new file mode 100644 index 00000000..f6b4174c --- /dev/null +++ b/test/launch_debug.c @@ -0,0 +1,103 @@ +/* + * 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. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <unistd.h> +#include <sys/types.h> +#include <string.h> +#include <bundle.h> +#include <bundle_internal.h> + +#include "aul.h" + +#define DLP_K_ATTACH_ARG "__DLP_ATTACH_ARG__" +#define SDK_ATTACH "ATTACH" + +static bundle *create_internal_bundle(int argc, char **argv) +{ + bundle *b; + int i; + int j; + int cnt; + char *arg[1024] = {0, }; + + b = bundle_create(); + if (b == NULL) + return NULL; + + for (i = 2; i < argc - 1; i++) { + if ((i + 1) > (argc - 1)) + bundle_add(b, argv[1], " "); + else if (argv[i] && strcmp(argv[i], AUL_K_SDK) == 0) + bundle_add(b, AUL_K_SDK, argv[i + 1]); + else if (argv[i] && strcmp(argv[i], DLP_K_ATTACH_ARG) == 0) { + arg[0] = strtok(argv[i + 1], ","); + + cnt = 1; + while ((arg[cnt] = strtok(NULL, ",")) != NULL) + cnt++; + + bundle_add(b, SDK_ATTACH, DLP_K_ATTACH_ARG); + bundle_add_str_array(b, DLP_K_ATTACH_ARG, NULL, cnt); + + for (j = 0; j < cnt; j++) + bundle_set_str_array_element(b, DLP_K_ATTACH_ARG, j, arg[j]); + } + } + + return b; +} + +static void print_usage(char *progname) +{ + printf("[usage] %s [appid] %s %s %s --attach,:[port],[pid]\n", + progname, AUL_K_SDK, SDK_ATTACH, DLP_K_ATTACH_ARG); + printf("ex) $ %s [appid] %s %s %s --attach,:10003,1234\n", + progname, AUL_K_SDK, SDK_ATTACH, DLP_K_ATTACH_ARG); +} + +int main(int argc, char **argv) +{ + int ret; + bundle *b; + + if (argc < 2) { + print_usage(argv[0]); + return -1; + } + + b = create_internal_bundle(argc, argv); + if (b == NULL) { + printf("out of memory\n"); + return -1; + } + + if (bundle_get_type(b, AUL_K_SDK) == BUNDLE_TYPE_NONE) { + print_usage(argv[0]); + bundle_free(b); + return -1; + } + + ret = aul_launch_app(argv[1], b); + if (ret < 0) + printf("Failed to launch %s\n", argv[1]); + + bundle_free(b); + + return 0; +} |