summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2015-12-27 15:54:36 -0800
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2015-12-27 15:54:36 -0800
commitd4a8c53d4828b3008d77b28d18393b1bc8e98de6 (patch)
treea2d6e399ea855923b6a81ddf8606f4432134a109
parent4724f7edfc7796d54a5f9cd09aaad2c023da7507 (diff)
parent5eeba49a88829ab7272f89f276a68d6cb69ec2df (diff)
downloadaul-1-d4a8c53d4828b3008d77b28d18393b1bc8e98de6.tar.gz
aul-1-d4a8c53d4828b3008d77b28d18393b1bc8e98de6.tar.bz2
aul-1-d4a8c53d4828b3008d77b28d18393b1bc8e98de6.zip
-rw-r--r--CMakeLists.txt5
-rw-r--r--include/app_launchpad_types.h22
-rw-r--r--include/app_sock.h73
-rw-r--r--include/aul_sock.h74
-rw-r--r--include/launch.h5
-rw-r--r--packaging/aul.spec1
-rw-r--r--src/app_group.c20
-rw-r--r--src/aul_sock.c (renamed from src/app_sock.c)724
-rw-r--r--src/key.c2
-rw-r--r--src/launch.c53
-rw-r--r--src/launch_with_result.c2
-rw-r--r--src/pkginfo.c26
-rwxr-xr-xsrc/service.c2
-rw-r--r--src/status.c12
14 files changed, 333 insertions, 688 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0a1ba667..b8f827cf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,7 @@ ENDIF (with_x11)
# Set required packages
INCLUDE(FindPkgConfig)
-SET(AUL-1_LIB_PKG_CHECK_MODULES dlog bundle dbus-glib-1 xdgmime libtzplatform-config pkgmgr-info libsystemd-daemon capi-system-info vconf sqlite3 iniparser)
+SET(AUL-1_LIB_PKG_CHECK_MODULES dlog bundle dbus-glib-1 xdgmime libtzplatform-config pkgmgr-info capi-system-info vconf sqlite3 iniparser)
IF (with_wayland)
pkg_check_modules(libpkgs REQUIRED ${AUL-1_LIB_PKG_CHECK_MODULES} wayland-client tizen-extension-client ecore-wayland)
ENDIF (with_wayland)
@@ -46,7 +46,6 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
# aul_mods : modules (static library)
add_library(aul_mods STATIC
- src/app_sock.c
src/simple_util.c
)
@@ -66,6 +65,7 @@ add_library(aul SHARED
src/aul_path.c
src/app_group.c
src/aul_rsc_mgr.c
+ src/aul_sock.c
)
TARGET_LINK_LIBRARIES(aul aul_mods ${libpkgs_LDFLAGS})
SET_TARGET_PROPERTIES(aul PROPERTIES SOVERSION ${MAJORVER})
@@ -93,6 +93,7 @@ CONFIGURE_FILE(feature/preexec_list.txt.in feature/preexec_list.txt @ONLY)
# Install headers, other files
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul.h DESTINATION include/aul)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_sock.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_rsc_mgr.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_svc.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_cmd.h DESTINATION include/aul)
diff --git a/include/app_launchpad_types.h b/include/app_launchpad_types.h
deleted file mode 100644
index e250d10f..00000000
--- a/include/app_launchpad_types.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.
- */
-
-#pragma once
-
-#define LAUNCHPAD_PROCESS_POOL_SOCK ".launchpad-process-pool-sock"
-#define DEBUG_LAUNCHPAD_SOCK ".debug-launchpad-sock"
-
-
diff --git a/include/app_sock.h b/include/app_sock.h
deleted file mode 100644
index d69ff04f..00000000
--- a/include/app_sock.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.
- */
-
-#pragma once
-
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#include "aul_cmd.h"
-
-#define AUL_SOCK_PREFIX "/tmp/alaunch"
-#define AUL_SOCK_MAXBUFF 65535
-#define LAUNCHPAD_PID -1
-#define WEB_LAUNCHPAD_PID -3
-#define DEBUG_LAUNCHPAD_PID -4
-#define ELOCALLAUNCH_ID 128
-#define EILLEGALACCESS 127
-#define ETERMINATING 126
-#define ENOLAUNCHPAD 125
-#define EREJECTED 123
-#define UNIX_PATH_MAX 108
-
-#define PAD_CMD_LAUNCH 0
-#define PAD_CMD_VISIBILITY 10
-#define PAD_CMD_ADD_LOADER 11
-#define PAD_CMD_REMOVE_LOADER 12
-
-typedef struct _app_pkt_t {
- int cmd;
- int len;
- unsigned char data[1];
-} app_pkt_t;
-#define AUL_PKT_HEADER_SIZE (sizeof(int) + sizeof(int))
-
-typedef struct _pkt_t {
- uid_t caller_uid;
- app_pkt_t *pkt;
-} pkt_t;
-
-int __create_server_sock(int pid);
-int __create_client_sock(int pid, uid_t uid);
-int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen);
-int __app_send_raw_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen);
-int __app_send_raw_with_noreply(int pid, int cmd, unsigned char *kb_data, int datalen);
-int __app_send_raw_with_noreply_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen);
-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, 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, const char *pad_type);
-int __create_server_sock_by_path(char *path);
-int __create_sock_activation(void);
-
-
diff --git a/include/aul_sock.h b/include/aul_sock.h
new file mode 100644
index 00000000..8fea4e9f
--- /dev/null
+++ b/include/aul_sock.h
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include "aul_cmd.h"
+
+#define AUL_SOCK_MAXBUFF 65535
+#define ELOCALLAUNCH_ID 128
+#define EILLEGALACCESS 127
+#define ETERMINATING 126
+#define ENOLAUNCHPAD 125
+#define EREJECTED 123
+
+#define AUL_PKT_HEADER_SIZE (sizeof(int) + sizeof(int))
+
+typedef struct _app_pkt_t {
+ int cmd;
+ int len;
+ unsigned char data[1];
+} app_pkt_t;
+
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_sock_create_server(int pid, uid_t uid);
+
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_sock_send_raw(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen);
+
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_sock_send_raw_async(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen);
+
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_sock_send_raw_async_with_fd(int fd, int cmd, unsigned char *kb_data, int datalen);
+
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_sock_send_raw_with_fd_reply(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen, int *ret_fd);
+
+/*
+ * This API is only for Appfw internally.
+ */
+app_pkt_t *aul_sock_send_raw_with_pkt_reply(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen);
+
+/*
+ * This API is only for Appfw internally.
+ */
+app_pkt_t *aul_sock_recv_pkt(int fd, int *clifd, struct ucred *cr);
diff --git a/include/launch.h b/include/launch.h
index 98cf8c89..28ff2498 100644
--- a/include/launch.h
+++ b/include/launch.h
@@ -18,8 +18,6 @@
#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);
@@ -40,9 +38,6 @@ int aul_send_result(bundle *kb, int is_cancel);
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, 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.spec b/packaging/aul.spec
index 54892866..1d6ac843 100644
--- a/packaging/aul.spec
+++ b/packaging/aul.spec
@@ -27,7 +27,6 @@ BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: libattr-devel
BuildRequires: pkgconfig(libtzplatform-config)
-BuildRequires: pkgconfig(libsystemd-daemon)
BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(iniparser)
BuildRequires: pkgconfig(sqlite3)
diff --git a/src/app_group.c b/src/app_group.c
index 3c3eeb32..e310e09c 100644
--- a/src/app_group.c
+++ b/src/app_group.c
@@ -25,7 +25,7 @@
#include "aul.h"
#include "aul_api.h"
#include "aul_util.h"
-#include "app_sock.h"
+#include "aul_sock.h"
#include "launch.h"
#include "simple_util.h"
@@ -65,8 +65,8 @@ API void aul_app_group_get_leader_pids(int *cnt, int **pids)
*cnt = 0;
*pids = NULL;
- ret = __app_send_cmd_with_result(AUL_UTIL_PID, APP_GROUP_GET_LEADER_PIDS,
- NULL, 0);
+ ret = aul_sock_send_raw_with_pkt_reply(AUL_UTIL_PID, getuid(),
+ APP_GROUP_GET_LEADER_PIDS, NULL, 0);
if (ret != NULL) {
*cnt = ret->len / sizeof(int);
if (ret->len > 0 && ret->len <= AUL_SOCK_MAXBUFF - 8) {
@@ -99,9 +99,8 @@ API void aul_app_group_get_group_pids(int leader_pid, int *cnt, int **pids)
bundle_add_str(b, AUL_K_LEADER_PID, buf);
bundle_encode(b, &br, &datalen);
- ret = __app_send_cmd_with_result(AUL_UTIL_PID, APP_GROUP_GET_GROUP_PIDS, br,
- datalen);
-
+ ret = aul_sock_send_raw_with_pkt_reply(AUL_UTIL_PID, getuid(),
+ APP_GROUP_GET_GROUP_PIDS, br, datalen);
if (ret != NULL) {
*cnt = ret->len / sizeof(int);
if (ret->len > 0 && ret->len <= AUL_SOCK_MAXBUFF - 8) {
@@ -141,7 +140,7 @@ API int aul_app_group_get_leader_pid(int pid)
API int aul_app_group_clear_top(void)
{
unsigned char dummy[1] = { 0 };
- return __app_send_raw(AUL_UTIL_PID, APP_GROUP_CLEAR_TOP, dummy, 0);
+ return aul_sock_send_raw(AUL_UTIL_PID, getuid(), APP_GROUP_CLEAR_TOP, dummy, 0);
}
API int aul_app_group_is_top(void)
@@ -185,7 +184,8 @@ API void aul_app_group_lower(int *exit)
{
int ret;
unsigned char dummy[1] = { 0 };
- ret = __app_send_raw(AUL_UTIL_PID, APP_GROUP_LOWER, dummy, 0);
+
+ ret = aul_sock_send_raw(AUL_UTIL_PID, getuid(), APP_GROUP_LOWER, dummy, 0);
*exit = ret;
}
@@ -195,8 +195,8 @@ API void aul_app_group_get_idle_pids(int *cnt, int **pids)
*cnt = 0;
*pids = NULL;
- ret = __app_send_cmd_with_result(AUL_UTIL_PID, APP_GROUP_GET_IDLE_PIDS,
- NULL, 0);
+ ret = aul_sock_send_raw_with_pkt_reply(AUL_UTIL_PID, getuid(),
+ APP_GROUP_GET_IDLE_PIDS, NULL, 0);
if (ret != NULL) {
*cnt = ret->len / sizeof(int);
if (ret->len > 0 && ret->len <= AUL_SOCK_MAXBUFF - 8) {
diff --git a/src/app_sock.c b/src/aul_sock.c
index f2d81141..16310810 100644
--- a/src/app_sock.c
+++ b/src/aul_sock.c
@@ -23,9 +23,9 @@
#include <sys/xattr.h>
#include <errno.h>
#include <fcntl.h>
-#include <systemd/sd-daemon.h>
-#include "app_sock.h"
+#include "aul_api.h"
+#include "aul_sock.h"
#include "simple_util.h"
#define MAX_NR_OF_DESCRIPTORS 2
@@ -33,7 +33,6 @@
static int __connect_client_sock(int sockfd, const struct sockaddr *saptr, socklen_t salen,
int nsec);
-
static inline void __set_sock_option(int fd, int cli)
{
int size;
@@ -46,7 +45,7 @@ static inline void __set_sock_option(int fd, int cli)
setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
}
-int __create_server_sock(int pid)
+API int aul_sock_create_server(int pid, uid_t uid)
{
struct sockaddr_un saddr;
struct sockaddr_un p_saddr;
@@ -69,7 +68,7 @@ int __create_server_sock(int pid)
memset(&saddr, 0, sizeof(saddr));
saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, UNIX_PATH_MAX, "/run/user/%d/%d", getuid(), pid);
+ snprintf(saddr.sun_path, sizeof(saddr.sun_path), "/run/user/%d/%d", uid, pid);
unlink(saddr.sun_path);
/* labeling to socket for SMACK */
@@ -116,12 +115,12 @@ int __create_server_sock(int pid)
}
/* support app launched by shell script */
- if (pid != LAUNCHPAD_PID) {
+ if (pid > 0) {
int pgid;
pgid = getpgid(pid);
if (pgid > 1) {
- snprintf(p_saddr.sun_path, UNIX_PATH_MAX, "/run/user/%d/%d",
- getuid(), pgid);
+ snprintf(p_saddr.sun_path, sizeof(p_saddr.sun_path),
+ "/run/user/%d/%d", uid, pgid);
if (link(saddr.sun_path, p_saddr.sun_path) < 0) {
if (errno == EEXIST)
_D("pg path - already exists");
@@ -134,68 +133,7 @@ int __create_server_sock(int pid)
return fd;
}
-
-int __create_server_sock_by_path(char *path)
-{
- struct sockaddr_un saddr;
- int fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
- /* support above version 2.6.27*/
- if (fd < 0) {
- if (errno == EINVAL) {
- fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (fd < 0) {
- _E("second chance - socket create error");
- return -1;
- }
- } else {
- _E("socket error");
- return -1;
- }
- }
-
- memset(&saddr, 0, sizeof(saddr));
- saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s", path);
- unlink(saddr.sun_path);
-
- if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
- _E("bind error");
- close(fd);
- return -1;
- }
-
- if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
- /* Flawfinder: ignore*/
- _E("failed to change the socket permission");
- close(fd);
- return -1;
- }
- __set_sock_option(fd, 0);
- if (listen(fd, 128) == -1) {
- _E("listen error");
- close(fd);
- return -1;
- }
- return fd;
-}
-
-int __create_sock_activation(void)
-{
- int fds;
-
- fds = sd_listen_fds(0);
- if (fds == 1)
- return SD_LISTEN_FDS_START;
-
- if (fds > 1)
- _E("Too many file descriptors received.\n");
- else
- _D("There is no socket stream");
-
- return -1;
-}
-
-int __create_agent_client_sock(int uid, const char *pad_type)
+static int __create_client_sock(int pid, uid_t uid)
{
int fd = -1;
struct sockaddr_un saddr = { 0, };
@@ -218,53 +156,8 @@ int __create_agent_client_sock(int uid, const char *pad_type)
}
saddr.sun_family = AF_UNIX;
- 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);
- if (ret < -1) {
- _E("maybe peer not launched or peer daed\n");
- if (retry > 0) {
- usleep(100 * 1000);
- retry--;
- goto retry_con;
- }
- }
- if (ret < 0) {
- close(fd);
- return -1;
- }
-
- __set_sock_option(fd, 1);
-
- return fd;
-}
-
-
-int __create_client_sock(int pid, uid_t uid)
-{
- int fd = -1;
- struct sockaddr_un saddr = { 0, };
- int retry = 1;
- int ret = -1;
-
- fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
- /* support above version 2.6.27*/
- if (fd < 0) {
- if (errno == EINVAL) {
- fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (fd < 0) {
- _E("second chance - socket create error");
- return -1;
- }
- } else {
- _E("socket error");
- return -1;
- }
- }
-
- saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, UNIX_PATH_MAX, "/run/user/%d/%d", uid, pid);
+ snprintf(saddr.sun_path, sizeof(saddr.sun_path),
+ "/run/user/%d/%d", uid, pid);
retry_con:
ret = __connect_client_sock(fd, (struct sockaddr *)&saddr, sizeof(saddr),
100 * 1000);
@@ -342,33 +235,13 @@ static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t
return (0);
}
-/**
- * @brief Send data (in raw) to the process with 'pid' via socket
- */
-int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
-{
- return __app_send_raw_for_uid(pid, getuid(), cmd, kb_data, datalen);
-}
-
-int __app_send_raw_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen)
+API int aul_sock_send_raw_async_with_fd(int fd, int cmd,
+ unsigned char *kb_data, int datalen)
{
- int fd;
int len;
int sent = 0;
- int res = 0;
app_pkt_t *pkt = NULL;
- if (kb_data == NULL) {
- _E("keybundle error\n");
- return -EINVAL;
- }
-
- _D("pid(%d) : cmd(%d)", pid, cmd);
-
- fd = __create_client_sock(pid, uid);
- if (fd < 0)
- return -ECOMM;
-
pkt = (app_pkt_t *)malloc(AUL_PKT_HEADER_SIZE + datalen);
if (NULL == pkt) {
_E("Malloc Failed!");
@@ -377,13 +250,14 @@ int __app_send_raw_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data,
pkt->cmd = cmd;
pkt->len = datalen;
- memcpy(pkt->data, kb_data, pkt->len);
+
+ if (kb_data)
+ memcpy(pkt->data, kb_data, pkt->len);
while (sent != AUL_PKT_HEADER_SIZE + pkt->len) {
len = send(fd, pkt, AUL_PKT_HEADER_SIZE + pkt->len - sent, 0);
if (len <= 0) {
- _E("send error pid:%d, fd:%d (errno %d)", pid, fd, errno);
- close(fd);
+ _E("send error fd:%d (errno %d)", fd, errno);
free(pkt);
return -ECOMM;
}
@@ -392,6 +266,36 @@ int __app_send_raw_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data,
free(pkt);
+ return 0;
+}
+
+/*
+ * @brief Send data (in raw) to the process with 'pid' via socket
+ */
+API int aul_sock_send_raw(int pid, uid_t uid, int cmd,
+ unsigned char *kb_data, int datalen)
+{
+ int fd;
+ int len;
+ int res;
+
+ if (kb_data == NULL) {
+ _E("keybundle error");
+ return -EINVAL;
+ }
+
+ _D("pid(%d): cmd(%d)", pid, cmd);
+
+ fd = __create_client_sock(pid, uid);
+ if (fd < 0)
+ return -ECOMM;
+
+ res = aul_sock_send_raw_async_with_fd(fd, cmd, kb_data, datalen);
+ if (res < 0) {
+ close(fd);
+ return res;
+ }
+
retry_recv:
len = recv(fd, &res, sizeof(int), 0);
if (len == -1) {
@@ -406,25 +310,181 @@ retry_recv:
res = -ECOMM;
}
}
+
close(fd);
return res;
}
+API int aul_sock_send_raw_async(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen)
+{
+ int fd;
+
+ if (kb_data == NULL) {
+ _E("keybundle error\n");
+ return -EINVAL;
+ }
+
+ _D("pid(%d) : cmd(%d)", pid, cmd);
+
+ fd = __create_client_sock(pid, uid);
+ if (fd < 0)
+ return -ECOMM;
+
+ aul_sock_send_raw_async_with_fd(fd, cmd, kb_data, datalen);
+
+ return fd;
+}
+
+API app_pkt_t *aul_sock_recv_pkt(int fd, int *clifd, struct ucred *cr)
+{
+ int len;
+ int ret;
+ struct sockaddr_un aul_addr = { 0, };
+ int sun_size;
+ app_pkt_t *pkt = NULL;
+ int cl = sizeof(struct ucred);
+ unsigned char buf[AUL_SOCK_MAXBUFF];
+ int cmd;
+ int datalen;
+
+ sun_size = sizeof(struct sockaddr_un);
+
+ if ((*clifd = accept(fd, (struct sockaddr *)&aul_addr,
+ (socklen_t *) &sun_size)) == -1) {
+ if (errno != EINTR)
+ _E("accept error");
+ return NULL;
+ }
+
+ if (getsockopt(*clifd, SOL_SOCKET, SO_PEERCRED, cr,
+ (socklen_t *) &cl) < 0) {
+ _E("peer information error");
+ close(*clifd);
+ return NULL;
+ }
+
+ __set_sock_option(*clifd, 1);
+
+ retry_recv:
+ /* receive header(cmd, datalen) */
+ len = recv(*clifd, buf, AUL_PKT_HEADER_SIZE, 0);
+ if (len < 0)
+ if (errno == EINTR)
+ goto retry_recv;
+
+ if (len < AUL_PKT_HEADER_SIZE) {
+ _E("recv error");
+ close(*clifd);
+ return NULL;
+ }
+ memcpy(&cmd, buf, sizeof(int));
+ memcpy(&datalen, buf + sizeof(int), sizeof(int));
+
+ /* allocate for a null byte */
+ pkt = (app_pkt_t *)calloc(1, AUL_PKT_HEADER_SIZE + datalen + 1);
+ if (pkt == NULL) {
+ close(*clifd);
+ return NULL;
+ }
+ pkt->cmd = cmd;
+ pkt->len = datalen;
+
+ len = 0;
+ while (len != pkt->len) {
+ ret = recv(*clifd, pkt->data + len, pkt->len - len, 0);
+ if (ret < 0) {
+ _E("recv error %d %d", len, pkt->len);
+ free(pkt);
+ close(*clifd);
+ return NULL;
+ }
+ len += ret;
+ _D("recv len %d %d", len, pkt->len);
+ }
+
+ return pkt;
+}
+
+API app_pkt_t *aul_sock_send_raw_with_pkt_reply(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen)
+{
+ int fd;
+ int len;
+ int ret;
+ app_pkt_t *pkt = NULL;
+ unsigned char buf[AUL_SOCK_MAXBUFF];
+
+ fd = __create_client_sock(pid, uid);
+ if (fd < 0)
+ return NULL;
+
+ ret = aul_sock_send_raw_async_with_fd(fd, cmd, kb_data, datalen);
+ if (ret < 0) {
+ close(fd);
+ return NULL;
+ }
+
+retry_recv:
+ /* receive header(cmd, datalen) */
+ len = recv(fd, buf, AUL_PKT_HEADER_SIZE, 0);
+ if (len < 0)
+ if (errno == EINTR)
+ goto retry_recv;
+
+ if (len < AUL_PKT_HEADER_SIZE) {
+ _E("recv error");
+ close(fd);
+ return NULL;
+ }
+ memcpy(&cmd, buf, sizeof(int));
+ memcpy(&len, buf + sizeof(int), sizeof(int));
+
+ /* allocate for a null byte */
+ pkt = (app_pkt_t *)calloc(1, AUL_PKT_HEADER_SIZE + len + 1);
+ if (pkt == NULL) {
+ close(fd);
+ return NULL;
+ }
+ pkt->cmd = cmd;
+ pkt->len = len;
+
+ len = 0;
+ while (len != pkt->len) {
+ ret = recv(fd, pkt->data + len, pkt->len - len, 0);
+ if (ret < 0) {
+ if (errno == EINTR) {
+ continue;
+ } else {
+ _E("recv error %s\n", strerror(errno));
+ free(pkt);
+ close(fd);
+ return NULL;
+ }
+ }
+ len += ret;
+ _D("recv len %d %d", len, pkt->len);
+ }
+ close(fd);
+
+ return pkt;
+}
static int __get_descriptors(struct cmsghdr *cmsg, struct msghdr *msg, int *fds, int maxdesc)
{
int retnr = 0;
+ int nrdesc;
+ int payload;
+ int *recvdesc;
+ int i;
+
if (cmsg == NULL || msg == NULL)
return 0;
if (cmsg->cmsg_type != SCM_RIGHTS)
return 0;
if (msg->msg_controllen > 0) {
- int nrdesc;
- int payload = cmsg->cmsg_len - sizeof(*cmsg);
- int *recvdesc = (int *)CMSG_DATA(cmsg);
- int i;
+ payload = cmsg->cmsg_len - sizeof(*cmsg);
+ recvdesc = (int *)CMSG_DATA(cmsg);
nrdesc = payload / sizeof(int);
retnr = nrdesc < maxdesc ? nrdesc : maxdesc;
@@ -435,6 +495,7 @@ static int __get_descriptors(struct cmsghdr *cmsg, struct msghdr *msg, int *fds,
close(*recvdesc++);
}
}
+
return retnr;
}
@@ -480,10 +541,11 @@ static int __recv_message(int sock, struct iovec *vec, int vec_max_size, int *ve
}
}
}
+
return ret;
}
-int __app_send_raw_with_fd_reply(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen, int *ret_fd)
+int aul_sock_send_raw_with_fd_reply(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen, int *ret_fd)
{
int fd;
int len;
@@ -504,7 +566,7 @@ int __app_send_raw_with_fd_reply(int pid, uid_t uid, int cmd, unsigned char *kb_
return -ECOMM;
}
- pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ pkt = (app_pkt_t *)malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
if (NULL == pkt) {
_E("Malloc Failed!");
return -ENOMEM;
@@ -555,7 +617,6 @@ int __app_send_raw_with_fd_reply(int pid, uid_t uid, int cmd, unsigned char *kb_
}
retry_recv:
-
if (cmd == APP_GET_SOCKET_PAIR) {
char recv_buff[1024];
struct iovec vec[3];
@@ -598,368 +659,3 @@ retry_recv:
return res;
}
-
-int __app_agent_send_raw(int uid, const char *pad_type,
- int cmd, unsigned char *kb_data, int datalen)
-{
- int fd;
- int len;
- int sent = 0;
- int res = 0;
- app_pkt_t *pkt = NULL;
-
- if (kb_data == NULL) {
- _E("keybundle error\n");
- return -EINVAL;
- }
-
- _D("uid(%d) : cmd(%d)", uid, cmd);
-
- fd = __create_agent_client_sock(uid, pad_type);
- if (fd < 0)
- return -ECOMM;
-
- pkt = (app_pkt_t *)malloc(AUL_PKT_HEADER_SIZE + datalen);
- if (NULL == pkt) {
- _E("Malloc Failed!");
- return -ENOMEM;
- }
-
- pkt->cmd = cmd;
- pkt->len = datalen;
- memcpy(pkt->data, kb_data, pkt->len);
-
- while (sent != AUL_PKT_HEADER_SIZE + pkt->len) {
- len = send(fd, pkt, AUL_PKT_HEADER_SIZE + pkt->len - sent, 0);
- if (len <= 0) {
- _E("send error uid:%d, fd:%d (errno %d)", uid, fd, errno);
- close(fd);
- free(pkt);
- return -ECOMM;
- }
- sent += len;
- }
-
- free(pkt);
-
-retry_recv:
- len = recv(fd, &res, sizeof(int), 0);
- if (len == -1) {
- if (errno == EAGAIN) {
- _E("recv timeout : %s", strerror(errno));
- res = -EAGAIN;
- } else if (errno == EINTR) {
- _D("recv : %s", strerror(errno));
- goto retry_recv;
- } else {
- _E("recv error : %s", strerror(errno));
- res = -ECOMM;
- }
- }
- close(fd);
-
- return res;
-}
-
-
-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;
- int sent = 0;
- int res = 0;
- app_pkt_t *pkt = NULL;
-
- if (kb_data == NULL) {
- _E("keybundle error\n");
- return -EINVAL;
- }
-
- _D("uid(%d) : cmd(%d)", uid, cmd);
-
- fd = __create_agent_client_sock(uid, pad_type);
- if (fd < 0)
- return -ECOMM;
-
- pkt = (app_pkt_t *)malloc(AUL_PKT_HEADER_SIZE + datalen);
- if (NULL == pkt) {
- _E("Malloc Failed!");
- return -ENOMEM;
- }
-
- pkt->cmd = cmd;
- pkt->len = datalen;
- memcpy(pkt->data, kb_data, pkt->len);
-
- while (sent != AUL_PKT_HEADER_SIZE + pkt->len) {
- len = send(fd, pkt, AUL_PKT_HEADER_SIZE + pkt->len - sent, 0);
- if (len <= 0) {
- _E("send error uid:%d, fd:%d (errno %d)", uid, fd, errno);
- close(fd);
- free(pkt);
- return -ECOMM;
- }
- sent += len;
- }
-
- free(pkt);
- close(fd);
-
- return res;
-}
-
-int __app_send_raw_with_noreply(int pid, int cmd, unsigned char *kb_data, int datalen)
-{
- return __app_send_raw_with_noreply_for_uid(pid, getuid(), cmd, kb_data, datalen);
-}
-
-int __app_send_raw_with_noreply_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen)
-{
- int fd;
- int len;
- int sent = 0;
- int res = 0;
- app_pkt_t *pkt = NULL;
-
- if (kb_data == NULL) {
- _E("keybundle error\n");
- return -EINVAL;
- }
-
- _D("pid(%d) : cmd(%d)", pid, cmd);
-
- fd = __create_client_sock(pid, uid);
- if (fd < 0)
- return -ECOMM;
-
- pkt = (app_pkt_t *)malloc(AUL_PKT_HEADER_SIZE + datalen);
- if (NULL == pkt) {
- _E("Malloc Failed!");
- return -ENOMEM;
- }
-
- pkt->cmd = cmd;
- pkt->len = datalen;
- memcpy(pkt->data, kb_data, pkt->len);
-
- while (sent != AUL_PKT_HEADER_SIZE + pkt->len) {
- len = send(fd, pkt, AUL_PKT_HEADER_SIZE + pkt->len - sent, 0);
- if (len <= 0) {
- _E("send error pid:%d, fd:%d (errno %d)", pid, fd, errno);
- close(fd);
- free(pkt);
- return -ECOMM;
- }
- sent += len;
- }
-
- free(pkt);
- close(fd);
-
- return res;
-}
-
-int __app_send_raw_with_delay_reply(int pid, int cmd, unsigned char *kb_data, int datalen)
-{
- return __app_send_raw_with_delay_reply_for_uid(pid, getuid(), cmd, kb_data, datalen);
-}
-
-int __app_send_raw_with_delay_reply_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen)
-{
- int fd;
- int len;
- int sent = 0;
- app_pkt_t *pkt = NULL;
-
- if (kb_data == NULL) {
- _E("keybundle error\n");
- return -EINVAL;
- }
-
- _D("pid(%d) : cmd(%d)", pid, cmd);
-
- fd = __create_client_sock(pid, uid);
- if (fd < 0)
- return -ECOMM;
-
- pkt = (app_pkt_t *)malloc(AUL_PKT_HEADER_SIZE + datalen);
- if (NULL == pkt) {
- _E("Malloc Failed!");
- return -ENOMEM;
- }
-
- pkt->cmd = cmd;
- pkt->len = datalen;
- memcpy(pkt->data, kb_data, pkt->len);
-
- while (sent != AUL_PKT_HEADER_SIZE + pkt->len) {
- len = send(fd, pkt, AUL_PKT_HEADER_SIZE + pkt->len - sent, 0);
- if (len <= 0) {
- _E("send error pid:%d, fd:%d (errno %d)", pid, fd, errno);
- close(fd);
- free(pkt);
- return -ECOMM;
- }
- sent += len;
- }
-
- free(pkt);
-
- return fd;
-}
-
-app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr)
-{
- int len;
- int ret;
- struct sockaddr_un aul_addr = { 0, };
- int sun_size;
- app_pkt_t *pkt = NULL;
- int cl = sizeof(struct ucred);
- unsigned char buf[AUL_SOCK_MAXBUFF];
- int cmd;
- int datalen;
-
- sun_size = sizeof(struct sockaddr_un);
-
- if ((*clifd = accept(fd, (struct sockaddr *)&aul_addr,
- (socklen_t *) &sun_size)) == -1) {
- if (errno != EINTR)
- _E("accept error");
- return NULL;
- }
-
- if (getsockopt(*clifd, SOL_SOCKET, SO_PEERCRED, cr,
- (socklen_t *) &cl) < 0) {
- _E("peer information error");
- close(*clifd);
- return NULL;
- }
-
- __set_sock_option(*clifd, 1);
-
- retry_recv:
- /* receive header(cmd, datalen) */
- len = recv(*clifd, buf, AUL_PKT_HEADER_SIZE, 0);
- if (len < 0)
- if (errno == EINTR)
- goto retry_recv;
-
- if (len < AUL_PKT_HEADER_SIZE) {
- _E("recv error");
- close(*clifd);
- return NULL;
- }
- memcpy(&cmd, buf, sizeof(int));
- memcpy(&datalen, buf + sizeof(int), sizeof(int));
-
- /* allocate for a null byte */
- pkt = (app_pkt_t *)calloc(1, AUL_PKT_HEADER_SIZE + datalen + 1);
- if (pkt == NULL) {
- close(*clifd);
- return NULL;
- }
- pkt->cmd = cmd;
- pkt->len = datalen;
-
- len = 0;
- while (len != pkt->len) {
- ret = recv(*clifd, pkt->data + len, pkt->len - len, 0);
- if (ret < 0) {
- _E("recv error %d %d", len, pkt->len);
- free(pkt);
- close(*clifd);
- return NULL;
- }
- len += ret;
- _D("recv len %d %d", len, pkt->len);
- }
-
- return pkt;
-}
-
-app_pkt_t *__app_send_cmd_with_result(int pid, int cmd, unsigned char *kb_data, int datalen)
-{
- return (app_pkt_t *)__app_send_cmd_with_result_for_uid(pid, getuid(), cmd, kb_data, 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 fd;
- int len;
- int ret;
- int sent = 0;
- app_pkt_t *pkt = NULL;
- unsigned char buf[AUL_SOCK_MAXBUFF];
-
- fd = __create_client_sock(pid, uid);
- if (fd < 0)
- return NULL;
-
- pkt = (app_pkt_t *)malloc(AUL_PKT_HEADER_SIZE + datalen);
- if (NULL == pkt) {
- _E("Malloc Failed!");
- return NULL;
- }
- pkt->cmd = cmd;
- pkt->len = datalen;
- if (kb_data)
- memcpy(pkt->data, kb_data, pkt->len);
-
- while (sent != AUL_PKT_HEADER_SIZE + pkt->len) {
- len = send(fd, pkt, AUL_PKT_HEADER_SIZE + pkt->len - sent, 0);
- if (len <= 0) {
- _E("send error pid:%d, fd:%d (errno %d)", pid, fd, errno);
- close(fd);
- free(pkt);
- return NULL;
- }
- sent += len;
- }
- free(pkt);
-
-retry_recv:
- /* receive header(cmd, datalen) */
- len = recv(fd, buf, AUL_PKT_HEADER_SIZE, 0);
- if (len < 0)
- if (errno == EINTR)
- goto retry_recv;
-
- if (len < AUL_PKT_HEADER_SIZE) {
- _E("recv error");
- close(fd);
- return NULL;
- }
- memcpy(&cmd, buf, sizeof(int));
- memcpy(&len, buf + sizeof(int), sizeof(int));
-
- /* allocate for a null byte */
- pkt = (app_pkt_t *)calloc(1, AUL_PKT_HEADER_SIZE + len + 1);
- if (pkt == NULL) {
- close(fd);
- return NULL;
- }
- pkt->cmd = cmd;
- pkt->len = len;
-
- len = 0;
- while (len != pkt->len) {
- ret = recv(fd, pkt->data + len, pkt->len - len, 0);
- if (ret < 0) {
- if (errno == EINTR) {
- continue;
- } else {
- _E("recv error %s\n", strerror(errno));
- free(pkt);
- close(fd);
- return NULL;
- }
- }
- len += ret;
- _D("recv len %d %d", len, pkt->len);
- }
- close(fd);
-
- return pkt;
-}
diff --git a/src/key.c b/src/key.c
index d25984e3..6c55862c 100644
--- a/src/key.c
+++ b/src/key.c
@@ -26,7 +26,7 @@
#include "aul_api.h"
#include "menu_db_util.h"
#include "simple_util.h"
-#include "app_sock.h"
+#include "aul_sock.h"
#include "aul_util.h"
#include "launch.h"
diff --git a/src/launch.c b/src/launch.c
index 70245dc8..a18f0686 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -30,7 +30,7 @@
#include "aul.h"
#include "aul_api.h"
-#include "app_sock.h"
+#include "aul_sock.h"
#include "perf.h"
#include "simple_util.h"
#include "launch.h"
@@ -161,7 +161,7 @@ static int __app_send_cmd_with_fd(int pid, int uid, int cmd, bundle *kb, int *re
if (res != BUNDLE_ERROR_NONE)
return AUL_R_EINVAL;
- if ((res = __app_send_raw_with_fd_reply(pid, uid, cmd, kb_data, datalen, ret_fd)) < 0) {
+ if ((res = aul_sock_send_raw_with_fd_reply(pid, uid, cmd, kb_data, datalen, ret_fd)) < 0) {
switch (res) {
case -EINVAL:
res = AUL_R_EINVAL;
@@ -203,41 +203,6 @@ static int __app_send_cmd_with_fd(int pid, int uid, int cmd, bundle *kb, int *re
}
/**
- * @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
- */
-API 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, pad_type, cmd, kb_data, datalen)) < 0)
- res = __get_aul_error(res);
- free(kb_data);
-
- return res;
-}
-
-API 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_agent_send_raw_with_noreply(uid, pad_type, cmd, kb_data, datalen)) < 0)
- res = __get_aul_error(res);
- free(kb_data);
-
- return res;
-}
-
-/**
* @brief encode kb and send it to 'pid'
* @param[in] pid receiver's pid
* @param[in] cmd message's status (APP_START | APP_RESULT)
@@ -255,7 +220,7 @@ API int app_send_cmd_for_uid(int pid, uid_t uid, int cmd, bundle *kb)
int res;
bundle_encode(kb, &kb_data, &datalen);
- if ((res = __app_send_raw_for_uid(pid, uid, cmd, kb_data, datalen)) < 0)
+ if ((res = aul_sock_send_raw(pid, uid, cmd, kb_data, datalen)) < 0)
res = __get_aul_error(res);
free(kb_data);
@@ -269,8 +234,14 @@ API int app_send_cmd_with_noreply(int pid, int cmd, bundle *kb)
int res;
bundle_encode(kb, &kb_data, &datalen);
- if ((res = __app_send_raw_with_noreply(pid, cmd, kb_data, datalen)) < 0)
+ res = aul_sock_send_raw_async(pid, getuid(), cmd, kb_data, datalen);
+ if (res > 0) {
+ close(res);
+ res = 0;
+ } else {
res = __get_aul_error(res);
+ }
+
free(kb_data);
return res;
@@ -458,7 +429,7 @@ int aul_sock_handler(int fd)
int pid;
int ret;
- if ((pkt = __app_recv_raw(fd, &clifd, &cr)) == NULL) {
+ if ((pkt = aul_sock_recv_pkt(fd, &clifd, &cr)) == NULL) {
_E("recv error");
return -1;
}
@@ -598,7 +569,7 @@ int aul_initialize()
if (aul_initialized)
return AUL_R_ECANCELED;
- aul_fd = __create_server_sock(getpid());
+ aul_fd = aul_sock_create_server(getpid(), getuid());
if (aul_fd < 0) {
_E("aul_init create sock failed");
return AUL_R_ECOMM;
diff --git a/src/launch_with_result.c b/src/launch_with_result.c
index b02edd23..f07c9ba0 100644
--- a/src/launch_with_result.c
+++ b/src/launch_with_result.c
@@ -24,7 +24,7 @@
#include "aul.h"
#include "aul_api.h"
-#include "app_sock.h"
+#include "aul_sock.h"
#include "simple_util.h"
#include "launch.h"
#include "aul_util.h"
diff --git a/src/pkginfo.c b/src/pkginfo.c
index 274ae6a7..0f6c0a87 100644
--- a/src/pkginfo.c
+++ b/src/pkginfo.c
@@ -23,7 +23,7 @@
#include "aul_api.h"
#include "menu_db_util.h"
#include "simple_util.h"
-#include "app_sock.h"
+#include "aul_sock.h"
#include "aul_util.h"
typedef struct _internal_param_t {
@@ -41,8 +41,8 @@ API int aul_app_get_pid(const char *appid)
if (appid == NULL)
return -1;
- ret = __app_send_raw(AUL_UTIL_PID, APP_GET_PID, (unsigned char *)appid,
- strlen(appid));
+ ret = aul_sock_send_raw(AUL_UTIL_PID, getuid(), APP_GET_PID,
+ (unsigned char *)appid, strlen(appid));
return ret;
}
@@ -54,8 +54,8 @@ API int aul_app_is_running(const char *appid)
if (appid == NULL)
return 0;
- ret = __app_send_raw(AUL_UTIL_PID, APP_IS_RUNNING, (unsigned char*)appid,
- strlen(appid));
+ ret = aul_sock_send_raw(AUL_UTIL_PID, getuid(), APP_IS_RUNNING,
+ (unsigned char*)appid, strlen(appid));
if (ret > 0)
return true;
@@ -76,7 +76,8 @@ API int aul_app_get_running_app_info(aul_app_info_iter_fn enum_fn,
if (enum_fn == NULL)
return AUL_R_EINVAL;
- pkt = __app_send_cmd_with_result(AUL_UTIL_PID, APP_RUNNING_INFO, NULL, 0);
+ pkt = aul_sock_send_raw_with_pkt_reply(AUL_UTIL_PID, getuid(),
+ APP_RUNNING_INFO, NULL, 0);
if (pkt == NULL)
return AUL_R_ERROR;
@@ -160,9 +161,9 @@ API int aul_app_get_appid_bypid_for_uid(int pid, char *appid, int len, uid_t uid
int ret;
if (pid != getpid()) {
- pkt = __app_send_cmd_with_result_for_uid(AUL_UTIL_PID, uid,
- APP_GET_APPID_BYPID, (unsigned char *)&pid,
- sizeof(pid));
+ pkt = aul_sock_send_raw_with_pkt_reply(AUL_UTIL_PID, uid,
+ APP_GET_APPID_BYPID, (unsigned char *)&pid,
+ sizeof(pid));
if (pkt == NULL)
return AUL_R_ERROR;
if (pkt->cmd == APP_GET_INFO_ERROR) {
@@ -230,7 +231,7 @@ API int aul_app_get_pkgid_bypid_for_uid(int pid, char *pkgid, int len, uid_t uid
if (pkgid == NULL)
return AUL_R_EINVAL;
- pkt = __app_send_cmd_with_result_for_uid(AUL_UTIL_PID, uid, cmd,
+ pkt = aul_sock_send_raw_with_pkt_reply(AUL_UTIL_PID, uid, cmd,
(unsigned char *)&pid, sizeof(pid));
if (pkt == NULL)
@@ -261,9 +262,8 @@ API int aul_delete_rua_history(bundle *b)
if (b != NULL)
bundle_encode(b, &br, &datalen);
- ret = __app_send_cmd_with_result(AUL_UTIL_PID, APP_REMOVE_HISTORY, br,
- datalen);
-
+ ret = aul_sock_send_raw_with_pkt_reply(AUL_UTIL_PID, getuid(),
+ APP_REMOVE_HISTORY, br, datalen);
if (ret != NULL) {
if (ret->len > 0) {
memcpy(&result, ret->data, ret->len);
diff --git a/src/service.c b/src/service.c
index f15bcaa9..1b9792ff 100755
--- a/src/service.c
+++ b/src/service.c
@@ -31,7 +31,7 @@
#include "aul.h"
#include "aul_api.h"
#include "aul_svc.h"
-#include "app_sock.h"
+#include "aul_sock.h"
#include "aul_svc_db.h"
#include "simple_util.h"
#include "aul_svc_priv_key.h"
diff --git a/src/status.c b/src/status.c
index 36eacbe9..72fc0060 100644
--- a/src/status.c
+++ b/src/status.c
@@ -22,7 +22,7 @@
#include <bundle_internal.h>
#include "aul_util.h"
-#include "app_sock.h"
+#include "aul_sock.h"
#include "aul_api.h"
#include "launch.h"
@@ -43,9 +43,12 @@ API int aul_status_update(int status)
app_status = status;
- ret = __app_send_raw_with_noreply(AUL_UTIL_PID, APP_STATUS_UPDATE, (unsigned char *)&status, sizeof(status));
+ ret = aul_sock_send_raw_async(AUL_UTIL_PID, getuid(), APP_STATUS_UPDATE,
+ (unsigned char *)&status, sizeof(status));
+ if (ret > 0) {
+ close(ret);
+ ret = 0;
- if (!ret) {
while (cb) {
if (cb->handler) {
if (cb->handler(app_status, cb->data) < 0)
@@ -66,7 +69,8 @@ API int aul_app_get_status_bypid(int pid)
if (pid == getpid())
return app_status;
- ret = __app_send_raw(AUL_UTIL_PID, APP_GET_STATUS, (unsigned char *)&pid, sizeof(pid));
+ ret = aul_sock_send_raw(AUL_UTIL_PID, getuid(), APP_GET_STATUS,
+ (unsigned char *)&pid, sizeof(pid));
return ret;
}