Add single-package restore to Bmgr feature set
Also sanity-check the package name on the Backup Manager side, failing gracefully
if the given package is not a backup/restore participant.
Bug: 2293977
Change-Id: I3575046ffcaa3cf45c1c602824baeadd64082f70
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 27faf3dc5..34e9cb9 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -2427,6 +2427,12 @@
throw new SecurityException("No permission to restore other packages");
}
+ // If the package has no backup agent, we obviously cannot proceed
+ if (app.applicationInfo.backupAgentName == null) {
+ Log.w(TAG, "Asked to restore package " + packageName + " with no agent");
+ return -1;
+ }
+
// So far so good; we're allowed to try to restore this package. Now
// check whether there is data for it in the current dataset, falling back
// to the ancestral dataset if not.