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) {
// 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);
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...");
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.");
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;
* 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