File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 1717package android .os ;
1818
1919import android .util .Config ;
20+ import android .util .Log ;
2021import android .util .Printer ;
2122
2223/**
@@ -106,6 +107,12 @@ public synchronized static final Looper getMainLooper() {
106107 public static final void loop () {
107108 Looper me = myLooper ();
108109 MessageQueue queue = me .mQueue ;
110+
111+ // Make sure the identity of this thread is that of the local process,
112+ // and keep track of what that identity token actually is.
113+ Binder .clearCallingIdentity ();
114+ final long ident = Binder .clearCallingIdentity ();
115+
109116 while (true ) {
110117 Message msg = queue .next (); // might block
111118 //if (!me.mRun) {
@@ -124,6 +131,17 @@ public static final void loop() {
124131 if (me .mLogging != null ) me .mLogging .println (
125132 "<<<<< Finished to " + msg .target + " "
126133 + msg .callback );
134+
135+ // Make sure that during the course of dispatching the
136+ // identity of the thread wasn't corrupted.
137+ final long newIdent = Binder .clearCallingIdentity ();
138+ if (ident != newIdent ) {
139+ Log .wtf ("Looper" , "Thread identity changed from 0x"
140+ + Long .toHexString (ident ) + " to 0x"
141+ + Long .toHexString (newIdent ) + " while dispatching to "
142+ + msg .target + " " + msg .callback + " what=" + msg .what );
143+ }
144+
127145 msg .recycle ();
128146 }
129147 }
You can’t perform that action at this time.
0 commit comments