int must_free = 0;
int ret = 0;
bundle *b;
+ char buf[MAX_PID_STR_BUFSZ];
traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "AUL:REQ_TO_PAD");
- SECURE_LOGD("launch request : %s", appid);
+ SECURE_LOGD("launch request : appid(%s), target_uid(%d)", appid, uid);
if (kb == NULL) {
kb = bundle_create();
must_free = 1;
bundle_del(kb, AUL_K_APPID);
bundle_add(kb, AUL_K_APPID, appid);
__set_stime(kb);
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_del(kb, AUL_K_TARGET_UID);
+ bundle_add(kb, AUL_K_TARGET_UID, buf);
switch (cmd) {
case APP_PAUSE:
bundle *b;
bundle_raw *kb_raw = NULL;
int len;
+ char buf[MAX_PID_STR_BUFSZ];
if (loader_path == NULL)
return AUL_R_EINVAL;
if (b == NULL)
return AUL_R_ERROR;
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_add_str(b, AUL_K_TARGET_UID, buf);
bundle_add_str(b, AUL_K_LOADER_PATH, loader_path);
if (kb) {
API int aul_remove_loader_for_uid(int loader_id, uid_t uid)
{
- char lid[MAX_PID_STR_BUFSZ];
+ char buf[MAX_PID_STR_BUFSZ];
int ret;
bundle *b;
return AUL_R_ERROR;
}
- snprintf(lid, sizeof(lid), "%d", loader_id);
- bundle_add_str(b, AUL_K_LOADER_ID, lid);
+ snprintf(buf, sizeof(buf), "%d", loader_id);
+ bundle_add_str(b, AUL_K_LOADER_ID, buf);
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_add_str(b, AUL_K_TARGET_UID, buf);
ret = app_send_cmd_for_uid(AUL_UTIL_PID, uid, APP_REMOVE_LOADER, b);
bundle_free(b);
API int aul_app_get_pid_for_uid(const char *appid, uid_t uid)
{
- int ret = 0;
+ int ret;
+ char buf[MAX_PID_STR_BUFSZ];
+ bundle *b;
if (appid == NULL)
return -1;
- ret = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_GET_PID,
- (unsigned char *)appid, strlen(appid), AUL_SOCK_NONE);
+ b = bundle_create();
+ if (b == NULL) {
+ _E("out of memory");
+ return -1;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_add(b, AUL_K_APPID, appid);
+ bundle_add(b, AUL_K_TARGET_UID, buf);
+
+ ret = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_GET_PID,
+ b, AUL_SOCK_NONE);
+ bundle_free(b);
return ret;
}
API int aul_app_is_running_for_uid(const char *appid, uid_t uid)
{
- int ret = 0;
-
- if (appid == NULL)
- return 0;
-
- ret = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_IS_RUNNING,
- (unsigned char*)appid, strlen(appid), AUL_SOCK_NONE);
+ int ret;
+ ret = aul_app_get_pid_for_uid(appid, uid);
if (ret > 0)
return true;
{
int ret;
int fd;
+ bundle *b;
+ char buf[MAX_PID_STR_BUFSZ];
internal_param_t param = {
enum_fn,
user_param
if (enum_fn == NULL)
return AUL_R_EINVAL;
- fd = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_RUNNING_INFO, NULL,
- 0, AUL_SOCK_ASYNC);
+ b = bundle_create();
+ if (b == NULL) {
+ _E("out of memory");
+ return AUL_R_ERROR;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_add(b, AUL_K_TARGET_UID, buf);
+
+ fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_RUNNING_INFO,
+ b, AUL_SOCK_ASYNC);
+ bundle_free(b);
if (fd < 0)
return aul_error_convert(fd);
{
int ret;
int fd;
+ bundle *b;
+ char buf[MAX_PID_STR_BUFSZ];
internal_param_t param = {
enum_fn,
user_param
if (enum_fn == NULL)
return AUL_R_EINVAL;
- fd = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_ALL_RUNNING_INFO, NULL,
- 0, AUL_SOCK_ASYNC);
+ b = bundle_create();
+ if (b == NULL) {
+ _E("out of memory");
+ return AUL_R_ERROR;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_add(b, AUL_K_TARGET_UID, buf);
+
+ fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_ALL_RUNNING_INFO,
+ b, AUL_SOCK_ASYNC);
+ bundle_free(b);
if (fd < 0)
return aul_error_convert(fd);
int fd;
int ret;
const char *preinit_appid;
+ bundle *b;
+ char buf[MAX_PID_STR_BUFSZ];
if (pid <= 0 || appid == NULL) {
_E("Invalid parameter");
}
}
- fd = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_GET_APPID_BYPID,
- (unsigned char *)&pid, sizeof(pid), AUL_SOCK_ASYNC);
+ b = bundle_create();
+ if (b == NULL) {
+ _E("out of memory");
+ return AUL_R_ERROR;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", pid);
+ bundle_add(b, AUL_K_PID, buf);
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_add(b, AUL_K_TARGET_UID, buf);
+
+ fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_GET_APPID_BYPID,
+ b, AUL_SOCK_ASYNC);
+ bundle_free(b);
if (fd <= 0)
return AUL_R_ERROR;
int fd;
int ret;
const char *preinit_pkgid;
+ bundle *b;
+ char buf[MAX_PID_STR_BUFSZ];
if (pid <= 0 || pkgid == NULL) {
_E("Invalid parameter");
}
}
- fd = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_GET_PKGID_BYPID,
- (unsigned char *)&pid, sizeof(pid), AUL_SOCK_ASYNC);
+ b = bundle_create();
+ if (b == NULL) {
+ _E("out of memory");
+ return AUL_R_ERROR;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", pid);
+ bundle_add(b, AUL_K_PID, buf);
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_add(b, AUL_K_TARGET_UID, buf);
+
+ fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_GET_PKGID_BYPID,
+ b, AUL_SOCK_ASYNC);
+ bundle_free(b);
if (fd <= 0)
return AUL_R_ERROR;
API int aul_update_rua_stat_for_uid(bundle *b, uid_t uid)
{
int ret;
+ char buf[MAX_PID_STR_BUFSZ];
+
+ if (b == NULL) {
+ _E("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_del(b, AUL_K_TARGET_UID);
+ bundle_add(b, AUL_K_TARGET_UID, buf);
ret = aul_sock_send_bundle(AUL_UTIL_PID, uid,
APP_UPDATE_RUA_STAT, b, AUL_SOCK_NONE);
API int aul_add_rua_history_for_uid(bundle *b, uid_t uid)
{
int ret;
+ char buf[MAX_PID_STR_BUFSZ];
if (b == NULL) {
SECURE_LOGE("invalid param");
return AUL_R_EINVAL;
}
+
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_del(b, AUL_K_TARGET_UID);
+ bundle_add(b, AUL_K_TARGET_UID, buf);
+
ret = aul_sock_send_bundle(AUL_UTIL_PID, uid,
APP_ADD_HISTORY, b, AUL_SOCK_NONE);
return ret;
API int aul_delete_rua_history_for_uid(bundle *b, uid_t uid)
{
int ret;
- bundle_raw *br = NULL;
- int datalen = 0;
+ char buf[MAX_PID_STR_BUFSZ];
+ bundle *kb = NULL;
+
+ if (b == NULL) {
+ kb = bundle_create();
+ if (kb == NULL) {
+ _E("out of memory");
+ return AUL_R_ERROR;
+ }
- /* b can be NULL if b is NULL delete all rua history */
- if (b != NULL)
- bundle_encode(b, &br, &datalen);
+ b = kb;
+ }
- ret = aul_sock_send_raw(AUL_UTIL_PID, uid,
- APP_REMOVE_HISTORY, br, datalen, AUL_SOCK_NONE);
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_del(b, AUL_K_TARGET_UID);
+ bundle_add(b, AUL_K_TARGET_UID, buf);
- if (br != NULL)
- free(br);
+ ret = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_REMOVE_HISTORY,
+ b, AUL_SOCK_NONE);
+ if (kb)
+ bundle_free(kb);
return ret;
}
API int aul_app_get_last_caller_pid_for_uid(int pid, uid_t uid)
{
int ret;
+ char buf[MAX_PID_STR_BUFSZ];
+ bundle *b;
if (pid < 0) {
_E("Invalid parameter");
return AUL_R_EINVAL;
}
- ret = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_GET_LAST_CALLER_PID,
- (unsigned char *)&pid, sizeof(int),
- AUL_SOCK_NONE);
+ b = bundle_create();
+ if (b == NULL) {
+ _E("Failed to create bundle");
+ return AUL_R_ERROR;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", pid);
+ bundle_add(b, AUL_K_PID, buf);
+ snprintf(buf, sizeof(buf), "%d", uid);
+ bundle_add(b, AUL_K_TARGET_UID, buf);
+
+ ret = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_GET_LAST_CALLER_PID,
+ b, AUL_SOCK_NONE);
+ bundle_free(b);
if (ret < 0)
return aul_error_convert(ret);