Wait for insets update before taking screenshot

When system is busy the insets may not be updated quickly enough, which
caused the resulting screenshot having a stable inset of status bar
height at the top and the number of matching pixels is wrong.

This is fairly easy to reproduce to run
ASurfaceControlTest#testSurfaceTransaction_scaleToZero with 10
iterations when system is booting.

Bug: 224167838
Test: atest
CtsViewTestCases:android.view.cts.ASurfaceControlTest#testSurfaceTransaction_scaleToZero
--iteration 10 when showing boot animation
Test: atest ASurfaceControlTest
Test: atest SurfaceControlTest

Change-Id: I7ad64c2bae677a46240d4774fa1b77d1f5c239fb
1 file changed