diff options
| author | Rahul Chaturvedi <rkc@google.com> | 2015-06-17 23:54:08 -0400 |
|---|---|---|
| committer | Rahul Chaturvedi <rkc@google.com> | 2015-06-22 16:28:24 -0400 |
| commit | 52613f9084f40100021fbf21173bda329a2d5cc3 (patch) | |
| tree | 76f285a5ac4375f74053fa9251e88f0c5c6ec535 /core/java/android/app/ApplicationThreadNative.java | |
| parent | 6186e89c382f2d02037ffd1fe579f065e1578521 (diff) | |
Add binder transaction tracking.
Add the ability to am to be able to track binder transact calls. This
will help us diagnose excessive IPC calls.
This CL adds the trace-ip command to am. The usage is,
To start binder transaction tracking,
am trace-ipc start
To stop tracking and dump the data to a file,
am trace-ipc stop --dump-file <FILE>
Bug: 21398706
Change-Id: Ic0c9b3be757dd0662a2750a0d8447e2a5ef1fa90
Diffstat (limited to 'core/java/android/app/ApplicationThreadNative.java')
| -rw-r--r-- | core/java/android/app/ApplicationThreadNative.java | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java index 146138007138..372fdaa743f2 100644 --- a/core/java/android/app/ApplicationThreadNative.java +++ b/core/java/android/app/ApplicationThreadNative.java @@ -288,6 +288,7 @@ public abstract class ApplicationThreadNative extends Binder IUiAutomationConnection uiAutomationConnection = IUiAutomationConnection.Stub.asInterface(binder); int testMode = data.readInt(); + boolean enableBinderTracking = data.readInt() != 0; boolean openGlTrace = data.readInt() != 0; boolean restrictedBackupMode = (data.readInt() != 0); boolean persistent = (data.readInt() != 0); @@ -296,8 +297,8 @@ public abstract class ApplicationThreadNative extends Binder HashMap<String, IBinder> services = data.readHashMap(null); Bundle coreSettings = data.readBundle(); bindApplication(packageName, info, providers, testName, profilerInfo, testArgs, - testWatcher, uiAutomationConnection, testMode, openGlTrace, - restrictedBackupMode, persistent, config, compatInfo, services, coreSettings); + testWatcher, uiAutomationConnection, testMode, enableBinderTracking, + openGlTrace, restrictedBackupMode, persistent, config, compatInfo, services, coreSettings); return true; } @@ -690,6 +691,28 @@ public abstract class ApplicationThreadNative extends Binder reply.writeNoException(); return true; } + + case START_BINDER_TRACKING_TRANSACTION: + { + data.enforceInterface(IApplicationThread.descriptor); + startBinderTracking(); + return true; + } + + case STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION: + { + data.enforceInterface(IApplicationThread.descriptor); + ParcelFileDescriptor fd = data.readFileDescriptor(); + if (fd != null) { + stopBinderTrackingAndDump(fd.getFileDescriptor()); + try { + fd.close(); + } catch (IOException e) { + } + } + return true; + } + } return super.onTransact(code, data, reply, flags); @@ -980,12 +1003,12 @@ class ApplicationThreadProxy implements IApplicationThread { } public final void bindApplication(String packageName, ApplicationInfo info, - List<ProviderInfo> providers, ComponentName testName, ProfilerInfo profilerInfo, - Bundle testArgs, IInstrumentationWatcher testWatcher, - IUiAutomationConnection uiAutomationConnection, int debugMode, - boolean openGlTrace, boolean restrictedBackupMode, boolean persistent, - Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services, - Bundle coreSettings) throws RemoteException { + List<ProviderInfo> providers, ComponentName testName, ProfilerInfo profilerInfo, + Bundle testArgs, IInstrumentationWatcher testWatcher, + IUiAutomationConnection uiAutomationConnection, int debugMode, + boolean enableBinderTracking, boolean openGlTrace, boolean restrictedBackupMode, boolean persistent, + Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services, + Bundle coreSettings) throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); data.writeString(packageName); @@ -1007,6 +1030,7 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeStrongInterface(testWatcher); data.writeStrongInterface(uiAutomationConnection); data.writeInt(debugMode); + data.writeInt(enableBinderTracking ? 1 : 0); data.writeInt(openGlTrace ? 1 : 0); data.writeInt(restrictedBackupMode ? 1 : 0); data.writeInt(persistent ? 1 : 0); @@ -1396,4 +1420,23 @@ class ApplicationThreadProxy implements IApplicationThread { mRemote.transact(NOTIFY_CLEARTEXT_NETWORK_TRANSACTION, data, null, IBinder.FLAG_ONEWAY); data.recycle(); } + + @Override + public void startBinderTracking() throws RemoteException { + Parcel data = Parcel.obtain(); + data.writeInterfaceToken(IApplicationThread.descriptor); + mRemote.transact(START_BINDER_TRACKING_TRANSACTION, data, null, + IBinder.FLAG_ONEWAY); + data.recycle(); + } + + @Override + public void stopBinderTrackingAndDump(FileDescriptor fd) throws RemoteException { + Parcel data = Parcel.obtain(); + data.writeInterfaceToken(IApplicationThread.descriptor); + data.writeFileDescriptor(fd); + mRemote.transact(STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION, data, null, + IBinder.FLAG_ONEWAY); + data.recycle(); + } } |
