Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03e16bbc authored by William Escande's avatar William Escande
Browse files

Wait for the looper to be acquired

TestLooperManager post a message on the looper, client using post a
message in front of queue can race with it and in some case, it end up
running before the looper is acquired.

Bug: 430185336
Test: atest ModulesUtilsTests
Test: atest StateMachineTest
Test: atest testStateMachineQuitNowAfterStart --rerun-until-failure 100
Flag: TEST_ONLY
Change-Id: I13783e93aa5103bd0b24cee8a9e9d84815aa8472
parent 8058a411
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -63,6 +63,7 @@ public class TestLooperManager {
        if (!mLooperIsMyLooper) {
        if (!mLooperIsMyLooper) {
            // Post a message that will keep the looper blocked as long as we are dispatching.
            // Post a message that will keep the looper blocked as long as we are dispatching.
            new Handler(looper).post(new LooperHolder());
            new Handler(looper).post(new LooperHolder());
            waitForLooperHolder();
        } else {
        } else {
            mLooperHolderLatch.countDown();
            mLooperHolderLatch.countDown();
        }
        }