From fbb0d2b7444790c200cc31126d826df6611c4a84 Mon Sep 17 00:00:00 2001 From: hyunho Date: Mon, 16 Mar 2020 17:11:43 +0900 Subject: [PATCH] Add set/unset private sharing aul_rpc_port_set_private_sharing aul_rpc_port_unset_private_sharing Change-Id: I7af3306be888cab615c04c84af9feacf0112417a Signed-off-by: hyunho --- include/aul_cmd.h | 2 ++ include/aul_rpc_port.h | 4 +++ src/aul_rpc_port.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) diff --git a/include/aul_cmd.h b/include/aul_cmd.h index 48f405d..2d7092a 100755 --- a/include/aul_cmd.h +++ b/include/aul_cmd.h @@ -181,6 +181,8 @@ enum app_cmd { WIDGET_DISABLE = 141, TRIGGER_APP_SCREEN_FOCUSED_FORCE = 142, WIDGET_EVENT = 143, + SET_PRIVATE_SHARING = 144, + UNSET_PRIVATE_SHARING = 145, APP_CMD_MAX }; diff --git a/include/aul_rpc_port.h b/include/aul_rpc_port.h index 5de80c7..315300c 100644 --- a/include/aul_rpc_port.h +++ b/include/aul_rpc_port.h @@ -30,6 +30,10 @@ int aul_rpc_port_create_socket_pair(const char *appid, const char *port_name, int aul_rpc_port_notify_rpc_finished(void); +int aul_rpc_port_set_private_sharing( + const char *appid, const char *paths[], unsigned int size); +int aul_rpc_port_unset_private_sharing(const char *appid); + #ifdef __cplusplus } #endif diff --git a/src/aul_rpc_port.c b/src/aul_rpc_port.c index fa22ee1..23a49cf 100644 --- a/src/aul_rpc_port.c +++ b/src/aul_rpc_port.c @@ -26,6 +26,7 @@ #include "aul_rpc_port.h" #include "aul_sock.h" #include "aul_util.h" +#include "aul_svc.h" static bundle *__create_bundle(const char *appid, const char *port_name) { @@ -148,3 +149,98 @@ API int aul_rpc_port_notify_rpc_finished(void) return AUL_R_OK; } +API int aul_rpc_port_set_private_sharing( + const char *appid, const char *paths[], unsigned int size) +{ + char buf[12]; + bundle *b; + int r; + + if (!appid || !paths) { + _E("Invalid parameter"); + return AUL_R_EINVAL; + } + + b = bundle_create(); + if (!b) { + _E("Out of memory"); + return AUL_R_ERROR; + } + + snprintf(buf, sizeof(buf), "%d", getpid()); + r = bundle_add(b, AUL_K_PID, buf); + if (r != BUNDLE_ERROR_NONE) { + _E("Failed to add pid(%d). err = %d", getpid(), r); + bundle_free(b); + return AUL_R_ERROR; + } + + r = bundle_add(b, AUL_K_CALLEE_APPID, appid); + if (r != BUNDLE_ERROR_NONE) { + _E("Failed to add callee appid(%s). err = %d", appid, r); + bundle_free(b); + return AUL_R_ERROR; + } + + r = bundle_add_str_array(b, AUL_SVC_DATA_PATH, paths, size); + if (r != BUNDLE_ERROR_NONE) { + _E("Failed to add paths(%d). err = %d", size, r); + bundle_free(b); + return AUL_R_ERROR; + } + + r = aul_sock_send_bundle(AUL_UTIL_PID, getuid(), + SET_PRIVATE_SHARING, b, AUL_SOCK_NOREPLY); + if (r != 0) { + _E("Failed to set private sharing(%d). err = %d", getpid(), r); + bundle_free(b); + return aul_error_convert(r); + } + bundle_free(b); + + return AUL_R_OK; +} + +API int aul_rpc_port_unset_private_sharing(const char *appid) +{ + char buf[12]; + bundle *b; + int r; + + if (!appid) { + _E("Invalid parameter"); + return AUL_R_EINVAL; + } + + b = bundle_create(); + if (!b) { + _E("Out of memory"); + return AUL_R_ERROR; + } + + snprintf(buf, sizeof(buf), "%d", getpid()); + r = bundle_add(b, AUL_K_PID, buf); + if (r != BUNDLE_ERROR_NONE) { + _E("Failed to add pid(%d). err = %d", getpid(), r); + bundle_free(b); + return AUL_R_ERROR; + } + + r = bundle_add(b, AUL_K_CALLEE_APPID, appid); + if (r != BUNDLE_ERROR_NONE) { + _E("Failed to add callee appid(%s). err = %d", appid, r); + bundle_free(b); + return AUL_R_ERROR; + } + + r = aul_sock_send_bundle(AUL_UTIL_PID, getuid(), + UNSET_PRIVATE_SHARING, b, AUL_SOCK_NOREPLY); + if (r != 0) { + _E("Failed to unset private sharing(%d). err = %d", getpid(), r); + bundle_free(b); + return aul_error_convert(r); + } + bundle_free(b); + + return AUL_R_OK; +} \ No newline at end of file -- 2.7.4