Attempts fixing test flakiness

There is a race condition between the test and the launched
activity, which could result in NullPointerException and
break the test.

Bug: 289865322
Test: atest ActivityThreadTest over 500 times on cf
Change-Id: I1e13c9c1dd796296263de0984675311866ba61f3
This commit is contained in:
Louis Chang
2023-07-12 11:03:53 +08:00
parent c9f03886f7
commit ebcb9c1e25

View File

@@ -884,12 +884,13 @@ public class ActivityThreadTest {
mConfig.setTo(config);
++mNumOfConfigChanges;
if (mConfigLatch != null) {
final CountDownLatch configLatch = mConfigLatch;
if (configLatch != null) {
if (mTestLatch != null) {
mTestLatch.countDown();
}
try {
mConfigLatch.await(TIMEOUT_SEC, TimeUnit.SECONDS);
configLatch.await(TIMEOUT_SEC, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}