Change default RTC 05/223005/4
authorInkyun Kil <inkyun.kil@samsung.com>
Wed, 22 Jan 2020 05:40:08 +0000 (14:40 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Wed, 29 Jan 2020 09:36:54 +0000 (18:36 +0900)
Change-Id: I8a5ac3adeaf2fcbd39fda776642f35af4e1150ef
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
include/alarm-internal.h
packaging/alarm-manager.spec
server/CMakeLists.txt
server/alarm-manager-util.c
server/alarm-manager-util.h
server/alarm-manager.c

index b64299d13727fcb31c990d92f9aa4be2eded32fb..b479fafbc1bc0199d4ac850293b05f558f3098ae 100644 (file)
@@ -61,15 +61,6 @@ enum async_param_type {
        SET_SYSTIME_WITH_PROPAGATION_DELAY,
 };
 
-typedef enum {
-       PROFILE_UNKNOWN = 0,
-       PROFILE_MOBILE,
-       PROFILE_WEARABLE,
-       PROFILE_TV,
-       PROFILE_IVI,
-       PROFILE_COMMON,
-} profile_t;
-
 #define        ALARM_TYPE_RELATIVE             0x80000000      /**< relative  */
 #define        ALARM_TYPE_WITHCB               0x40000000      /**< withcb  */
 #define        ALARM_TYPE_PERIOD               0x10000000      /**< periodic */
index 8ebb1968c5aab7311be2c5fe9a9843d35b165efa..611b86202e4cffe48b94f4f44c11498c635372e3 100644 (file)
@@ -34,7 +34,6 @@ BuildRequires: pkgconfig(libsystemd)
 BuildRequires: pkgconfig(eventsystem)
 BuildRequires: pkgconfig(notification)
 BuildRequires: python-xml
-BuildRequires: pkgconfig(capi-system-info)
 BuildRequires: pkgconfig(cert-svc-vcore)
 BuildRequires: pkgconfig(cynara-client)
 BuildRequires: pkgconfig(cynara-session)
index 2dc595d63688998ff77f1febd3b16a9aa2691f30..67c87c90d174466d388f9a9c0c568df80391daa8 100755 (executable)
@@ -6,7 +6,7 @@ AUX_SOURCE_DIRECTORY(./ SRCS)
 
 PKG_CHECK_MODULES(svr_pkgs REQUIRED glib-2.0 dlog aul bundle appsvc pkgmgr-info pkgmgr vconf
                gio-2.0 gio-unix-2.0 capi-system-device libtzplatform-config libsystemd-login
-               eventsystem notification capi-system-info sqlite3 cert-svc-vcore
+               eventsystem notification sqlite3 cert-svc-vcore
                cynara-session cynara-client cynara-creds-gdbus)
 
 FOREACH(flag ${svr_pkgs_CFLAGS_OTHER})
index 1486adbb26976f2df6c06317c95a5f981138af9e..9515a52fbef268456294e25522ac627c317a5ce8 100644 (file)
@@ -16,7 +16,6 @@
 
 #define _GNU_SOURCE
 #include <fcntl.h>
-#include <system_info.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -52,47 +51,6 @@ static int __bg_category_func(const char *name, void *user_data)
        return 0;
 }
 
