diff options
| author | Jeff Brown <jeffbrown@google.com> | 2013-04-11 19:21:32 -0700 |
|---|---|---|
| committer | Jeff Brown <jeffbrown@google.com> | 2013-04-11 20:40:04 -0700 |
| commit | 024136f57e5f8b4c11a4fe0fd83061eb6d372d26 (patch) | |
| tree | 5a44d54558df69fd7241caea051f13746f701174 /core/java/android/os/MessageQueue.java | |
| parent | a2f289a40db821c1961e16c2f4acc5785dbb3394 (diff) | |
Ensure looper quits after all other messages are handled.
Bug: 8596303
Change-Id: Ie8bfbbe810f5ade2afd870c8e675ce1353a80e5d
Diffstat (limited to 'core/java/android/os/MessageQueue.java')
| -rw-r--r-- | core/java/android/os/MessageQueue.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/java/android/os/MessageQueue.java b/core/java/android/os/MessageQueue.java index e0d40c96aafa..c058bfce28e6 100644 --- a/core/java/android/os/MessageQueue.java +++ b/core/java/android/os/MessageQueue.java @@ -132,11 +132,6 @@ public final class MessageQueue { nativePollOnce(mPtr, nextPollTimeoutMillis); synchronized (this) { - if (mQuiting) { - dispose(); - return null; - } - // Try to retrieve the next message. Return if found. final long now = SystemClock.uptimeMillis(); Message prevMsg = null; @@ -170,6 +165,12 @@ public final class MessageQueue { nextPollTimeoutMillis = -1; } + // Process the quit message now that all pending messages have been handled. + if (mQuiting) { + dispose(); + return null; + } + // If first time idle, then get the number of idlers to run. // Idle handles only run if the queue is empty or if the first message // in the queue (possibly a barrier) is due to be handled in the future. |
