OSDN Git Service

Remove adb shell bmgr restore <package>
authorBernardo Rufino <brufino@google.com>
Wed, 30 May 2018 09:09:25 +0000 (10:09 +0100)
committerBernardo Rufino <brufino@google.com>
Wed, 6 Jun 2018 08:25:26 +0000 (08:25 +0000)
Also put comment on RestoreSession saying that it doesn't kill the app
in the end.

Bug: 29255593
Test: Builds
      adb shell bmgr help, verify usage
      adb shell bmgr restore android, verify no-op

Change-Id: I89304149ea6c03a80937e321cf3a46fd173308e2

cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
core/java/android/app/backup/RestoreSession.java

index 84a04e5..448ce15 100644 (file)
@@ -704,34 +704,11 @@ public final class Bmgr {
                 return;
             }
         }
-
-        System.out.println("done");
     }
 
     private void doRestorePackage(String pkg) {
-        try {
-            mRestore = mBmgr.beginRestoreSession(pkg, null);
-            if (mRestore == null) {
-                System.err.println(BMGR_NOT_RUNNING_ERR);
-                return;
-            }
-
-            RestoreObserver observer = new RestoreObserver();
-            // TODO implement monitor here
-            int err = mRestore.restorePackage(pkg, observer, null );
-            if (err == 0) {
-                // Off and running -- wait for the restore to complete
-                observer.waitForCompletion();
-            } else {
-                System.err.println("Unable to restore package " + pkg);
-            }
-
-            // And finally shut down the session
-            mRestore.endRestoreSession();
-        } catch (RemoteException e) {
-            System.err.println(e.toString());
-            System.err.println(BMGR_NOT_RUNNING_ERR);
-        }
+        System.err.println("The syntax 'restore <package>' is no longer supported, please use ");
+        System.err.println("'restore <token> <package>'.");
     }
 
     private void doRestoreAll(long token, HashSet<String> filter) {
@@ -784,6 +761,8 @@ public final class Bmgr {
 
             // once the restore has finished, close down the session and we're done
             mRestore.endRestoreSession();
+
+            System.out.println("done");
         } catch (RemoteException e) {
             System.err.println(e.toString());
             System.err.println(BMGR_NOT_RUNNING_ERR);
@@ -823,7 +802,6 @@ public final class Bmgr {
         System.err.println("       bmgr transport WHICH|-c WHICH_COMPONENT");
         System.err.println("       bmgr restore TOKEN");
         System.err.println("       bmgr restore TOKEN PACKAGE...");
-        System.err.println("       bmgr restore PACKAGE");
         System.err.println("       bmgr run");
         System.err.println("       bmgr wipe TRANSPORT PACKAGE");
         System.err.println("       bmgr fullbackup PACKAGE...");
@@ -867,10 +845,6 @@ public final class Bmgr {
         System.err.println("'restore' operation supplying only a token, but applies a filter to the");
         System.err.println("set of applications to be restored.");
         System.err.println("");
-        System.err.println("The 'restore' command when given just a package name intiates a restore of");
-        System.err.println("just that one package according to the restore set selection algorithm");
-        System.err.println("used by the RestoreSession.restorePackage() method.");
-        System.err.println("");
         System.err.println("The 'run' command causes any scheduled backup operation to be initiated");
         System.err.println("immediately, without the usual waiting period for batching together");
         System.err.println("data changes.");
index 69d964d..2e0f940 100644 (file)
 package android.app.backup;
 
 import android.annotation.SystemApi;
-import android.app.backup.RestoreObserver;
-import android.app.backup.RestoreSet;
-import android.app.backup.IRestoreObserver;
-import android.app.backup.IRestoreSession;
 import android.content.Context;
 import android.os.Bundle;
 import android.os.Handler;
@@ -199,6 +195,10 @@ public class RestoreSession {
      * backup dataset has no matching data.  If no backup data exists for this package
      * in either source, a nonzero value will be returned.
      *
+     * <p class="caution">Note: Unlike other restore operations, this method doesn't terminate the
+     * application after the restore. The application continues running to receive the
+     * {@link RestoreObserver} callbacks on the {@code observer} argument.
+     *
      * @return Zero on success; nonzero on error.  The observer will only receive
      *   progress callbacks if this method returned zero.
      * @param packageName The name of the package whose data to restore.  If this is