SF: Add trace section flags and InputWindowInfo to sf trace
Trace section flags allow users to specify sections of the trace to be collected. By default, all
sections are collected. Options are:
TRACE_CRITICAL - adds data critical for debugging
TRACE_INPUT - adds InputWindowInfo
TRACE_EXTRA - adds non essential data (metadata, derived data)
TRACE_ALL - includes all sections (default)
To set the trace flags from shell:
$ adb shell su root service call SurfaceFlinger 1033 i32 <trace_flags>
Bug: 123992966
Test: record and view sf trace
Change-Id: Icfd4d2bde08a4b3d04e37eca72ff505c7ea518f7
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 55fcb01..f6251b8 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4644,13 +4644,14 @@
result.append("\n");
}
-LayersProto SurfaceFlinger::dumpProtoInfo(LayerVector::StateSet stateSet) const {
+LayersProto SurfaceFlinger::dumpProtoInfo(LayerVector::StateSet stateSet,
+ uint32_t traceFlags) const {
LayersProto layersProto;
const bool useDrawing = stateSet == LayerVector::StateSet::Drawing;
const State& state = useDrawing ? mDrawingState : mCurrentState;
state.traverseInZOrder([&](Layer* layer) {
LayerProto* layerProto = layersProto.add_layers();
- layer->writeToProto(layerProto, stateSet);
+ layer->writeToProto(layerProto, stateSet, traceFlags);
});
return layersProto;
@@ -4993,9 +4994,9 @@
code == IBinder::SYSPROPS_TRANSACTION) {
return OK;
}
- // Numbers from 1000 to 1032 are currently use for backdoors. The code
+ // Numbers from 1000 to 1033 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 <= 1032) {
+ if (code >= 1000 && code <= 1033) {
ALOGV("Accessing SurfaceFlinger through backdoor code: %u", code);
return OK;
}
@@ -5303,6 +5304,14 @@
mDebugEnableProtectedContent = n;
return NO_ERROR;
}
+ // Set trace flags
+ case 1033: {
+ n = data.readUint32();
+ ALOGD("Updating trace flags to 0x%x", n);
+ mTracing.setTraceFlags(n);
+ reply->writeInt32(NO_ERROR);
+ return NO_ERROR;
+ }
}
}
return err;