summaryrefslogtreecommitdiff
path: root/cmds
diff options
context:
space:
mode:
authorJohan Toras Halseth <johanth@google.com>2017-03-03 15:37:43 +0000
committerMichal Karpinski <mkarpinski@google.com>2017-03-24 23:51:48 +0000
commitb59a4b85ade3f1f408def6a0dd3dbb146225bdd7 (patch)
treec0591b4086fde7cfcab9654a3cffff12cc9a5a75 /cmds
parentb1c88ecf05bd8992dccd17e6f0b59db7e7ac819f (diff)
Add support for key-value packages to adb backup/restore.
For adding CTS tests for packages having key-value backup agents, we add support for key-value backups to the adb backup/restore command. Previously, packages not supporting fullbackup would just be skipped on this command. Now, by adding the -keyvalue flag to the adb backup command, packages supporting key-value will also be added to the resulting tarball. Similarly, if the tarball being supplied to adb restore contains data from key-value packages, it will be restored. This will later be utilized for writing CTS tests for such packages. Test: adb backup -includekeyvalue -all && adb restore backup.ab Change-Id: I7b4ccfb7072d01d29a888952145d7cce90a4f59e
Diffstat (limited to 'cmds')
-rw-r--r--cmds/bu/src/com/android/commands/bu/Backup.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/cmds/bu/src/com/android/commands/bu/Backup.java b/cmds/bu/src/com/android/commands/bu/Backup.java
index ffc0f875c79c..db17b28b8182 100644
--- a/cmds/bu/src/com/android/commands/bu/Backup.java
+++ b/cmds/bu/src/com/android/commands/bu/Backup.java
@@ -53,15 +53,15 @@ public final class Backup {
String arg = nextArg();
if (arg.equals("backup")) {
- doFullBackup(OsConstants.STDOUT_FILENO);
+ doBackup(OsConstants.STDOUT_FILENO);
} else if (arg.equals("restore")) {
- doFullRestore(OsConstants.STDIN_FILENO);
+ doRestore(OsConstants.STDIN_FILENO);
} else {
Log.e(TAG, "Invalid operation '" + arg + "'");
}
}
- private void doFullBackup(int socketFd) {
+ private void doBackup(int socketFd) {
ArrayList<String> packages = new ArrayList<String>();
boolean saveApks = false;
boolean saveObbs = false;
@@ -70,6 +70,7 @@ public final class Backup {
boolean doWidgets = false;
boolean allIncludesSystem = true;
boolean doCompress = true;
+ boolean doKeyValue = false;
String arg;
while ((arg = nextArg()) != null) {
@@ -100,6 +101,8 @@ public final class Backup {
doCompress = true;
} else if ("-nocompress".equals(arg)) {
doCompress = false;
+ } else if ("-includekeyvalue".equals(arg)) {
+ doKeyValue = true;
} else {
Log.w(TAG, "Unknown backup flag " + arg);
continue;
@@ -123,8 +126,8 @@ public final class Backup {
try {
fd = ParcelFileDescriptor.adoptFd(socketFd);
String[] packArray = new String[packages.size()];
- mBackupManager.fullBackup(fd, saveApks, saveObbs, saveShared, doWidgets,
- doEverything, allIncludesSystem, doCompress, packages.toArray(packArray));
+ mBackupManager.adbBackup(fd, saveApks, saveObbs, saveShared, doWidgets, doEverything,
+ allIncludesSystem, doCompress, doKeyValue, packages.toArray(packArray));
} catch (RemoteException e) {
Log.e(TAG, "Unable to invoke backup manager for backup");
} finally {
@@ -136,12 +139,12 @@ public final class Backup {
}
}
- private void doFullRestore(int socketFd) {
+ private void doRestore(int socketFd) {
// No arguments to restore
ParcelFileDescriptor fd = null;
try {
fd = ParcelFileDescriptor.adoptFd(socketFd);
- mBackupManager.fullRestore(fd);
+ mBackupManager.adbRestore(fd);
} catch (RemoteException e) {
Log.e(TAG, "Unable to invoke backup manager for restore");
} finally {