diff options
author | Gaurav Asati <gasati@codeaurora.org> | 2013-10-09 14:07:46 +0530 |
---|---|---|
committer | Gaurav Asati <gasati@codeaurora.org> | 2013-11-08 23:18:53 +0530 |
commit | d2584b606745eb0f7be1251f0d79f7867ba73e10 (patch) | |
tree | 8132891bbcaa0513ff127b22ec8322bc48995679 /jni/com_android_bluetooth_a2dp.cpp | |
parent | 30143f7ed5a38eed3581f5e3418acbf70b5d558d (diff) | |
download | android_packages_apps_Bluetooth-d2584b606745eb0f7be1251f0d79f7867ba73e10.tar.gz android_packages_apps_Bluetooth-d2584b606745eb0f7be1251f0d79f7867ba73e10.tar.bz2 android_packages_apps_Bluetooth-d2584b606745eb0f7be1251f0d79f7867ba73e10.zip |
Bluetooth: Check A2dp device priority.
Add support to update stack for A2dp priority
of device.
Change-Id: I65971ffc68e055d68091f73a489a8d8c69c9420b
CRs-Fixed: 510957
Diffstat (limited to 'jni/com_android_bluetooth_a2dp.cpp')
-rw-r--r-- | jni/com_android_bluetooth_a2dp.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/jni/com_android_bluetooth_a2dp.cpp b/jni/com_android_bluetooth_a2dp.cpp index 415f6fe91..28c03aed2 100644 --- a/jni/com_android_bluetooth_a2dp.cpp +++ b/jni/com_android_bluetooth_a2dp.cpp @@ -28,6 +28,7 @@ namespace android { static jmethodID method_onConnectionStateChanged; static jmethodID method_onAudioStateChanged; +static jmethodID method_onCheckConnectionPriority; static const btav_interface_t *sBluetoothA2dpInterface = NULL; static jobject mCallbacksObj = NULL; @@ -93,10 +94,33 @@ static void bta2dp_audio_state_callback(btav_audio_state_t state, bt_bdaddr_t* b sCallbackEnv->DeleteLocalRef(addr); } +static void bta2dp_connection_priority_callback(bt_bdaddr_t* bd_addr) { + jbyteArray addr; + + ALOGI("%s", __FUNCTION__); + + if (!checkCallbackThread()) { \ + ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__); \ + return; \ + } + addr = sCallbackEnv->NewByteArray(sizeof(bt_bdaddr_t)); + if (!addr) { + ALOGE("Fail to new jbyteArray bd addr for connection state"); + checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__); + return; + } + + sCallbackEnv->SetByteArrayRegion(addr, 0, sizeof(bt_bdaddr_t), (jbyte*) bd_addr); + sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onCheckConnectionPriority, addr); + checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__); + sCallbackEnv->DeleteLocalRef(addr); +} + static btav_callbacks_t sBluetoothA2dpCallbacks = { sizeof(sBluetoothA2dpCallbacks), bta2dp_connection_state_callback, - bta2dp_audio_state_callback + bta2dp_audio_state_callback, + bta2dp_connection_priority_callback }; static void classInitNative(JNIEnv* env, jclass clazz) { @@ -109,6 +133,9 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_onAudioStateChanged = env->GetMethodID(clazz, "onAudioStateChanged", "(I[B)V"); + + method_onCheckConnectionPriority = + env->GetMethodID(clazz, "onCheckConnectionPriority", "([B)V"); /* if ( (btInf = getBluetoothInterface()) == NULL) { ALOGE("Bluetooth module is not loaded"); @@ -225,18 +252,30 @@ static jboolean disconnectA2dpNative(JNIEnv *env, jobject object, jbyteArray add } if ( (status = sBluetoothA2dpInterface->disconnect((bt_bdaddr_t *)addr)) != BT_STATUS_SUCCESS) { - ALOGE("Failed HF disconnection, status: %d", status); + ALOGE("Failed A2DP disconnection, status: %d", status); } env->ReleaseByteArrayElements(address, addr, 0); return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE; } +static void allowConnectionNative(JNIEnv *env, jobject object, int is_valid) { + + if (!sBluetoothA2dpInterface) { + ALOGE("sBluetoothA2dpInterface is NULL "); + return; + } + + sBluetoothA2dpInterface->allow_connection(is_valid); + +} + static JNINativeMethod sMethods[] = { {"classInitNative", "()V", (void *) classInitNative}, {"initNative", "()V", (void *) initNative}, {"cleanupNative", "()V", (void *) cleanupNative}, {"connectA2dpNative", "([B)Z", (void *) connectA2dpNative}, {"disconnectA2dpNative", "([B)Z", (void *) disconnectA2dpNative}, + {"allowConnectionNative", "(I)V", (void *) allowConnectionNative}, }; int register_com_android_bluetooth_a2dp(JNIEnv* env) |