Add exceptions to handle states 52/175252/4
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 9 Apr 2018 22:50:22 +0000 (07:50 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Tue, 10 Apr 2018 00:08:48 +0000 (00:08 +0000)
If the state of the running watch-application is paused,
the watch-core doesn't invoke the time tick callback.
And, if the state is not running, the watch-core doesn't invoke
the pause callback.

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

index 6c99053..14f32a9 100755 (executable)
@@ -452,15 +452,18 @@ static Eina_Bool __time_tick_cb(void *data)
        };
        double sec;
 
-       __get_timeinfo(&timeinfo);
+       _D("state: %d", __state);
+       if (__context.callback.time_tick && __state != WS_PAUSED) {
+               __get_timeinfo(&timeinfo);
 
-       /* Set a next timer */
-       sec = __get_next_tick_sec();
-       watch_tick = ecore_timer_add(sec, __time_tick_cb, data);
-       __on_time_tick(&timeinfo, data);
+               /* Set a next timer */
+               sec = __get_next_tick_sec();
+               watch_tick = ecore_timer_add(sec, __time_tick_cb, data);
+               __on_time_tick(&timeinfo, data);
 
-       if (timeinfo.timezone)
-               free(timeinfo.timezone);
+               if (timeinfo.timezone)
+                       free(timeinfo.timezone);
+       }
 
        return ECORE_CALLBACK_CANCEL;
 }
@@ -612,9 +615,11 @@ static int __on_pause(void *data)
        /* Cancel the time_tick callback */
        __time_tick_cancel();
 
-       appcore_efl_base_on_pause();
-       if (__context.callback.pause)
-               __context.callback.pause(__context.data);
+       if (__state == WS_RUNNING) {
+               appcore_efl_base_on_pause();
+               if (__context.callback.pause)
+                       __context.callback.pause(__context.data);
+       }
 
        __state = WS_PAUSED;
 
@@ -654,18 +659,16 @@ static int __on_resume(void *data)
                return APP_ERROR_NONE;
        }
 
-       if (__state != WS_PAUSED && __state != WS_CREATED) {
-               _E("Invalid state");
-               return APP_ERROR_NONE;
-       }
-
-       appcore_efl_base_on_resume();
-
        if (__context.ambient_mode) {
                __context.ambient_mode_skip_resume = false;
                return 0;
        }
 
+       if (__state != WS_PAUSED && __state != WS_CREATED)
+               return APP_ERROR_NONE;
+
+       appcore_efl_base_on_resume();
+
        if (__context.callback.resume)
                __context.callback.resume(__context.data);