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

Commit c1c8b4dd authored by Shai Barack's avatar Shai Barack
Browse files

Improve TestLooperManager check on execute()

Looper.isCurrentThread() does exactly what we need.

Checking the same condition via a side effect on
Looper.myLooper() is harder to read.
It's also less reliable, because I caught some (terrible)
tests manipulating ThreadLocals.

Bug: 379472827
Change-Id: Id67eddcb57329cb42b5b4ba6b09595ec720f6cdb
Flag: android.os.message_queue_testability
Test: android.os.cts.TestLooperManagerTest
parent b1843033
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public class TestLooperManager {
     */
    public void execute(Message message) {
        checkReleased();
        if (Looper.myLooper() == mLooper) {
        if (mLooper.isCurrentThread()) {
            // This is being called from the thread it should be executed on, we can just dispatch.
            message.target.dispatchMessage(message);
        } else {