diff options
-rw-r--r-- | jni/com_android_bluetooth_a2dp.cpp | 10 | ||||
-rw-r--r-- | jni/com_android_bluetooth_hfp.cpp | 11 |
2 files changed, 14 insertions, 7 deletions
diff --git a/jni/com_android_bluetooth_a2dp.cpp b/jni/com_android_bluetooth_a2dp.cpp index 0edf4b46a..ebc23a5a8 100644 --- a/jni/com_android_bluetooth_a2dp.cpp +++ b/jni/com_android_bluetooth_a2dp.cpp @@ -20,9 +20,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 + //if (sCallbackEnv == NULL) { + sCallbackEnv = getCallbackEnv(); + //} JNIEnv* env = AndroidRuntime::getJNIEnv(); if (sCallbackEnv != env || sCallbackEnv == NULL) return false; diff --git a/jni/com_android_bluetooth_hfp.cpp b/jni/com_android_bluetooth_hfp.cpp index 6b4c61eed..f8b0b16d0 100644 --- a/jni/com_android_bluetooth_hfp.cpp +++ b/jni/com_android_bluetooth_hfp.cpp @@ -43,10 +43,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 + //if (sCallbackEnv == NULL) { + sCallbackEnv = getCallbackEnv(); + //} JNIEnv* env = AndroidRuntime::getJNIEnv(); if (sCallbackEnv != env || sCallbackEnv == NULL) return false; return true; |