diff options
author | Jiwoong Im <jiwoong.im@samsung.com> | 2015-11-17 18:19:31 +0900 |
---|---|---|
committer | Jiwoong Im <jiwoong.im@samsung.com> | 2015-11-23 13:59:58 +0900 |
commit | 20e5320aa310ec7823bc600b4cad111c8772aebf (patch) | |
tree | 24337437c74eaa553d7da9ada0cfd5827756b9b0 | |
parent | 26f9ea6d4f4760fdfc3d39f6f1591a110088985e (diff) | |
download | alarm-manager-20e5320aa310ec7823bc600b4cad111c8772aebf.tar.gz alarm-manager-20e5320aa310ec7823bc600b4cad111c8772aebf.tar.bz2 alarm-manager-20e5320aa310ec7823bc600b4cad111c8772aebf.zip |
add ERR_ALARM_NOT_PERMITTED_APP error codesubmit/tizen/20151123.053026accepted/tizen/wearable/20151124.084721accepted/tizen/tv/20151124.084702accepted/tizen/mobile/20151124.084645
Change-Id: I4eb7b1ead0d56e5aa93a9eb8a31e33c8452cbb94
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
-rw-r--r-- | alarm-manager.c | 120 | ||||
-rw-r--r-- | alarm_mgr.xml | 1 | ||||
-rw-r--r-- | include/alarm-internal.h | 8 | ||||
-rw-r--r-- | include/alarm.h | 2 | ||||
-rw-r--r-- | src/alarm-lib-stub.c | 1 | ||||
-rw-r--r-- | src/alarm-lib.c | 129 |
6 files changed, 217 insertions, 44 deletions
diff --git a/alarm-manager.c b/alarm-manager.c index 1d19f9b..12d416e 100644 --- a/alarm-manager.c +++ b/alarm-manager.c @@ -139,7 +139,7 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, uid_t const char *dst_service_name, const char *dst_service_name_mod, int *error_code); static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id, - uid_t uid, int pid, char *bundle_data, int *error_code); + long requested_interval, uid_t uid, int pid, char *bundle_data, int *error_code); static bool __alarm_delete(uid_t uid, alarm_id_t alarm_id, int *error_code); static bool __alarm_update(uid_t uid, int pid, char *app_service_name, alarm_id_t alarm_id, @@ -160,7 +160,7 @@ static bool __initialize_db(); static void __initialize(); void on_bus_name_owner_changed(GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data); -bool __get_caller_unique_name(int pid, char *unique_name); +bool __get_caller_unique_name(int pid, char *unique_name, uid_t uid); #ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG static void __initialize_module_log(void); @@ -691,7 +691,7 @@ static bool __alarm_update_due_time_of_all_items_in_list(double diff_time) } static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id, - uid_t uid, int pid, char *bundle_data, int *error_code) + long requested_interval, uid_t uid, int pid, char *bundle_data, int *error_code) { time_t current_time; time_t due_time; @@ -720,8 +720,9 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id __alarm_info->uid = uid; __alarm_info->pid = pid; __alarm_info->alarm_id = -1; + __alarm_info->requested_interval = requested_interval; - if (!__get_caller_unique_name(pid, app_name)) { + if (!__get_caller_unique_name(pid, app_name, uid)) { *error_code = ERR_ALARM_SYSTEM_FAIL; free(__alarm_info); return false; @@ -732,7 +733,7 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id // caller __alarm_info->quark_caller_pkgid = g_quark_from_string("null"); - if (aul_app_get_appid_bypid(pid, caller_appid, 256) == AUL_R_OK) { + if (aul_app_get_appid_bypid_for_uid(pid, caller_appid, 256, uid) == AUL_R_OK) { if (pkgmgrinfo_appinfo_get_usr_appinfo(caller_appid, uid, &caller_handle) == PMINFO_R_OK) { if (pkgmgrinfo_appinfo_get_pkgid(caller_handle, &caller_pkgid) == PMINFO_R_OK) { if (caller_pkgid) { @@ -859,7 +860,7 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, uid_t __alarm_info->is_ref = is_ref; // Get caller_appid to get caller's package id. There is no callee. - if (aul_app_get_appid_bypid(pid, caller_appid, 256) == AUL_R_OK) { + if (aul_app_get_appid_bypid_for_uid(pid, caller_appid, 256, uid) == AUL_R_OK) { if (pkgmgrinfo_appinfo_get_usr_appinfo(caller_appid, uid, &caller_handle) == PMINFO_R_OK) { if (pkgmgrinfo_appinfo_get_pkgid(caller_handle, &caller_pkgid) == PMINFO_R_OK) { if (caller_pkgid) { @@ -873,7 +874,7 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, uid_t __alarm_info->quark_callee_pkgid = g_quark_from_string("null"); SECURE_LOGD("caller_pkgid = %s, callee_pkgid = null", g_quark_to_string(__alarm_info->quark_caller_pkgid)); - if (!__get_caller_unique_name(pid, app_name)) { + if (!__get_caller_unique_name(pid, app_name, uid)) { *error_code = ERR_ALARM_SYSTEM_FAIL; free(__alarm_info); return false; @@ -1247,6 +1248,30 @@ static int __have_ui_apps(bundle *b, uid_t uid) return app.is_ui_app; } +static int __compare_api_version(int *result, int pid, uid_t uid) { + int ret = 0; + pkgmgrinfo_pkginfo_h pkginfo = NULL; + char pkgid[512] = {0, }; + char *pkg_version; + + if (aul_app_get_pkgid_bypid_for_uid(pid, pkgid, sizeof(pkgid), uid) != AUL_R_OK) { + ALARM_MGR_EXCEPTION_PRINT("aul_app_get_pkgid_bypid() is failed. PID %d may not be app.", getpid()); + } else { + ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &pkginfo); + if (ret != PMINFO_R_OK) { + ALARM_MGR_EXCEPTION_PRINT("Failed to get pkginfo\n"); + } else { + ret = pkgmgrinfo_pkginfo_get_api_version(pkginfo, &pkg_version); + if (ret != PMINFO_R_OK) { + ALARM_MGR_EXCEPTION_PRINT("Failed to check api version [%d]\n", ret); + } + *result = strverscmp(pkg_version, "2.4"); + pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo); + } + } + return ret; +} + static void __alarm_expired() { int ret; @@ -1315,37 +1340,38 @@ static void __alarm_expired() if (bundle_add_str(b,"http://tizen.org/appcontrol/data/alarm_id", alarm_id_val)){ ALARM_MGR_EXCEPTION_PRINT("Unable to add alarm id to the bundle\n"); } - else - { - appid = (char *)appsvc_get_appid(b); - if (appid && !__is_ui_app(appid, __alarm_info->uid)) { - ALARM_MGR_EXCEPTION_PRINT("ui-application can only be launched\n"); - } - else if( (__alarm_info->alarm_info.alarm_type & ALARM_TYPE_NOLAUNCH) && !aul_app_is_running(appid)) - { - ALARM_MGR_EXCEPTION_PRINT("This alarm is ignored\n"); + else { + int result = 0; + + if (__compare_api_version(&result, app_pid, __alarm_info->uid) < 0) { + ALARM_MGR_EXCEPTION_PRINT("Unable to check api version\n"); + result = -1; } - else - { - if (__have_ui_apps(b, __alarm_info->uid)) - { - if ( appsvc_usr_run_service(b, 0, NULL, NULL, __alarm_info->uid) < 0) - { - ALARM_MGR_EXCEPTION_PRINT("Unable to run app svc\n"); + + if (result < 0) { /* before 2.4 */ + if ( appsvc_usr_run_service(b, 0, NULL, NULL, __alarm_info->uid) < 0) { + ALARM_MGR_EXCEPTION_PRINT("Unable to run app svc\n"); + } + else { + ALARM_MGR_LOG_PRINT("Successfuly ran app svc\n"); + } + } else { /* since 2.4 */ + appid = (char *)appsvc_get_appid(b); + if( (__alarm_info->alarm_info.alarm_type & ALARM_TYPE_NOLAUNCH) && !aul_app_is_running(appid)) { + ALARM_MGR_EXCEPTION_PRINT("This alarm is ignored\n"); + } else if ( !(__alarm_info->alarm_info.alarm_type & ALARM_TYPE_INEXACT) || + !__can_skip_expired_cb(__alarm_info->alarm_id) ) { + if (appsvc_usr_run_service(b, 0, NULL, NULL, __alarm_info->uid ) < 0) { + ALARM_MGR_EXCEPTION_PRINT("Unable to launch app [%s] \n", appid); } - else - { - device_display_change_state(DISPLAY_STATE_NORMAL); + else { ALARM_MGR_LOG_PRINT("Successfuly ran app svc\n"); + if (__is_ui_app(appid, __alarm_info->uid)) { + device_display_change_state(DISPLAY_STATE_NORMAL); + } } } - else - { - ALARM_MGR_EXCEPTION_PRINT("ui-application can only be launched\n"); - } - } - } bundle_free(b); } @@ -1624,7 +1650,7 @@ static int __on_app_uninstalled(uid_t target_uid, int req_id, const char *pkg_ty return ALARMMGR_RESULT_SUCCESS; } -bool __get_caller_unique_name(int pid, char *unique_name) +bool __get_caller_unique_name(int pid, char *unique_name, uid_t uid) { char caller_appid[256] = {0,}; char caller_cmdline[512] = {0,}; @@ -1634,8 +1660,8 @@ bool __get_caller_unique_name(int pid, char *unique_name) return false; } - if (aul_app_get_appid_bypid(pid, caller_appid, - sizeof(caller_appid)) == AUL_R_OK) { + if (aul_app_get_appid_bypid_for_uid(pid, caller_appid, + sizeof(caller_appid), uid) == AUL_R_OK) { /* When a caller is an application, the unique name is appID. */ strncpy(unique_name, caller_appid, strlen(caller_appid)); } else { @@ -1816,7 +1842,7 @@ int __display_unlock_state(char *state, char *flag) return ret; } -static long __get_proper_interval(long interval) +static long __get_proper_interval(long interval, int alarm_type) { GSList *gs_iter = NULL; __alarm_info_t *entry = NULL; @@ -1832,7 +1858,8 @@ static long __get_proper_interval(long interval) } } - while (maxInterval * 2 <= interval) { + while (maxInterval * 2 <= interval || + (alarm_type & ALARM_TYPE_INEXACT && maxInterval < MIN_INEXACT_INTERVAL) ) { maxInterval *= 2; } @@ -2132,6 +2159,7 @@ gboolean alarm_manager_alarm_create_appsvc(AlarmManager *pObject, GDBusMethodInv int start_hour, int start_min, int start_sec, int end_year, int end_month, int end_day, int mode_day_of_week, + unsigned int mode_interval, int mode_repeat, int alarm_type, int reserved_info, char *bundle_data, @@ -2170,7 +2198,15 @@ gboolean alarm_manager_alarm_create_appsvc(AlarmManager *pObject, GDBusMethodInv alarm_info.alarm_type = alarm_type; alarm_info.reserved_info = reserved_info; - if (!__alarm_create_appsvc(&alarm_info, &alarm_id, uid, pid, bundle_data, &return_code)) { + if ((alarm_info.alarm_type & ALARM_TYPE_INEXACT)) { + alarm_info.alarm_type |= ALARM_TYPE_PERIOD; + alarm_info.mode.u_interval.interval = + __get_proper_interval(mode_interval, alarm_info.alarm_type); + } else if (mode_interval <= 0){ + alarm_info.mode.u_interval.interval = 0; + } + + if (!__alarm_create_appsvc(&alarm_info, &alarm_id, mode_interval, uid, pid, bundle_data, &return_code)) { ALARM_MGR_EXCEPTION_PRINT("Unable to create alarm! return_code[%d]", return_code); #ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG strncpy(log_tag, "FAIL: CREATE", strlen("FAIL: CREATE")); @@ -2307,7 +2343,7 @@ gboolean alarm_manager_alarm_create_periodic(AlarmManager *obj, GDBusMethodInvoc if (is_ref) alarm_info.mode.u_interval.interval = interval * 60; else - alarm_info.mode.u_interval.interval = __get_proper_interval(interval * 60); + alarm_info.mode.u_interval.interval = __get_proper_interval(interval * 60, alarm_info.alarm_type); } if (!__alarm_create(&alarm_info, &alarm_id, uid, pid, method, interval * 60, is_ref, @@ -2398,7 +2434,7 @@ gboolean alarm_manager_alarm_delete_all(AlarmManager *obj, GDBusMethodInvocation uid = __get_caller_uid(name); pid = __get_caller_pid(name); - if (!__get_caller_unique_name(pid, app_name)) { + if (!__get_caller_unique_name(pid, app_name, uid)) { return_code = ERR_ALARM_SYSTEM_FAIL; g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code)); #ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG @@ -2542,7 +2578,7 @@ gboolean alarm_manager_alarm_get_number_of_ids(AlarmManager *pObject, GDBusMetho uid = __get_caller_uid(name); pid = __get_caller_pid(name); - if (!__get_caller_unique_name(pid, app_name)) { + if (!__get_caller_unique_name(pid, app_name, uid)) { return_code = ERR_ALARM_SYSTEM_FAIL; g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", num_of_ids, return_code)); return true; @@ -2589,7 +2625,7 @@ gboolean alarm_manager_alarm_get_list_of_ids(AlarmManager *pObject, GDBusMethodI return true; } - if (!__get_caller_unique_name(pid, app_name)) { + if (!__get_caller_unique_name(pid, app_name, uid)) { return_code = ERR_ALARM_SYSTEM_FAIL; g_dbus_method_invocation_return_value(invoc, g_variant_new("(@aiii)", g_variant_new("ai", NULL), num_of_ids, return_code)); return true; diff --git a/alarm_mgr.xml b/alarm_mgr.xml index faf03a0..2d362f9 100644 --- a/alarm_mgr.xml +++ b/alarm_mgr.xml @@ -42,6 +42,7 @@ <arg type="i" name="alarm_info_end_month" direction="in" /> <arg type="i" name="alarm_info_end_day" direction="in" /> <arg type="i" name="alarm_info_mode_day_of_week" direction="in" /> + <arg type="i" name="alarm_info_mode_interval" direction="in" /> <arg type="i" name="alarm_info_mode_repeat" direction="in" /> <arg type="i" name="alarm_info_alarm_type" direction="in" /> <arg type="i" name="alarm_info_reserved_info" direction="in" /> diff --git a/include/alarm-internal.h b/include/alarm-internal.h index eaa99d9..377c5f4 100644 --- a/include/alarm-internal.h +++ b/include/alarm-internal.h @@ -42,6 +42,7 @@ #define MAX_SERVICE_NAME_LEN 256 #define MAX_PKG_NAME_LEN MAX_SERVICE_NAME_LEN-8 #define MAX_PKG_ID_LEN 256 +#define MIN_INEXACT_INTERVAL 600 #define SYSTEM_TIME_CHANGED "setting_time_changed" @@ -196,6 +197,11 @@ typedef struct { alarm_id_t alarm_id; } __expired_alarm_t; +typedef struct _bg_category_cb_info_t { + char *appid; + bool has_bg; +} bg_category_cb_info_t; + time_t _alarm_next_duetime(__alarm_info_t *alarm_info); bool _alarm_schedule(); bool _clear_scheduled_alarm_list(); @@ -210,6 +216,8 @@ bool _alarm_set_timer(__alarm_server_context_t *alarm_context, int timer, time_t bool _alarm_disable_timer(__alarm_server_context_t alarm_context); bool _init_scheduled_alarm_list(); +time_t _get_periodic_alarm_standard_time(void); + #ifdef _DEBUG_MODE_ #define ALARM_MGR_LOG_PRINT(FMT, ARG...) do { printf("%5d", getpid()); printf ("%s() : "FMT"\n", __FUNCTION__, ##ARG); } while (false) diff --git a/include/alarm.h b/include/alarm.h index b4d4796..fe34d18 100644 --- a/include/alarm.h +++ b/include/alarm.h @@ -186,6 +186,7 @@ typedef enum { * This enumeration has error codes of alarm */ typedef enum { + ERR_ALARM_NOT_PERMITTED_APP = -11, ERR_ALARM_INVALID_PARAM = -10, /**<Invalid parameter*/ ERR_ALARM_INVALID_ID, /**<Invalid id*/ @@ -226,6 +227,7 @@ typedef enum { #define ALARM_TYPE_DEFAULT 0x0 /*< non volatile */ #define ALARM_TYPE_VOLATILE 0x02 /*< volatile */ #define ALARM_TYPE_NOLAUNCH 0x04 /*<without launch */ +#define ALARM_TYPE_INEXACT 0x08 /*<inexact alarm */ /** diff --git a/src/alarm-lib-stub.c b/src/alarm-lib-stub.c index 86de591..4fb5c60 100644 --- a/src/alarm-lib-stub.c +++ b/src/alarm-lib-stub.c @@ -84,6 +84,7 @@ bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info alarm_info->end.month, alarm_info->end.day, alarm_info->mode.u_interval.day_of_week, + alarm_info->mode.u_interval.interval, alarm_info->mode.repeat, alarm_info->alarm_type, alarm_info->reserved_info, diff --git a/src/alarm-lib.c b/src/alarm-lib.c index 6d9f164..2339b7c 100644 --- a/src/alarm-lib.c +++ b/src/alarm-lib.c @@ -37,6 +37,7 @@ #include <appsvc.h> #include <aul.h> #include <gio/gio.h> +#include <pkgmgr-info.h> #ifndef EXPORT_API #define EXPORT_API __attribute__ ((visibility("default"))) @@ -216,6 +217,92 @@ static bool __alarm_validate_time(alarm_date_t *date, int *error_code) return true; } +static int __compare_api_version(int *result, uid_t uid) { + int ret = 0; + pkgmgrinfo_pkginfo_h pkginfo = NULL; + char pkgid[512] = {0, }; + char *pkg_version; + + if (aul_app_get_pkgid_bypid_for_uid(getpid(), pkgid, sizeof(pkgid), uid) != AUL_R_OK) { + ALARM_MGR_EXCEPTION_PRINT("aul_app_get_pkgid_bypid() is failed. PID %d may not be app.", getpid()); + } else { + ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &pkginfo); + if (ret != PMINFO_R_OK) { + ALARM_MGR_EXCEPTION_PRINT("Failed to get pkginfo\n"); + } else { + ret = pkgmgrinfo_pkginfo_get_api_version(pkginfo, &pkg_version); + if (ret != PMINFO_R_OK) { + ALARM_MGR_EXCEPTION_PRINT("Failed to check api version [%d]\n", ret); + } + *result = strverscmp(pkg_version, "2.4"); + pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo); + } + } + return ret; +} + +static int __bg_category_func(const char *name, void *user_data) +{ + bg_category_cb_info_t *info = (bg_category_cb_info_t *)user_data; + ALARM_MGR_LOG_PRINT("appid[%s], bg name = %s", info->appid, name); + if (name && + strncmp("enable", name, strlen(name)) && strncmp("disable", name, strlen(name))) { + info->has_bg = true; + return -1; + } + + return 0; +} + +static bool __is_permitted(const char *app_id, int alarm_type) +{ + if (app_id == NULL) { + ALARM_MGR_EXCEPTION_PRINT("app_id is NULL. Only expicit launch is permitted\n"); + return false; + } + + pkgmgrinfo_appinfo_h handle = NULL; + int ret; + bool _return = false; + + ret = pkgmgrinfo_appinfo_get_usr_appinfo(app_id, getuid(), &handle); + if (ret != PMINFO_R_OK) { + ALARM_MGR_EXCEPTION_PRINT("Failed to get appinfo [%s]\n", app_id); + } else { + char *app_type = NULL; + ret = pkgmgrinfo_appinfo_get_component_type(handle, &app_type); + if (app_type && strcmp("uiapp", app_type) == 0) { + ALARM_MGR_LOG_PRINT("[%s] is ui application. It is allowed", app_id); + _return = true; + goto out; + } else if (app_type && strcmp("svcapp", app_type) == 0) { + ALARM_MGR_LOG_PRINT("[%s] is service application.", app_id); + + bg_category_cb_info_t info = { + .appid = app_id, + .has_bg = false + }; + + if (alarm_type & ALARM_TYPE_INEXACT) { + _return = true; + ret = pkgmgrinfo_appinfo_foreach_background_category(handle, __bg_category_func, &info); + if (ret == PMINFO_R_OK && info.has_bg) { + ALARM_MGR_LOG_PRINT("[%s] has background categories.", app_id); + _return = true; + goto out; + } else { + ALARM_MGR_EXCEPTION_PRINT("Failed to foreach background category. [%s] is not allowed\n", app_id); + } + } + } + } + +out : + if (handle) + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return _return; +} + static int __sub_init() { GError *error = NULL; @@ -449,6 +536,9 @@ EXPORT_API int alarmmgr_set_repeat_mode(alarm_entry_t *alarm, if (repeat == ALARM_REPEAT_MODE_REPEAT || repeat == ALARM_REPEAT_MODE_WEEKLY) { + if (interval <= 0) { + return ERR_ALARM_INVALID_PARAM; + } alarm_info->mode.u_interval.interval = interval; } @@ -769,7 +859,8 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, time_t interval, void *bundle_data, alarm_id_t *alarm_id) { - int error_code = 0;; + int error_code = 0; + int result; struct timeval current_time; struct tm duetime_tm; alarm_info_t alarm_info; @@ -818,6 +909,20 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, alarm_info.alarm_type = alarm_type; alarm_info.alarm_type |= ALARM_TYPE_RELATIVE; + if (__compare_api_version(&result, getuid()) < 0) + return ERR_ALARM_SYSTEM_FAIL; + + if (result < 0) { + if (alarm_info.alarm_type & ALARM_TYPE_INEXACT) { + alarm_info.alarm_type ^= ALARM_TYPE_INEXACT; + } + } else { //Since 2.4 + if (!__is_permitted(appid, alarm_info.alarm_type)) { + ALARM_MGR_EXCEPTION_PRINT("[%s] is not permitted \n", appid); + return ERR_ALARM_NOT_PERMITTED_APP; + } + } + gettimeofday(¤t_time, NULL); if (current_time.tv_usec > 500 * 1000) @@ -846,6 +951,10 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, alarm_info.start.min = duetime_tm.tm_min; alarm_info.start.sec = duetime_tm.tm_sec; + if ((alarm_info.alarm_type & ALARM_TYPE_INEXACT) && interval < MIN_INEXACT_INTERVAL) { + interval = MIN_INEXACT_INTERVAL; + } + if (interval <= 0) { alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE; alarm_info.mode.u_interval.interval = 0; @@ -857,7 +966,7 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, ALARM_MGR_EXCEPTION_PRINT("trigger_at_time(%d), start(%d-%d-%d, %02d:%02d:%02d), repeat(%d), interval(%d), type(%d)", trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year, alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec, - alarm_info.mode.repeat, alarm_info.mode.u_interval, alarm_info.alarm_type); + alarm_info.mode.repeat, alarm_info.mode.u_interval.interval, alarm_info.alarm_type); if (!_send_alarm_create_appsvc(alarm_context, &alarm_info, alarm_id, b, &error_code)) { return error_code; @@ -875,6 +984,7 @@ EXPORT_API int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time, char dst_service_name_mod[MAX_SERVICE_NAME_LEN] = { 0 }; int i = 0; int j = 0; + int result; int error_code; struct timeval current_time; struct tm duetime_tm; @@ -984,6 +1094,7 @@ EXPORT_API int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time, EXPORT_API int alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time, time_t interval, alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id) { + int result; int error_code = 0; struct timeval current_time; struct tm duetime_tm; @@ -1013,6 +1124,20 @@ EXPORT_API int alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time, alarm_info.alarm_type |= ALARM_TYPE_RELATIVE; alarm_info.alarm_type |= ALARM_TYPE_WITHCB; + if (__compare_api_version(&result, getuid()) < 0) + return ERR_ALARM_SYSTEM_FAIL; + + if (result < 0) { + if (alarm_info.alarm_type & ALARM_TYPE_INEXACT) { + alarm_info.alarm_type ^= ALARM_TYPE_INEXACT; + } + } else { //Since 2.4 + if (!__is_permitted(appid, alarm_info.alarm_type)) { + ALARM_MGR_EXCEPTION_PRINT("[%s] is not permitted \n", appid); + return ERR_ALARM_NOT_PERMITTED_APP; + } + } + gettimeofday(¤t_time, NULL); if (current_time.tv_usec > 500 * 1000) |