summaryrefslogtreecommitdiff
path: root/core/java/android/os/ShellCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/os/ShellCommand.java')
-rw-r--r--core/java/android/os/ShellCommand.java37
1 files changed, 36 insertions, 1 deletions
diff --git a/core/java/android/os/ShellCommand.java b/core/java/android/os/ShellCommand.java
index e4a12e84e466..6223235e628f 100644
--- a/core/java/android/os/ShellCommand.java
+++ b/core/java/android/os/ShellCommand.java
@@ -17,6 +17,7 @@
package android.os;
import android.util.Slog;
+
import com.android.internal.util.FastPrintWriter;
import java.io.BufferedInputStream;
@@ -118,13 +119,33 @@ public abstract class ShellCommand {
mErrPrintWriter.flush();
}
if (DEBUG) Slog.d(TAG, "Sending command result on " + mTarget);
- mResultReceiver.send(res, null);
+ if (mResultReceiver != null) {
+ mResultReceiver.send(res, null);
+ }
}
if (DEBUG) Slog.d(TAG, "Finished command " + mCmd + " on " + mTarget);
return res;
}
/**
+ * Adopt the ResultReceiver that was given to this shell command from it, taking
+ * it over. Primarily used to dispatch to another shell command. Once called,
+ * this shell command will no longer return its own result when done.
+ */
+ public ResultReceiver adoptResultReceiver() {
+ ResultReceiver rr = mResultReceiver;
+ mResultReceiver = null;
+ return rr;
+ }
+
+ /**
+ * Return the raw FileDescriptor for the output stream.
+ */
+ public FileDescriptor getOutFileDescriptor() {
+ return mOut;
+ }
+
+ /**
* Return direct raw access (not buffered) to the command's output data stream.
*/
public OutputStream getRawOutputStream() {
@@ -145,6 +166,13 @@ public abstract class ShellCommand {
}
/**
+ * Return the raw FileDescriptor for the error stream.
+ */
+ public FileDescriptor getErrFileDescriptor() {
+ return mErr;
+ }
+
+ /**
* Return direct raw access (not buffered) to the command's error output data stream.
*/
public OutputStream getRawErrorStream() {
@@ -168,6 +196,13 @@ public abstract class ShellCommand {
}
/**
+ * Return the raw FileDescriptor for the input stream.
+ */
+ public FileDescriptor getInFileDescriptor() {
+ return mIn;
+ }
+
+ /**
* Return direct raw access (not buffered) to the command's input data stream.
*/
public InputStream getRawInputStream() {