Add get id by surface ID feature 49/149749/3
authorHyunho Kang <hhstark.kang@samsung.com>
Mon, 3 Jul 2017 10:24:17 +0000 (19:24 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Thu, 21 Sep 2017 11:02:04 +0000 (11:02 +0000)
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 <hhstark.kang@samsung.com>
include/aul_cmd.h
include/aul_screen_connector.h
src/aul_screen_connector.c

index cf16ccc..4077bdf 100644 (file)
@@ -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
 };
index 247c50f..f435901 100644 (file)
@@ -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
index 3f03565..3ab25c9 100644 (file)
@@ -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;
+}