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

Commit 60583906 authored by Jeff Brown's avatar Jeff Brown
Browse files

Fix crash when Looper used after quit.

Calling Looper.loop() after quit() isn't supported but it shouldn't
crash either.

Bug: 8808624
Change-Id: I73ea54444ed908c2e8964645f4a8cd08b842baac
parent 43afbe58
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -125,6 +125,14 @@ public final class MessageQueue {
    }

    Message next() {
        // Return here if the message loop has already quit and been disposed.
        // This can happen if the application tries to restart a looper after quit
        // which is not supported.
        final int ptr = mPtr;
        if (ptr == 0) {
            return null;
        }

        int pendingIdleHandlerCount = -1; // -1 only during first iteration
        int nextPollTimeoutMillis = 0;
        for (;;) {
@@ -132,9 +140,7 @@ public final class MessageQueue {
                Binder.flushPendingCommands();
            }

            // We can assume mPtr != 0 because the loop is obviously still running.
            // The looper will not call this method after the loop quits.
            nativePollOnce(mPtr, nextPollTimeoutMillis);
            nativePollOnce(ptr, nextPollTimeoutMillis);

            synchronized (this) {
                // Try to retrieve the next message.  Return if found.