Add API for writing SF traces to file
Currently the API supports only starting or stopping the trace, and writes to file when the trace is stopped. However, in some scenarios we would like to maintain the trace active, and just dump the trace.
Bug: 205138504
Test: all API, check if files are created under /data/misc/wmtrace
Change-Id: I0102d5f9a96afc159372c5b8ad2261b72f13462f
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 0a8f9ec..88317e9 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5605,9 +5605,9 @@
code == IBinder::SYSPROPS_TRANSACTION) {
return OK;
}
- // Numbers from 1000 to 1041 are currently used for backdoors. The code
+ // Numbers from 1000 to 1042 are currently used for backdoors. The code
// in onTransact verifies that the user is root, and has access to use SF.
- if (code >= 1000 && code <= 1041) {
+ if (code >= 1000 && code <= 1042) {
ALOGV("Accessing SurfaceFlinger through backdoor code: %u", code);
return OK;
}
@@ -6062,6 +6062,16 @@
reply->writeInt32(NO_ERROR);
return NO_ERROR;
}
+ case 1042: { // Write layers trace or transaction trace to file
+ if (mTransactionTracing) {
+ mTransactionTracing->writeToFile();
+ }
+ if (mLayerTracingEnabled) {
+ mLayerTracing.writeToFile();
+ }
+ reply->writeInt32(NO_ERROR);
+ return NO_ERROR;
+ }
}
}
return err;