#include <tbm_surface.h>
#include <pkgmgr-info.h>
#include <aul_app_com.h>
+#include <aul.h>
+#include <aul_screen_connector.h>
#define API __attribute__((visibility("default")))
#undef LOG_TAG
#define LOG_TAG "WATCH_CONTROL"
-#ifdef LOGE
+#ifndef _E
#define _E LOGE
#endif
-#ifdef LOGD
+#ifndef _D
#define _D LOGD
#endif
+#ifndef _W
+#define _W LOGW
+#endif
+
#define KEY_SCREEN_SHAPE_CIRCLE "http://tizen.org/feature/screen.shape.circle"
#define METADATA_SETUP_APPID "http://tizen.org/metadata/watch/setup-appid"
static Evas_Object *__win;
static char *__watch_appid;
+static char *__watch_instance_id;
static char *viewer_appid;
static int __is_dead_signal_connected;
static aul_app_com_connection_h __conn_dead_signal;
_D("w: %d, h: %d, x: %d y: %d", w, h, x, y);
evas_object_smart_callback_call(__win, WATCH_SMART_SIGNAL_ADDED, image);
evas_object_data_set(__win, "tbm,watch", image);
+
+ if (__watch_instance_id)
+ free(__watch_instance_id);
+ __watch_instance_id = strdup(instance_id);
+ if (__watch_instance_id == NULL)
+ _W("Out of memory");
}
static void __screen_connector_toolkit_evas_removed_cb(const char *appid, const char *instance_id, int pid,
{
screen_connector_toolkit_evas_ops ops;
screen_connector_toolkit_evas_h handle;
- char *appid = NULL;
int ret;
ops.added_cb = __screen_connector_toolkit_evas_added_cb;
ops.removed_cb = __screen_connector_toolkit_evas_removed_cb;
ops.updated_cb = __screen_connector_toolkit_evas_updated_cb;
- handle = screen_connector_toolkit_evas_add_by_rid(&ops, resource_id, SCREEN_CONNECTOR_SCREEEN_TYPE_WATCH, NULL);
+ handle = screen_connector_toolkit_evas_add_by_rid(&ops, resource_id,
+ SCREEN_CONNECTOR_SCREEEN_TYPE_WATCH, NULL);
if (handle == NULL) {
_E("Fail screen_connector_toolkit_evas_add_by_rid");
return -1;
}
- ret = aul_screen_connector_get_appid_by_surface_id_request(resource_id,
- &appid);
- if (ret == AUL_R_OK) {
- if (__watch_appid)
- free(__watch_appid);
- __watch_appid = appid;
- } else {
- screen_connector_toolkit_evas_remove(handle);
+ if (__watch_appid) {
+ free(__watch_appid);
+ __watch_appid = NULL;
+ }
+
+ ret = aul_screen_connector_get_appid_by_surface_id(resource_id,
+ &__watch_appid);
+ if (ret != AUL_R_OK) {
_E("Fail to get appid of %d", resource_id);
+ screen_connector_toolkit_evas_remove(handle);
return -1;
}
+ if (__watch_instance_id) {
+ free(__watch_instance_id);
+ __watch_instance_id = NULL;
+ }
+
+ ret = aul_screen_connector_get_instance_id_by_surface_id(resource_id,
+ &__watch_instance_id);
+ if (ret != AUL_R_OK) {
+ _E("Failed to get instance id by surface id(%d)", resource_id);
+ screen_connector_toolkit_evas_remove(handle);
+ return -1;
+ }
+
+ _D("appid(%s), instance_id(%s), rid(%d)",
+ __watch_appid, __watch_instance_id, resource_id);
+
return 0;
}
free(__watch_appid);
__watch_appid = strdup(app_id);
+ if (__watch_appid == NULL)
+ _E("Out of memory");
return 0;
}
static int __change_viewer_visibility(bool visible)
{
- int state;
- bundle *b = bundle_create();
-
- if (b == NULL) {
- _E("out of memory");
- return -1;
- }
+ int status;
+ int r;
- if (__watch_appid == NULL) {
+ if (__watch_appid == NULL || __watch_instance_id == NULL) {
_E("watch is not added");
return -1;
}
if (visible)
- state = WATCH_CONTROL_RESUME;
+ status = AUL_SCREEN_STATUS_RESUME;
else
- state = WATCH_CONTROL_PAUSE;
+ status = AUL_SCREEN_STATUS_PAUSE;
- bundle_add_byte(b, WATCH_CONTROL_STATE, &state, sizeof(int));
+ r = aul_screen_connector_update_screen_viewer_status(status,
+ __watch_instance_id);
+ if (r < 0) {
+ _E("Failed to update screen viewer status");
+ return -1;
+ }
- _D("send watch control state to %s(%d)", __watch_appid, state);
- aul_app_com_send(__watch_appid, b);
- bundle_free(b);
+ _D("send watch control status to %s:%s:%d",
+ __watch_appid, __watch_instance_id, status);
return 0;
}