SF: fix frame timeline timestamp
Fix a bug with setting the timestamp on a packet due to operator
precedence where unary plus takes precedence on the ternary operation
Fixes: 185346474
Test: Collect perfetto traces and observe timeline slices
Change-Id: If1a8f13e7a77dabf0c510181e5aa27aaf7cf0f56
diff --git a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
index ec59888..66beff2 100644
--- a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
+++ b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
@@ -669,12 +669,12 @@
// frame in the trace.
nsecs_t endTime =
(mPresentState == PresentState::Dropped ? mDropTime : mActuals.endTime);
- packet->set_timestamp(static_cast<uint64_t>(endTime - kPredictionExpiredStartTimeDelta +
- monoBootOffset));
+ const auto timestamp = endTime - kPredictionExpiredStartTimeDelta;
+ packet->set_timestamp(static_cast<uint64_t>(timestamp + monoBootOffset));
} else {
- packet->set_timestamp(static_cast<uint64_t>(monoBootOffset + mActuals.startTime == 0
- ? mPredictions.startTime
- : mActuals.startTime));
+ const auto timestamp =
+ mActuals.startTime == 0 ? mPredictions.startTime : mActuals.startTime;
+ packet->set_timestamp(static_cast<uint64_t>(timestamp + monoBootOffset));
}
auto* event = packet->set_frame_timeline_event();