Loading TEST_MAPPING 0 → 100644 +417 −0 Original line number Diff line number Diff line { "presubmit": [ // android_test targets { "name": "CtsBluetoothTestCases" }, { "name": "BluetoothInstrumentationTests" }, //{ // "name": "GoogleBluetoothInstrumentationTests" //}, //{ // "name": "FrameworkBluetoothTests" //}, { "name": "ServiceBluetoothTests" }, // device only tests // Broken //{ // "name": "bluetooth-test-audio-hal-interface" //}, { "name": "net_test_audio_a2dp_hw" }, { "name": "net_test_audio_hearing_aid_hw" }, { "name": "net_test_bluetooth" }, { "name": "net_test_bta" }, { "name": "net_test_btif" }, { "name": "net_test_btif_hf_client_service" }, { "name": "net_test_btif_profile_queue" }, { "name": "net_test_device" }, { "name": "net_test_device_iot_config" }, { "name": "net_test_gatt_conn_multiplexing" }, { "name": "net_test_hci" }, { "name": "net_test_stack" }, { "name": "net_test_stack_a2dp_codecs_native" }, { "name": "net_test_stack_ad_parser" }, { "name": "net_test_stack_multi_adv" }, // go/a-unit-tests tests (unit_test: true) // Thoses test run on the host in the CI automatically. // Run the one that are available on the device on the // device as well { "name": "bluetooth_csis_test" }, { "name": "bluetooth_flatbuffer_tests" }, { "name": "bluetooth_groups_test" }, { "name": "bluetooth_has_test" }, { "name": "bluetooth_hh_test" }, { "name": "bluetooth_le_audio_client_test" }, { "name": "bluetooth_le_audio_test" }, { "name": "bluetooth_packet_parser_test" }, { "name": "bluetooth_test_broadcaster" }, { "name": "bluetooth_test_broadcaster_state_machine" }, { "name": "bluetooth_test_common" }, { "name": "bluetooth_test_gd_unit" }, { "name": "bluetooth_test_sdp" }, { "name": "bluetooth_vc_test" }, { "name": "bt_host_test_bta" }, { "name": "libaptx_enc_tests" }, { "name": "libaptxhd_enc_tests" }, { "name": "net_test_avrcp" }, { "name": "net_test_btcore" }, { "name": "net_test_btif_config_cache" }, { "name": "net_test_btif_hh" }, { "name": "net_test_btif_rc" }, { "name": "net_test_btif_stack" }, { "name": "net_test_btm_iso" }, { "name": "net_test_btpackets" }, { "name": "net_test_eatt" }, { "name": "net_test_hci_fragmenter_native" }, { "name": "net_test_main_shim" }, { "name": "net_test_osi" }, { "name": "net_test_performance" }, { "name": "net_test_stack_a2dp_native" }, { "name": "net_test_stack_acl" }, { "name": "net_test_stack_avdtp" }, { "name": "net_test_stack_btm" }, { "name": "net_test_stack_btu" }, { "name": "net_test_stack_gatt" }, { "name": "net_test_stack_gatt_native" }, { "name": "net_test_stack_gatt_sr_hash_native" }, { "name": "net_test_stack_hci" }, { "name": "net_test_stack_hid" }, { "name": "net_test_stack_l2cap" }, { "name": "net_test_stack_rfcomm" }, { "name": "net_test_stack_sdp" }, { "name": "net_test_stack_smp" }, { "name": "net_test_types" } ], "hwasan-presubmit": [ // android_test targets { "name": "CtsBluetoothTestCases" }, { "name": "BluetoothInstrumentationTests" }, //{ // "name": "GoogleBluetoothInstrumentationTests" //}, //{ // "name": "FrameworkBluetoothTests" //}, { "name": "ServiceBluetoothTests" }, // device only tests // Broken //{ // "name": "bluetooth-test-audio-hal-interface" //}, { "name": "net_test_audio_a2dp_hw" }, { "name": "net_test_audio_hearing_aid_hw" }, { "name": "net_test_bluetooth" }, { "name": "net_test_bta" }, { "name": "net_test_btif" }, { "name": "net_test_btif_hf_client_service" }, { "name": "net_test_btif_profile_queue" }, { "name": "net_test_device" }, { "name": "net_test_device_iot_config" }, { "name": "net_test_gatt_conn_multiplexing" }, { "name": "net_test_hci" }, { "name": "net_test_stack" }, { "name": "net_test_stack_a2dp_codecs_native" }, { "name": "net_test_stack_ad_parser" }, { "name": "net_test_stack_multi_adv" }, // go/a-unit-tests tests (unit_test: true) // Thoses test run on the host in the CI automatically. // Run the one that are available on the device on the // device as well { "name": "bluetooth_csis_test" }, { "name": "bluetooth_flatbuffer_tests" }, { "name": "bluetooth_groups_test" }, { "name": "bluetooth_has_test" }, { "name": "bluetooth_hh_test" }, { "name": "bluetooth_le_audio_client_test" }, // b/271319421 // { // "name": "bluetooth_le_audio_test" // }, { "name": "bluetooth_packet_parser_test" }, { "name": "bluetooth_test_broadcaster" }, { "name": "bluetooth_test_broadcaster_state_machine" }, { "name": "bluetooth_test_common" }, { "name": "bluetooth_test_gd_unit" }, { "name": "bluetooth_test_sdp" }, { "name": "bluetooth_vc_test" }, { "name": "bt_host_test_bta" }, { "name": "libaptx_enc_tests" }, { "name": "libaptxhd_enc_tests" }, { "name": "net_test_avrcp" }, { "name": "net_test_btcore" }, { "name": "net_test_btif_config_cache" }, { "name": "net_test_btif_hh" }, { "name": "net_test_btif_rc" }, { "name": "net_test_btif_stack" }, { "name": "net_test_btm_iso" }, { "name": "net_test_btpackets" }, { "name": "net_test_eatt" }, { "name": "net_test_hci_fragmenter_native" }, { "name": "net_test_main_shim" }, { "name": "net_test_osi" }, { "name": "net_test_performance" }, { "name": "net_test_stack_a2dp_native" }, { "name": "net_test_stack_acl" }, { "name": "net_test_stack_avdtp" }, { "name": "net_test_stack_btm" }, { "name": "net_test_stack_btu" }, { "name": "net_test_stack_gatt" }, { "name": "net_test_stack_gatt_native" }, { "name": "net_test_stack_gatt_sr_hash_native" }, { "name": "net_test_stack_hci" }, { "name": "net_test_stack_hid" }, { "name": "net_test_stack_l2cap" }, { "name": "net_test_stack_rfcomm" }, { "name": "net_test_stack_sdp" }, { "name": "net_test_stack_smp" }, { "name": "net_test_types" } ] } android/app/Android.bp +1 −8 Original line number Diff line number Diff line Loading @@ -67,8 +67,8 @@ cc_library_shared { "packages/modules/Bluetooth/system/types", ], static_libs: [ "libbluetooth-types", "libbluetooth", "libbluetooth-types", "libbluetooth_core_rs", "libbluetooth_core_rs_bridge", "libc++fs", Loading Loading @@ -201,13 +201,6 @@ android_app { optimize: false, proguard_flags_files: ["proguard.flags"], }, required: [ "android.hardware.bluetooth.audio-V3-ndk", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", "android.hardware.bluetooth@1.0", "android.hardware.bluetooth@1.1", ], apex_available: [ "com.android.btservices", ], Loading android/app/jni/com_android_bluetooth_avrcp_target.cpp +206 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,27 @@ static void volumeDeviceConnected( static void volumeDeviceDisconnected(const RawAddress& address); static void setVolume(int8_t volume); using ListPlayerSettingsCb = PlayerSettingsInterface::ListPlayerSettingsCallback; static void listPlayerSettings(ListPlayerSettingsCb cb); ListPlayerSettingsCb list_player_settings_cb; using ListPlayerSettingValuesCb = PlayerSettingsInterface::ListPlayerSettingValuesCallback; static void listPlayerSettingValues(PlayerAttribute setting, ListPlayerSettingValuesCb cb); ListPlayerSettingValuesCb list_player_setting_values_cb; using GetCurrentPlayerSettingValueCb = PlayerSettingsInterface::GetCurrentPlayerSettingValueCallback; static void getPlayerSettings(std::vector<PlayerAttribute> attributes, GetCurrentPlayerSettingValueCb cb); GetCurrentPlayerSettingValueCb get_current_player_setting_value_cb; using SetPlayerSettingValueCb = PlayerSettingsInterface::SetPlayerSettingValueCallback; static void setPlayerSettings(std::vector<PlayerAttribute> attributes, std::vector<uint8_t> values, SetPlayerSettingValueCb cb); SetPlayerSettingValueCb set_player_setting_value_cb; // Local Variables // TODO (apanicke): Use a map here to store the callback in order to // support multi-browsing Loading @@ -71,6 +92,18 @@ std::map<std::string, GetFolderItemsCb> get_folder_items_cb_map; std::map<RawAddress, ::bluetooth::avrcp::VolumeInterface::VolumeChangedCb> volumeCallbackMap; template <typename T> void copyJavaArraytoCppVector(JNIEnv* env, const jbyteArray& jArray, std::vector<T>& cVec) { size_t len = (size_t)env->GetArrayLength(jArray); if (len == 0) return; jbyte* elements = env->GetByteArrayElements(jArray, nullptr); T* array = reinterpret_cast<T*>(elements); cVec.reserve(len); std::copy(array, array + len, std::back_inserter(cVec)); env->ReleaseByteArrayElements(jArray, elements, 0); } // TODO (apanicke): In the future, this interface should guarantee that // all calls happen on the JNI Thread. Right now this is very difficult // as it is hard to get a handle on the JNI thread from here. Loading Loading @@ -150,6 +183,30 @@ class VolumeInterfaceImpl : public VolumeInterface { }; static VolumeInterfaceImpl mVolumeInterface; class PlayerSettingsInterfaceImpl : public PlayerSettingsInterface { public: void ListPlayerSettings(ListPlayerSettingsCallback cb) { listPlayerSettings(cb); } void ListPlayerSettingValues(PlayerAttribute setting, ListPlayerSettingValuesCallback cb) { listPlayerSettingValues(setting, cb); } void GetCurrentPlayerSettingValue(std::vector<PlayerAttribute> attributes, GetCurrentPlayerSettingValueCallback cb) { getPlayerSettings(attributes, cb); } void SetPlayerSettings(std::vector<PlayerAttribute> attributes, std::vector<uint8_t> values, SetPlayerSettingValueCallback cb) { setPlayerSettings(attributes, values, cb); } }; static PlayerSettingsInterfaceImpl mPlayerSettingsInterface; static jmethodID method_getCurrentSongInfo; static jmethodID method_getPlaybackStatus; static jmethodID method_sendMediaKeyEvent; Loading @@ -170,6 +227,11 @@ static jmethodID method_volumeDeviceDisconnected; static jmethodID method_setVolume; static jmethodID method_listPlayerSettings; static jmethodID method_listPlayerSettingValues; static jmethodID method_getPlayerSettings; static jmethodID method_setPlayerSettings; static void classInitNative(JNIEnv* env, jclass clazz) { method_getCurrentSongInfo = env->GetMethodID( clazz, "getCurrentSongInfo", "()Lcom/android/bluetooth/audio_util/Metadata;"); Loading Loading @@ -212,6 +274,18 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_setVolume = env->GetMethodID(clazz, "setVolume", "(I)V"); method_listPlayerSettings = env->GetMethodID(clazz, "listPlayerSettingsRequest", "()V"); method_listPlayerSettingValues = env->GetMethodID(clazz, "listPlayerSettingValuesRequest", "(B)V"); method_getPlayerSettings = env->GetMethodID(clazz, "getCurrentPlayerSettingValuesRequest", "([B)V"); method_setPlayerSettings = env->GetMethodID(clazz, "setPlayerSettingsRequest", "([B[B)V"); ALOGI("%s: AvrcpTargetJni initialized!", __func__); } Loading @@ -222,7 +296,8 @@ static void initNative(JNIEnv* env, jobject object) { mJavaInterface = env->NewGlobalRef(object); sServiceInterface = getBluetoothInterface()->get_avrcp_service(); sServiceInterface->Init(&mAvrcpInterface, &mVolumeInterface); sServiceInterface->Init(&mAvrcpInterface, &mVolumeInterface, &mPlayerSettingsInterface); } static void registerBipServerNative(JNIEnv* env, jobject object, Loading Loading @@ -900,6 +975,127 @@ static void setBipClientStatusNative(JNIEnv* env, jobject object, sServiceInterface->SetBipClientStatus(bdaddr, status); } // Called from native to list available player settings static void listPlayerSettings(ListPlayerSettingsCb cb) { ALOGD("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid() || !mJavaInterface) return; list_player_settings_cb = std::move(cb); sCallbackEnv->CallVoidMethod(mJavaInterface, method_listPlayerSettings); } static void listPlayerSettingsResponseNative(JNIEnv* env, jobject object, jbyteArray attributes) { ALOGD("%s", __func__); std::vector<PlayerAttribute> attributes_vector; copyJavaArraytoCppVector(env, attributes, attributes_vector); list_player_settings_cb.Run(std::move(attributes_vector)); } // Called from native to list available values for player setting static void listPlayerSettingValues(PlayerAttribute attribute, ListPlayerSettingValuesCb cb) { ALOGD("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid() || !mJavaInterface) return; list_player_setting_values_cb = std::move(cb); sCallbackEnv->CallVoidMethod(mJavaInterface, method_listPlayerSettingValues, (jbyte)attribute); } static void listPlayerSettingValuesResponseNative(JNIEnv* env, jobject object, jbyte attribute, jbyteArray values) { ALOGD("%s", __func__); PlayerAttribute player_attribute = static_cast<PlayerAttribute>(attribute); std::vector<uint8_t> values_vector; copyJavaArraytoCppVector(env, values, values_vector); list_player_setting_values_cb.Run(player_attribute, std::move(values_vector)); } // Called from native to get current player settings static void getPlayerSettings(std::vector<PlayerAttribute> attributes, GetCurrentPlayerSettingValueCb cb) { ALOGD("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid() || !mJavaInterface) return; jbyteArray attributes_array = sCallbackEnv->NewByteArray(attributes.size()); sCallbackEnv->SetByteArrayRegion( attributes_array, 0, attributes.size(), reinterpret_cast<const jbyte*>(attributes.data())); get_current_player_setting_value_cb = std::move(cb); sCallbackEnv->CallVoidMethod(mJavaInterface, method_getPlayerSettings, attributes_array); } static void getPlayerSettingsResponseNative(JNIEnv* env, jobject object, jbyteArray attributes, jbyteArray values) { ALOGD("%s", __func__); std::vector<PlayerAttribute> attributes_vector; std::vector<uint8_t> values_vector; copyJavaArraytoCppVector(env, attributes, attributes_vector); copyJavaArraytoCppVector(env, values, values_vector); get_current_player_setting_value_cb.Run(std::move(attributes_vector), std::move(values_vector)); } // Called from native to set current player settings static void setPlayerSettings(std::vector<PlayerAttribute> attributes, std::vector<uint8_t> values, SetPlayerSettingValueCb cb) { ALOGD("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid() || !mJavaInterface) return; jbyteArray attributes_array = sCallbackEnv->NewByteArray(attributes.size()); sCallbackEnv->SetByteArrayRegion( attributes_array, 0, attributes.size(), reinterpret_cast<const jbyte*>(attributes.data())); jbyteArray values_array = sCallbackEnv->NewByteArray(values.size()); sCallbackEnv->SetByteArrayRegion( values_array, 0, values.size(), reinterpret_cast<const jbyte*>(values.data())); set_player_setting_value_cb = std::move(cb); sCallbackEnv->CallVoidMethod(mJavaInterface, method_setPlayerSettings, attributes_array, values_array); } static void setPlayerSettingsResponseNative(JNIEnv* env, jobject object, jboolean success) { ALOGD("%s", __func__); set_player_setting_value_cb.Run(success); } static void sendPlayerSettingsNative(JNIEnv* env, jobject object, jbyteArray attributes, jbyteArray values) { ALOGD("%s", __func__); std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex); if (mServiceCallbacks == nullptr) { ALOGW("%s: Service not loaded.", __func__); return; } std::vector<PlayerAttribute> attributes_vector; std::vector<uint8_t> values_vector; copyJavaArraytoCppVector(env, attributes, attributes_vector); copyJavaArraytoCppVector(env, values, values_vector); mServiceCallbacks->SendPlayerSettingsChanged(attributes_vector, values_vector); } static JNINativeMethod sMethods[] = { {"classInitNative", "()V", (void*)classInitNative}, {"initNative", "()V", (void*)initNative}, Loading @@ -920,6 +1116,15 @@ static JNINativeMethod sMethods[] = { (void*)sendVolumeChangedNative}, {"setBipClientStatusNative", "(Ljava/lang/String;Z)V", (void*)setBipClientStatusNative}, {"listPlayerSettingsResponseNative", "([B)V", (void*)listPlayerSettingsResponseNative}, {"listPlayerSettingValuesResponseNative", "(B[B)V", (void*)listPlayerSettingValuesResponseNative}, {"getPlayerSettingsResponseNative", "([B[B)V", (void*)getPlayerSettingsResponseNative}, {"setPlayerSettingsResponseNative", "(Z)V", (void*)setPlayerSettingsResponseNative}, {"sendPlayerSettingsNative", "([B[B)V", (void*)sendPlayerSettingsNative}, }; int register_com_android_bluetooth_avrcp_target(JNIEnv* env) { Loading android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp +1 −14 Original line number Diff line number Diff line Loading @@ -41,19 +41,6 @@ extern bt_interface_t bluetoothInterface; namespace android { // Both // OOB_ADDRESS_SIZE is 6 bytes address + 1 byte address type #define OOB_ADDRESS_SIZE 7 #define OOB_C_SIZE 16 #define OOB_R_SIZE 16 #define OOB_NAME_MAX_SIZE 256 // Classic #define OOB_DATA_LEN_SIZE 2 #define OOB_COD_SIZE 3 // LE #define OOB_TK_SIZE 16 #define OOB_LE_FLAG_SIZE 1 #define OOB_LE_ROLE_SIZE 1 #define OOB_LE_APPEARANCE_SIZE 2 #define TRANSPORT_AUTO 0 #define TRANSPORT_BREDR 1 Loading Loading @@ -1274,7 +1261,7 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData, } oobDataLengthBytes = env->GetByteArrayElements(oobDataLength, NULL); memcpy(oob_data.oob_data_length, oobDataLengthBytes, len); memcpy(oob_data.oob_data_length, oobDataLengthBytes, OOB_DATA_LEN_SIZE); env->ReleaseByteArrayElements(oobDataLength, oobDataLengthBytes, 0); // Optional Loading android/app/jni/com_android_bluetooth_gatt.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ #include "hardware/bt_gatt.h" #include "rust/cxx.h" #include "rust/src/gatt/ffi/gatt_shim.h" #include "src/core/ffi.rs.h" #include "src/gatt/ffi.rs.h" #include "utils/Log.h" #define info(fmt, ...) ALOGI("%s(L%d): " fmt, __func__, __LINE__, ##__VA_ARGS__) Loading Loading @@ -1393,10 +1392,6 @@ static void initializeNative(JNIEnv* env, jobject object) { JniDistanceMeasurementCallbacks::GetInstance()); mCallbacksObj = env->NewGlobalRef(object); auto callbacks = std::make_unique<bluetooth::gatt::GattServerCallbacks>( sGattServerCallbacks); bluetooth::rust_shim::init(std::move(callbacks)); } static void cleanupNative(JNIEnv* env, jobject object) { Loading Loading
TEST_MAPPING 0 → 100644 +417 −0 Original line number Diff line number Diff line { "presubmit": [ // android_test targets { "name": "CtsBluetoothTestCases" }, { "name": "BluetoothInstrumentationTests" }, //{ // "name": "GoogleBluetoothInstrumentationTests" //}, //{ // "name": "FrameworkBluetoothTests" //}, { "name": "ServiceBluetoothTests" }, // device only tests // Broken //{ // "name": "bluetooth-test-audio-hal-interface" //}, { "name": "net_test_audio_a2dp_hw" }, { "name": "net_test_audio_hearing_aid_hw" }, { "name": "net_test_bluetooth" }, { "name": "net_test_bta" }, { "name": "net_test_btif" }, { "name": "net_test_btif_hf_client_service" }, { "name": "net_test_btif_profile_queue" }, { "name": "net_test_device" }, { "name": "net_test_device_iot_config" }, { "name": "net_test_gatt_conn_multiplexing" }, { "name": "net_test_hci" }, { "name": "net_test_stack" }, { "name": "net_test_stack_a2dp_codecs_native" }, { "name": "net_test_stack_ad_parser" }, { "name": "net_test_stack_multi_adv" }, // go/a-unit-tests tests (unit_test: true) // Thoses test run on the host in the CI automatically. // Run the one that are available on the device on the // device as well { "name": "bluetooth_csis_test" }, { "name": "bluetooth_flatbuffer_tests" }, { "name": "bluetooth_groups_test" }, { "name": "bluetooth_has_test" }, { "name": "bluetooth_hh_test" }, { "name": "bluetooth_le_audio_client_test" }, { "name": "bluetooth_le_audio_test" }, { "name": "bluetooth_packet_parser_test" }, { "name": "bluetooth_test_broadcaster" }, { "name": "bluetooth_test_broadcaster_state_machine" }, { "name": "bluetooth_test_common" }, { "name": "bluetooth_test_gd_unit" }, { "name": "bluetooth_test_sdp" }, { "name": "bluetooth_vc_test" }, { "name": "bt_host_test_bta" }, { "name": "libaptx_enc_tests" }, { "name": "libaptxhd_enc_tests" }, { "name": "net_test_avrcp" }, { "name": "net_test_btcore" }, { "name": "net_test_btif_config_cache" }, { "name": "net_test_btif_hh" }, { "name": "net_test_btif_rc" }, { "name": "net_test_btif_stack" }, { "name": "net_test_btm_iso" }, { "name": "net_test_btpackets" }, { "name": "net_test_eatt" }, { "name": "net_test_hci_fragmenter_native" }, { "name": "net_test_main_shim" }, { "name": "net_test_osi" }, { "name": "net_test_performance" }, { "name": "net_test_stack_a2dp_native" }, { "name": "net_test_stack_acl" }, { "name": "net_test_stack_avdtp" }, { "name": "net_test_stack_btm" }, { "name": "net_test_stack_btu" }, { "name": "net_test_stack_gatt" }, { "name": "net_test_stack_gatt_native" }, { "name": "net_test_stack_gatt_sr_hash_native" }, { "name": "net_test_stack_hci" }, { "name": "net_test_stack_hid" }, { "name": "net_test_stack_l2cap" }, { "name": "net_test_stack_rfcomm" }, { "name": "net_test_stack_sdp" }, { "name": "net_test_stack_smp" }, { "name": "net_test_types" } ], "hwasan-presubmit": [ // android_test targets { "name": "CtsBluetoothTestCases" }, { "name": "BluetoothInstrumentationTests" }, //{ // "name": "GoogleBluetoothInstrumentationTests" //}, //{ // "name": "FrameworkBluetoothTests" //}, { "name": "ServiceBluetoothTests" }, // device only tests // Broken //{ // "name": "bluetooth-test-audio-hal-interface" //}, { "name": "net_test_audio_a2dp_hw" }, { "name": "net_test_audio_hearing_aid_hw" }, { "name": "net_test_bluetooth" }, { "name": "net_test_bta" }, { "name": "net_test_btif" }, { "name": "net_test_btif_hf_client_service" }, { "name": "net_test_btif_profile_queue" }, { "name": "net_test_device" }, { "name": "net_test_device_iot_config" }, { "name": "net_test_gatt_conn_multiplexing" }, { "name": "net_test_hci" }, { "name": "net_test_stack" }, { "name": "net_test_stack_a2dp_codecs_native" }, { "name": "net_test_stack_ad_parser" }, { "name": "net_test_stack_multi_adv" }, // go/a-unit-tests tests (unit_test: true) // Thoses test run on the host in the CI automatically. // Run the one that are available on the device on the // device as well { "name": "bluetooth_csis_test" }, { "name": "bluetooth_flatbuffer_tests" }, { "name": "bluetooth_groups_test" }, { "name": "bluetooth_has_test" }, { "name": "bluetooth_hh_test" }, { "name": "bluetooth_le_audio_client_test" }, // b/271319421 // { // "name": "bluetooth_le_audio_test" // }, { "name": "bluetooth_packet_parser_test" }, { "name": "bluetooth_test_broadcaster" }, { "name": "bluetooth_test_broadcaster_state_machine" }, { "name": "bluetooth_test_common" }, { "name": "bluetooth_test_gd_unit" }, { "name": "bluetooth_test_sdp" }, { "name": "bluetooth_vc_test" }, { "name": "bt_host_test_bta" }, { "name": "libaptx_enc_tests" }, { "name": "libaptxhd_enc_tests" }, { "name": "net_test_avrcp" }, { "name": "net_test_btcore" }, { "name": "net_test_btif_config_cache" }, { "name": "net_test_btif_hh" }, { "name": "net_test_btif_rc" }, { "name": "net_test_btif_stack" }, { "name": "net_test_btm_iso" }, { "name": "net_test_btpackets" }, { "name": "net_test_eatt" }, { "name": "net_test_hci_fragmenter_native" }, { "name": "net_test_main_shim" }, { "name": "net_test_osi" }, { "name": "net_test_performance" }, { "name": "net_test_stack_a2dp_native" }, { "name": "net_test_stack_acl" }, { "name": "net_test_stack_avdtp" }, { "name": "net_test_stack_btm" }, { "name": "net_test_stack_btu" }, { "name": "net_test_stack_gatt" }, { "name": "net_test_stack_gatt_native" }, { "name": "net_test_stack_gatt_sr_hash_native" }, { "name": "net_test_stack_hci" }, { "name": "net_test_stack_hid" }, { "name": "net_test_stack_l2cap" }, { "name": "net_test_stack_rfcomm" }, { "name": "net_test_stack_sdp" }, { "name": "net_test_stack_smp" }, { "name": "net_test_types" } ] }
android/app/Android.bp +1 −8 Original line number Diff line number Diff line Loading @@ -67,8 +67,8 @@ cc_library_shared { "packages/modules/Bluetooth/system/types", ], static_libs: [ "libbluetooth-types", "libbluetooth", "libbluetooth-types", "libbluetooth_core_rs", "libbluetooth_core_rs_bridge", "libc++fs", Loading Loading @@ -201,13 +201,6 @@ android_app { optimize: false, proguard_flags_files: ["proguard.flags"], }, required: [ "android.hardware.bluetooth.audio-V3-ndk", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", "android.hardware.bluetooth@1.0", "android.hardware.bluetooth@1.1", ], apex_available: [ "com.android.btservices", ], Loading
android/app/jni/com_android_bluetooth_avrcp_target.cpp +206 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,27 @@ static void volumeDeviceConnected( static void volumeDeviceDisconnected(const RawAddress& address); static void setVolume(int8_t volume); using ListPlayerSettingsCb = PlayerSettingsInterface::ListPlayerSettingsCallback; static void listPlayerSettings(ListPlayerSettingsCb cb); ListPlayerSettingsCb list_player_settings_cb; using ListPlayerSettingValuesCb = PlayerSettingsInterface::ListPlayerSettingValuesCallback; static void listPlayerSettingValues(PlayerAttribute setting, ListPlayerSettingValuesCb cb); ListPlayerSettingValuesCb list_player_setting_values_cb; using GetCurrentPlayerSettingValueCb = PlayerSettingsInterface::GetCurrentPlayerSettingValueCallback; static void getPlayerSettings(std::vector<PlayerAttribute> attributes, GetCurrentPlayerSettingValueCb cb); GetCurrentPlayerSettingValueCb get_current_player_setting_value_cb; using SetPlayerSettingValueCb = PlayerSettingsInterface::SetPlayerSettingValueCallback; static void setPlayerSettings(std::vector<PlayerAttribute> attributes, std::vector<uint8_t> values, SetPlayerSettingValueCb cb); SetPlayerSettingValueCb set_player_setting_value_cb; // Local Variables // TODO (apanicke): Use a map here to store the callback in order to // support multi-browsing Loading @@ -71,6 +92,18 @@ std::map<std::string, GetFolderItemsCb> get_folder_items_cb_map; std::map<RawAddress, ::bluetooth::avrcp::VolumeInterface::VolumeChangedCb> volumeCallbackMap; template <typename T> void copyJavaArraytoCppVector(JNIEnv* env, const jbyteArray& jArray, std::vector<T>& cVec) { size_t len = (size_t)env->GetArrayLength(jArray); if (len == 0) return; jbyte* elements = env->GetByteArrayElements(jArray, nullptr); T* array = reinterpret_cast<T*>(elements); cVec.reserve(len); std::copy(array, array + len, std::back_inserter(cVec)); env->ReleaseByteArrayElements(jArray, elements, 0); } // TODO (apanicke): In the future, this interface should guarantee that // all calls happen on the JNI Thread. Right now this is very difficult // as it is hard to get a handle on the JNI thread from here. Loading Loading @@ -150,6 +183,30 @@ class VolumeInterfaceImpl : public VolumeInterface { }; static VolumeInterfaceImpl mVolumeInterface; class PlayerSettingsInterfaceImpl : public PlayerSettingsInterface { public: void ListPlayerSettings(ListPlayerSettingsCallback cb) { listPlayerSettings(cb); } void ListPlayerSettingValues(PlayerAttribute setting, ListPlayerSettingValuesCallback cb) { listPlayerSettingValues(setting, cb); } void GetCurrentPlayerSettingValue(std::vector<PlayerAttribute> attributes, GetCurrentPlayerSettingValueCallback cb) { getPlayerSettings(attributes, cb); } void SetPlayerSettings(std::vector<PlayerAttribute> attributes, std::vector<uint8_t> values, SetPlayerSettingValueCallback cb) { setPlayerSettings(attributes, values, cb); } }; static PlayerSettingsInterfaceImpl mPlayerSettingsInterface; static jmethodID method_getCurrentSongInfo; static jmethodID method_getPlaybackStatus; static jmethodID method_sendMediaKeyEvent; Loading @@ -170,6 +227,11 @@ static jmethodID method_volumeDeviceDisconnected; static jmethodID method_setVolume; static jmethodID method_listPlayerSettings; static jmethodID method_listPlayerSettingValues; static jmethodID method_getPlayerSettings; static jmethodID method_setPlayerSettings; static void classInitNative(JNIEnv* env, jclass clazz) { method_getCurrentSongInfo = env->GetMethodID( clazz, "getCurrentSongInfo", "()Lcom/android/bluetooth/audio_util/Metadata;"); Loading Loading @@ -212,6 +274,18 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_setVolume = env->GetMethodID(clazz, "setVolume", "(I)V"); method_listPlayerSettings = env->GetMethodID(clazz, "listPlayerSettingsRequest", "()V"); method_listPlayerSettingValues = env->GetMethodID(clazz, "listPlayerSettingValuesRequest", "(B)V"); method_getPlayerSettings = env->GetMethodID(clazz, "getCurrentPlayerSettingValuesRequest", "([B)V"); method_setPlayerSettings = env->GetMethodID(clazz, "setPlayerSettingsRequest", "([B[B)V"); ALOGI("%s: AvrcpTargetJni initialized!", __func__); } Loading @@ -222,7 +296,8 @@ static void initNative(JNIEnv* env, jobject object) { mJavaInterface = env->NewGlobalRef(object); sServiceInterface = getBluetoothInterface()->get_avrcp_service(); sServiceInterface->Init(&mAvrcpInterface, &mVolumeInterface); sServiceInterface->Init(&mAvrcpInterface, &mVolumeInterface, &mPlayerSettingsInterface); } static void registerBipServerNative(JNIEnv* env, jobject object, Loading Loading @@ -900,6 +975,127 @@ static void setBipClientStatusNative(JNIEnv* env, jobject object, sServiceInterface->SetBipClientStatus(bdaddr, status); } // Called from native to list available player settings static void listPlayerSettings(ListPlayerSettingsCb cb) { ALOGD("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid() || !mJavaInterface) return; list_player_settings_cb = std::move(cb); sCallbackEnv->CallVoidMethod(mJavaInterface, method_listPlayerSettings); } static void listPlayerSettingsResponseNative(JNIEnv* env, jobject object, jbyteArray attributes) { ALOGD("%s", __func__); std::vector<PlayerAttribute> attributes_vector; copyJavaArraytoCppVector(env, attributes, attributes_vector); list_player_settings_cb.Run(std::move(attributes_vector)); } // Called from native to list available values for player setting static void listPlayerSettingValues(PlayerAttribute attribute, ListPlayerSettingValuesCb cb) { ALOGD("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid() || !mJavaInterface) return; list_player_setting_values_cb = std::move(cb); sCallbackEnv->CallVoidMethod(mJavaInterface, method_listPlayerSettingValues, (jbyte)attribute); } static void listPlayerSettingValuesResponseNative(JNIEnv* env, jobject object, jbyte attribute, jbyteArray values) { ALOGD("%s", __func__); PlayerAttribute player_attribute = static_cast<PlayerAttribute>(attribute); std::vector<uint8_t> values_vector; copyJavaArraytoCppVector(env, values, values_vector); list_player_setting_values_cb.Run(player_attribute, std::move(values_vector)); } // Called from native to get current player settings static void getPlayerSettings(std::vector<PlayerAttribute> attributes, GetCurrentPlayerSettingValueCb cb) { ALOGD("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid() || !mJavaInterface) return; jbyteArray attributes_array = sCallbackEnv->NewByteArray(attributes.size()); sCallbackEnv->SetByteArrayRegion( attributes_array, 0, attributes.size(), reinterpret_cast<const jbyte*>(attributes.data())); get_current_player_setting_value_cb = std::move(cb); sCallbackEnv->CallVoidMethod(mJavaInterface, method_getPlayerSettings, attributes_array); } static void getPlayerSettingsResponseNative(JNIEnv* env, jobject object, jbyteArray attributes, jbyteArray values) { ALOGD("%s", __func__); std::vector<PlayerAttribute> attributes_vector; std::vector<uint8_t> values_vector; copyJavaArraytoCppVector(env, attributes, attributes_vector); copyJavaArraytoCppVector(env, values, values_vector); get_current_player_setting_value_cb.Run(std::move(attributes_vector), std::move(values_vector)); } // Called from native to set current player settings static void setPlayerSettings(std::vector<PlayerAttribute> attributes, std::vector<uint8_t> values, SetPlayerSettingValueCb cb) { ALOGD("%s", __func__); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); if (!sCallbackEnv.valid() || !mJavaInterface) return; jbyteArray attributes_array = sCallbackEnv->NewByteArray(attributes.size()); sCallbackEnv->SetByteArrayRegion( attributes_array, 0, attributes.size(), reinterpret_cast<const jbyte*>(attributes.data())); jbyteArray values_array = sCallbackEnv->NewByteArray(values.size()); sCallbackEnv->SetByteArrayRegion( values_array, 0, values.size(), reinterpret_cast<const jbyte*>(values.data())); set_player_setting_value_cb = std::move(cb); sCallbackEnv->CallVoidMethod(mJavaInterface, method_setPlayerSettings, attributes_array, values_array); } static void setPlayerSettingsResponseNative(JNIEnv* env, jobject object, jboolean success) { ALOGD("%s", __func__); set_player_setting_value_cb.Run(success); } static void sendPlayerSettingsNative(JNIEnv* env, jobject object, jbyteArray attributes, jbyteArray values) { ALOGD("%s", __func__); std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex); if (mServiceCallbacks == nullptr) { ALOGW("%s: Service not loaded.", __func__); return; } std::vector<PlayerAttribute> attributes_vector; std::vector<uint8_t> values_vector; copyJavaArraytoCppVector(env, attributes, attributes_vector); copyJavaArraytoCppVector(env, values, values_vector); mServiceCallbacks->SendPlayerSettingsChanged(attributes_vector, values_vector); } static JNINativeMethod sMethods[] = { {"classInitNative", "()V", (void*)classInitNative}, {"initNative", "()V", (void*)initNative}, Loading @@ -920,6 +1116,15 @@ static JNINativeMethod sMethods[] = { (void*)sendVolumeChangedNative}, {"setBipClientStatusNative", "(Ljava/lang/String;Z)V", (void*)setBipClientStatusNative}, {"listPlayerSettingsResponseNative", "([B)V", (void*)listPlayerSettingsResponseNative}, {"listPlayerSettingValuesResponseNative", "(B[B)V", (void*)listPlayerSettingValuesResponseNative}, {"getPlayerSettingsResponseNative", "([B[B)V", (void*)getPlayerSettingsResponseNative}, {"setPlayerSettingsResponseNative", "(Z)V", (void*)setPlayerSettingsResponseNative}, {"sendPlayerSettingsNative", "([B[B)V", (void*)sendPlayerSettingsNative}, }; int register_com_android_bluetooth_avrcp_target(JNIEnv* env) { Loading
android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp +1 −14 Original line number Diff line number Diff line Loading @@ -41,19 +41,6 @@ extern bt_interface_t bluetoothInterface; namespace android { // Both // OOB_ADDRESS_SIZE is 6 bytes address + 1 byte address type #define OOB_ADDRESS_SIZE 7 #define OOB_C_SIZE 16 #define OOB_R_SIZE 16 #define OOB_NAME_MAX_SIZE 256 // Classic #define OOB_DATA_LEN_SIZE 2 #define OOB_COD_SIZE 3 // LE #define OOB_TK_SIZE 16 #define OOB_LE_FLAG_SIZE 1 #define OOB_LE_ROLE_SIZE 1 #define OOB_LE_APPEARANCE_SIZE 2 #define TRANSPORT_AUTO 0 #define TRANSPORT_BREDR 1 Loading Loading @@ -1274,7 +1261,7 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData, } oobDataLengthBytes = env->GetByteArrayElements(oobDataLength, NULL); memcpy(oob_data.oob_data_length, oobDataLengthBytes, len); memcpy(oob_data.oob_data_length, oobDataLengthBytes, OOB_DATA_LEN_SIZE); env->ReleaseByteArrayElements(oobDataLength, oobDataLengthBytes, 0); // Optional Loading
android/app/jni/com_android_bluetooth_gatt.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ #include "hardware/bt_gatt.h" #include "rust/cxx.h" #include "rust/src/gatt/ffi/gatt_shim.h" #include "src/core/ffi.rs.h" #include "src/gatt/ffi.rs.h" #include "utils/Log.h" #define info(fmt, ...) ALOGI("%s(L%d): " fmt, __func__, __LINE__, ##__VA_ARGS__) Loading Loading @@ -1393,10 +1392,6 @@ static void initializeNative(JNIEnv* env, jobject object) { JniDistanceMeasurementCallbacks::GetInstance()); mCallbacksObj = env->NewGlobalRef(object); auto callbacks = std::make_unique<bluetooth::gatt::GattServerCallbacks>( sGattServerCallbacks); bluetooth::rust_shim::init(std::move(callbacks)); } static void cleanupNative(JNIEnv* env, jobject object) { Loading