Support metadata default tick 74/124674/6
authorHyunho Kang <hhstark.kang@samsung.com>
Wed, 12 Apr 2017 05:41:46 +0000 (14:41 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Fri, 14 Apr 2017 01:30:42 +0000 (10:30 +0900)
- keys
http://developer.samsung.com/tizen/metadata/tickpersecond
http://developer.samsung.com/tizen/metadata/minutetick

Change-Id: I71f42a6fff3e974d2192b0b7710f4b02dd4fa127
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
CMakeLists.txt
packaging/appcore-watch.spec
src/watch_app_main.c

index 72b9609..a3651e0 100644 (file)
@@ -40,6 +40,7 @@ pkg_check_modules(pkg_watch REQUIRED
                screen_connector_provider
                appcore-common
                appcore-efl
+               pkgmgr-info
                )
 FOREACH(flag ${pkg_watch_CFLAGS})
        SET(EXTRA_CFLAGS_watch "${EXTRA_CFLAGS_watch} ${flag}")
index 374ff0f..139b586 100644 (file)
@@ -22,6 +22,7 @@ BuildRequires:        pkgconfig(ecore-wayland)
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(screen_connector_provider)
+BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires:  cmake
 
 
index fd561b5..375a611 100755 (executable)
@@ -47,6 +47,7 @@
 #include <app_control.h>
 #include <app_control_internal.h>
 #include <bundle_internal.h>
+#include <pkgmgr-info.h>
 
 #include "appcore-watch-log.h"
 #include "watch_app_private.h"
@@ -67,6 +68,8 @@
 #define ONE_MINUTE_IN_SEC      60
 #define ONE_HOUR_IN_SEC                3600
 #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"
 
 typedef enum {
        WATCH_APP_STATE_NOT_RUNNING = 0, /* The application has been launched or was running but was terminated */
@@ -390,6 +393,54 @@ static void __time_tick_cancel(void)
        }
 }
 
+static void __set_default_tick_by_metadata()
+{
+       char appid[APPID_BUFFER_MAX] = {0,};
+       pkgmgrinfo_appinfo_h handle = NULL;
+       char *second_tick = NULL;
+       char *minute_tick = NULL;
+       int ret;
+       int tick;
+
+       ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
+       if (ret < 0) {
+               _E("fail to get the appid from the pid : %d", getpid());
+               return;
+       }
+
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret != PMINFO_R_OK)
+               return;
+
+       /* If both minute tick & second tick are declared, only minute tick has to be applied */
+       pkgmgrinfo_appinfo_get_metadata_value(handle, METADATA_MINUTE_TICK, &minute_tick);
+       if (minute_tick) {
+               sscanf(minute_tick, "%d", &tick);
+               if (tick > 0) {
+                       _D("set default tick %d, type %d", tick, WATCH_APP_TIME_TICKS_PER_MINUTE);
+                       app_tick_type = WATCH_APP_TIME_TICKS_PER_MINUTE;
+                       app_tick_resolution = tick;
+                       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+                       return;
+               }
+       }
+
+       pkgmgrinfo_appinfo_get_metadata_value(handle, METADATA_TICK_PER_SECOND, &second_tick);
+       if (second_tick) {
+               sscanf(second_tick, "%d", &tick);
+               if (tick > 0) {
+                       _D("set default tick %d, type %d", tick, WATCH_APP_TIME_TICKS_PER_SECOND);
+                       app_tick_type = WATCH_APP_TIME_TICKS_PER_SECOND;
+                       app_tick_resolution = tick;
+                       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+                       return;
+               }
+       }
+
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       return;
+}
+
 static int __on_create(void *data)
 {
        watch_app_create_cb create_cb;
@@ -408,6 +459,7 @@ static int __on_create(void *data)
 
        /* Alarm init */
        __alarm_init();
+       __set_default_tick_by_metadata();
        __context.state = WATCH_APP_STATE_RUNNING;
 
        return APP_ERROR_NONE;