summaryrefslogtreecommitdiff
path: root/cmds/bmgr
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2009-06-29 14:56:28 -0700
committerChristopher Tate <ctate@google.com>2009-06-29 15:33:27 -0700
commit6ef58a1509b9d3348a33ca5686917796c2759aa5 (patch)
tree0cdfef7bf8e2085dc2888c4222aba7481683ee2f /cmds/bmgr
parent3a608f829b54a7653c9cc2b3bdbda0641cca37bb (diff)
downloadbase-6ef58a1509b9d3348a33ca5686917796c2759aa5.tar.gz
Implement persistent enable/disable of the backup manager
Backup & restore is still enabled by default, but with the expectation that it will be enabled during the course of the Setup Wizard or some other privileged entity that has notified the user about the ramifications. While disabled, data-changed notices will still be collected, but no backup pass will be scheduled. When the backup manager is later enabled, any pending data-changed notices will then be processed and the apps invoked for backup.
Diffstat (limited to 'cmds/bmgr')
-rw-r--r--cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
index c3ddd2014e8c..c90b8622b833 100644
--- a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
+++ b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
@@ -62,6 +62,16 @@ public final class Bmgr {
String op = args[0];
mNextArg = 1;
+ if ("enabled".equals(op)) {
+ doEnabled();
+ return;
+ }
+
+ if ("enable".equals(op)) {
+ doEnable();
+ return;
+ }
+
if ("run".equals(op)) {
doRun();
return;
@@ -91,6 +101,41 @@ public final class Bmgr {
showUsage();
}
+ private String enableToString(boolean enabled) {
+ return enabled ? "enabled" : "disabled";
+ }
+
+ private void doEnabled() {
+ try {
+ boolean isEnabled = mBmgr.isBackupEnabled();
+ System.out.println("Backup Manager currently "
+ + enableToString(isEnabled));
+ } catch (RemoteException e) {
+ System.err.println(e.toString());
+ System.err.println(BMGR_NOT_RUNNING_ERR);
+ }
+ }
+
+ private void doEnable() {
+ String arg = nextArg();
+ if (arg == null) {
+ showUsage();
+ return;
+ }
+
+ try {
+ boolean enable = Boolean.parseBoolean(arg);
+ mBmgr.setBackupEnabled(enable);
+ System.out.println("Backup Manager now " + enableToString(enable));
+ } catch (NumberFormatException e) {
+ showUsage();
+ return;
+ } catch (RemoteException e) {
+ System.err.println(e.toString());
+ System.err.println(BMGR_NOT_RUNNING_ERR);
+ }
+ }
+
private void doRun() {
try {
mBmgr.backupNow();
@@ -291,6 +336,8 @@ public final class Bmgr {
private static void showUsage() {
System.err.println("usage: bmgr [backup|restore|list|transport|run]");
System.err.println(" bmgr backup PACKAGE");
+ System.err.println(" bmgr enable BOOL");
+ System.err.println(" bmgr enabled");
System.err.println(" bmgr list transports");
System.err.println(" bmgr list sets");
System.err.println(" bmgr transport WHICH");
@@ -301,6 +348,14 @@ public final class Bmgr {
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 'enable' command enables or disables the entire backup mechanism.");
+ System.err.println("If the argument is 'true' it will be enabled, otherwise it will be");
+ System.err.println("disabled. When disabled, neither backup or restore operations will");
+ System.err.println("be performed.");
+ System.err.println("");
+ System.err.println("The 'enabled' command reports the current enabled/disabled state of");
+ System.err.println("the backup mechanism.");
+ 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");