static watch_base_time_tick_resolution_e app_tick_type
= WATCH_BASE_TIME_TICKS_PER_SECOND;
static int app_tick_resolution = 1;
-static aul_app_com_connection_h __conn_viewer_state;
struct app_event_handler {
app_event_type_e type;
int width;
int height;
enum watch_visible_state watch_visibility;
- int viewer_visibility;
bool ambient_mode;
bool ambient_mode_skip_resume;
bool bg_launch;
static int __on_ui_base_resume(void *data)
{
_W("_watch_base_signal_resume");
- if (__context.viewer_visibility != AUL_SCREEN_STATUS_RESUME) {
- _D("Viewer is paused, do not resume watch");
- return APP_ERROR_NONE;
- }
-
if (__context.ambient_mode) {
__context.ambient_mode_skip_resume = false;
return 0;
{
LOGW("on window show bg_launch(%d)", __context.bg_launch);
appcore_ui_base_window_on_show(type, event);
- if (__context.viewer_visibility == AUL_SCREEN_STATUS_RESUME) {
- if (__context.bg_launch) {
- appcore_ui_base_resume();
- appcore_ui_base_pause();
- } else {
- appcore_ui_base_resume();
- }
+ if (__context.bg_launch) {
+ appcore_ui_base_resume();
+ appcore_ui_base_pause();
} else {
- _D("viewer is not resumed, do not resume watch");
+ appcore_ui_base_resume();
}
}
} else {
__context.watch_visibility = WVS_RESUME;
__context.bg_launch = false;
- if (__context.viewer_visibility == AUL_SCREEN_STATUS_RESUME) {
- __remove_pause_timer();
- __on_ui_base_resume(NULL);
- } else {
- _D("Viewer is paused, do not resume watch");
- }
+ __remove_pause_timer();
+ __on_ui_base_resume(NULL);
}
}
return 0;
}
-static int __viewer_state_handler(const char *widget_id, aul_app_com_result_e e,
- bundle *envelope, void *user_data)
-{
- int *state = NULL;
- size_t state_sz = 0;
- struct _watch_base_time_s timeinfo = {
- .timezone = NULL
- };
-
- bundle_get_byte(envelope, "__AUL_SC_VIEWER_STATUS__", (void **)&state,
- &state_sz);
- if (state == NULL) {
- _E("Failed to get viewer status");
- return -1;
- }
-
- _D("receive viewer state %d", *state);
- if (*state != AUL_SCREEN_STATUS_PRE_RESUME) {
- __context.viewer_visibility = *state;
- _D("set viewer state to %d", *state);
- }
-
- if (*state == AUL_SCREEN_STATUS_RESUME &&
- __context.watch_visibility == WVS_RESUME) {
- __remove_pause_timer();
- __on_ui_base_resume(NULL);
- } else if (*state == AUL_SCREEN_STATUS_PAUSE) {
- __add_pause_timer();
- } else if (*state == AUL_SCREEN_STATUS_PRE_RESUME) {
- __remove_pause_timer();
- _D("call pre resume tick");
- __on_pre_resume(NULL);
- }
-
- if (timeinfo.timezone)
- free(timeinfo.timezone);
-
- return 0;
-}
-
-static void __lcd_on_handler(void *user_data)
-{
- _D("Call pre resume tick");
- __remove_pause_timer();
- __on_pre_resume(NULL);
-}
-
EXPORT_API void watch_base_on_create(int width, int height)
{
_W("watch_base_on_create");
EXPORT_API int watch_base_init(int argc, char **argv,
watch_base_ops *callback, void *user_data)
{
- int ret;
bundle *kb;
char *width_str = NULL;
char *height_str = NULL;
int width = 360;
int height = 360;
appcore_ui_base_ops ops = appcore_ui_base_get_default_ops();
- char *viewer_visibility_str = NULL;
if (!watch_base_check_feature())
return APP_ERROR_NOT_SUPPORTED;
if (kb) {
bundle_get_str(kb, "WATCH_WIDTH", &width_str);
bundle_get_str(kb, "WATCH_HEIGHT", &height_str);
- bundle_get_str(kb, "WATCH_VIEWER_VISIBILITY",
- &viewer_visibility_str);
bundle_get_str(kb, "WATCH_BG_LAUNCH", &bg_launch_str);
if (width_str)
if (height_str)
height = atoi(height_str);
- if (viewer_visibility_str) {
- __context.viewer_visibility =
- atoi(viewer_visibility_str);
- }
-
if (bg_launch_str)
bg_launch = atoi(bg_launch_str);
_E("failed to get launch argv");
}
- ret = aul_app_com_create(__context.appid, NULL, __viewer_state_handler,
- NULL, &__conn_viewer_state);
- if (ret < 0) {
- free(__context.appid);
- __context.appid = NULL;
- return watch_base_set_error(APP_ERROR_INVALID_CONTEXT,
- __FUNCTION__, "Failed to create app com");
- }
-
__context.callback = *callback;
__context.bg_launch = bg_launch;
__context.width = width;
__context.data = user_data;
__context.state = WATCH_BASE_STATE_CREATING;
__context.extra = NULL;
- _watch_base_signal_listen_lcd_status_signal(__lcd_on_handler, NULL);
return appcore_ui_base_init(ops, argc, argv, NULL, 0);
}
__unset_ambient_changed_cb();
free(__context.appid);
__context.appid = NULL;
- aul_app_com_leave(__conn_viewer_state);
- __conn_viewer_state = NULL;
- _watch_base_signal_ignore_lcd_status_signal();
appcore_ui_base_fini();
__context.state = WATCH_BASE_STATE_NOT_RUNNING;
}
#define CLOCK_START "clockbegin"
#define CLOCK_STOP "clockstop"
-#define DEVICED_PATH_DISPLAY "/Org/Tizen/System/DeviceD/Display"
-#define DEVICED_INTERFACE_DISPLAY "org.tizen.system.deviced.display"
-#define LCD_ON "LCDOn"
-
static GDBusConnection *conn;
static unsigned int __conn_ref;
static guint s_id;
static int (*_deviced_signal_alpm_handler)(int ambient, void *data);
static void *_deviced_signal_alpm_data;
-static guint __lcd_sid;
-static void (*__deviced_signal_lcd_handler)(void *data);
-static void *__deviced_signal_lcd_data;
/* LCOV_EXCL_START */
static void __dbus_signal_filter(GDBusConnection *connection,
return 0;
}
/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __lcd_on_signal_handler(GDBusConnection *connection,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
-{
- _I("LCD ON");
- if (__deviced_signal_lcd_handler)
- __deviced_signal_lcd_handler(__deviced_signal_lcd_data);
-}
-/* LCOV_EXCL_STOP */
-
-int _watch_base_signal_listen_lcd_status_signal(void (*func)(void *), void *data)
-{
- if (__dbus_init() < 0)
- return -1;
-
- __lcd_sid = g_dbus_connection_signal_subscribe(conn,
- NULL,
- DEVICED_INTERFACE_DISPLAY,
- LCD_ON,
- DEVICED_PATH_DISPLAY,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __lcd_on_signal_handler,
- NULL,
- NULL);
- if (!__lcd_sid) {
- _E("Failed to subscribe LCD status signal");
- return -1;
- }
-
- __deviced_signal_lcd_handler = func;
- __deviced_signal_lcd_data = data;
-
- _D("Listen LCD status signal");
-
- return 0;
-}
-
-void _watch_base_signal_ignore_lcd_status_signal(void)
-{
- __deviced_signal_lcd_handler = NULL;
- __deviced_signal_lcd_data = NULL;
-
- if (__lcd_sid) {
- g_dbus_connection_signal_unsubscribe(conn, __lcd_sid);
- __lcd_sid = 0;
- }
-
- __dbus_fini();
-
- _D("Ignore LCD status signal");
-}