diff options
author | 2025-03-20 16:33:19 -0700 | |
---|---|---|
committer | 2025-03-20 16:33:19 -0700 | |
commit | d3d6319c49935ac46de7adabfbff35f5c7ec66c7 (patch) | |
tree | d7255ec4e015dab75d78763dd786436953595cba | |
parent | c62de3fc6be9e43a569f09eda405da9440163979 (diff) | |
parent | 3201950c76d10806bc93b3e720ad756e3bf3ee67 (diff) |
Snap for 13248265 from 3201950c76d10806bc93b3e720ad756e3bf3ee67 to 25Q2-release
Change-Id: I983f5c2cf784be45b86880621e1dc0c552f60621
-rw-r--r-- | android/app/res/values-as/strings.xml | 8 | ||||
-rw-r--r-- | android/app/src/com/android/bluetooth/btservice/AdapterService.java | 15 | ||||
-rw-r--r-- | android/app/src/com/android/bluetooth/gatt/GattService.java | 19 | ||||
-rw-r--r-- | flags/connectivity.aconfig | 24 | ||||
-rw-r--r-- | flags/gap.aconfig | 20 | ||||
-rw-r--r-- | flags/hfp.aconfig | 10 | ||||
-rw-r--r-- | framework/tests/bumble/src/android/bluetooth/hid/HidHeadTrackerTest.java | 9 | ||||
-rw-r--r-- | framework/tests/bumble/src/android/bluetooth/hid/HidHostDualModeTest.java | 6 | ||||
-rw-r--r-- | system/bta/le_audio/state_machine.cc | 14 | ||||
-rw-r--r-- | system/gd/hci/acl_manager/le_impl.h | 15 | ||||
-rw-r--r-- | system/gd/hci/acl_manager/le_impl_test.cc | 303 | ||||
-rw-r--r-- | system/stack/eatt/eatt_impl.h | 6 | ||||
-rw-r--r-- | system/stack/gatt/gatt_main.cc | 2 | ||||
-rw-r--r-- | system/stack/test/eatt/eatt_test.cc | 1 |
14 files changed, 181 insertions, 271 deletions
diff --git a/android/app/res/values-as/strings.xml b/android/app/res/values-as/strings.xml index 2776941946..c53ee123e2 100644 --- a/android/app/res/values-as/strings.xml +++ b/android/app/res/values-as/strings.xml @@ -35,7 +35,7 @@ <string name="incoming_file_confirm_content" msgid="6573502088511901157">"অন্তৰ্গামী ফাইল গ্ৰহণ কৰিবনে?"</string> <string name="incoming_file_confirm_cancel" msgid="9205906062663982692">"প্ৰত্যাখ্যান কৰক"</string> <string name="incoming_file_confirm_ok" msgid="5046926299036238623">"গ্ৰহণ কৰক"</string> - <string name="incoming_file_confirm_timeout_ok" msgid="8612187577686515660">"ঠিক"</string> + <string name="incoming_file_confirm_timeout_ok" msgid="8612187577686515660">"ঠিক আছে"</string> <string name="incoming_file_confirm_timeout_content" msgid="3221412098281076974">"\"<xliff:g id="SENDER">%1$s</xliff:g>\"ৰ পৰা লাভ কৰা ফাইলটো গ্ৰহণ কৰোঁতে সময় ওকলিছে"</string> <string name="incoming_file_confirm_Notification_title" msgid="5381395500920804895">"অন্তৰ্গামী ফাইল"</string> <string name="incoming_file_confirm_Notification_content" msgid="2669135531488877921">"<xliff:g id="SENDER">%1$s</xliff:g> এটা ফাইল পঠিয়াবলৈ সাজু: <xliff:g id="FILE">%2$s</xliff:g>"</string> @@ -58,18 +58,18 @@ <string name="download_fail_line1" msgid="3149552664349685007">"ফাইল লাভ কৰা নহ\'ল"</string> <string name="download_fail_line2" msgid="4289018531070750414">"ফাইল: <xliff:g id="FILE">%1$s</xliff:g>"</string> <string name="download_fail_line3" msgid="2214989413171231684">"কাৰণ: <xliff:g id="REASON">%1$s</xliff:g>"</string> - <string name="download_fail_ok" msgid="3272322648250767032">"ঠিক"</string> + <string name="download_fail_ok" msgid="3272322648250767032">"ঠিক আছে"</string> <string name="download_succ_line5" msgid="1720346308221503270">"ফাইল লাভ কৰা হ’ল"</string> <string name="download_succ_ok" msgid="7488662808922799824">"খোলক"</string> <string name="upload_line1" msgid="1912803923255989287">"প্ৰতি: \"<xliff:g id="RECIPIENT">%1$s</xliff:g>\""</string> <string name="upload_line3" msgid="5964902647036741603">"ফাইলৰ প্ৰকাৰ: <xliff:g id="TYPE">%1$s</xliff:g> (<xliff:g id="SIZE">%2$s</xliff:g>)"</string> <string name="upload_line5" msgid="3477751464103201364">"ফাইল প্ৰেৰণ কৰি থকা হৈছে…"</string> <string name="upload_succ_line5" msgid="165979135931118211">"ফাইল প্ৰেৰণ কৰা হ’ল"</string> - <string name="upload_succ_ok" msgid="6797291708604959167">"ঠিক"</string> + <string name="upload_succ_ok" msgid="6797291708604959167">"ঠিক আছে"</string> <string name="upload_fail_line1" msgid="7044307783071776426">"\"<xliff:g id="RECIPIENT">%1$s</xliff:g>\"লৈ ফাইলটো পঠিয়াব পৰা নগ\'ল।"</string> <string name="upload_fail_line1_2" msgid="6102642590057711459">"ফাইল: <xliff:g id="FILE">%1$s</xliff:g>"</string> <string name="upload_fail_cancel" msgid="1632528037932779727">"বন্ধ কৰক"</string> - <string name="bt_error_btn_ok" msgid="2802751202009957372">"ঠিক"</string> + <string name="bt_error_btn_ok" msgid="2802751202009957372">"ঠিক আছে"</string> <string name="unknown_file" msgid="3719981572107052685">"অজ্ঞাত ফাইল"</string> <string name="unknown_file_desc" msgid="9185609398960437760">"এইধৰণৰ ফাইল পৰিচালনা কৰিবলৈ কোনো এপ্ নাই। \n"</string> <string name="not_exist_file" msgid="5097565588949092486">"কোনো ফাইল নাই"</string> diff --git a/android/app/src/com/android/bluetooth/btservice/AdapterService.java b/android/app/src/com/android/bluetooth/btservice/AdapterService.java index e9202c4f6c..182e75cceb 100644 --- a/android/app/src/com/android/bluetooth/btservice/AdapterService.java +++ b/android/app/src/com/android/bluetooth/btservice/AdapterService.java @@ -3106,16 +3106,13 @@ public class AdapterService extends Service { public int getConnectionState(BluetoothDevice device) { final String address = device.getAddress(); - if (Flags.apiGetConnectionStateUsingIdentityAddress()) { - int connectionState = mNativeInterface.getConnectionState(getBytesFromAddress(address)); - final String identityAddress = getIdentityAddress(address); - if (identityAddress != null) { - connectionState |= - mNativeInterface.getConnectionState(getBytesFromAddress(identityAddress)); - } - return connectionState; + int connectionState = mNativeInterface.getConnectionState(getBytesFromAddress(address)); + final String identityAddress = getIdentityAddress(address); + if (identityAddress != null) { + connectionState |= + mNativeInterface.getConnectionState(getBytesFromAddress(identityAddress)); } - return mNativeInterface.getConnectionState(getBytesFromAddress(address)); + return connectionState; } int getConnectionHandle(BluetoothDevice device, int transport) { diff --git a/android/app/src/com/android/bluetooth/gatt/GattService.java b/android/app/src/com/android/bluetooth/gatt/GattService.java index bc5aeb3367..10190b09ef 100644 --- a/android/app/src/com/android/bluetooth/gatt/GattService.java +++ b/android/app/src/com/android/bluetooth/gatt/GattService.java @@ -2319,21 +2319,14 @@ public class GattService extends ProfileService { int handle = 0; Integer connId = 0; - if (!Flags.gattServerRequestsFix()) { - HandleMap.Entry entry = mHandleMap.getByRequestId(requestId); - if (entry != null) { - handle = entry.mHandle; - } - connId = mServerMap.connIdByAddress(serverIf, address); + HandleMap.RequestData requestData = mHandleMap.getRequestDataByRequestId(requestId); + if (requestData != null) { + handle = requestData.handle(); + connId = requestData.connId(); } else { - HandleMap.RequestData requestData = mHandleMap.getRequestDataByRequestId(requestId); - if (requestData != null) { - handle = requestData.handle(); - connId = requestData.connId(); - } else { - connId = mServerMap.connIdByAddress(serverIf, address); - } + connId = mServerMap.connIdByAddress(serverIf, address); } + mNativeInterface.gattServerSendResponse( serverIf, connId != null ? connId : 0, diff --git a/flags/connectivity.aconfig b/flags/connectivity.aconfig index 482c7e68e8..738c294078 100644 --- a/flags/connectivity.aconfig +++ b/flags/connectivity.aconfig @@ -2,30 +2,6 @@ package: "com.android.bluetooth.flags" container: "com.android.bt" flag { - name: "api_get_connection_state_using_identity_address" - namespace: "bluetooth" - description: "Use identity address to check current connection state" - bug: "319471537" -} - -flag { - name: "use_le_shim_connection_map_guard" - namespace: "bluetooth" - description: "Guard the le shim connection map with a mutex" - bug: "302054609" -} - -flag { - name: "improve_create_connection_for_already_connecting_device" - namespace: "bluetooth" - description: "Make sure to not stop controller with create connection cancel when not needed" - bug: "356593752" - metadata { - purpose: PURPOSE_BUGFIX - } -} - -flag { name: "allow_gatt_connect_from_the_apps_without_making_leaudio_device_active" namespace: "bluetooth" description: "Allows for GATT connection without making LeAudio device active after connection" diff --git a/flags/gap.aconfig b/flags/gap.aconfig index 8e7d9c99ac..9dcdcd4b2b 100644 --- a/flags/gap.aconfig +++ b/flags/gap.aconfig @@ -70,26 +70,6 @@ flag { } flag { - name: "gatt_disconnect_fix" - namespace: "bluetooth" - description: "Fix GATT disconnect handling" - bug: "361538527" - metadata { - purpose: PURPOSE_BUGFIX - } -} - -flag { - name: "gatt_server_requests_fix" - namespace: "bluetooth" - description: "Fix GATT server handling" - bug: "361331170" - metadata { - purpose: PURPOSE_BUGFIX - } -} - -flag { name: "le_scan_msft_support" namespace: "bluetooth" description: "Support MSFT HCI extension for LE Scanning. go/bt-msft-aosp-dd" diff --git a/flags/hfp.aconfig b/flags/hfp.aconfig index c1611242aa..9e3bd50b5d 100644 --- a/flags/hfp.aconfig +++ b/flags/hfp.aconfig @@ -132,3 +132,13 @@ flag { purpose: PURPOSE_BUGFIX } } + +flag { + name: "hfp_volume_control_property" + namespace: "bluetooth" + description: "Check system property before hands-free volume UI request." + bug: "404152232" + metadata { + purpose: PURPOSE_BUGFIX + } +} diff --git a/framework/tests/bumble/src/android/bluetooth/hid/HidHeadTrackerTest.java b/framework/tests/bumble/src/android/bluetooth/hid/HidHeadTrackerTest.java index 38527362ba..3df5075936 100644 --- a/framework/tests/bumble/src/android/bluetooth/hid/HidHeadTrackerTest.java +++ b/framework/tests/bumble/src/android/bluetooth/hid/HidHeadTrackerTest.java @@ -64,6 +64,7 @@ import android.util.Log; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.platform.app.InstrumentationRegistry; +import com.android.bluetooth.flags.Flags; import com.android.compatibility.common.util.AdoptShellPermissionsRule; import org.hamcrest.CustomTypeSafeMatcher; @@ -353,6 +354,7 @@ public class HidHeadTrackerTest { BluetoothDevice.ACTION_UUID, BluetoothDevice.ACTION_ACL_CONNECTED, BluetoothDevice.ACTION_ACL_DISCONNECTED, + BluetoothHidHost.ACTION_CONNECTION_STATE_CHANGED, BluetoothDevice.ACTION_FOUND); } @@ -405,6 +407,7 @@ public class HidHeadTrackerTest { unregisterIntentActions( BluetoothDevice.ACTION_UUID, BluetoothDevice.ACTION_ACL_CONNECTED, + BluetoothHidHost.ACTION_CONNECTION_STATE_CHANGED, BluetoothDevice.ACTION_FOUND); } @@ -490,8 +493,10 @@ public class HidHeadTrackerTest { */ private void verifyTransportSwitch(BluetoothDevice device, int fromTransport, int toTransport) { assertThat(fromTransport).isNotEqualTo(toTransport); - verifyConnectionState(mBumbleDevice, equalTo(fromTransport), equalTo(STATE_DISCONNECTING)); - + if (!Flags.ignoreUnselectedHidTransportStates()) { + verifyConnectionState( + mBumbleDevice, equalTo(fromTransport), equalTo(STATE_DISCONNECTING)); + } // Capture the next intent with filter // Filter is necessary as otherwise it will corrupt all other unordered verifications final Intent[] savedIntent = {null}; diff --git a/framework/tests/bumble/src/android/bluetooth/hid/HidHostDualModeTest.java b/framework/tests/bumble/src/android/bluetooth/hid/HidHostDualModeTest.java index fb89c738ad..45c329e460 100644 --- a/framework/tests/bumble/src/android/bluetooth/hid/HidHostDualModeTest.java +++ b/framework/tests/bumble/src/android/bluetooth/hid/HidHostDualModeTest.java @@ -66,6 +66,7 @@ import android.util.Log; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.platform.app.InstrumentationRegistry; +import com.android.bluetooth.flags.Flags; import com.android.compatibility.common.util.AdoptShellPermissionsRule; import org.hamcrest.CustomTypeSafeMatcher; @@ -503,8 +504,9 @@ public class HidHostDualModeTest { */ private void verifyTransportSwitch(BluetoothDevice device, int fromTransport, int toTransport) { assertThat(fromTransport).isNotEqualTo(toTransport); - verifyConnectionState(mDevice, equalTo(fromTransport), equalTo(STATE_DISCONNECTING)); - + if (!Flags.ignoreUnselectedHidTransportStates()) { + verifyConnectionState(mDevice, equalTo(fromTransport), equalTo(STATE_DISCONNECTING)); + } // Capture the next intent with filter // Filter is necessary as otherwise it will corrupt all other unordered verifications final Intent[] savedIntent = {null}; diff --git a/system/bta/le_audio/state_machine.cc b/system/bta/le_audio/state_machine.cc index e5ce67cf9d..b3f20fba39 100644 --- a/system/bta/le_audio/state_machine.cc +++ b/system/bta/le_audio/state_machine.cc @@ -681,8 +681,16 @@ public: kLogHciEvent, group->group_id_, leAudioDevice->address_, kLogSetDataPathOp + "cis_h:" + loghex(conn_handle) + " STATUS=" + loghex(status)); + /* Find ASE and later update state for the given cis.*/ + auto ase = leAudioDevice->GetFirstActiveAseByCisAndDataPathState(CisState::CONNECTED, + DataPathState::CONFIGURING); + if (status) { - log::error("failed to setup data path"); + log::error("Failed to setup data path for {}, cis handle: {:#x}, error: {:#x}", + leAudioDevice->address_, conn_handle, status); + if (ase && ase->cis_conn_hdl == conn_handle) { + ase->data_path_state = DataPathState::IDLE; + } StopStream(group); return; @@ -696,10 +704,6 @@ public: return; } - /* Update state for the given cis.*/ - auto ase = leAudioDevice->GetFirstActiveAseByCisAndDataPathState(CisState::CONNECTED, - DataPathState::CONFIGURING); - if (!ase || ase->cis_conn_hdl != conn_handle) { log::error("Cannot find ase by handle {}", conn_handle); return; diff --git a/system/gd/hci/acl_manager/le_impl.h b/system/gd/hci/acl_manager/le_impl.h index ef5bfb0d7d..122f76525e 100644 --- a/system/gd/hci/acl_manager/le_impl.h +++ b/system/gd/hci/acl_manager/le_impl.h @@ -1063,15 +1063,12 @@ public: add_device_to_accept_list(address_with_type); } - if (com::android::bluetooth::flags:: - improve_create_connection_for_already_connecting_device()) { - bool in_accept_list_due_to_direct_connect = - direct_connections_.find(address_with_type) != direct_connections_.end(); - - if (already_in_accept_list && (in_accept_list_due_to_direct_connect || !is_direct)) { - log::info("Device {} already in accept list. Stop here.", address_with_type); - return; - } + bool in_accept_list_due_to_direct_connect = + direct_connections_.find(address_with_type) != direct_connections_.end(); + + if (already_in_accept_list && (in_accept_list_due_to_direct_connect || !is_direct)) { + log::info("Device {} already in accept list. Stop here.", address_with_type); + return; } if (is_direct) { diff --git a/system/gd/hci/acl_manager/le_impl_test.cc b/system/gd/hci/acl_manager/le_impl_test.cc index 274b6827c9..f54d316d30 100644 --- a/system/gd/hci/acl_manager/le_impl_test.cc +++ b/system/gd/hci/acl_manager/le_impl_test.cc @@ -284,164 +284,6 @@ protected: hci_layer_->IncomingEvent(LeSetRandomAddressCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); } - void test_direct_connection_after_background_connection() { - set_random_device_address_policy(); - - hci::AddressWithType address({0x21, 0x22, 0x23, 0x24, 0x25, 0x26}, - AddressType::PUBLIC_DEVICE_ADDRESS); - - // arrange: Create background connection. Remember that acl_manager adds device background list - le_impl_->add_device_to_background_connection_list(address); - le_impl_->create_le_connection(address, true, /* is_direct */ false); - hci_layer_->GetCommand(OpCode::LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST); - hci_layer_->IncomingEvent( - LeAddDeviceToFilterAcceptListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); - auto raw_bg_create_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION); - hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01)); - sync_handler(); - - // act: Create direct connection - le_impl_->create_le_connection(address, true, /* is_direct */ true); - auto cancel_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION_CANCEL); - if (cancel_connection.IsValid()) { - hci_layer_->IncomingEvent( - LeCreateConnectionCancelCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); - hci_layer_->IncomingLeMetaEvent(LeConnectionCompleteBuilder::Create( - ErrorCode::UNKNOWN_CONNECTION, kHciHandle, Role::CENTRAL, - AddressType::PUBLIC_DEVICE_ADDRESS, Address::kEmpty, 0x0000, 0x0000, 0x0000, - ClockAccuracy::PPM_30)); - } - auto raw_direct_create_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION); - - // assert - auto bg_create_connection = - LeCreateConnectionView::Create(LeConnectionManagementCommandView::Create( - AclCommandView::Create(raw_bg_create_connection))); - EXPECT_TRUE(bg_create_connection.IsValid()); - auto direct_create_connection = - LeCreateConnectionView::Create(LeConnectionManagementCommandView::Create( - AclCommandView::Create(raw_direct_create_connection))); - EXPECT_TRUE(direct_create_connection.IsValid()); - log::info("Scan Interval {}", direct_create_connection.GetLeScanInterval()); - ASSERT_NE(direct_create_connection.GetLeScanInterval(), - bg_create_connection.GetLeScanInterval()); - - hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01)); - sync_handler(); - - // Check state is ARMED - ASSERT_EQ(ConnectabilityState::ARMED, le_impl_->connectability_state_); - - // Simulate timeout on direct connect. Verify background connect is still in place - EXPECT_CALL(mock_le_connection_callbacks_, - OnLeConnectFail(_, ErrorCode::CONNECTION_ACCEPT_TIMEOUT)) - .Times(1); - le_impl_->on_create_connection_timeout(address); - sync_handler(); - cancel_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION_CANCEL); - hci_layer_->IncomingEvent( - LeCreateConnectionCancelCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); - hci_layer_->IncomingLeMetaEvent(LeConnectionCompleteBuilder::Create( - ErrorCode::UNKNOWN_CONNECTION, kHciHandle, Role::CENTRAL, - AddressType::PUBLIC_DEVICE_ADDRESS, Address::kEmpty, 0x0000, 0x0000, 0x0000, - ClockAccuracy::PPM_30)); - EXPECT_TRUE(cancel_connection.IsValid()); - raw_bg_create_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION); - bg_create_connection = LeCreateConnectionView::Create(LeConnectionManagementCommandView::Create( - AclCommandView::Create(raw_bg_create_connection))); - EXPECT_TRUE(bg_create_connection.IsValid()); - sync_handler(); - ASSERT_TRUE(le_impl_->create_connection_timeout_alarms_.empty()); - - hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01)); - sync_handler(); - - // Check state is ARMED - ASSERT_EQ(ConnectabilityState::ARMED, le_impl_->connectability_state_); - } - - void test_direct_connect_after_direct_connect() { - set_random_device_address_policy(); - - hci::AddressWithType address({0x21, 0x22, 0x23, 0x24, 0x25, 0x26}, - AddressType::PUBLIC_DEVICE_ADDRESS); - - // Create first direct connection - le_impl_->create_le_connection(address, true, /* is_direct */ true); - hci_layer_->GetCommand(OpCode::LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST); - hci_layer_->IncomingEvent( - LeAddDeviceToFilterAcceptListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); - auto raw_direct_1_create_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION); - hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01)); - sync_handler(); - - // Check state is ARMED - ASSERT_EQ(ConnectabilityState::ARMED, le_impl_->connectability_state_); - - // assert - auto direct_1_create_connection = - LeCreateConnectionView::Create(LeConnectionManagementCommandView::Create( - AclCommandView::Create(raw_direct_1_create_connection))); - EXPECT_TRUE(direct_1_create_connection.IsValid()); - - log::info("Second direct connect to the same device"); - - // Create second direct connection - le_impl_->create_le_connection(address, true, /* is_direct */ true); - sync_handler(); - - CommandView cancel_connection = CommandView::Create( - PacketView<packet::kLittleEndian>(std::make_shared<std::vector<uint8_t>>())); - - if (!com::android::bluetooth::flags:: - improve_create_connection_for_already_connecting_device()) { - cancel_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION_CANCEL); - if (cancel_connection.IsValid()) { - hci_layer_->IncomingEvent( - LeCreateConnectionCancelCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); - hci_layer_->IncomingLeMetaEvent(LeConnectionCompleteBuilder::Create( - ErrorCode::UNKNOWN_CONNECTION, kHciHandle, Role::CENTRAL, - AddressType::PUBLIC_DEVICE_ADDRESS, Address::kEmpty, 0x0000, 0x0000, 0x0000, - ClockAccuracy::PPM_30)); - } - - auto raw_direct_2_create_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION); - - auto direct_2_create_connection = - LeCreateConnectionView::Create(LeConnectionManagementCommandView::Create( - AclCommandView::Create(raw_direct_2_create_connection))); - EXPECT_TRUE(direct_2_create_connection.IsValid()); - hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01)); - sync_handler(); - } else { - hci_layer_->AssertNoQueuedCommand(); - } - - log::info("Simulate timeout"); - - EXPECT_CALL(mock_le_connection_callbacks_, - OnLeConnectFail(_, ErrorCode::CONNECTION_ACCEPT_TIMEOUT)) - .Times(1); - le_impl_->on_create_connection_timeout(address); - sync_handler(); - cancel_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION_CANCEL); - EXPECT_TRUE(cancel_connection.IsValid()); - hci_layer_->IncomingEvent( - LeCreateConnectionCancelCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); - hci_layer_->IncomingLeMetaEvent(LeConnectionCompleteBuilder::Create( - ErrorCode::UNKNOWN_CONNECTION, kHciHandle, Role::CENTRAL, - AddressType::PUBLIC_DEVICE_ADDRESS, Address::kEmpty, 0x0000, 0x0000, 0x0000, - ClockAccuracy::PPM_30)); - sync_handler(); - ASSERT_TRUE(le_impl_->create_connection_timeout_alarms_.empty()); - - hci_layer_->GetCommand(OpCode::LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST); - hci_layer_->IncomingEvent( - LeRemoveDeviceFromFilterAcceptListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); - hci_layer_->AssertNoQueuedCommand(); - ASSERT_EQ(ConnectabilityState::DISARMED, le_impl_->connectability_state_); - } - // Need to store the LeAclConnection so it is not immediately dropped => disconnected std::unique_ptr<LeAclConnection> create_enhanced_connection(std::string remote_address_string, int handle) { @@ -1693,29 +1535,138 @@ TEST_F(LeImplTest, DisconnectionAcceptlistCallback) { } TEST_F(LeImplTest, direct_connection_after_background_connection) { - // TODO b/356593752 - remove when test removing flag - com::android::bluetooth::flags::provider_ - ->improve_create_connection_for_already_connecting_device(false); - test_direct_connection_after_background_connection(); -} + set_random_device_address_policy(); + + hci::AddressWithType address({0x21, 0x22, 0x23, 0x24, 0x25, 0x26}, + AddressType::PUBLIC_DEVICE_ADDRESS); + + // arrange: Create background connection. Remember that acl_manager adds device background list + le_impl_->add_device_to_background_connection_list(address); + le_impl_->create_le_connection(address, true, /* is_direct */ false); + hci_layer_->GetCommand(OpCode::LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST); + hci_layer_->IncomingEvent( + LeAddDeviceToFilterAcceptListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); + auto raw_bg_create_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION); + hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01)); + sync_handler(); -TEST_F(LeImplTest, direct_connection_after_background_connection_with_improvement) { - com::android::bluetooth::flags::provider_ - ->improve_create_connection_for_already_connecting_device(true); - test_direct_connection_after_background_connection(); + // act: Create direct connection + le_impl_->create_le_connection(address, true, /* is_direct */ true); + auto cancel_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION_CANCEL); + if (cancel_connection.IsValid()) { + hci_layer_->IncomingEvent( + LeCreateConnectionCancelCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); + hci_layer_->IncomingLeMetaEvent(LeConnectionCompleteBuilder::Create( + ErrorCode::UNKNOWN_CONNECTION, kHciHandle, Role::CENTRAL, + AddressType::PUBLIC_DEVICE_ADDRESS, Address::kEmpty, 0x0000, 0x0000, 0x0000, + ClockAccuracy::PPM_30)); + } + auto raw_direct_create_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION); + + // assert + auto bg_create_connection = + LeCreateConnectionView::Create(LeConnectionManagementCommandView::Create( + AclCommandView::Create(raw_bg_create_connection))); + EXPECT_TRUE(bg_create_connection.IsValid()); + auto direct_create_connection = + LeCreateConnectionView::Create(LeConnectionManagementCommandView::Create( + AclCommandView::Create(raw_direct_create_connection))); + EXPECT_TRUE(direct_create_connection.IsValid()); + log::info("Scan Interval {}", direct_create_connection.GetLeScanInterval()); + ASSERT_NE(direct_create_connection.GetLeScanInterval(), bg_create_connection.GetLeScanInterval()); + + hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01)); + sync_handler(); + + // Check state is ARMED + ASSERT_EQ(ConnectabilityState::ARMED, le_impl_->connectability_state_); + + // Simulate timeout on direct connect. Verify background connect is still in place + EXPECT_CALL(mock_le_connection_callbacks_, + OnLeConnectFail(_, ErrorCode::CONNECTION_ACCEPT_TIMEOUT)) + .Times(1); + le_impl_->on_create_connection_timeout(address); + sync_handler(); + cancel_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION_CANCEL); + hci_layer_->IncomingEvent( + LeCreateConnectionCancelCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); + hci_layer_->IncomingLeMetaEvent(LeConnectionCompleteBuilder::Create( + ErrorCode::UNKNOWN_CONNECTION, kHciHandle, Role::CENTRAL, + AddressType::PUBLIC_DEVICE_ADDRESS, Address::kEmpty, 0x0000, 0x0000, 0x0000, + ClockAccuracy::PPM_30)); + EXPECT_TRUE(cancel_connection.IsValid()); + raw_bg_create_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION); + bg_create_connection = LeCreateConnectionView::Create(LeConnectionManagementCommandView::Create( + AclCommandView::Create(raw_bg_create_connection))); + EXPECT_TRUE(bg_create_connection.IsValid()); + sync_handler(); + ASSERT_TRUE(le_impl_->create_connection_timeout_alarms_.empty()); + + hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01)); + sync_handler(); + + // Check state is ARMED + ASSERT_EQ(ConnectabilityState::ARMED, le_impl_->connectability_state_); } TEST_F(LeImplTest, direct_connection_after_direct_connection) { - // TODO b/356593752 - remove when test removing flag - com::android::bluetooth::flags::provider_ - ->improve_create_connection_for_already_connecting_device(false); - test_direct_connect_after_direct_connect(); -} + set_random_device_address_policy(); -TEST_F(LeImplTest, direct_connection_after_direct_connection_with_improvement) { - com::android::bluetooth::flags::provider_ - ->improve_create_connection_for_already_connecting_device(true); - test_direct_connect_after_direct_connect(); + hci::AddressWithType address({0x21, 0x22, 0x23, 0x24, 0x25, 0x26}, + AddressType::PUBLIC_DEVICE_ADDRESS); + + // Create first direct connection + le_impl_->create_le_connection(address, true, /* is_direct */ true); + hci_layer_->GetCommand(OpCode::LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST); + hci_layer_->IncomingEvent( + LeAddDeviceToFilterAcceptListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); + auto raw_direct_1_create_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION); + hci_layer_->IncomingEvent(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01)); + sync_handler(); + + // Check state is ARMED + ASSERT_EQ(ConnectabilityState::ARMED, le_impl_->connectability_state_); + + // assert + auto direct_1_create_connection = + LeCreateConnectionView::Create(LeConnectionManagementCommandView::Create( + AclCommandView::Create(raw_direct_1_create_connection))); + EXPECT_TRUE(direct_1_create_connection.IsValid()); + + log::info("Second direct connect to the same device"); + + // Create second direct connection + le_impl_->create_le_connection(address, true, /* is_direct */ true); + sync_handler(); + + CommandView cancel_connection = CommandView::Create( + PacketView<packet::kLittleEndian>(std::make_shared<std::vector<uint8_t>>())); + + hci_layer_->AssertNoQueuedCommand(); + + log::info("Simulate timeout"); + + EXPECT_CALL(mock_le_connection_callbacks_, + OnLeConnectFail(_, ErrorCode::CONNECTION_ACCEPT_TIMEOUT)) + .Times(1); + le_impl_->on_create_connection_timeout(address); + sync_handler(); + cancel_connection = hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION_CANCEL); + EXPECT_TRUE(cancel_connection.IsValid()); + hci_layer_->IncomingEvent( + LeCreateConnectionCancelCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); + hci_layer_->IncomingLeMetaEvent(LeConnectionCompleteBuilder::Create( + ErrorCode::UNKNOWN_CONNECTION, kHciHandle, Role::CENTRAL, + AddressType::PUBLIC_DEVICE_ADDRESS, Address::kEmpty, 0x0000, 0x0000, 0x0000, + ClockAccuracy::PPM_30)); + sync_handler(); + ASSERT_TRUE(le_impl_->create_connection_timeout_alarms_.empty()); + + hci_layer_->GetCommand(OpCode::LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST); + hci_layer_->IncomingEvent( + LeRemoveDeviceFromFilterAcceptListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS)); + hci_layer_->AssertNoQueuedCommand(); + ASSERT_EQ(ConnectabilityState::DISARMED, le_impl_->connectability_state_); } TEST_F(LeImplTest, direct_connection_cancel_but_connected) { diff --git a/system/stack/eatt/eatt_impl.h b/system/stack/eatt/eatt_impl.h index 0d27726af4..b602636f0d 100644 --- a/system/stack/eatt/eatt_impl.h +++ b/system/stack/eatt/eatt_impl.h @@ -723,11 +723,7 @@ struct eatt_impl { tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(channel->bda_, BT_TRANSPORT_LE); log::warn("disconnecting channel {:#x} for {}", channel->cid_, channel->bda_); - if (com::android::bluetooth::flags::gatt_disconnect_fix()) { - EattExtension::GetInstance()->Disconnect(channel->bda_, channel->cid_); - } else { - gatt_disconnect(p_tcb); - } + EattExtension::GetInstance()->Disconnect(channel->bda_, channel->cid_); } void start_indication_confirm_timer(const RawAddress& bd_addr, uint16_t cid) { diff --git a/system/stack/gatt/gatt_main.cc b/system/stack/gatt/gatt_main.cc index 19fd83990a..5228369a26 100644 --- a/system/stack/gatt/gatt_main.cc +++ b/system/stack/gatt/gatt_main.cc @@ -282,7 +282,7 @@ bool gatt_disconnect(tGATT_TCB* p_tcb) { return true; } - if (com::android::bluetooth::flags::gatt_disconnect_fix() && p_tcb->eatt) { + if (p_tcb->eatt) { /* ATT is fixed channel and it is expected to drop ACL. * Make sure all EATT channels are disconnected before doing that. */ diff --git a/system/stack/test/eatt/eatt_test.cc b/system/stack/test/eatt/eatt_test.cc index 5d7a2eeea8..17f4908b3e 100644 --- a/system/stack/test/eatt/eatt_test.cc +++ b/system/stack/test/eatt/eatt_test.cc @@ -660,7 +660,6 @@ TEST_F(EattTest, ChannelUnavailableWhileReconfiguring) { } TEST_F(EattTest, DisconnectChannelOnIndicationConfirmationTimeout) { - com::android::bluetooth::flags::provider_->gatt_disconnect_fix(true); ConnectDeviceEattSupported(1); eatt_instance_->StartIndicationConfirmationTimer(test_address, test_local_cids[0]); |