summaryrefslogtreecommitdiffstats
path: root/jni/com_android_bluetooth_a2dp.cpp
diff options
context:
space:
mode:
authorGaurav Asati <gasati@codeaurora.org>2014-07-17 12:07:09 +0530
committerLinux Build Service Account <lnxbuild@localhost>2016-08-24 08:17:31 -0600
commitd7d3744bd87c253da4f3beced4cc029a91dbc48e (patch)
tree1e7c0ce3502141eb2e5cd199e9abf7058c414c69 /jni/com_android_bluetooth_a2dp.cpp
parent1a01dc6a857cd097fe0de8a962e0950f2e29e056 (diff)
downloadandroid_packages_apps_Bluetooth-d7d3744bd87c253da4f3beced4cc029a91dbc48e.tar.gz
android_packages_apps_Bluetooth-d7d3744bd87c253da4f3beced4cc029a91dbc48e.tar.bz2
android_packages_apps_Bluetooth-d7d3744bd87c253da4f3beced4cc029a91dbc48e.zip
BT: Multi A2dp support in Bluetooth App
1. Added support for Multi A2dp connections in Bluetooth application. 2. All connection transition states for 2nd HS onwards is handled in new state- MultiConnectionPending. 3. The changes are done to handle proper state transition for all connected HS. Change-Id: Ib7d16a4a647ba5d7e38a8c2edc4581474725ab6c Conflicts: src/com/android/bluetooth/avrcp/Avrcp.java src/com/android/bluetooth/btservice/AdapterService.java Bluetooth: Add support for multi Streaming. Add changes to support dual streaming for A2dp Change-Id: I84882d850ffd374bb998ef5e942464e2972d64bf Bluetooth: A2dp MultiCast/ Soft Hands-off. - Allow new profile connection on same ACL - Reset scan mode to last set scan mode before starting multicast - Check for mTargetDevice before moving to disconnected state. - Remove playing device from list on disconnect Change-Id: I24fa041783abba1584730930336b65a9586cb778 Bluetooth: Send Track change notification - Send track change notification to both devices. - Check for absolute volume support in both connected HS before updating audio - Reject 2nd incoming connection, when connecting event is received in pending state and already processing incoming connection. Change-Id: Ia5271febddcbf69c205fbebc7a11964a1ef0719c Dual A2DP: Update playstate on suspend - playstate update for suspend case to reflect the right state to remote device. Change-Id: If11acb9126ac8f424c622d786d4eaf3f155ca0c6 A2DP/AG: Increase A2DP/AG application level connection timeout - Application level connection timeout should be higher than lower level possible timeout to avoid race conditions. Stack level timeout for user response timeout is 30 seconds, hence during such scenarios stack will be still not timed out but application starts cleanup. Change-Id: I606e81fcea2e02c0cf4e5e47dba216bcbef42db4 Bluetooth: Update AudioManager for ABS volume - Update audiomanager for abs volume after RC features is received. - Update audiomanager when any of connected HS is disconnected. Change-Id: Ie2479cf538a830ba47c5a6418199caef2a81e78a Conflicts: src/com/android/bluetooth/avrcp/Avrcp.java Bluetooth: Block new ACL connections. - During active multicast, no new ACL should be created. - Do not proceed to new A2dp connection during active multicast. Change-Id: I0b9f6e7648976095ece8de4a41fbe10634c07131 Dual A2DP: Update currentDevice for unexpected disconnection - While in multipending state, currentDevice should be updated when disconnection is initiated for one device but happens for other device which is currentDevice. - Increase the connection timeout to 38 seconds to accomodate LMP response timeout and page timeout. CRs-Fixed: 835641 Change-Id: I54d439e458a212d6acf3031e5d1e89706071cfa9 Dual A2DP: Do not initiate bonding while multicast - Bonding has to be disabled while active multicast is on. This has to be explicitly taken care for avoiding the bonding and connection from available devices. Change-Id: Ic82686dd100201ca6171fbc3ab14c0b9690a850c CRs-Fixed: 837415 Misc A2dp Multicast Changes for proper Avrcp handling - Send play status update only if Music streaming is in progress. - Send play status update based on device specific stored state. - Remove multi player implementation as it causes mismatch in stored playback state and actual player state. - Logging changes for scan state update. CRs-Fixed: 839396 Change-Id: I539d949c32cbe1871f3c737bdd0e092798f729c1 Proper assignment of track number and play position - Initialize track number with value as -1 but on receiving meta update set it to 0 if media player in use is not capable of setting it to valid value. This change will help supporting 3rd party media player apps which are not capable of updating mentioned fields properly. - Explicitly send play-position as 0 in getPlayStatus response when position is not initialized as specification suggests that -1 is not a valid value for this command response. As per specification -1 will still be sent as the play position in interim response of Play Postion Changed notification. CRs-Fixed: 836672 Change-Id: I3e10ec4e49df095485fa630b95bf829e755686f1 Misc Avrcp handling for Multi connection scenarios - Handle avrcp TG connection state change update from stack and add remove respective devices to Avrcp connected device list. - Proper clean-up of device entries in A2dp and Handsfree state-machine. - Sending playback state changed as Paused when playback switches from that device to another. - Reject pending notifications when addressed player changes even to non 1.5 capable player. CRs-Fixed: 843335 Change-Id: Iafbeb17907e8bc5409ee996b966824fd4ba87417 Conflicts: src/com/android/bluetooth/avrcp/Avrcp.java Proper handling of Player settings attribute change - Proper handling of Player setting attribute change - Logging enhancement in player setting attrbute path. - Formatting changes. CRs-Fixed: 845462 Change-Id: I06067a091a21082b2668c31762f078da557841ee Conflicts: src/com/android/bluetooth/avrcp/Avrcp.java Dual A2DP: Update the connection state after timeout in Connected state When initiating incoming/outgoing connections, there is a possiblity that CONNECT_TIMEOUT for outgoing happens after successfully connecting to two other devices and this will be received in Connected state. We need to update the connection state and clear the target device. Change-Id: I0a1ad01f85b6f45b9276c6da9ce0e6b34f75990e Proper handling of Setting Addressed Player Proper handling of Setting Addressed Player ID. Make addressed Player ID as device independent. As otherwise device wont update the same after reconnection if any change has happened in between. CRs-Fixed: 855172 Change-Id: I23a4c3e9670fcd6538e0e3f5ef8c0be116a25de4 Change Play Position and Play status handling Change Play Position and Play status handling in a way that play positions are not kept device speific anymore as that belongs to change in player state, not device state. Play state changing to playing is sent only when device is identified as active one in hand-off mode. CRs-Fixed: 856063 Conflicts: src/com/android/bluetooth/a2dp/A2dpStateMachine.java Change-Id: Ia7e859c28a1826ac2686c432690030741a3c67bc
Diffstat (limited to 'jni/com_android_bluetooth_a2dp.cpp')
-rw-r--r--jni/com_android_bluetooth_a2dp.cpp77
1 files changed, 73 insertions, 4 deletions
diff --git a/jni/com_android_bluetooth_a2dp.cpp b/jni/com_android_bluetooth_a2dp.cpp
index b621ce46f..ec666dd1c 100644
--- a/jni/com_android_bluetooth_a2dp.cpp
+++ b/jni/com_android_bluetooth_a2dp.cpp
@@ -1,4 +1,7 @@
/*
+ * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,6 +31,8 @@
namespace android {
static jmethodID method_onConnectionStateChanged;
static jmethodID method_onAudioStateChanged;
+static jmethodID method_onCheckConnectionPriority;
+static jmethodID method_onMulticastStateChanged;
static const btav_interface_t *sBluetoothA2dpInterface = NULL;
static jobject mCallbacksObj = NULL;
@@ -93,11 +98,48 @@ 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 void bta2dp_multicast_enabled_callback(int state) {
+
+ ALOGI("%s", __FUNCTION__);
+
+ if (!checkCallbackThread()) { \
+ ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__); \
+ return; \
+ }
+
+ sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onMulticastStateChanged, state);
+ checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
+}
+
static btav_callbacks_t sBluetoothA2dpCallbacks = {
sizeof(sBluetoothA2dpCallbacks),
bta2dp_connection_state_callback,
bta2dp_audio_state_callback,
- NULL, /* audio_config_cb */
+ NULL,
+ bta2dp_connection_priority_callback,
+ bta2dp_multicast_enabled_callback,
};
static void classInitNative(JNIEnv* env, jclass clazz) {
@@ -107,10 +149,16 @@ static void classInitNative(JNIEnv* env, jclass clazz) {
method_onAudioStateChanged =
env->GetMethodID(clazz, "onAudioStateChanged", "(I[B)V");
+ method_onCheckConnectionPriority =
+ env->GetMethodID(clazz, "onCheckConnectionPriority", "([B)V");
+
+ method_onMulticastStateChanged =
+ env->GetMethodID(clazz, "onMulticastStateChanged", "(I)V");
ALOGI("%s: succeeds", __FUNCTION__);
}
-static void initNative(JNIEnv *env, jobject object) {
+static void initNative(JNIEnv *env, jobject object, jint maxA2dpConnections,
+ jint multiCastState) {
const bt_interface_t* btInf;
bt_status_t status;
@@ -137,7 +185,8 @@ static void initNative(JNIEnv *env, jobject object) {
return;
}
- if ( (status = sBluetoothA2dpInterface->init(&sBluetoothA2dpCallbacks)) != BT_STATUS_SUCCESS) {
+ if ( (status = sBluetoothA2dpInterface->init(&sBluetoothA2dpCallbacks,
+ maxA2dpConnections, multiCastState)) != BT_STATUS_SUCCESS) {
ALOGE("Failed to initialize Bluetooth A2DP, status: %d", status);
sBluetoothA2dpInterface = NULL;
return;
@@ -206,12 +255,32 @@ static jboolean disconnectA2dpNative(JNIEnv *env, jobject object, jbyteArray add
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}
+static void allowConnectionNative(JNIEnv *env, jobject object, int is_valid, jbyteArray address) {
+
+ jbyte *addr;
+ if (!sBluetoothA2dpInterface) {
+ ALOGE("sBluetoothA2dpInterface is NULL ");
+ return;
+ }
+
+ addr = env->GetByteArrayElements(address, NULL);
+
+ if (!addr) {
+ jniThrowIOException(env, EINVAL);
+ return ;
+ }
+
+ sBluetoothA2dpInterface->allow_connection(is_valid, (bt_bdaddr_t *)addr);
+ env->ReleaseByteArrayElements(address, addr, 0);
+}
+
static JNINativeMethod sMethods[] = {
{"classInitNative", "()V", (void *) classInitNative},
- {"initNative", "()V", (void *) initNative},
+ {"initNative", "(II)V", (void *) initNative},
{"cleanupNative", "()V", (void *) cleanupNative},
{"connectA2dpNative", "([B)Z", (void *) connectA2dpNative},
{"disconnectA2dpNative", "([B)Z", (void *) disconnectA2dpNative},
+ {"allowConnectionNative", "(I[B)V", (void *) allowConnectionNative},
};
int register_com_android_bluetooth_a2dp(JNIEnv* env)