+enum class PackageDisableFilterStatus {
+ None,
+ True,
+ False
+};
+
+PackageDisableFilterStatus GetPackageDisableFilterStatus(
+ const pkgmgrinfo_filter_x* filter) {
+ GSList* tmp_list = nullptr;
+ pkgmgrinfo_node_x* tmp_node = nullptr;
+ int property = -1;
+
+ property = _pminfo_appinfo_convert_to_prop_bool(
+ PMINFO_APPINFO_PROP_APP_DISABLE);
+ for (tmp_list = filter->list; tmp_list != nullptr;
+ tmp_list = g_slist_next(tmp_list)) {
+ tmp_node = reinterpret_cast<pkgmgrinfo_node_x*>(tmp_list->data);
+ if (property != tmp_node->prop)
+ continue;
+
+ return strcasecmp(tmp_node->value, "true") == 0 ?
+ PackageDisableFilterStatus::True : PackageDisableFilterStatus::False;
+ }
+
+ return PackageDisableFilterStatus::None;
+}
+
+bool CheckPkgDisableFilter(PackageDisableFilterStatus expected,
+ const char* package_disable, application_x* app_info) {
+ if (!package_disable)
+ return true;
+
+ PackageDisableFilterStatus result = strcasecmp(package_disable, "true") == 0 ?
+ PackageDisableFilterStatus::True : PackageDisableFilterStatus::False;
+
+ if (expected == result)
+ return true;
+
+ if (result == PackageDisableFilterStatus::True)
+ LOGW("The package [%s] to which the application [%s] belongs is disabled",
+ app_info->package, app_info->appid);
+
+ return false;
+}
+
+bool CheckAppDisableFilter(const pkgmgrinfo_filter_x* filter,
+ const application_x* app_info) {
+ GSList* tmp_list = nullptr;
+ pkgmgrinfo_node_x* tmp_node = nullptr;
+ int property = -1;
+
+ property = _pminfo_appinfo_convert_to_prop_bool(
+ PMINFO_APPINFO_PROP_APP_DISABLE);
+ for (tmp_list = filter->list; tmp_list != nullptr;
+ tmp_list = g_slist_next(tmp_list)) {
+ tmp_node = reinterpret_cast<pkgmgrinfo_node_x*>(tmp_list->data);
+ if (property != tmp_node->prop)
+ continue;
+
+ if (strcasecmp(tmp_node->value, app_info->is_disabled) == 0)
+ return true;
+
+ if (strcasecmp(app_info->is_disabled, "true") == 0)
+ LOGW("The application [%s] is disabled", app_info->appid);
+
+ return false;
+ }
+ return true;
+}
+