Merge "Merge 6f2fb570 from honeycomb. do not merge." into gingerbread
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index 7a53874..8db2553 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -603,6 +603,15 @@
static void android_os_Binder_restoreCallingIdentity(JNIEnv* env, jobject clazz, jlong token)
{
+ // XXX temporary sanity check to debug crashes.
+ int uid = (int)(token>>32);
+ if (uid > 0 && uid < 999) {
+ // In Android currently there are no uids in this range.
+ char buf[128];
+ sprintf(buf, "Restoring bad calling ident: 0x%Lx", token);
+ jniThrowException(env, "java/lang/IllegalStateException", buf);
+ return;
+ }
IPCThreadState::self()->restoreCallingIdentity(token);
}