+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_appinfo(app_id, &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) {
+ 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;
+}
+