OSDN Git Service

A couple of restore fixes:
authorChristopher Tate <ctate@google.com>
Fri, 25 Jul 2014 01:58:23 +0000 (18:58 -0700)
committerChristopher Tate <ctate@google.com>
Fri, 25 Jul 2014 01:58:23 +0000 (18:58 -0700)
* Fix crasher after transport-level failure attempting to ask for
  the name of the next package to be restored

* Current-dataset single-package restore path no longer requires
  that the package have its own backup agent.

Bug 16548983

Change-Id: Id37f2f0e6075d53c414d9a997bf738bbf0cfff8b

services/backup/java/com/android/server/backup/BackupManagerService.java

index 56b8c92..595e91e 100644 (file)
@@ -6645,8 +6645,8 @@ if (MORE_DEBUG) Slog.v(TAG, "   + got " + nRead + "; now wanting " + (size - soF
             UnifiedRestoreState nextState = UnifiedRestoreState.FINAL;
             try {
                 mRestoreDescription = mTransport.nextRestorePackage();
-                final int type = mRestoreDescription.getDataType();
-                final String pkgName = mRestoreDescription.getPackageName();
+                final String pkgName = (mRestoreDescription != null)
+                        ? mRestoreDescription.getPackageName() : null;
                 if (pkgName == null) {
                     Slog.e(TAG, "Failure getting next package name");
                     EventLog.writeEvent(EventLogTags.RESTORE_TRANSPORT_FAILURE);
@@ -6717,6 +6717,7 @@ if (MORE_DEBUG) Slog.v(TAG, "   + got " + nRead + "; now wanting " + (size - soF
 
                 // Reset per-package preconditions and fire the appropriate next state
                 mWidgetData = null;
+                final int type = mRestoreDescription.getDataType();
                 if (type == RestoreDescription.TYPE_KEY_VALUE) {
                     nextState = UnifiedRestoreState.RESTORE_KEYVALUE;
                 } else if (type == RestoreDescription.TYPE_FULL_STREAM) {
@@ -8470,12 +8471,6 @@ if (MORE_DEBUG) Slog.v(TAG, "   + got " + nRead + "; now wanting " + (size - soF
                 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) {
-                Slog.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.