Add WM API to start and stop transcation trace

Provides a way to eaily collect transaction traces from Flicker like is done for layer traces

Bug: 230462538
Test: collect transaction traces in Flicker using this API
Change-Id: Ie27cf60cac012af8fd23835cd0c6f0250dc72e42
This commit is contained in:
Pablo Gamito
2022-06-13 23:08:46 +00:00
parent a158b44d48
commit a8ed28baa9
2 changed files with 40 additions and 0 deletions

View File

@@ -748,6 +748,11 @@ interface IWindowManager
*/
void setLayerTracingFlags(int flags);
/**
* Toggle active SurfaceFlinger transaction tracing.
*/
void setActiveTransactionTracing(boolean active);
/**
* Forwards a scroll capture request to the appropriate window, if available.
*

View File

@@ -8764,6 +8764,41 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
/**
* Toggle active transaction tracing.
* Setting to true increases the buffer size for active debugging.
* Setting to false resets the buffer size and dumps the trace to file.
*/
public void setActiveTransactionTracing(boolean active) {
if (!checkCallingPermission(
android.Manifest.permission.DUMP, "setActiveTransactionTracing()")) {
throw new SecurityException("Requires DUMP permission");
}
final long token = Binder.clearCallingIdentity();
try {
Parcel data = null;
try {
IBinder sf = ServiceManager.getService("SurfaceFlinger");
if (sf != null) {
data = Parcel.obtain();
data.writeInterfaceToken("android.ui.ISurfaceComposer");
data.writeInt(active ? 1 : 0);
sf.transact(/* TRANSACTION_TRACE_CONTROL_CODE */ 1041, data,
null, 0 /* flags */);
}
} catch (RemoteException e) {
Slog.e(TAG, "Failed to set transaction tracing");
} finally {
if (data != null) {
data.recycle();
}
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
@Override
public boolean mirrorDisplay(int displayId, SurfaceControl outSurfaceControl) {
if (!checkCallingPermission(READ_FRAME_BUFFER, "mirrorDisplay()")) {