diff options
| author | Dianne Hackborn <hackbod@google.com> | 2017-10-20 16:16:32 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2017-10-25 12:19:26 -0700 |
| commit | c81983a0c3d7bfe8384dbf48909f4bcf300e36d2 (patch) | |
| tree | 5bde759ec82eb5330ff0f79f277d137b9efb1be4 /core/java/android | |
| parent | 8664028d4f0642ea44c83f87a85184813ac39972 (diff) | |
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
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/ActivityManager.java | 40 | ||||
| -rw-r--r-- | core/java/android/os/BatteryStats.java | 2 | ||||
| -rw-r--r-- | core/java/android/os/Binder.java | 4 | ||||
| -rw-r--r-- | core/java/android/os/ShellCommand.java | 37 |
4 files changed, 67 insertions, 16 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index a1eda6597f60..280b1e80b01d 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -46,6 +46,7 @@ import android.graphics.Matrix; import android.graphics.Point; import android.graphics.Rect; import android.os.BatteryStats; +import android.os.Binder; import android.os.Build; import android.os.Build.VERSION_CODES; import android.os.Bundle; @@ -3885,21 +3886,36 @@ public class ActivityManager { IBinder service = ServiceManager.checkService(name); if (service == null) { pw.println(" (Service not found)"); + pw.flush(); return; } - TransferPipe tp = null; - try { - pw.flush(); - tp = new TransferPipe(); - tp.setBufferPrefix(" "); - service.dumpAsync(tp.getWriteFd().getFileDescriptor(), args); - tp.go(fd, 10000); - } catch (Throwable e) { - if (tp != null) { - tp.kill(); + pw.flush(); + if (service instanceof Binder) { + // If this is a local object, it doesn't make sense to do an async dump with it, + // just directly dump. + try { + service.dump(fd, args); + } catch (Throwable e) { + pw.println("Failure dumping service:"); + e.printStackTrace(pw); + pw.flush(); + } + } else { + // Otherwise, it is remote, do the dump asynchronously to avoid blocking. + TransferPipe tp = null; + try { + pw.flush(); + tp = new TransferPipe(); + tp.setBufferPrefix(" "); + service.dumpAsync(tp.getWriteFd().getFileDescriptor(), args); + tp.go(fd, 10000); + } catch (Throwable e) { + if (tp != null) { + tp.kill(); + } + pw.println("Failure dumping service:"); + e.printStackTrace(pw); } - pw.println("Failure dumping service:"); - e.printStackTrace(pw); } } diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java index a8a65e37f914..a8bd940326d6 100644 --- a/core/java/android/os/BatteryStats.java +++ b/core/java/android/os/BatteryStats.java @@ -6453,7 +6453,7 @@ public abstract class BatteryStats implements Parcelable { pw.println(); } } - if (!filtering || (flags&(DUMP_CHARGED_ONLY|DUMP_DAILY_ONLY)) != 0) { + if (!filtering || (flags & DUMP_DAILY_ONLY) != 0) { pw.println("Daily stats:"); pw.print(" Current start time: "); pw.println(DateFormat.format("yyyy-MM-dd-HH-mm-ss", diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index e9e695bbdf10..66e1651997b4 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -167,7 +167,7 @@ public class Binder implements IBinder { try { if (binder instanceof BinderProxy) { ((BinderProxy) binder).mWarnOnBlocking = false; - } else if (binder != null + } else if (binder != null && binder.getInterfaceDescriptor() != null && binder.queryLocalInterface(binder.getInterfaceDescriptor()) == null) { Log.w(TAG, "Unable to allow blocking on interface " + binder); } @@ -414,7 +414,7 @@ public class Binder implements IBinder { * descriptor. */ public @Nullable IInterface queryLocalInterface(@NonNull String descriptor) { - if (mDescriptor.equals(descriptor)) { + if (mDescriptor != null && mDescriptor.equals(descriptor)) { return mOwner; } return null; 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() { |
