diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-02-09 14:19:23 -0800 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2011-02-09 14:19:23 -0800 |
commit | e5dea7537cadbf79614730f96d9e92cc2b12ad5a (patch) | |
tree | d9c6e3f8aac245371ba1515a04a0e1428c8c97cf /core/java/android/os/Looper.java | |
parent | be4b39d2fde3d34539752b99238ceebd97ccf580 (diff) | |
download | frameworks_base-e5dea7537cadbf79614730f96d9e92cc2b12ad5a.zip frameworks_base-e5dea7537cadbf79614730f96d9e92cc2b12ad5a.tar.gz frameworks_base-e5dea7537cadbf79614730f96d9e92cc2b12ad5a.tar.bz2 |
Attempt to reduce problems from issue #3183612
java.lang.SecurityException: Neither user 1209 nor current...
...process has android.permission.WAKE_LOCK.
It looks like, somehow, the calling uid/pid of the SyncHandler
thread is getting corrupted. This change has Looper check for
these values changing from their original defaults and, if there
is a problem, resetting them and logging a WTF. Hopefully this
will avoid crashing the process, while also giving us more
helpful error reports about what is going on.
Change-Id: Iff06d575951fb8c06e2a3c31141f2907a715eb81
Diffstat (limited to 'core/java/android/os/Looper.java')
-rw-r--r-- | core/java/android/os/Looper.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java index d360140..994c242 100644 --- a/core/java/android/os/Looper.java +++ b/core/java/android/os/Looper.java @@ -17,6 +17,7 @@ package android.os; import android.util.Config; +import android.util.Log; import android.util.Printer; /** @@ -106,6 +107,12 @@ public class Looper { public static final void loop() { Looper me = myLooper(); 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 (!me.mRun) { @@ -124,6 +131,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(); } } |