From: Hyunho Kang Date: Thu, 10 Nov 2016 05:42:33 +0000 (+0900) Subject: Add surface creator pid managing logic X-Git-Tag: submit/tizen_3.0/20161111.000156^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=98df5f5e11d2b75a0c8c0c7c1094724cf3a4341f;p=platform%2Fcore%2Fappfw%2Faul-1.git Add surface creator pid managing logic - watch needs creator's pid to terminated old watch face Change-Id: If514cde01623f60a926d716ba88c07b7f951e32f Signed-off-by: Hyunho Kang --- diff --git a/include/aul_rsm_viewer.h b/include/aul_rsm_viewer.h index 9bb112d..bbaa549 100644 --- a/include/aul_rsm_viewer.h +++ b/include/aul_rsm_viewer.h @@ -36,10 +36,9 @@ struct aul_rsm_handler_s { typedef struct aul_rsm_handler_s aul_rsm_handler; int aul_rsm_viewer_set_surface_handler(const char *id, aul_rsm_handler *cbs, void *data); - int aul_rsm_viewer_set_surface_handler_by_rid(int resource_id, aul_rsm_handler *cbs, void *data); - int aul_rsm_viewer_get_surface_rid(const char *id, int *resource_id); +int aul_rsm_viewer_get_surface_pid(const char *id, int *pid); #ifdef __cplusplus diff --git a/src/aul_rsm.c b/src/aul_rsm.c index c643291..7a0a770 100644 --- a/src/aul_rsm.c +++ b/src/aul_rsm.c @@ -36,6 +36,7 @@ struct __remote_surface_s { struct __surface_s { char *id; + int pid; void (*update_cb)(struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time, void *data); void (*missing_cb)(struct tizen_remote_surface *trs, void *data); void *data; @@ -124,6 +125,7 @@ static void __rsp_resource_id_cb(void *data, struct tizen_remote_surface_provide { struct __remote_surface_s *remote = (struct __remote_surface_s *)data; bundle *envelope = bundle_create(); + int pid = getpid(); if (envelope == NULL) { _E("failed to create envelope"); @@ -132,6 +134,7 @@ static void __rsp_resource_id_cb(void *data, struct tizen_remote_surface_provide bundle_add_str(envelope, "__AUL_RSP_RESOURCE_ID__", remote->id); bundle_add_byte(envelope, "__AUL_RSP_SURFACE_ID__", &res_id, sizeof(uint32_t)); + bundle_add_byte(envelope, "__AUL_RSP_SURFACE_CREATOR_PID__", &pid, sizeof(int)); if (aul_app_com_send("tbm_surface_notify", envelope) < 0) { _E("failed to send surface notify"); @@ -235,21 +238,8 @@ static const struct tizen_remote_surface_listener __rs_listener = { __rs_missing_cb, }; -static void __redirect_surface(char *id, int res_id) +static void __redirect_surface(struct __surface_s *surface) { - struct __surface_s *surface = NULL; - - if (id) { - surface = g_hash_table_lookup(__viewer_tbl, id); - if (!surface) { - _E("unknown surface"); - return; - } - } - - surface->resource_id = res_id; - surface->surface = tizen_remote_surface_manager_create_surface(__rsm, - (uint32_t)res_id, __tbm); tizen_remote_surface_add_listener(surface->surface, &__rs_listener, surface); tizen_remote_surface_redirect(surface->surface); @@ -261,13 +251,31 @@ static int __tbm_handler(const char *endpoint, aul_app_com_result_e e, char *id = NULL; uint32_t *res_id = NULL; size_t sz; + int *pid = NULL; + struct __surface_s *surface = NULL; bundle_get_str(envelope, "__AUL_RSP_RESOURCE_ID__", &id); - bundle_get_byte(envelope, "__AUL_RSP_SURFACE_ID__", (void **)&res_id, - &sz); + bundle_get_byte(envelope, "__AUL_RSP_SURFACE_ID__", (void **)&res_id, &sz); + bundle_get_byte(envelope, "__AUL_RSP_SURFACE_CREATOR_PID__", (void **)&pid, &sz); + if (id) { + surface = g_hash_table_lookup(__viewer_tbl, id); + if (!surface) { + _E("unknown surface"); + return 0; + } + } + + if (pid != NULL) + surface->pid = (int)*pid; + + surface->resource_id = *res_id; + surface->surface = tizen_remote_surface_manager_create_surface(__rsm, + (uint32_t)*res_id, __tbm); + + _D("__tbm_handler %d, %d, %s", *pid, *res_id, id); if (id && res_id) - __redirect_surface(id, (int)*res_id); + __redirect_surface(surface); else _E("bad tbm message received. missing arguments"); @@ -349,10 +357,12 @@ API int aul_rsm_viewer_set_surface_handler(const char *id, aul_rsm_handler *cbs, API int aul_rsm_viewer_set_surface_handler_by_rid(int resource_id, aul_rsm_handler *cbs, void *data) { char buf[32]; + struct __surface_s *surface; snprintf(buf, sizeof(buf), "%d", resource_id); aul_rsm_viewer_set_surface_handler(buf, cbs, data); - __redirect_surface(buf, resource_id); + surface = g_hash_table_lookup(__viewer_tbl, buf); + __redirect_surface(surface); return 0; } @@ -380,3 +390,27 @@ API int aul_rsm_viewer_get_surface_rid(const char *id, int *resource_id) *resource_id = surface->resource_id; return 0; } + +API int aul_rsm_viewer_get_surface_pid(const char *id, int *pid) +{ + struct __surface_s *surface; + + if (!id || !pid) { + _E("illegal arguments"); + return -1; + } + + surface = g_hash_table_lookup(__viewer_tbl, id); + if (!surface) { + _E("unknown surface"); + return -1; + } + + if (surface->pid < 1) { + _E("resource id not yet initialized"); + return -1; + } + + *pid = surface->pid; + return 0; +}