From b59a4b85ade3f1f408def6a0dd3dbb146225bdd7 Mon Sep 17 00:00:00 2001 From: Johan Toras Halseth Date: Fri, 3 Mar 2017 15:37:43 +0000 Subject: 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 --- cmds/bu/src/com/android/commands/bu/Backup.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'cmds/bu/src') 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 packages = new ArrayList(); 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 { -- cgit v1.2.3-59-g8ed1b