Loading android/app/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -63,6 +63,7 @@ cc_library_shared { ], ], include_dirs: [ include_dirs: [ "packages/modules/Bluetooth/system/types", "packages/modules/Bluetooth/system/types", "packages/modules/Bluetooth/system/gd", ], ], static_libs: [ static_libs: [ "libbluetooth-types", "libbluetooth-types", Loading android/app/jni/com_android_bluetooth_hfp.cpp +14 −10 Original line number Original line Diff line number Diff line Loading @@ -16,14 +16,14 @@ #define LOG_TAG "BluetoothHeadsetServiceJni" #define LOG_TAG "BluetoothHeadsetServiceJni" #include <mutex> #include <shared_mutex> #include "com_android_bluetooth.h" #include "com_android_bluetooth.h" #include "hardware/bluetooth_headset_callbacks.h" #include "hardware/bluetooth_headset_callbacks.h" #include "hardware/bluetooth_headset_interface.h" #include "hardware/bluetooth_headset_interface.h" #include "hardware/bt_hf.h" #include "hardware/bt_hf.h" #include "utils/Log.h" #include "os/log.h" #include <mutex> #include <shared_mutex> namespace android { namespace android { Loading Loading @@ -78,7 +78,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks { void ConnectionStateCallback( void ConnectionStateCallback( bluetooth::headset::bthf_connection_state_t state, bluetooth::headset::bthf_connection_state_t state, RawAddress* bd_addr) override { RawAddress* bd_addr) override { ALOGI("%s %d for %s", __func__, state, bd_addr->ToString().c_str()); ALOGI("%s %d for %s", __func__, state, ADDRESS_TO_LOGGABLE_CSTR(*bd_addr)); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); CallbackEnv sCallbackEnv(__func__); Loading @@ -93,7 +93,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks { void AudioStateCallback(bluetooth::headset::bthf_audio_state_t state, void AudioStateCallback(bluetooth::headset::bthf_audio_state_t state, RawAddress* bd_addr) override { RawAddress* bd_addr) override { ALOGI("%s, %d for %s", __func__, state, bd_addr->ToString().c_str()); ALOGI("%s, %d for %s", __func__, state, ADDRESS_TO_LOGGABLE_CSTR(*bd_addr)); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); CallbackEnv sCallbackEnv(__func__); Loading Loading @@ -515,7 +515,8 @@ static jboolean connectHfpNative(JNIEnv* env, jobject object, jniThrowIOException(env, EINVAL); jniThrowIOException(env, EINVAL); return JNI_FALSE; return JNI_FALSE; } } ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str()); ALOGI("%s: device %s", __func__, ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr))); bt_status_t status = sBluetoothHfpInterface->Connect((RawAddress*)addr); bt_status_t status = sBluetoothHfpInterface->Connect((RawAddress*)addr); if (status != BT_STATUS_SUCCESS) { if (status != BT_STATUS_SUCCESS) { ALOGE("Failed HF connection, status: %d", status); ALOGE("Failed HF connection, status: %d", status); Loading @@ -537,7 +538,8 @@ static jboolean disconnectHfpNative(JNIEnv* env, jobject object, jniThrowIOException(env, EINVAL); jniThrowIOException(env, EINVAL); return JNI_FALSE; return JNI_FALSE; } } ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str()); ALOGI("%s: device %s", __func__, ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr))); bt_status_t status = sBluetoothHfpInterface->Disconnect((RawAddress*)addr); bt_status_t status = sBluetoothHfpInterface->Disconnect((RawAddress*)addr); if (status != BT_STATUS_SUCCESS) { if (status != BT_STATUS_SUCCESS) { ALOGE("Failed HF disconnection, status: %d", status); ALOGE("Failed HF disconnection, status: %d", status); Loading @@ -559,7 +561,8 @@ static jboolean connectAudioNative(JNIEnv* env, jobject object, jniThrowIOException(env, EINVAL); jniThrowIOException(env, EINVAL); return JNI_FALSE; return JNI_FALSE; } } ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str()); ALOGI("%s: device %s", __func__, ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr))); bt_status_t status = bt_status_t status = sBluetoothHfpInterface->ConnectAudio((RawAddress*)addr, false); sBluetoothHfpInterface->ConnectAudio((RawAddress*)addr, false); if (status != BT_STATUS_SUCCESS) { if (status != BT_STATUS_SUCCESS) { Loading @@ -582,7 +585,8 @@ static jboolean disconnectAudioNative(JNIEnv* env, jobject object, jniThrowIOException(env, EINVAL); jniThrowIOException(env, EINVAL); return JNI_FALSE; return JNI_FALSE; } } ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str()); ALOGI("%s: device %s", __func__, ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr))); bt_status_t status = bt_status_t status = sBluetoothHfpInterface->DisconnectAudio((RawAddress*)addr); sBluetoothHfpInterface->DisconnectAudio((RawAddress*)addr); if (status != BT_STATUS_SUCCESS) { if (status != BT_STATUS_SUCCESS) { Loading Loading
android/app/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -63,6 +63,7 @@ cc_library_shared { ], ], include_dirs: [ include_dirs: [ "packages/modules/Bluetooth/system/types", "packages/modules/Bluetooth/system/types", "packages/modules/Bluetooth/system/gd", ], ], static_libs: [ static_libs: [ "libbluetooth-types", "libbluetooth-types", Loading
android/app/jni/com_android_bluetooth_hfp.cpp +14 −10 Original line number Original line Diff line number Diff line Loading @@ -16,14 +16,14 @@ #define LOG_TAG "BluetoothHeadsetServiceJni" #define LOG_TAG "BluetoothHeadsetServiceJni" #include <mutex> #include <shared_mutex> #include "com_android_bluetooth.h" #include "com_android_bluetooth.h" #include "hardware/bluetooth_headset_callbacks.h" #include "hardware/bluetooth_headset_callbacks.h" #include "hardware/bluetooth_headset_interface.h" #include "hardware/bluetooth_headset_interface.h" #include "hardware/bt_hf.h" #include "hardware/bt_hf.h" #include "utils/Log.h" #include "os/log.h" #include <mutex> #include <shared_mutex> namespace android { namespace android { Loading Loading @@ -78,7 +78,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks { void ConnectionStateCallback( void ConnectionStateCallback( bluetooth::headset::bthf_connection_state_t state, bluetooth::headset::bthf_connection_state_t state, RawAddress* bd_addr) override { RawAddress* bd_addr) override { ALOGI("%s %d for %s", __func__, state, bd_addr->ToString().c_str()); ALOGI("%s %d for %s", __func__, state, ADDRESS_TO_LOGGABLE_CSTR(*bd_addr)); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); CallbackEnv sCallbackEnv(__func__); Loading @@ -93,7 +93,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks { void AudioStateCallback(bluetooth::headset::bthf_audio_state_t state, void AudioStateCallback(bluetooth::headset::bthf_audio_state_t state, RawAddress* bd_addr) override { RawAddress* bd_addr) override { ALOGI("%s, %d for %s", __func__, state, bd_addr->ToString().c_str()); ALOGI("%s, %d for %s", __func__, state, ADDRESS_TO_LOGGABLE_CSTR(*bd_addr)); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); CallbackEnv sCallbackEnv(__func__); Loading Loading @@ -515,7 +515,8 @@ static jboolean connectHfpNative(JNIEnv* env, jobject object, jniThrowIOException(env, EINVAL); jniThrowIOException(env, EINVAL); return JNI_FALSE; return JNI_FALSE; } } ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str()); ALOGI("%s: device %s", __func__, ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr))); bt_status_t status = sBluetoothHfpInterface->Connect((RawAddress*)addr); bt_status_t status = sBluetoothHfpInterface->Connect((RawAddress*)addr); if (status != BT_STATUS_SUCCESS) { if (status != BT_STATUS_SUCCESS) { ALOGE("Failed HF connection, status: %d", status); ALOGE("Failed HF connection, status: %d", status); Loading @@ -537,7 +538,8 @@ static jboolean disconnectHfpNative(JNIEnv* env, jobject object, jniThrowIOException(env, EINVAL); jniThrowIOException(env, EINVAL); return JNI_FALSE; return JNI_FALSE; } } ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str()); ALOGI("%s: device %s", __func__, ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr))); bt_status_t status = sBluetoothHfpInterface->Disconnect((RawAddress*)addr); bt_status_t status = sBluetoothHfpInterface->Disconnect((RawAddress*)addr); if (status != BT_STATUS_SUCCESS) { if (status != BT_STATUS_SUCCESS) { ALOGE("Failed HF disconnection, status: %d", status); ALOGE("Failed HF disconnection, status: %d", status); Loading @@ -559,7 +561,8 @@ static jboolean connectAudioNative(JNIEnv* env, jobject object, jniThrowIOException(env, EINVAL); jniThrowIOException(env, EINVAL); return JNI_FALSE; return JNI_FALSE; } } ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str()); ALOGI("%s: device %s", __func__, ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr))); bt_status_t status = bt_status_t status = sBluetoothHfpInterface->ConnectAudio((RawAddress*)addr, false); sBluetoothHfpInterface->ConnectAudio((RawAddress*)addr, false); if (status != BT_STATUS_SUCCESS) { if (status != BT_STATUS_SUCCESS) { Loading @@ -582,7 +585,8 @@ static jboolean disconnectAudioNative(JNIEnv* env, jobject object, jniThrowIOException(env, EINVAL); jniThrowIOException(env, EINVAL); return JNI_FALSE; return JNI_FALSE; } } ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str()); ALOGI("%s: device %s", __func__, ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr))); bt_status_t status = bt_status_t status = sBluetoothHfpInterface->DisconnectAudio((RawAddress*)addr); sBluetoothHfpInterface->DisconnectAudio((RawAddress*)addr); if (status != BT_STATUS_SUCCESS) { if (status != BT_STATUS_SUCCESS) { Loading