summaryrefslogtreecommitdiffstats
path: root/cmds/bmgr
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2009-06-26 21:07:13 -0700
committerChristopher Tate <ctate@google.com>2009-06-26 21:14:41 -0700
commit9171749700853305f3e6abbcdbd9e02f3a71d459 (patch)
tree7aaa1fada6783a588d1662165730e8d3f4ef591c /cmds/bmgr
parent4cb1276e143e175590c69ceefa58eb721aa52846 (diff)
downloadframeworks_base-9171749700853305f3e6abbcdbd9e02f3a71d459.zip
frameworks_base-9171749700853305f3e6abbcdbd9e02f3a71d459.tar.gz
frameworks_base-9171749700853305f3e6abbcdbd9e02f3a71d459.tar.bz2
Use system properties to track the current transport
This change retools the transport selection mechanism a fair bit. Transports are now specified by name rather than by numeric ID, and the name of the currently selected transport is stored in a persistent system property under the name "persist.service.bkup.trans". The name -> IBackupTransport translation is now handled by maintaining a map from the names to the live IBackupTransport objects that correspond. The Google transport service observer now registers and unregisters the transport as the service goes up and down. The bmgr command has been expanded to include real transport interrogation and selection by name, and some documentation has been written for it.
Diffstat (limited to 'cmds/bmgr')
-rw-r--r--cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java65
1 files changed, 54 insertions, 11 deletions
diff --git a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
index c299bff..c3ddd20 100644
--- a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
+++ b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
@@ -124,11 +124,14 @@ public final class Bmgr {
private void doTransport() {
try {
- int which = Integer.parseInt(nextArg());
- int old = mBmgr.selectBackupTransport(which);
- System.out.println("Selected transport " + which + " (formerly " + old + ")");
- } catch (NumberFormatException e) {
- showUsage();
+ String which = nextArg();
+ String old = mBmgr.selectBackupTransport(which);
+ if (old == null) {
+ System.out.println("Unknown transport '" + which
+ + "' specified; no changes made.");
+ } else {
+ System.out.println("Selected transport " + which + " (formerly " + old + ")");
+ }
} catch (RemoteException e) {
System.err.println(e.toString());
System.err.println(BMGR_NOT_RUNNING_ERR);
@@ -144,7 +147,7 @@ public final class Bmgr {
// The rest of the 'list' options work with a restore session on the current transport
try {
- int curTransport = mBmgr.getCurrentTransport();
+ String curTransport = mBmgr.getCurrentTransport();
mRestore = mBmgr.beginRestoreSession(curTransport);
if (mRestore == null) {
System.err.println(BMGR_NOT_RUNNING_ERR);
@@ -153,6 +156,8 @@ public final class Bmgr {
if ("sets".equals(arg)) {
doListRestoreSets();
+ } else if ("transports".equals(arg)) {
+ doListTransports();
}
mRestore.endRestoreSession();
@@ -163,6 +168,22 @@ public final class Bmgr {
}
private void doListTransports() {
+ try {
+ String current = mBmgr.getCurrentTransport();
+ String[] transports = mBmgr.listAllTransports();
+ if (transports == null || transports.length == 0) {
+ System.out.println("No transports available.");
+ return;
+ }
+
+ for (String t : transports) {
+ String pad = (t.equals(current)) ? " * " : " ";
+ System.out.println(pad + t);
+ }
+ } catch (RemoteException e) {
+ System.err.println(e.toString());
+ System.err.println(BMGR_NOT_RUNNING_ERR);
+ }
}
private void doListRestoreSets() {
@@ -217,7 +238,7 @@ public final class Bmgr {
try {
boolean didRestore = false;
- int curTransport = mBmgr.getCurrentTransport();
+ String curTransport = mBmgr.getCurrentTransport();
mRestore = mBmgr.beginRestoreSession(curTransport);
if (mRestore == null) {
System.err.println(BMGR_NOT_RUNNING_ERR);
@@ -269,11 +290,33 @@ public final class Bmgr {
private static void showUsage() {
System.err.println("usage: bmgr [backup|restore|list|transport|run]");
- System.err.println(" bmgr backup [-f] package");
+ System.err.println(" bmgr backup PACKAGE");
+ System.err.println(" bmgr list transports");
System.err.println(" bmgr list sets");
- System.err.println(" #bmgr list transports");
- System.err.println(" #bmgr transport which#");
- System.err.println(" bmgr restore token#");
+ System.err.println(" bmgr transport WHICH");
+ System.err.println(" bmgr restore TOKEN");
System.err.println(" bmgr run");
+ System.err.println("");
+ System.err.println("The 'backup' command schedules a backup pass for the named package.");
+ System.err.println("Note that the backup pass will effectively be a no-op if the package");
+ System.err.println("does not actually have changed data to store.");
+ System.err.println("");
+ System.err.println("The 'list transports' command reports the names of the backup transports");
+ System.err.println("currently available on the device. These names can be passed as arguments");
+ System.err.println("to the 'transport' command. The currently selected transport is indicated");
+ System.err.println("with a '*' character.");
+ System.err.println("");
+ System.err.println("The 'list sets' command reports the token and name of each restore set");
+ System.err.println("available to the device via the current transport.");
+ System.err.println("");
+ System.err.println("The 'transport' command designates the named transport as the currently");
+ System.err.println("active one. This setting is persistent across reboots.");
+ System.err.println("");
+ System.err.println("The 'restore' command initiates a restore operation, using the restore set");
+ System.err.println("from the current transport whose token matches the argument.");
+ 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.");
}
}