summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/os/Looper.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java
index 898c64272206..8204e3c82da2 100644
--- a/core/java/android/os/Looper.java
+++ b/core/java/android/os/Looper.java
@@ -112,6 +112,12 @@ public class Looper {
throw new RuntimeException("No Looper; Looper.prepare() wasn't called on this thread.");
}
MessageQueue queue = me.mQueue;
+
+ // Make sure the identity of this thread is that of the local process,
+ // and keep track of what that identity token actually is.
+ Binder.clearCallingIdentity();
+ final long ident = Binder.clearCallingIdentity();
+
while (true) {
Message msg = queue.next(); // might block
if (msg != null) {
@@ -127,6 +133,17 @@ public class Looper {
if (me.mLogging != null) me.mLogging.println(
"<<<<< Finished to " + msg.target + " "
+ msg.callback);
+
+ // Make sure that during the course of dispatching the
+ // identity of the thread wasn't corrupted.
+ final long newIdent = Binder.clearCallingIdentity();
+ if (ident != newIdent) {
+ Log.wtf("Looper", "Thread identity changed from 0x"
+ + Long.toHexString(ident) + " to 0x"
+ + Long.toHexString(newIdent) + " while dispatching to "
+ + msg.target + " " + msg.callback + " what=" + msg.what);
+ }
+
msg.recycle();
}
}