Deflaking GraphicsStatsValidationTest

Background:
- onFrameMetricsAvailable is invoked at a regular cadence for each frame rendered. This calls onDrawFinished. onDrawFinished increments mFrameIndex with an assumption that it was invoked for the previously scheduled Frame.
- scheduleDraw is the first step of many involved in drawing a single frame. This schedules a callback for "setupFrame" which then sets up the frame for drawing.

Current Behavior:
(With some non-zero probability) For first frame being drawn, if the periodic invocation of onFrameMetricsAvailable for the frame rendered previously (the one before the first frame of test) is called sometime after scheduleDraw() call but before setupFrame() is invoked, we observe that this can lead to this frame being skipped. This is because onFrameMetricsAvailable calls onDrawFinished which then increments mFrameIndex which in turn calls scheduleDraw and mostly likely overrides the setupFrame callback for the earlier frame.

Solution:
If onFrameMetricsAvailable is called between scheduleDraw and setupFrame, skip incrementing mFrameIndex in onDrawFinished. Further, tightened the logic of updating mDroppedReportsCount and mRenderedFrames to ensure that right set of frames were being counted.
Bug: 161775219
Change-Id: I3744f3d9fdcf7757a7b55d6e57ca1d66c55e3220
Test: atest com.android.server.cts.GraphicsStatsValidationTest
(cherry picked from commit 05216b002a57967f0e3010487fc0759732ef7a23)
1 file changed