From 02758a9a80ab82154aa172ef1a0138f4c1d6e9bd Mon Sep 17 00:00:00 2001 From: Leonard Mosescu Date: Thu, 6 Oct 2016 17:32:05 -0700 Subject: Adding "attach-agent" to ActivityManagerShellCommand This new command is used to attach runtime agents to a running application: attach-agent Attach an agent to the specified , which may be either a process name or a PID. Test: m test-art-host, manual testing: . invalid syntax, missing arguments . invalid syntax, extra arguments . invalid numeric PID . invalid process name . valid process, not debuggable . valid process, missing agent . valid process, valid agent Bug: 31682382 Change-Id: I61cc8bf20addb1702acc8e7aae65b2f9ed7c5ca0 Merged-In: Ife88dbf23991dde7945d9208e54cd014bb7ecdc6 --- core/java/android/app/ApplicationThreadNative.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'core/java/android/app/ApplicationThreadNative.java') diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java index 05d9d7e412f0..ad7f577f1e1d 100644 --- a/core/java/android/app/ApplicationThreadNative.java +++ b/core/java/android/app/ApplicationThreadNative.java @@ -502,6 +502,14 @@ public abstract class ApplicationThreadNative extends Binder return true; } + case ATTACH_AGENT_TRANSACTION: + { + data.enforceInterface(IApplicationThread.descriptor); + String agent = data.readString(); + attachAgent(agent); + return true; + } + case DUMP_ACTIVITY_TRANSACTION: { data.enforceInterface(IApplicationThread.descriptor); ParcelFileDescriptor fd = data.readFileDescriptor(); @@ -1305,6 +1313,14 @@ class ApplicationThreadProxy implements IApplicationThread { data.recycle(); } + public void attachAgent(String agent) throws RemoteException { + Parcel data = Parcel.obtain(); + data.writeInterfaceToken(IApplicationThread.descriptor); + data.writeString(agent); + mRemote.transact(ATTACH_AGENT_TRANSACTION, data, null, IBinder.FLAG_ONEWAY); + data.recycle(); + } + public void setCoreSettings(Bundle coreSettings) throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); -- cgit v1.2.3