summaryrefslogtreecommitdiffstats
path: root/cmds/bu
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2011-06-10 18:33:16 -0700
committerChristopher Tate <ctate@google.com>2011-06-20 19:26:31 -0700
commite26e96bcc19b1cdac690d21b3986f09a502739e6 (patch)
treecd6054763d0a2043088027f9cac129ecef27beb0 /cmds/bu
parent3106a9b7f5c5c6a62d3fa5772d8c2bb41d22c6eb (diff)
downloadframeworks_base-e26e96bcc19b1cdac690d21b3986f09a502739e6.zip
frameworks_base-e26e96bcc19b1cdac690d21b3986f09a502739e6.tar.gz
frameworks_base-e26e96bcc19b1cdac690d21b3986f09a502739e6.tar.bz2
Pass the data fd number as a command line argument to 'bu'
This way we don't have to muck with stdin/stdout just to get known fds for data handling. Change-Id: If87d19f4867c883a32d4e9afb91b915511b9df19
Diffstat (limited to 'cmds/bu')
-rw-r--r--cmds/bu/src/com/android/commands/bu/Backup.java20
1 files changed, 8 insertions, 12 deletions
diff --git a/cmds/bu/src/com/android/commands/bu/Backup.java b/cmds/bu/src/com/android/commands/bu/Backup.java
index e81f799..4c4bf98 100644
--- a/cmds/bu/src/com/android/commands/bu/Backup.java
+++ b/cmds/bu/src/com/android/commands/bu/Backup.java
@@ -22,8 +22,6 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
-import java.io.FileDescriptor;
-import java.io.IOException;
import java.util.ArrayList;
public final class Backup {
@@ -51,17 +49,19 @@ public final class Backup {
return;
}
+ int socketFd = Integer.parseInt(nextArg());
+
String arg = nextArg();
if (arg.equals("backup")) {
- doFullBackup();
+ doFullBackup(socketFd);
} else if (arg.equals("restore")) {
- doFullRestore();
+ doFullRestore(socketFd);
} else {
Log.e(TAG, "Invalid operation '" + arg + "'");
}
}
- private void doFullBackup() {
+ private void doFullBackup(int socketFd) {
ArrayList<String> packages = new ArrayList<String>();
boolean saveApks = false;
boolean saveShared = false;
@@ -100,24 +100,20 @@ public final class Backup {
}
try {
- ParcelFileDescriptor fd = ParcelFileDescriptor.dup(FileDescriptor.out);
+ ParcelFileDescriptor fd = ParcelFileDescriptor.adoptFd(socketFd);
String[] packArray = new String[packages.size()];
mBackupManager.fullBackup(fd, saveApks, saveShared, doEverything,
packages.toArray(packArray));
- } catch (IOException e) {
- Log.e(TAG, "Can't dup out");
} catch (RemoteException e) {
Log.e(TAG, "Unable to invoke backup manager for backup");
}
}
- private void doFullRestore() {
+ private void doFullRestore(int socketFd) {
// No arguments to restore
try {
- ParcelFileDescriptor fd = ParcelFileDescriptor.dup(FileDescriptor.in);
+ ParcelFileDescriptor fd = ParcelFileDescriptor.adoptFd(socketFd);
mBackupManager.fullRestore(fd);
- } catch (IOException e) {
- Log.e(TAG, "Can't dup System.in");
} catch (RemoteException e) {
Log.e(TAG, "Unable to invoke backup manager for restore");
}