Fix bug about background category management 78/52478/2 accepted/tizen/mobile/20151124.234111 accepted/tizen/tv/20151124.234122 accepted/tizen/wearable/20151124.234135 submit/tizen/20151124.090814
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 23 Nov 2015 13:38:12 +0000 (22:38 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 23 Nov 2015 14:04:18 +0000 (23:04 +0900)
- Add an exception at alarmmgr_add_alarm_appsvc_with_localtime()

Change-Id: I2e54ab00267f561c2510844cda7d3b679980317f
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/alarm-lib.c

index 2339b7c..787de2c 100644 (file)
@@ -284,7 +284,6 @@ static bool __is_permitted(const char *app_id, int alarm_type)
                        };
 
                        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);
@@ -679,6 +678,7 @@ EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, vo
        const char *operation = NULL;
        int error_code = 0;
        const char *appid = NULL;
+       int result;
 
        bundle *b=(bundle *)bundle_data;
 
@@ -718,6 +718,14 @@ EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, vo
                return ERR_ALARM_INVALID_PARAM;
        }
 
+       if (__compare_api_version(&result, getuid()) < 0)
+               return ERR_ALARM_SYSTEM_FAIL;
+
+       if (result >= 0 && !__is_permitted(appid, alarm_info->alarm_type)) {
+               ALARM_MGR_EXCEPTION_PRINT("[%s] is not permitted \n", appid);
+               return ERR_ALARM_NOT_PERMITTED_APP;
+       }
+
        if (alarm_info == NULL || alarm_id == NULL) {
                ALARM_MGR_EXCEPTION_PRINT("Invalid parameter\n");
                return ERR_ALARM_INVALID_PARAM;