Use pkgmgrinfo_appinfo_foreach_appcontrol_v3() instead 63/318763/2
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 8 Oct 2024 04:38:47 +0000 (13:38 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 8 Oct 2024 05:59:27 +0000 (14:59 +0900)
To improve the performance of amd initialization, amd should use
pkgmgrinfo_appinfo_foreach_appcontrol_v3() function.

Requires:
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/pkgmgr-info/+/318744/

Change-Id: I51fd10437a4ce2b6d1dc87ced4b173ada399434f
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/app_info/app_info.cc
src/lib/app_info/app_info.hh

index 2bb60b191327843c7518aeb842fa1262861095e5..fef850748d10d2208fbd9c7e89c0d8892f77d16d 100644 (file)
@@ -100,10 +100,10 @@ AppInfo::Builder& AppInfo::Builder::SetSubmodeMainId(
 }
 
 std::vector<std::string> AppInfo::Builder::GetAppControlPrivileges(
-    const char* operation) {
+    pkgmgrinfo_appinfo_app_control_h handle) {
   std::vector<std::string> privileges;
-  int ret = pkgmgrinfo_appinfo_foreach_appcontrol_privileges(
-      app_id_.c_str(), operation,
+  int ret = pkgmgrinfo_appinfo_appcontrol_foreach_privilege(
+      handle,
       [](const char* privilege_name, void* user_data) {
         if (privilege_name == nullptr || privilege_name[0] == '\n') return 0;
 
@@ -114,19 +114,28 @@ std::vector<std::string> AppInfo::Builder::GetAppControlPrivileges(
       },
       static_cast<void*>(&privileges));
   if (ret != PMINFO_R_OK)
-    _E("pkgmgrinfo_appinfo_foreach_appcontrol_privileges() is failed");
+    _E("pkgmgrinfo_appinfo_appcontrol_foreach_privilege() is failed");
 
   return privileges;
 }
 
 AppInfo::Builder& AppInfo::Builder::SetAppControl(pkgmgrinfo_appinfo_h handle) {
-  int ret = pkgmgrinfo_appinfo_foreach_appcontrol_v2(
+  int ret = pkgmgrinfo_appinfo_foreach_appcontrol_v3(
       handle,
-      [](const char* operation, const char* uri, const char* mime,
-         const char* id, void* user_data) -> int {
+      [](pkgmgrinfo_appinfo_app_control_h appcontrol, void* user_data) -> int {
         auto* builder = static_cast<AppInfo::Builder*>(user_data);
         std::vector<std::string> privileges =
-            builder->GetAppControlPrivileges(operation);
+            builder->GetAppControlPrivileges(appcontrol);
+
+        const char* operation = nullptr;
+        pkgmgrinfo_appinfo_appcontrol_get_operation(appcontrol, &operation);
+        const char* uri = nullptr;
+        pkgmgrinfo_appinfo_appcontrol_get_uri(appcontrol, &uri);
+        const char* mime = nullptr;
+        pkgmgrinfo_appinfo_appcontrol_get_mime(appcontrol, &mime);
+        const char* id = nullptr;
+        pkgmgrinfo_appinfo_appcontrol_get_id(appcontrol, &id);
+
         auto mime_type = Util::Split(mime ? mime : "NULL/", "/");
         auto* app_control = new (std::nothrow) AppControlInfo(
             operation, uri ? uri : "NULL", mime ? mime : "NULL", mime_type[0],
index a7c251668bf1168da6f22f6879198b94be598768..ad76ba45b328907852aaf0834ada4725f61cde35 100644 (file)
@@ -71,7 +71,8 @@ class AppInfo : public std::enable_shared_from_this<AppInfo> {
     operator AppInfo*();
 
    private:
-    std::vector<std::string> GetAppControlPrivileges(const char* operation);
+    std::vector<std::string> GetAppControlPrivileges(
+        pkgmgrinfo_appinfo_app_control_h handle);
 
    private:
     std::string app_id_;