From 0c098c47a5ec999bcdfe1659e1efa5bf927ce2ed Mon Sep 17 00:00:00 2001 From: Ruslan Tkhakokhov Date: Wed, 5 Aug 2020 17:15:12 +0100 Subject: [PATCH] Don't check allowBackup in PackageManager During restore at install, PackageManager checks the allowBackup flag for the package to determine whether or not to request a restore by calling BackupManager::restoreAtInstall(). The above check isn't needed because B&R code verifies package elibility before running backup / restore anyway. Furthermore, this check breaks device-to-device migrations where we ignore allowBackup flag: PackageManager doesn't know if the data is restored to the device from cloud or directrly transferred from another device. Remove the check altogether since it's not needed as described above. Bug: 160407842 Test: 1. atest PackageManagerServiceTest 2. Manual: Run restore at install for packages with allowBackup=true/false and verify the flag is respected. Change-Id: I6ca61869129f5fabd40c01cd314cbf0f15e1f7fc --- .../java/com/android/server/pm/PackageManagerService.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 344f9cfdbc96d..ffd23788223ec 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -14541,13 +14541,11 @@ public class PackageManagerService extends IPackageManager.Stub Log.v(TAG, "restoreAndPostInstall userId=" + userId + " package=" + res.pkg); } - // A restore should be performed at this point if (a) the install - // succeeded, (b) the operation is not an update, and (c) the new - // package has not opted out of backup participation. + // A restore should be requested at this point if (a) the install + // succeeded, (b) the operation is not an update. final boolean update = res.removedInfo != null && res.removedInfo.removedPackage != null; - boolean allowBackup = res.pkg != null && res.pkg.isAllowBackup(); - boolean doRestore = !update && allowBackup; + boolean doRestore = !update; // Set up the post-install work request bookkeeping. This will be used // and cleaned up by the post-install event handling regardless of whether