OSDN Git Service

Fixed checkCallbck thread so that callback env is always intitialized
authorPriti Aghera <paghera@broadcom.com>
Wed, 4 Apr 2012 19:32:12 +0000 (12:32 -0700)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Tue, 17 Jul 2012 04:55:59 +0000 (21:55 -0700)
Change-Id: Id959c99a0aa7823d36a0437d0b59972052f3edb9

jni/com_android_bluetooth_hid.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 845b728..cae1056
@@ -28,9 +28,13 @@ static jobject mCallbacksObj = NULL;
 static JNIEnv *sCallbackEnv = NULL;
 
 static bool checkCallbackThread() {
-    if (sCallbackEnv == NULL) {
-        sCallbackEnv = getCallbackEnv();
-    }
+
+    // Always fetch the latest callbackEnv from AdapterService.
+    // Caching this could cause this sCallbackEnv to go out-of-sync
+    // with the AdapterService's ENV if an ASSOCIATE/DISASSOCIATE event
+    // is received
+
+    sCallbackEnv = getCallbackEnv();
 
     JNIEnv* env = AndroidRuntime::getJNIEnv();
     if (sCallbackEnv != env || sCallbackEnv == NULL) return false;