-profile_t _get_profile()
-{
-       static profile_t saved = PROFILE_UNKNOWN;
-       char *profileName;
-       int r;
-
-       if (__builtin_expect(saved != PROFILE_UNKNOWN, 1))
-               return saved;
-
-       r = system_info_get_platform_string("http://tizen.org/feature/profile",
-                       &profileName);
-       if (r != SYSTEM_INFO_ERROR_NONE) {
-               LOGD("Failed to get profile info. error(%d)", r);
-               return saved;
-       }
-
-       switch (*profileName) {
-       case 'm':
-       case 'M':
-               saved = PROFILE_MOBILE;
-               break;
-       case 'w':
-       case 'W':
-               saved = PROFILE_WEARABLE;
-               break;
-       case 't':
-       case 'T':
-               saved = PROFILE_TV;
-               break;
-       case 'i':
-       case 'I':
-               saved = PROFILE_IVI;
-               break;
-       default: // common or unknown ==> ALL ARE COMMON.
-               saved = PROFILE_COMMON;
-       }
-       free(profileName);
-
-       return saved;
-}
-
 int _pkg_is_global(const char *callee_pkgid, uid_t uid)
 {
        int retval;
index b37019dd4bf5a14864d5f38d13222adcdbbc1fd2..0e010ed16124a70565edd11d02376716446a6e1d 100644 (file)
@@ -30,7 +30,6 @@ extern "C" {
 #define ALARMMGR_LOG_TAG_SIZE          20
 #define ALARMMGR_LOG_MESSAGE_SIZE      330
 
-profile_t _get_profile();
 int _cynara_check(GDBusMethodInvocation *invocation, const char* privilege,
                pid_t pid);
 char* _get_pkgid_by_appid(const char* app_id, uid_t uid);
index ddc5db345f2572e501d03de92d425985f78fcf06..e0434ef5784084085d00187de63d7173572b1177 100644 (file)
@@ -59,8 +59,6 @@
 #define RTC_WKALM_BOOT_SET _IOW('p', 0x80, struct rtc_wkalrm)
 #endif
 
-#define _APPFW_FEATURE_WAKEUP_USING_RTC (_get_profile() != PROFILE_TV)
-
 #define PATH_LIB_ALARMMGR_PLUGIN "/usr/lib/libalarm-server-plugin.so"
 
 static void *plugin_handle;
@@ -86,6 +84,7 @@ GHashTable *caller_appid_cache_table;
 
 bool is_time_changed = false; /* for calculating next duetime */
 static time_t periodic_alarm_standard_time = 0;
+static bool using_rtc = false;
 
 struct running_info_t {
        pid_t pid;
@@ -232,7 +231,7 @@ void __free_cached_value(gpointer data)
 
 void _rtc_set()
 {
-       if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
+       if (using_rtc) {
                char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
 #ifdef _SIMUL /* RTC does not work in simulator. */
                LOGE("because it is simulator's mode, we don't set RTC.");
@@ -296,7 +295,7 @@ static bool __set_time(time_t _time)
                return false;
        }
 
-       if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
+       if (using_rtc) {
                char buf[1024];
                char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
                char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
@@ -392,7 +391,8 @@ static void __alarm_add_to_list(__alarm_info_t *__alarm_info)
                        LOGE("Saving alarm_id(%d) in DB is failed.", __alarm_info->alarm_id);
        }
 
-       DO_AFTER_ALARM_CREATE(__alarm_info->pid, __alarm_info->app_unique_name);
+       if (using_rtc)
+               DO_AFTER_ALARM_CREATE(__alarm_info->pid, __alarm_info->app_unique_name);
 }
 
 static bool __check_bundle_for_update(const gchar *b_data, uid_t uid)
@@ -1599,7 +1599,8 @@ void _alarm_expired()
 
                _save_alarm_info_log("EXPIRED", __alarm_info);
 
-               DO_AFTER_ALARM_EXPIRE(__alarm_info->pid, __alarm_info->app_unique_name);
+               if (using_rtc)
+                       DO_AFTER_ALARM_EXPIRE(__alarm_info->pid, __alarm_info->app_unique_name);
 
                if (__alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE) {
                        __alarm_remove_from_list(__alarm_info->uid, __alarm_info->alarm_id, NULL);
@@ -1754,7 +1755,7 @@ static int __on_app_installed(uid_t target_uid, int req_id, const char *pkg_type
        __alarm_info_t *entry = NULL;
        bool is_restored = false;
 
-       if (GET_POWER_SAVING_MODE() == -1)
+       if (using_rtc && GET_POWER_SAVING_MODE() == -1)
                return ALARMMGR_RESULT_SUCCESS;
 
        if ((key && strncmp(key, "end", 3) != 0) || (val && strncmp(val, "ok", 2) != 0))
@@ -1800,14 +1801,15 @@ static int __on_app_uninstalled(uid_t target_uid, int req_id, const char *pkg_ty
        __alarm_info_t *entry = NULL;
        alarm_info_t *alarm_info = NULL;
        bool is_deleted = false;
-       int is_power_saving_mode;
+       int is_power_saving_mode = 0;
 
        SECURE_LOGD("pkg_type(%s), pkgid(%s), key(%s), value(%s)", pkg_type, pkgid, key, val);
 
        if ((key && strncmp(key, "end", 3) != 0) || (val && strncmp(val, "ok", 2) != 0))
                return ALARMMGR_RESULT_SUCCESS;
 
-       is_power_saving_mode = GET_POWER_SAVING_MODE();
+       if (using_rtc)
+               is_power_saving_mode = GET_POWER_SAVING_MODE();
 
        for (gs_iter = alarm_context.alarms; gs_iter != NULL;) {
                entry = (__alarm_info_t *)gs_iter->data;
@@ -1993,7 +1995,7 @@ static int __check_modifiable(uid_t uid, pid_t pid, int alarm_id)
 
 int alarm_manager_alarm_set_rtc_time(GVariant *parameters)
 {
-       if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
+       if (using_rtc) {
                int retval = 0;
                struct tm tm, *alarm_tm = NULL;
                char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
@@ -2204,7 +2206,9 @@ int alarm_manager_alarm_set_timezone(GVariant* parameters)
        }
 
        tzset();
-       DO_AFTER_TIMEZONE_SET();
+
+       if (using_rtc)
+               DO_AFTER_TIMEZONE_SET();
 
        /* Rescheduling alarms */
        _alarm_disable_timer();
@@ -3033,40 +3037,41 @@ static int __load_module(const char *path)
        plugin_handle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
        if (!plugin_handle) {
                LOGE("Failed to load - %s", dlerror());
-               return -1;
+               using_rtc = false;
+               return 0;
+       } else {
+               using_rtc = true;
        }
 
-       if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
-               RTC_INIT = dlsym(plugin_handle, "RTC_INIT");
-               if (!RTC_INIT) {
-                       LOGE("Failed to find PLUGIN_INIT");
-                       goto out;
-               }
+       RTC_INIT = dlsym(plugin_handle, "RTC_INIT");
+       if (!RTC_INIT) {
+               LOGE("Failed to find PLUGIN_INIT");
+               goto out;
+       }
 
-               CLEAR_WAKEUP_RTC = dlsym(plugin_handle, "CLEAR_WAKEUP_RTC");
-               if (!CLEAR_WAKEUP_RTC) {
-                       LOGE("Failed to find CLEAR_WAKEUP_RTC");
-                       goto out;
-               }
+       CLEAR_WAKEUP_RTC = dlsym(plugin_handle, "CLEAR_WAKEUP_RTC");
+       if (!CLEAR_WAKEUP_RTC) {
+               LOGE("Failed to find CLEAR_WAKEUP_RTC");
+               goto out;
+       }
 
-               SET_WAKEUP_RTC = dlsym(plugin_handle, "SET_WAKEUP_RTC");
-               if (!SET_WAKEUP_RTC) {
-                       LOGE("Failed to find SET_WAKEUP_RTC");
-                       goto out;
-               }
+       SET_WAKEUP_RTC = dlsym(plugin_handle, "SET_WAKEUP_RTC");
+       if (!SET_WAKEUP_RTC) {
+               LOGE("Failed to find SET_WAKEUP_RTC");
+               goto out;
+       }
 
-               SET_WAKEUP_RTC_WITH_DATETIME = dlsym(plugin_handle,
-                               "SET_WAKEUP_RTC_WITH_DATETIME");
-               if (!SET_WAKEUP_RTC_WITH_DATETIME) {
-                       LOGE("Failed to find SET_WAKEUP_RTC_WITH_DATETIME");
-                       goto out;
-               }
+       SET_WAKEUP_RTC_WITH_DATETIME = dlsym(plugin_handle,
+                       "SET_WAKEUP_RTC_WITH_DATETIME");
+       if (!SET_WAKEUP_RTC_WITH_DATETIME) {
+               LOGE("Failed to find SET_WAKEUP_RTC_WITH_DATETIME");
+               goto out;
+       }
 
-               SET_SYSTIME_RTC = dlsym(plugin_handle, "SET_SYSTIME_RTC");
-               if (!SET_SYSTIME_RTC) {
-                       LOGE("Failed to find SET_SYSTIME_RTC");
-                       goto out;
-               }
+       SET_SYSTIME_RTC = dlsym(plugin_handle, "SET_SYSTIME_RTC");
+       if (!SET_SYSTIME_RTC) {
+               LOGE("Failed to find SET_SYSTIME_RTC");
+               goto out;
        }
 
        DO_AFTER_TIMEZONE_SET = dlsym(plugin_handle, "DO_AFTER_TIMEZONE_SET");
@@ -3147,16 +3152,16 @@ void _alarm_initialize()
                exit(1);
        }
 
-       if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
+       if (using_rtc) {
                if (RTC_INIT() != 0) {
                        LOGE("rtc init failed");
                        exit(1);
                }
-       }
 
-       if (PS_MODE_INIT() != 0) {
-               LOGE("power saving mode init failed");
-               exit(1);
+               if (PS_MODE_INIT() != 0) {
+                       LOGE("power saving mode init failed");
+                       exit(1);
+               }
        }
 
        __initialize_alarm_list();
@@ -3167,7 +3172,7 @@ void _alarm_initialize()
                                g_direct_equal, NULL, __free_cached_value);
        }
 
-       if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
+       if (using_rtc) {
                tzset();
                DO_AFTER_TIMEZONE_SET();
        }