OSDN Git Service

Clear BT Interface pointer during cleanup for BT on/off cycles to work
authorKausik Sinnaswamy <kausik@broadcom.com>
Mon, 16 Apr 2012 11:11:08 +0000 (16:41 +0530)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Tue, 17 Jul 2012 04:59:47 +0000 (21:59 -0700)
Change-Id: I89cdf7714c78b2b8dcbcdc6e78cd2500f85df986

jni/com_android_bluetooth_pan.cpp

index ccdf33b..0d9c240 100644 (file)
@@ -91,8 +91,9 @@ static void classInitNative(JNIEnv* env, jclass clazz) {
 
     info("succeeds");
 }
+static const bt_interface_t* btIf;
+
 static void initializeNative(JNIEnv *env, jobject object) {
-    static const bt_interface_t* btIf;
     debug("pan");
     if(btIf)
         return;
@@ -131,13 +132,8 @@ static void initializeNative(JNIEnv *env, jobject object) {
 }
 
 static void cleanupNative(JNIEnv *env, jobject object) {
-    const bt_interface_t* btInf;
     bt_status_t status;
-
-    if ( (btInf = getBluetoothInterface()) == NULL) {
-        LOGE("Bluetooth module is not loaded");
-        return;
-    }
+    if (!btIf) return;
 
     if (sPanIf !=NULL) {
         LOGW("Cleaning up Bluetooth PAN Interface...");
@@ -150,6 +146,7 @@ static void cleanupNative(JNIEnv *env, jobject object) {
         env->DeleteGlobalRef(mCallbacksObj);
         mCallbacksObj = NULL;
     }
+    btIf = NULL;
 }
 
 static jboolean enablePanNative(JNIEnv *env, jobject object, jint local_role) {