#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"
#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 */
}
}
+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;
/* Alarm init */
__alarm_init();
+ __set_default_tick_by_metadata();
__context.state = WATCH_APP_STATE_RUNNING;
return APP_ERROR_NONE;