Optimize package installation 62/190662/1
authorKonrad Lipinski <k.lipinski2@partner.samsung.com>
Thu, 4 Oct 2018 11:56:14 +0000 (13:56 +0200)
committerKonrad Lipinski <k.lipinski2@partner.samsung.com>
Thu, 4 Oct 2018 12:01:40 +0000 (14:01 +0200)
appInstallSmackRules no longer updates the same rules repeatedly for
non-hybrid packages with multiple applications (every application has
the same process label so it's enough to do just one).

Change-Id: I4ba581a9ad5c297f87d591c647a6c56780d4978a

src/common/service_impl.cpp

index 31527946f04c933922445799fc840af4686bc406..e8cff86ee1d0d9725502c2241ac9318da13342d4 100644 (file)
@@ -668,12 +668,14 @@ int ServiceImpl::appInstallSmackRules(app_inst_req &req, InstallHelper &ih)
     SmackRules::Labels pkgLabels;
 
     try {
-        for (auto &app : req.apps) {
-            // Check if hybridity is changed if the package is installed
-            if (ih.isUserPkgInstalled and ih.isOldPkgHybrid != req.isHybrid) {
+        // Check if hybridity is changed if the package is installed
+        if (ih.isUserPkgInstalled && ih.isOldPkgHybrid != req.isHybrid) {
+            for (auto &app : req.apps) {
                 std::string oldAppLabel = SmackLabels::generateProcessLabel(
                     app.appName, req.pkgName, ih.isOldPkgHybrid);
                 SmackRules::uninstallApplicationRules(app.appName, oldAppLabel);
+                if (req.isHybrid) // was not hybrid - all labels were the same
+                    break;
             }
         }
 
@@ -690,6 +692,8 @@ int ServiceImpl::appInstallSmackRules(app_inst_req &req, InstallHelper &ih)
 
             SmackRules::installApplicationRules(app.appName, appLabel, req.pkgName,
                                                 authorId, pkgLabels);
+            if (!req.isHybrid) // is not hybrid - all labels are the same
+                break;
         }
 
         SmackRules::generateSharedRORules(pkgsProcessLabels, pkgsInfo);