Fix screen viewer state feature 02/150602/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 6 Jul 2017 02:29:24 +0000 (11:29 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 18 Sep 2017 04:55:00 +0000 (13:55 +0900)
Requires:
 - https://review.tizen.org/gerrit/#/c/137133/ (aul-1)
 - https://review.tizen.org/gerrit/#/c/137134/ (amd)
 - https://review.tizen.org/gerrit/#/c/137136/ (widget-viewer)
 - https://review.tizen.org/gerrit/#/c/137437/ (appcore-watch)

Change-Id: Ie34e89124e1b77aff5d135e29f8061f88932cb5d
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/watch_app_main.c

index bac5222..416e5d5 100755 (executable)
@@ -49,6 +49,7 @@
 #include <bundle_internal.h>
 #include <pkgmgr-info.h>
 #include <aul_app_com.h>
+#include <aul_screen_connector.h>
 
 #include "appcore-watch-log.h"
 #include "watch_app_private.h"
@@ -71,7 +72,6 @@
 #define ONE_DAY_IN_SEC         86400
 #define METADATA_TICK_PER_SECOND       "http://developer.samsung.com/tizen/metadata/tickpersecond"
 #define METADATA_MINUTE_TICK           "http://developer.samsung.com/tizen/metadata/minutetick"
-#define WATCH_CONTROL_STATE "watch,state"
 
 typedef enum {
        WATCH_APP_STATE_NOT_RUNNING = 0, /* The application has been launched or was running but was terminated */
@@ -100,12 +100,6 @@ enum watch_visible_state {
        WVS_RESUME
 };
 
-enum viewer_visible_state {
-       WATCH_CONTROL_UNKNOWN,
-       WATCH_CONTROL_PAUSE,
-       WATCH_CONTROL_RESUME
-};
-
 #define WATCH_APP_EVENT_MAX 5
 static Ecore_Timer *watch_tick = NULL;
 static alarm_id_t alarm_id = 0;
@@ -133,7 +127,7 @@ struct watch_app_context {
        int width;
        int height;
        enum watch_visible_state watch_visibility;
-       enum viewer_visible_state viewer_visibility;
+       int viewer_visibility;
        bool ambient_mode;
        bool ambient_mode_skip_resume;
        void *data;
@@ -551,7 +545,7 @@ static int __on_resume(void *data)
        _W("_watch_core_resume");
 
        __context.watch_visibility = WVS_RESUME;
-       if (__context.viewer_visibility != WATCH_CONTROL_RESUME) {
+       if (__context.viewer_visibility != AUL_SCREEN_STATUS_RESUME) {
                _D("Viewer is paused, do not resume watch");
                return APP_ERROR_NONE;
        }
@@ -655,7 +649,7 @@ static void __on_window_visibility(int type, void *event, void *data)
                __on_pause(NULL);
        } else {
                __context.watch_visibility = WVS_RESUME;
-               if (__context.viewer_visibility == WATCH_CONTROL_RESUME)
+               if (__context.viewer_visibility == AUL_SCREEN_STATUS_RESUME)
                        __on_resume(NULL);
                else
                        _D("Viewer is paused, do not resume watch");
@@ -718,15 +712,19 @@ static int __viewer_state_handler(const char *widget_id, aul_app_com_result_e e,
        int *state = NULL;
        size_t state_sz = 0;
 
-       bundle_get_byte(envelope, WATCH_CONTROL_STATE, (void **)&state,
+       bundle_get_byte(envelope, "__AUL_SC_VIEWER_STATUS__", (void **)&state,
                        &state_sz);
+       if (state == NULL) {
+               _E("Failed to get viewer status");
+               return -1;
+       }
        __context.viewer_visibility = *state;
        _D("set viewer state to %d", *state);
 
-       if (*state == WATCH_CONTROL_RESUME &&
+       if (*state == AUL_SCREEN_STATUS_RESUME &&
                        __context.watch_visibility == WVS_RESUME)
                __on_resume(NULL);
-       else if (*state == WATCH_CONTROL_PAUSE)
+       else if (*state == AUL_SCREEN_STATUS_PAUSE)
                __on_pause(NULL);
 
        return 0;
@@ -798,7 +796,7 @@ EXPORT_API int watch_app_main(int argc, char **argv,
        __context.callback = *callback;
        __context.width = width;
        __context.height = height;
-       __context.viewer_visibility = WATCH_CONTROL_UNKNOWN;
+       __context.viewer_visibility = -1;
        __context.watch_visibility = WVS_UNKNOWN;
        __context.ambient_mode = false;
        __context.ambient_mode_skip_resume = false;