From 73140e4df9ed9cfcc897f5cd0742b81d9839d4d4 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Thu, 31 Jul 2014 13:51:21 -0700 Subject: [PATCH] Attempt install-time restore even for no-agent apps Packages without their own backup agents can still have restorable data to be delivered. Correct the logic for attempting a restore at install time so that it no longer requires an app-defined backup agent. Bug 16688665 Change-Id: I7dcf7ef85ad6b5b393a2c97ce62f1b2eec9d3520 --- .../java/com/android/server/pm/PackageManagerService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index ee6d4d02e75ec..2b55bf55ad57d 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -8257,11 +8257,11 @@ public class PackageManagerService extends IPackageManager.Stub { // 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 a backupAgent defined. + // package has not opted out of backup participation. final boolean update = res.removedInfo.removedPackage != null; - boolean doRestore = (!update - && res.pkg != null - && res.pkg.applicationInfo.backupAgentName != null); + final int flags = (res.pkg == null) ? 0 : res.pkg.applicationInfo.flags; + boolean doRestore = !update + && ((flags & ApplicationInfo.FLAG_ALLOW_BACKUP) != 0); // Set up the post-install work request bookkeeping. This will be used // and cleaned up by the post-install event handling regardless of whether