summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorLouis Chang <louischang@google.com>2019-12-05 16:22:57 +0800
committerLouis Chang <louischang@google.com>2020-03-13 14:51:29 +0800
commit59e85c25a65b9d89855de9366fef499003a65e29 (patch)
tree24551c9fe212762ead8e0c681830cfd3ed99f000 /core/java
parentf489f1994fb5fa9594e86dedc172b6501cd72982 (diff)
Add warning message when entering loop twice
The messages in queue could be executed before current message completed. Bug: 140599188 Test: calling Looper.loop() twice Change-Id: I1a4628606ed974e7a6a76b2832044959a9261bb9
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/Looper.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java
index b478dbe2555d..a7e326378228 100644
--- a/core/java/android/os/Looper.java
+++ b/core/java/android/os/Looper.java
@@ -77,6 +77,7 @@ public final class Looper {
@UnsupportedAppUsage
final MessageQueue mQueue;
final Thread mThread;
+ private boolean mInLoop;
@UnsupportedAppUsage
private Printer mLogging;
@@ -155,6 +156,12 @@ public final class Looper {
if (me == null) {
throw new RuntimeException("No Looper; Looper.prepare() wasn't called on this thread.");
}
+ if (me.mInLoop) {
+ Slog.w(TAG, "Loop again would have the queued messages be executed"
+ + " before this one completed.");
+ }
+
+ me.mInLoop = true;
final MessageQueue queue = me.mQueue;
// Make sure the identity of this thread is that of the local process,