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

Commit ea5a8302 authored by Eugene Susla's avatar Eugene Susla Committed by Automerger Merge Worker
Browse files

Merge "Prevent HandlerThread from losing interrupted flag" am: f86d2fb4 am: 9cdea35a

Change-Id: Ia3712877cb377a0cc5b0dcd1f6716b5bc439b78f
parents e417eb13 9cdea35a
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -79,15 +79,27 @@ public class HandlerThread extends Thread {
            return null;
        }

        boolean wasInterrupted = false;

        // If the thread has been started, wait until the looper has been created.
        synchronized (this) {
            while (isAlive() && mLooper == null) {
                try {
                    wait();
                } catch (InterruptedException e) {
                    wasInterrupted = true;
                }
            }
        }

        /*
         * We may need to restore the thread's interrupted flag, because it may
         * have been cleared above since we eat InterruptedExceptions
         */
        if (wasInterrupted) {
            Thread.currentThread().interrupt();
        }

        return mLooper;
    }