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

Commit d0d99a47 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Fix crash when Looper used after quit."

parents a6eba00d 60583906
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.