Pass surface control id to callback to accurately identify surface metrics belongs to
Avoid getting the wrong frame info when duplicate frame numbers are found in the ring buffer. Will ensure there isn't a mismatch in the metrics data reported.
Test: Existing tests
Bug: 197515602
Change-Id: Iff9ba01f575f94e5a9872ee48c0dd1e5067880c3
diff --git a/native/android/surface_control.cpp b/native/android/surface_control.cpp
index 1f246e5..31350ee 100644
--- a/native/android/surface_control.cpp
+++ b/native/android/surface_control.cpp
@@ -146,28 +146,25 @@
uint64_t frameNumber;
};
-void ASurfaceControl_registerSurfaceStatsListener(ASurfaceControl* control, void* context,
- ASurfaceControl_SurfaceStatsListener func) {
- SurfaceStatsCallback callback = [func](void* callback_context,
- nsecs_t,
- const sp<Fence>&,
- const SurfaceStats& surfaceStats) {
-
+void ASurfaceControl_registerSurfaceStatsListener(ASurfaceControl* control, int32_t id,
+ void* context,
+ ASurfaceControl_SurfaceStatsListener func) {
+ SurfaceStatsCallback callback = [func, control, id](void* callback_context, nsecs_t,
+ const sp<Fence>&,
+ const SurfaceStats& surfaceStats) {
ASurfaceControlStats aSurfaceControlStats;
- ASurfaceControl* aSurfaceControl =
- reinterpret_cast<ASurfaceControl*>(surfaceStats.surfaceControl.get());
aSurfaceControlStats.acquireTime = surfaceStats.acquireTime;
aSurfaceControlStats.previousReleaseFence = surfaceStats.previousReleaseFence;
aSurfaceControlStats.frameNumber = surfaceStats.eventStats.frameNumber;
- (*func)(callback_context, aSurfaceControl, &aSurfaceControlStats);
+ (*func)(callback_context, control, id, &aSurfaceControlStats);
};
+
TransactionCompletedListener::getInstance()->addSurfaceStatsListener(context,
reinterpret_cast<void*>(func), ASurfaceControl_to_SurfaceControl(control), callback);
}
-
void ASurfaceControl_unregisterSurfaceStatsListener(void* context,
ASurfaceControl_SurfaceStatsListener func) {
TransactionCompletedListener::getInstance()->removeSurfaceStatsListener(context,