Add bmgr command to enable/disable auto restore

Bug: 139658304
Test: 1. atest AutoRestoreHostSideTest
      2. "bmgr autorestore true", verify auto restore enabled via
         dumpsys
         "bmgr autorestore false", verify auto restore disabled via
	 dumpsys

Change-Id: I1174d2db172d06e90fd79385b9f0c64f4e8f4201
This commit is contained in:
Ruslan Tkhakokhov
2019-08-27 08:50:10 +01:00
parent 35fa063e89
commit 6baf03e1ad

View File

@@ -125,6 +125,11 @@ public class Bmgr {
return;
}
if ("autorestore".equals(op)) {
doAutoRestore(userId);
return;
}
if ("enabled".equals(op)) {
doEnabled(userId);
return;
@@ -213,6 +218,26 @@ public class Bmgr {
return true;
}
private void doAutoRestore(int userId) {
String arg = nextArg();
if (arg == null) {
showUsage();
return;
}
try {
boolean enable = Boolean.parseBoolean(arg);
mBmgr.setAutoRestore(enable);
System.out.println(
"Auto restore is now "
+ (enable ? "enabled" : "disabled")
+ " for user "
+ userId);
} catch (RemoteException e) {
handleRemoteException(e);
}
}
private String activatedToString(boolean activated) {
return activated ? "activated" : "deactivated";
}
@@ -918,6 +943,7 @@ public class Bmgr {
System.err.println(" bmgr init TRANSPORT...");
System.err.println(" bmgr activate BOOL");
System.err.println(" bmgr activated");
System.err.println(" bmgr autorestore BOOL");
System.err.println("");
System.err.println("The '--user' option specifies the user on which the operation is run.");
System.err.println("It must be the first argument before the operation.");
@@ -992,6 +1018,9 @@ public class Bmgr {
System.err.println("");
System.err.println("The 'activated' command reports the current activated/deactivated");
System.err.println("state of the backup mechanism.");
System.err.println("");
System.err.println("The 'autorestore' command enables or disables automatic restore when");
System.err.println("a new package is installed.");
}
private static class BackupMonitor extends IBackupManagerMonitor.Stub {