AUL_SCREEN_CONNECTOR_EVENT_TYPE_UPDATE,
} aul_screen_connector_event_type_e;
+typedef enum {
+ AUL_SCREEN_STATUS_RESUME,
+ AUL_SCREEN_STATUS_PAUSE,
+} aul_screen_status_e;
+
typedef void (*aul_screen_viewer_cb)(const char *appid,
const char *instance_id, const int pid,
const unsigned int surface_id,
*/
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,
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_screen_connector_get_appid_by_surface_id(unsigned int surface_id,
char **appid);
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_screen_connector_get_instance_id_by_surface_id(unsigned int surface_id,
+ char **instance_id);
+
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_screen_connector_update_screen_viewer_status(aul_screen_status_e status,
+ const char *provider_instance_id);
+
#ifdef __cplusplus
}
#endif
return AUL_R_OK;
}
-API int aul_screen_connector_get_appid_by_surface_id_request(
- unsigned int surface_id,
- char **appid)
+static bundle *__send_request_with_surface_id(int cmd, unsigned int surface_id)
{
- int ret;
+ app_pkt_t *pkt = NULL;
+ bundle *b;
int fd;
+ int r;
+
+ b = bundle_create();
+ if (b == NULL) {
+ _E("Out of memory");
+ return NULL;
+ }
+
+ r = bundle_add_byte(b, "__AUL_SC_SURFACE__",
+ &surface_id, sizeof(unsigned int));
+ if (r != BUNDLE_ERROR_NONE) {
+ _E("Failed to add surface id(%u)", surface_id);
+ bundle_free(b);
+ return NULL;
+ }
+
+ fd = aul_sock_send_bundle(AUL_UTIL_PID, getuid(), cmd, b,
+ AUL_SOCK_ASYNC);
+ bundle_free(b);
+ if (fd < 0) {
+ _E("Failed to send request(%d)", cmd);
+ return NULL;
+ }
+
+ aul_sock_recv_reply_pkt(fd, &pkt);
+ if (pkt == NULL) {
+ _E("Failed to receive the packet");
+ return NULL;
+ }
+
+ b = bundle_decode(pkt->data, pkt->len);
+ free(pkt);
+ if (b == NULL) {
+ _E("Failed to decode bundle data");
+ return NULL;
+ }
+
+ return b;
+}
+
+API int aul_screen_connector_get_appid_by_surface_id(unsigned int surface_id,
+ char **appid)
+{
+ const char *val;
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 = __send_request_with_surface_id(APP_GET_APPID_BY_SURFACE_ID,
+ surface_id);
+ if (b == NULL)
+ return AUL_R_ERROR;
+
+ val = bundle_get_val(b, AUL_K_APPID);
+ if (val == NULL) {
+ _E("Failed to get appid");
+ bundle_free(b);
+ return AUL_R_ERROR;
+ }
+
+ *appid = strdup(val);
+ if (*appid == NULL) {
+ _E("Out of memory");
+ bundle_free(b);
+ return AUL_R_ERROR;
+ }
+ bundle_free(b);
+
+ return AUL_R_OK;
+}
+
+API int aul_screen_connector_get_instance_id_by_surface_id(
+ unsigned int surface_id, char **instance_id)
+{
+ const char *val;
+ bundle *b;
+
+ if (instance_id == NULL) {
+ _E("Invalid parameter");
+ return AUL_R_ERROR;
+ }
+
+ b = __send_request_with_surface_id(APP_GET_INSTANCE_ID_BY_SURFACE_ID,
+ surface_id);
+ if (b == NULL)
+ return AUL_R_ERROR;
+
+ val = bundle_get_val(b, AUL_K_INSTANCE_ID);
+ if (val == NULL) {
+ _E("Failed to get instance id");
+ bundle_free(b);
+ return AUL_R_ERROR;
+ }
+
+ *instance_id = strdup(val);
+ if (*instance_id == NULL) {
+ _E("Out of memory");
+ bundle_free(b);
+ return AUL_R_ERROR;
+ }
+ bundle_free(b);
+
+ return AUL_R_OK;
+}
+
+
+API int aul_screen_connector_update_screen_viewer_status(
+ aul_screen_status_e status, const char *provider_instance_id)
+{
+ bundle *b;
+ int ret;
+
+ if (provider_instance_id == NULL ||
+ status < AUL_SCREEN_STATUS_RESUME ||
+ status > AUL_SCREEN_STATUS_PAUSE) {
+ _E("Invalid parameter");
+ return AUL_R_ERROR;
+ }
+
b = bundle_create();
if (b == NULL) {
- _E("out of memory");
+ _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;
+ ret = bundle_add(b, AUL_K_INSTANCE_ID, provider_instance_id);
+ if (ret != BUNDLE_ERROR_NONE) {
+ _E("Failed to add provider instance id");
+ bundle_free(b);
+ return AUL_R_ERROR;
}
- bundle_free(b);
- if (ret < 0) {
- _E("Failed to get appid");
- return ret;
+ ret = bundle_add_byte(b, "__AUL_SC_VIEWER_STATUS__",
+ &status, sizeof(aul_screen_status_e));
+ if (ret != BUNDLE_ERROR_NONE) {
+ _E("Failed to add screen status");
+ bundle_free(b);
+ return AUL_R_ERROR;
}
- return AUL_R_OK;
+ ret = aul_sock_send_bundle(AUL_UTIL_PID, getuid(),
+ UPDATE_SCREEN_VIEWER_STATUS, b, AUL_SOCK_NOREPLY);
+ bundle_free(b);
+
+ return ret;
}