WATCH_APP_STATE_RUNNING, /* The application is running in the foreground and background */
} watch_app_state_e;
+enum watch_state {
+ WS_NONE,
+ WS_CREATED,
+ WS_RUNNING,
+ WS_PAUSED,
+ WS_DYING,
+};
+
struct _watch_time_s {
int year;
int month;
struct watch_app_context __context;
static double __prev_target_tick = -1;
static Evas_Object *__watch_win;
+enum watch_state __state;
static void __on_ambient_tick(void *watchtime, void *data);
static void __on_ambient_changed(int ambient, void *data);
if (create_cb == NULL || create_cb(__context.width, __context.height, __context.data) == false)
return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__,
"watch_app_create_cb() returns false");
+ __state = WS_CREATED;
/* Alarm init */
__alarm_init();
{
_W("_watch_core_pause");
+ if (__state == WS_CREATED) {
+ _E("Invalid state");
+ return APP_ERROR_NONE;
+ }
+
/* clear pre resume flag */
__pre_resume_called = 0;
if (__context.callback.pause)
__context.callback.pause(__context.data);
+ __state = WS_PAUSED;
+
return APP_ERROR_NONE;
}
/* LCOV_EXCL_STOP */
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) {
if (__context.callback.resume)
__context.callback.resume(__context.data);
+ __state = WS_RUNNING;
+
if (!watch_tick) {
__time_tick_cb(data);
} else {
{
_W("_watch_core_terminate");
+ __state = WS_DYING;
if (appcore_efl_base_is_resumed())
appcore_efl_base_pause();