From c81983a0c3d7bfe8384dbf48909f4bcf300e36d2 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Fri, 20 Oct 2017 16:16:32 -0700 Subject: Start removing remaining pm code to package manager Everything is now moved out of the pm command except for the various install commands. I am going to hold of on those since they require doing some resolution with the current implementations in the package manager to make sure they match and behave identically to the implementations currently in the pm command. But other than that, everything in pm is now just redirecting over to "cmd package". Also fix up some of the dumpsys output of a few other sevices when asking to print the data for a particular package, so the "pm dump" command gives a little more sane result. Test: manual Change-Id: I139e06e560203b72243d7eea9543c2240db0f8f8 --- core/java/android/os/ShellCommand.java | 37 +++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'core/java/android/os/ShellCommand.java') 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,12 +119,32 @@ 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. */ @@ -144,6 +165,13 @@ public abstract class ShellCommand { return mOutPrintWriter; } + /** + * 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. */ @@ -167,6 +195,13 @@ public abstract class ShellCommand { return mErrPrintWriter; } + /** + * 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. */ -- cgit v1.2.3