From 185974202b73781d36a920ca4cfae1a20126a057 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Mon, 3 Jul 2017 19:24:17 +0900 Subject: [PATCH] Add get id by surface ID feature Viewer apps that add watch with surface id do not have a watch appid, so in order to pass resume / pause to watch, amd must supply the id of the app with the surface id. - aul_screen_connector_get_appid_by_surface_id_request Change-Id: I6128e975665a95f8c7889b8ac6e4982e98842184 Signed-off-by: Hyunho Kang --- include/aul_cmd.h | 1 + include/aul_screen_connector.h | 3 +++ src/aul_screen_connector.c | 59 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/include/aul_cmd.h b/include/aul_cmd.h index cf16ccc..4077bdf 100644 --- a/include/aul_cmd.h +++ b/include/aul_cmd.h @@ -122,6 +122,7 @@ enum app_cmd { APP_WINDOW_DETACH = 91, APP_START_RES_ASYNC = 92, APP_NOTIFY_EXIT = 93, + GET_APPID_BY_SURFACE_ID = 94, APP_CMD_MAX }; diff --git a/include/aul_screen_connector.h b/include/aul_screen_connector.h index 247c50f..f435901 100644 --- a/include/aul_screen_connector.h +++ b/include/aul_screen_connector.h @@ -73,6 +73,9 @@ int aul_screen_connector_add_screen_viewer(aul_screen_viewer_cb callback, */ int aul_screen_connector_remove_screen_viewer(aul_screen_viewer_h handle); +int aul_screen_connector_get_appid_by_surface_id_request(unsigned int surface_id, + char **appid); + #ifdef __cplusplus } #endif diff --git a/src/aul_screen_connector.c b/src/aul_screen_connector.c index 3f03565..3ab25c9 100644 --- a/src/aul_screen_connector.c +++ b/src/aul_screen_connector.c @@ -401,3 +401,62 @@ API int aul_screen_connector_send_update_request(const char *appid, return AUL_R_OK; } + +API int aul_screen_connector_get_appid_by_surface_id_request( + unsigned int surface_id, + char **appid) +{ + int ret; + int fd; + bundle *b; + bundle *ret_kb; + app_pkt_t *pkt = NULL; + char *ret_appid = NULL; + + if (appid == NULL) { + _E("Invalid parameter"); + return AUL_R_ERROR; + } + + b = bundle_create(); + if (b == NULL) { + _E("out of memory"); + return AUL_R_ERROR; + } + + bundle_add_byte(b, "__AUL_SC_SURFACE__", + &surface_id, sizeof(unsigned int)); + + fd = aul_sock_send_bundle(AUL_UTIL_PID, getuid(), + GET_APPID_BY_SURFACE_ID, b, AUL_SOCK_ASYNC); + + if (fd > 0) { + ret = aul_sock_recv_reply_pkt(fd, &pkt); + if (ret < 0 || pkt == NULL) { + _E("failed to get appid of %d", surface_id); + } else { + ret_kb = bundle_decode(pkt->data, pkt->len); + if (ret_kb) { + bundle_get_str(ret_kb, AUL_K_APPID, &ret_appid); + if (ret_appid) + *appid = strdup(ret_appid); + bundle_free(ret_kb); + if (*appid == NULL) { + _E("Out of memory"); + bundle_free(b); + return AUL_R_ERROR; + } + } + } + } else { + ret = fd; + } + + bundle_free(b); + if (ret < 0) { + _E("Failed to get appid"); + return ret; + } + + return AUL_R_OK; +} -- 2.7.4