Fix testKeepScreenOnCrossProcess latches
Fix issue where we were waiting on the wrong latch in SurfaceControlViewHostTests#testKeepScreenOnCrossProcess
Bug: 377740802
Flag: EXEMPT bugfix
Test: SurfaceControlViewHostTests
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:18848ee8c867d9048ad85ab99f394736eeec8399)
Merged-In: I859e7e2aca9bc9bdd34b7249510abcce639648df
Change-Id: I859e7e2aca9bc9bdd34b7249510abcce639648df
diff --git a/tests/surfacecontrol/src/android/view/surfacecontrol/cts/SurfaceControlViewHostTests.java b/tests/surfacecontrol/src/android/view/surfacecontrol/cts/SurfaceControlViewHostTests.java
index 9daebc1..4c1ead93 100644
--- a/tests/surfacecontrol/src/android/view/surfacecontrol/cts/SurfaceControlViewHostTests.java
+++ b/tests/surfacecontrol/src/android/view/surfacecontrol/cts/SurfaceControlViewHostTests.java
@@ -1687,22 +1687,22 @@
// Assert the KEEP_SCREEN_ON flag is not set on the main window yet.
assertNotEquals(FLAG_KEEP_SCREEN_ON, (windowState.getFlags() & FLAG_KEEP_SCREEN_ON));
- final CountDownLatch countDownLatch = new CountDownLatch(1);
+ final CountDownLatch keepScreenOnSetLatch = new CountDownLatch(1);
mActivityRule.runOnUiThread(() -> mSurfaceView.getViewTreeObserver().addOnDrawListener(
- countDownLatch::countDown));
+ keepScreenOnSetLatch::countDown));
mTestService.setKeepScreenOnFlag(true);
- countDownLatch.await(WAIT_TIMEOUT_S, TimeUnit.SECONDS);
+ keepScreenOnSetLatch.await(WAIT_TIMEOUT_S, TimeUnit.SECONDS);
mWmState.computeState();
windowState = mWmState.getWindowState(TEST_ACTIVITY);
// Assert the KEEP_SCREEN_ON flag is now set on the main window.
assertEquals(FLAG_KEEP_SCREEN_ON, (windowState.getFlags() & FLAG_KEEP_SCREEN_ON));
- final CountDownLatch countDownLatch2 = new CountDownLatch(1);
+ final CountDownLatch keepScreenOnUnsetLatch = new CountDownLatch(1);
mActivityRule.runOnUiThread(() -> mSurfaceView.getViewTreeObserver().addOnDrawListener(
- countDownLatch2::countDown));
+ keepScreenOnUnsetLatch::countDown));
mTestService.setKeepScreenOnFlag(false);
- countDownLatch.await(WAIT_TIMEOUT_S, TimeUnit.SECONDS);
+ keepScreenOnUnsetLatch.await(WAIT_TIMEOUT_S, TimeUnit.SECONDS);
mWmState.computeState();
windowState = mWmState.getWindowState(TEST_ACTIVITY);