Loading android/app/src/com/android/bluetooth/btservice/BondStateMachine.java +4 −4 Original line number Diff line number Diff line Loading @@ -202,7 +202,7 @@ final class BondStateMachine extends StateMachine { Log.e( TAG, "In stable state, received invalid newState: " + state2str(newState)); + bondStateToString(newState)); } break; case BONDED_INTENT_DELAY: Loading Loading @@ -599,9 +599,9 @@ final class BondStateMachine extends StateMachine { "Bond State Change Intent:" + device + " " + state2str(oldState) + bondStateToString(oldState) + " => " + state2str(newState)); + bondStateToString(newState)); } void bondStateChangeCallback(int status, byte[] address, int newState, int hciReason) { Loading Loading @@ -803,7 +803,7 @@ final class BondStateMachine extends StateMachine { } } private String state2str(int state) { public static String bondStateToString(int state) { if (state == BluetoothDevice.BOND_NONE) { return "BOND_NONE"; } else if (state == BluetoothDevice.BOND_BONDING) { Loading android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +12 −2 Original line number Diff line number Diff line Loading @@ -1125,9 +1125,19 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { * @param uuids are the services supported by the remote device */ void onUuidsDiscovered(BluetoothDevice device, ParcelUuid[] uuids) { debugLog("onUuidsDiscovered: discovered services for device " + device); int bondState = mAdapterService.getBondState(device); debugLog( "onUuidsDiscovered: discovered services for device " + device + " (" + BondStateMachine.bondStateToString(bondState) + ")"); if (uuids != null) { if (!Flags.unbondedProfileForbidFix() || bondState != BluetoothDevice.BOND_NONE) { processInitProfilePriorities(device, uuids); } else { debugLog("Device in BOND_NONE state, won't connect profiles" + device); } } else { warnLog("onUuidsDiscovered: uuids is null for device " + device); } Loading flags/pairing.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -104,3 +104,13 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "transmit_smp_packets_before_release" namespace: "bluetooth" description: "Ensure that SMP packets are transmitted before SMP channel is released" bug: "357106628" metadata { purpose: PURPOSE_BUGFIX } } framework/tests/bumble/src/android/bluetooth/RfcommTest.kt +9 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.bluetooth import android.Manifest import android.content.Context import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry import com.android.compatibility.common.util.AdoptShellPermissionsRule import com.google.common.truth.Truth Loading @@ -30,14 +29,16 @@ import kotlinx.coroutines.* import kotlinx.coroutines.channels.* import org.junit.After import org.junit.Before import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 import pandora.RfcommProto import pandora.RfcommProto.ServerId import pandora.RfcommProto.StartServerRequest @RunWith(AndroidJUnit4::class) @RunWith(JUnit4::class) @kotlinx.coroutines.ExperimentalCoroutinesApi class RfcommTest { private val mContext = ApplicationProvider.getApplicationContext<Context>() Loading Loading @@ -77,16 +78,19 @@ class RfcommTest { } @Test @Ignore("b/355328584") fun clientConnectToOpenServerSocketBondedInsecure() { startServer { serverId -> createConnectAcceptSocket(isSecure = false, serverId) } } @Test @Ignore("b/355328584") fun clientConnectToOpenServerSocketBondedSecure() { startServer { serverId -> createConnectAcceptSocket(isSecure = true, serverId) } } @Test @Ignore("b/355328584") fun clientSendDataOverInsecureSocket() { startServer { serverId -> val (insecureSocket, connection) = createConnectAcceptSocket(isSecure = false, serverId) Loading @@ -104,6 +108,7 @@ class RfcommTest { } @Test @Ignore("b/355328584") fun clientSendDataOverSecureSocket() { startServer { serverId -> val (secureSocket, connection) = createConnectAcceptSocket(isSecure = true, serverId) Loading @@ -121,6 +126,7 @@ class RfcommTest { } @Test @Ignore("b/355328584") fun clientReceiveDataOverInsecureSocket() { startServer { serverId -> val (insecureSocket, connection) = createConnectAcceptSocket(isSecure = false, serverId) Loading @@ -139,6 +145,7 @@ class RfcommTest { } @Test @Ignore("b/355328584") fun clientReceiveDataOverSecureSocket() { startServer { serverId -> val (secureSocket, connection) = createConnectAcceptSocket(isSecure = true, serverId) Loading system/audio_hal_interface/aidl/client_interface_aidl.cc +41 −28 Original line number Diff line number Diff line Loading @@ -16,17 +16,22 @@ #define LOG_TAG "BTAudioClientAIDL" #include "client_interface_aidl.h" #include "aidl/client_interface_aidl.h" #include <android/binder_manager.h> #include <bluetooth/log.h> #include <com_android_bluetooth_flags.h> #include <memory> #include <set> #include <thread> #include <utility> #include <vector> #include "bta/ag/bta_ag_int.h" const uint8_t kFetchAudioProviderRetryNumber = 3; namespace bluetooth { namespace audio { namespace aidl { Loading Loading @@ -174,6 +179,10 @@ void BluetoothAudioClientInterface::FetchAudioProvider() { if (provider_ != nullptr) { log::warn("refetch"); } // Retry if audioserver restarts in the middle of fetching. // When audioserver restarts, IBluetoothAudioProviderFactory service is also // re-registered, so we need to re-fetch the service. for (int retry_no = 0; retry_no < kFetchAudioProviderRetryNumber; ++retry_no) { auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(::ndk::SpAIBinder( AServiceManager_waitForService(kDefaultAudioProviderFactoryInterface.c_str()))); Loading @@ -200,16 +209,20 @@ void BluetoothAudioClientInterface::FetchAudioProvider() { aidl_retval = provider_factory->openProvider(transport_->GetSessionType(), &provider_); if (!aidl_retval.isOk()) { log::fatal("BluetoothAudioHal::openProvider failure: {}", aidl_retval.getDescription()); log::error("BluetoothAudioHal::openProvider failure: {}, retry number {}", aidl_retval.getDescription(), retry_no + 1); } else { provider_factory_ = std::move(provider_factory); break; } } log::assert_that(provider_ != nullptr, "assert failed: provider_ != nullptr"); binder_status_t binder_status = AIBinder_linkToDeath(provider_factory->asBinder().get(), death_recipient_.get(), this); AIBinder_linkToDeath(provider_factory_->asBinder().get(), death_recipient_.get(), this); if (binder_status != STATUS_OK) { log::error("Failed to linkToDeath {}", static_cast<int>(binder_status)); } provider_factory_ = std::move(provider_factory); log::info("IBluetoothAudioProvidersFactory::openProvider() returned {}{}", fmt::ptr(provider_.get()), (provider_->isRemote() ? " (remote)" : " (local)")); Loading Loading @@ -524,7 +537,7 @@ size_t BluetoothAudioSinkClientInterface::ReadAudioData(uint8_t* p_buf, uint32_t if (avail_to_read > len - total_read) { avail_to_read = len - total_read; } if (data_mq_->read((MqDataType*)p_buf + total_read, avail_to_read) == 0) { if (data_mq_->read(reinterpret_cast<MqDataType*>(p_buf) + total_read, avail_to_read) == 0) { log::warn("len={} total_read={} failed", len, total_read); break; } Loading Loading
android/app/src/com/android/bluetooth/btservice/BondStateMachine.java +4 −4 Original line number Diff line number Diff line Loading @@ -202,7 +202,7 @@ final class BondStateMachine extends StateMachine { Log.e( TAG, "In stable state, received invalid newState: " + state2str(newState)); + bondStateToString(newState)); } break; case BONDED_INTENT_DELAY: Loading Loading @@ -599,9 +599,9 @@ final class BondStateMachine extends StateMachine { "Bond State Change Intent:" + device + " " + state2str(oldState) + bondStateToString(oldState) + " => " + state2str(newState)); + bondStateToString(newState)); } void bondStateChangeCallback(int status, byte[] address, int newState, int hciReason) { Loading Loading @@ -803,7 +803,7 @@ final class BondStateMachine extends StateMachine { } } private String state2str(int state) { public static String bondStateToString(int state) { if (state == BluetoothDevice.BOND_NONE) { return "BOND_NONE"; } else if (state == BluetoothDevice.BOND_BONDING) { Loading
android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +12 −2 Original line number Diff line number Diff line Loading @@ -1125,9 +1125,19 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { * @param uuids are the services supported by the remote device */ void onUuidsDiscovered(BluetoothDevice device, ParcelUuid[] uuids) { debugLog("onUuidsDiscovered: discovered services for device " + device); int bondState = mAdapterService.getBondState(device); debugLog( "onUuidsDiscovered: discovered services for device " + device + " (" + BondStateMachine.bondStateToString(bondState) + ")"); if (uuids != null) { if (!Flags.unbondedProfileForbidFix() || bondState != BluetoothDevice.BOND_NONE) { processInitProfilePriorities(device, uuids); } else { debugLog("Device in BOND_NONE state, won't connect profiles" + device); } } else { warnLog("onUuidsDiscovered: uuids is null for device " + device); } Loading
flags/pairing.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -104,3 +104,13 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "transmit_smp_packets_before_release" namespace: "bluetooth" description: "Ensure that SMP packets are transmitted before SMP channel is released" bug: "357106628" metadata { purpose: PURPOSE_BUGFIX } }
framework/tests/bumble/src/android/bluetooth/RfcommTest.kt +9 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.bluetooth import android.Manifest import android.content.Context import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry import com.android.compatibility.common.util.AdoptShellPermissionsRule import com.google.common.truth.Truth Loading @@ -30,14 +29,16 @@ import kotlinx.coroutines.* import kotlinx.coroutines.channels.* import org.junit.After import org.junit.Before import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 import pandora.RfcommProto import pandora.RfcommProto.ServerId import pandora.RfcommProto.StartServerRequest @RunWith(AndroidJUnit4::class) @RunWith(JUnit4::class) @kotlinx.coroutines.ExperimentalCoroutinesApi class RfcommTest { private val mContext = ApplicationProvider.getApplicationContext<Context>() Loading Loading @@ -77,16 +78,19 @@ class RfcommTest { } @Test @Ignore("b/355328584") fun clientConnectToOpenServerSocketBondedInsecure() { startServer { serverId -> createConnectAcceptSocket(isSecure = false, serverId) } } @Test @Ignore("b/355328584") fun clientConnectToOpenServerSocketBondedSecure() { startServer { serverId -> createConnectAcceptSocket(isSecure = true, serverId) } } @Test @Ignore("b/355328584") fun clientSendDataOverInsecureSocket() { startServer { serverId -> val (insecureSocket, connection) = createConnectAcceptSocket(isSecure = false, serverId) Loading @@ -104,6 +108,7 @@ class RfcommTest { } @Test @Ignore("b/355328584") fun clientSendDataOverSecureSocket() { startServer { serverId -> val (secureSocket, connection) = createConnectAcceptSocket(isSecure = true, serverId) Loading @@ -121,6 +126,7 @@ class RfcommTest { } @Test @Ignore("b/355328584") fun clientReceiveDataOverInsecureSocket() { startServer { serverId -> val (insecureSocket, connection) = createConnectAcceptSocket(isSecure = false, serverId) Loading @@ -139,6 +145,7 @@ class RfcommTest { } @Test @Ignore("b/355328584") fun clientReceiveDataOverSecureSocket() { startServer { serverId -> val (secureSocket, connection) = createConnectAcceptSocket(isSecure = true, serverId) Loading
system/audio_hal_interface/aidl/client_interface_aidl.cc +41 −28 Original line number Diff line number Diff line Loading @@ -16,17 +16,22 @@ #define LOG_TAG "BTAudioClientAIDL" #include "client_interface_aidl.h" #include "aidl/client_interface_aidl.h" #include <android/binder_manager.h> #include <bluetooth/log.h> #include <com_android_bluetooth_flags.h> #include <memory> #include <set> #include <thread> #include <utility> #include <vector> #include "bta/ag/bta_ag_int.h" const uint8_t kFetchAudioProviderRetryNumber = 3; namespace bluetooth { namespace audio { namespace aidl { Loading Loading @@ -174,6 +179,10 @@ void BluetoothAudioClientInterface::FetchAudioProvider() { if (provider_ != nullptr) { log::warn("refetch"); } // Retry if audioserver restarts in the middle of fetching. // When audioserver restarts, IBluetoothAudioProviderFactory service is also // re-registered, so we need to re-fetch the service. for (int retry_no = 0; retry_no < kFetchAudioProviderRetryNumber; ++retry_no) { auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(::ndk::SpAIBinder( AServiceManager_waitForService(kDefaultAudioProviderFactoryInterface.c_str()))); Loading @@ -200,16 +209,20 @@ void BluetoothAudioClientInterface::FetchAudioProvider() { aidl_retval = provider_factory->openProvider(transport_->GetSessionType(), &provider_); if (!aidl_retval.isOk()) { log::fatal("BluetoothAudioHal::openProvider failure: {}", aidl_retval.getDescription()); log::error("BluetoothAudioHal::openProvider failure: {}, retry number {}", aidl_retval.getDescription(), retry_no + 1); } else { provider_factory_ = std::move(provider_factory); break; } } log::assert_that(provider_ != nullptr, "assert failed: provider_ != nullptr"); binder_status_t binder_status = AIBinder_linkToDeath(provider_factory->asBinder().get(), death_recipient_.get(), this); AIBinder_linkToDeath(provider_factory_->asBinder().get(), death_recipient_.get(), this); if (binder_status != STATUS_OK) { log::error("Failed to linkToDeath {}", static_cast<int>(binder_status)); } provider_factory_ = std::move(provider_factory); log::info("IBluetoothAudioProvidersFactory::openProvider() returned {}{}", fmt::ptr(provider_.get()), (provider_->isRemote() ? " (remote)" : " (local)")); Loading Loading @@ -524,7 +537,7 @@ size_t BluetoothAudioSinkClientInterface::ReadAudioData(uint8_t* p_buf, uint32_t if (avail_to_read > len - total_read) { avail_to_read = len - total_read; } if (data_mq_->read((MqDataType*)p_buf + total_read, avail_to_read) == 0) { if (data_mq_->read(reinterpret_cast<MqDataType*>(p_buf) + total_read, avail_to_read) == 0) { log::warn("len={} total_read={} failed", len, total_read); break; } Loading