diff options
author | Anubhav Gupta <anubhavg@codeaurora.org> | 2013-11-08 14:18:37 +0530 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2013-12-03 07:30:34 -0800 |
commit | de7eb803b81de6f6196aa8f176bc7f094519b2b0 (patch) | |
tree | 45b4f01aa7a772af004772a9c558d7301a982527 /jni/com_android_bluetooth_a2dp.cpp | |
parent | 8fa3e57a5e1bdfc2627838f9fc29d26a6492ae2d (diff) | |
download | android_packages_apps_Bluetooth-de7eb803b81de6f6196aa8f176bc7f094519b2b0.tar.gz android_packages_apps_Bluetooth-de7eb803b81de6f6196aa8f176bc7f094519b2b0.tar.bz2 android_packages_apps_Bluetooth-de7eb803b81de6f6196aa8f176bc7f094519b2b0.zip |
Bluetooth: support for A2DP SINK
- added awareness of remote sep type
- manage audio focus
- handles stream suspend
CRs-Fixed: 580884
Change-Id: Ifbf2139baeb8b5c6e7e7622e7d9804cd1243061a
Diffstat (limited to 'jni/com_android_bluetooth_a2dp.cpp')
-rw-r--r-- | jni/com_android_bluetooth_a2dp.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/jni/com_android_bluetooth_a2dp.cpp b/jni/com_android_bluetooth_a2dp.cpp index 28c03aed2..095a8dddc 100644 --- a/jni/com_android_bluetooth_a2dp.cpp +++ b/jni/com_android_bluetooth_a2dp.cpp @@ -269,6 +269,36 @@ static void allowConnectionNative(JNIEnv *env, jobject object, int is_valid) { } +static jboolean isSrcNative(JNIEnv *env, jobject object, jbyteArray address) { + jbyte *addr; + bt_status_t status; + + if (!sBluetoothA2dpInterface) return JNI_FALSE; + + addr = env->GetByteArrayElements(address, NULL); + if (!addr) { + jniThrowIOException(env, EINVAL); + return JNI_FALSE; + } + + if ( (status = sBluetoothA2dpInterface->is_src((bt_bdaddr_t *)addr)) != BT_STATUS_SUCCESS) { + ALOGE("Failed HF disconnection, status: %d", status); + } + env->ReleaseByteArrayElements(address, addr, 0); + return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE; +} + +static void suspendA2dpNative(JNIEnv *env, jobject object) { + + if (!sBluetoothA2dpInterface) { + ALOGE("sBluetoothA2dpInterface is NULL "); + return; + } + + sBluetoothA2dpInterface->suspend_sink(); +} + + static JNINativeMethod sMethods[] = { {"classInitNative", "()V", (void *) classInitNative}, {"initNative", "()V", (void *) initNative}, @@ -276,11 +306,13 @@ static JNINativeMethod sMethods[] = { {"connectA2dpNative", "([B)Z", (void *) connectA2dpNative}, {"disconnectA2dpNative", "([B)Z", (void *) disconnectA2dpNative}, {"allowConnectionNative", "(I)V", (void *) allowConnectionNative}, + {"isSrcNative", "([B)Z", (void *) isSrcNative}, + {"suspendA2dpNative", "()V", (void *) suspendA2dpNative}, }; int register_com_android_bluetooth_a2dp(JNIEnv* env) { - return jniRegisterNativeMethods(env, "com/android/bluetooth/a2dp/A2dpStateMachine", + return jniRegisterNativeMethods(env, "com/android/bluetooth/a2dp/A2dpStateMachine", sMethods, NELEM(sMethods)); } |