Support UI Thread Separate (UTS) App Model (#464)
[platform/core/dotnet/launcher.git] / NativeLauncher / tool / privilege_common.cc
index 737a971..66f38eb 100644 (file)
@@ -64,8 +64,22 @@ void checkInternetPrivilegeAndDisableIPv6(const char* pkgId, const std::string&
 
 static int checkAppPrivilegeListCb(pkgmgrinfo_appinfo_h handle, void *user_data)
 {
+       int ret = 0;
+       char* appType = NULL;
+
+       ret = pkgmgrinfo_appinfo_get_apptype(handle, &appType);
+       if (ret != PMINFO_R_OK) {
+               _SERR("Failed to get apptype");
+               return 0;
+       }
+
+       // skip if appType is NULL or appType does not contains "dotnet",
+       if (appType == NULL || (appType != NULL && strstr(appType, "dotnet") == NULL)) {
+               return 0;
+       }
+
        char *pkgId = NULL;
-       int ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgId);
+       ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgId);
        if (ret != PMINFO_R_OK || pkgId == NULL) {
                _SERR("Failed to get package id");
                return 0;
@@ -83,40 +97,10 @@ static int checkAppPrivilegeListCb(pkgmgrinfo_appinfo_h handle, void *user_data)
        return 0;
 }
 
-static void checkAppPrivilegeByAppType(const char* type)
-{
-       pkgmgrinfo_appinfo_filter_h filter;
-
-       int ret = pkgmgrinfo_appinfo_filter_create(&filter);
-       if (ret != PMINFO_R_OK) {
-               _SERR("Failed to create appinfo filter");
-               return;
-       }
-
-       ret = pkgmgrinfo_appinfo_filter_add_string(filter, PMINFO_APPINFO_PROP_APP_TYPE, type);
-       if (ret != PMINFO_R_OK) {
-               pkgmgrinfo_appinfo_filter_destroy(filter);
-               _SERR("Failed to add appinfo filter (%s)", type);
-               return;
-       }
-
-       ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(filter, checkAppPrivilegeListCb, NULL);
-       if (ret != PMINFO_R_OK) {
-               _SERR("Failed to pkgmgrinfo_appinfo_filter_foreach_appinfo");
-               pkgmgrinfo_appinfo_filter_destroy(filter);
-               return;
-       }
-
-       pkgmgrinfo_appinfo_filter_destroy(filter);
-
-       return;
-}
-
 void checkAllAppPrivilege()
 {
-       std::vector<const char*> appTypeList = {"dotnet", "dotnet-nui", "dotnet-inhouse"};
-
-       for (auto& type : appTypeList) {
-               checkAppPrivilegeByAppType(type);
+       int ret = pkgmgrinfo_appinfo_get_installed_list(checkAppPrivilegeListCb, NULL);
+       if (ret != PMINFO_R_OK) {
+               _SERR("Failed to get installed list");
        }
 }