summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/app/src/com/android/bluetooth/bas/BatteryStateMachine.java23
-rw-r--r--android/app/src/com/android/bluetooth/btservice/PhonePolicy.java1
-rw-r--r--android/app/tests/unit/src/com/android/bluetooth/bas/BatteryStateMachineTest.java2
-rw-r--r--system/btif/src/btif_bqr.cc1
-rw-r--r--system/btif/src/btif_dm.cc17
-rw-r--r--system/stack/acl/ble_acl.cc3
-rw-r--r--system/stack/acl/btm_acl.cc80
-rw-r--r--system/stack/btu/btu_hcif.cc8
-rw-r--r--system/stack/include/acl_hci_link_interface.h2
-rw-r--r--system/test/mock/mock_stack_acl.cc12
-rw-r--r--system/test/mock/mock_stack_acl.h18
11 files changed, 26 insertions, 141 deletions
diff --git a/android/app/src/com/android/bluetooth/bas/BatteryStateMachine.java b/android/app/src/com/android/bluetooth/bas/BatteryStateMachine.java
index c53f352b92..b86562d7a0 100644
--- a/android/app/src/com/android/bluetooth/bas/BatteryStateMachine.java
+++ b/android/app/src/com/android/bluetooth/bas/BatteryStateMachine.java
@@ -223,14 +223,16 @@ public class BatteryStateMachine extends StateMachine {
return false;
}
- if (mBluetoothGatt == null) {
+ if (mGattCallback == null) {
mGattCallback = new GattCallback();
- mBluetoothGatt = mDevice.connectGatt(service, /*autoConnect=*/false,
- mGattCallback, TRANSPORT_AUTO, /*opportunistic=*/true,
- PHY_LE_1M_MASK | PHY_LE_2M_MASK, getHandler());
- } else {
- mBluetoothGatt.connect();
}
+ if (mBluetoothGatt != null) {
+ Log.w(TAG, "Trying connectGatt with existing BluetoothGatt instance.");
+ mBluetoothGatt.close();
+ }
+ mBluetoothGatt = mDevice.connectGatt(service, /*autoConnect=*/false,
+ mGattCallback, TRANSPORT_AUTO, /*opportunistic=*/true,
+ PHY_LE_1M_MASK | PHY_LE_2M_MASK, getHandler());
return mBluetoothGatt != null;
}
@@ -256,6 +258,11 @@ public class BatteryStateMachine extends StateMachine {
log(TAG, "Enter (" + mDevice + "): " + messageWhatToString(
getCurrentMessage().what));
+ if (mBluetoothGatt != null) {
+ mBluetoothGatt.close();
+ mBluetoothGatt = null;
+ }
+
if (mLastConnectionState != BluetoothProfile.STATE_DISCONNECTED) {
// Don't broadcast during startup
dispatchConnectionStateChanged(mLastConnectionState,
@@ -575,7 +582,9 @@ public class BatteryStateMachine extends StateMachine {
int batteryLevel = value[0] & 0xFF;
BatteryService service = mServiceRef.get();
- service.handleBatteryChanged(mDevice, batteryLevel);
+ if (service != null) {
+ service.handleBatteryChanged(mDevice, batteryLevel);
+ }
}
}
}
diff --git a/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java b/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java
index 9b83ccf01b..e04d0fd2ac 100644
--- a/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java
+++ b/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java
@@ -174,6 +174,7 @@ class PhonePolicy {
break;
case BluetoothDevice.ACTION_ACL_CONNECTED:
mHandler.obtainMessage(MESSAGE_DEVICE_CONNECTED, intent).sendToTarget();
+ break;
default:
Log.e(TAG, "Received unexpected intent, action=" + action);
break;
diff --git a/android/app/tests/unit/src/com/android/bluetooth/bas/BatteryStateMachineTest.java b/android/app/tests/unit/src/com/android/bluetooth/bas/BatteryStateMachineTest.java
index f5470ddaba..a63f0e3738 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/bas/BatteryStateMachineTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/bas/BatteryStateMachineTest.java
@@ -19,6 +19,7 @@ package com.android.bluetooth.bas;
import static android.bluetooth.BluetoothGatt.GATT_SUCCESS;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.after;
@@ -157,6 +158,7 @@ public class BatteryStateMachineTest {
// Check that we are in Disconnected state
Assert.assertThat(mBatteryStateMachine.getCurrentState(),
IsInstanceOf.instanceOf(BatteryStateMachine.Disconnected.class));
+ assertNull(mBatteryStateMachine.mBluetoothGatt);
}
@Test
diff --git a/system/btif/src/btif_bqr.cc b/system/btif/src/btif_bqr.cc
index cc75905328..a728d8089d 100644
--- a/system/btif/src/btif_bqr.cc
+++ b/system/btif/src/btif_bqr.cc
@@ -395,6 +395,7 @@ void CategorizeBqrEvent(uint8_t length, const uint8_t* p_bqr_event) {
case QUALITY_REPORT_ID_APPROACH_LSTO:
case QUALITY_REPORT_ID_A2DP_AUDIO_CHOPPY:
case QUALITY_REPORT_ID_SCO_VOICE_CHOPPY:
+ case QUALITY_REPORT_ID_LE_AUDIO_CHOPPY:
if (length < kLinkQualityParamTotalLen) {
LOG(FATAL) << __func__
<< ": Parameter total length: " << std::to_string(length)
diff --git a/system/btif/src/btif_dm.cc b/system/btif/src/btif_dm.cc
index d781a1336f..bc59694759 100644
--- a/system/btif/src/btif_dm.cc
+++ b/system/btif/src/btif_dm.cc
@@ -1123,22 +1123,14 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
break;
case HCI_ERR_PAIRING_NOT_ALLOWED:
- if (!bluetooth::shim::is_gd_security_enabled()) {
- is_bonded_device_removed = (btif_storage_remove_bonded_device(
- &bd_addr) == BT_STATUS_SUCCESS);
- } else {
- is_bonded_device_removed = true;
- }
+ is_bonded_device_removed = false;
status = BT_STATUS_AUTH_REJECTED;
break;
/* map the auth failure codes, so we can retry pairing if necessary */
case HCI_ERR_AUTH_FAILURE:
case HCI_ERR_KEY_MISSING:
- is_bonded_device_removed = (bluetooth::shim::is_gd_security_enabled())
- ? true
- : (btif_storage_remove_bonded_device(
- &bd_addr) == BT_STATUS_SUCCESS);
+ is_bonded_device_removed = false;
[[fallthrough]];
case HCI_ERR_HOST_REJECT_SECURITY:
case HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE:
@@ -1169,10 +1161,7 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
/* Remove Device as bonded in nvram as authentication failed */
BTIF_TRACE_DEBUG("%s(): removing hid pointing device from nvram",
__func__);
- is_bonded_device_removed = (bluetooth::shim::is_gd_security_enabled())
- ? true
- : (btif_storage_remove_bonded_device(
- &bd_addr) == BT_STATUS_SUCCESS);
+ is_bonded_device_removed = false;
}
// Report bond state change to java only if we are bonding to a device or
// a device is removed from the pairing list.
diff --git a/system/stack/acl/ble_acl.cc b/system/stack/acl/ble_acl.cc
index 30b645c94b..448dabd12c 100644
--- a/system/stack/acl/ble_acl.cc
+++ b/system/stack/acl/ble_acl.cc
@@ -145,8 +145,7 @@ void acl_ble_enhanced_connection_complete_from_shim(
// The legacy stack continues the LE connection after the read remote version
// complete has been received.
- l2cble_notify_le_connection(address_with_type.bda);
- l2cble_use_preferred_conn_params(address_with_type.bda);
+ // maybe_chain_more_commands_after_read_remote_version_complete
}
void acl_ble_connection_fail(const tBLE_BD_ADDR& address_with_type,
diff --git a/system/stack/acl/btm_acl.cc b/system/stack/acl/btm_acl.cc
index 563215112a..85eb5d8580 100644
--- a/system/stack/acl/btm_acl.cc
+++ b/system/stack/acl/btm_acl.cc
@@ -91,7 +91,6 @@ struct StackAclBtmAcl {
bool change_connection_packet_types(tACL_CONN& link,
const uint16_t new_packet_type_bitmask);
void btm_establish_continue(tACL_CONN* p_acl_cb);
- void btm_read_remote_features(uint16_t handle);
void btm_set_default_link_policy(tLINK_POLICY settings);
void btm_acl_role_changed(tHCI_STATUS hci_status, const RawAddress& bd_addr,
tHCI_ROLE new_role);
@@ -834,24 +833,6 @@ void btm_process_remote_version_complete(uint8_t status, uint16_t handle,
}
}
-void btm_read_remote_version_complete_raw(uint8_t* p) {
- uint8_t status;
- uint16_t handle;
- uint8_t lmp_version;
- uint16_t manufacturer;
- uint16_t lmp_subversion;
-
- STREAM_TO_UINT8(status, p);
- STREAM_TO_UINT16(handle, p);
- STREAM_TO_UINT8(lmp_version, p);
- STREAM_TO_UINT16(manufacturer, p);
- STREAM_TO_UINT16(lmp_subversion, p);
-
- ASSERT_LOG(false, "gd acl layer should be receiving this completion");
- btm_read_remote_version_complete(static_cast<tHCI_STATUS>(status), handle,
- lmp_version, manufacturer, lmp_version);
-}
-
void btm_read_remote_version_complete(tHCI_STATUS status, uint16_t handle,
uint8_t lmp_version,
uint16_t manufacturer,
@@ -898,40 +879,6 @@ void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,
/*******************************************************************************
*
- * Function btm_read_remote_features
- *
- * Description Local function called to send a read remote supported
- * features/remote extended features page[0].
- *
- * Returns void
- *
- ******************************************************************************/
-void StackAclBtmAcl::btm_read_remote_features(uint16_t handle) {
- uint8_t acl_idx;
- tACL_CONN* p_acl_cb;
-
- acl_idx = btm_handle_to_acl_index(handle);
- if (acl_idx >= MAX_L2CAP_LINKS) {
- LOG_WARN("Unable to find active acl");
- return;
- }
-
- p_acl_cb = &btm_cb.acl_cb_.acl_db[acl_idx];
- memset(p_acl_cb->peer_lmp_feature_pages, 0,
- sizeof(p_acl_cb->peer_lmp_feature_pages));
-
- /* first send read remote supported features HCI command */
- /* because we don't know whether the remote support extended feature command
- */
- if (bluetooth::shim::is_gd_l2cap_enabled()) {
- // GD L2cap reads this automatically
- return;
- }
- btsnd_hcic_rmt_features_req(handle);
-}
-
-/*******************************************************************************
- *
* Function btm_read_remote_ext_features
*
* Description Local function called to send a read remote extended
@@ -948,33 +895,6 @@ void btm_read_remote_ext_features(uint16_t handle, uint8_t page_number) {
btsnd_hcic_rmt_ext_features(handle, page_number);
}
-/*******************************************************************************
- *
- * Function btm_read_remote_features_complete
- *
- * Description This function is called when the remote supported features
- * complete event is received from the HCI.
- *
- * Returns void
- *
- ******************************************************************************/
-void btm_read_remote_features_complete_raw(uint8_t* p) {
- uint8_t status;
- uint16_t handle;
-
- STREAM_TO_UINT8(status, p);
-
- if (status != HCI_SUCCESS) {
- LOG_WARN("Uanble to read remote features status:%s",
- hci_error_code_text(static_cast<tHCI_STATUS>(status)).c_str());
- return;
- }
-
- STREAM_TO_UINT16(handle, p);
-
- btm_read_remote_features_complete(handle, p);
-}
-
void btm_read_remote_features_complete(uint16_t handle, uint8_t* features) {
tACL_CONN* p_acl_cb = internal_.acl_get_connection_from_handle(handle);
if (p_acl_cb == nullptr) {
diff --git a/system/stack/btu/btu_hcif.cc b/system/stack/btu/btu_hcif.cc
index b191e8a4f6..a356b56581 100644
--- a/system/stack/btu/btu_hcif.cc
+++ b/system/stack/btu/btu_hcif.cc
@@ -265,15 +265,9 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
case HCI_ENCRYPTION_KEY_REFRESH_COMP_EVT:
btu_hcif_encryption_key_refresh_cmpl_evt(p);
break;
- case HCI_READ_RMT_FEATURES_COMP_EVT:
- btm_read_remote_features_complete_raw(p);
- break;
case HCI_READ_RMT_EXT_FEATURES_COMP_EVT:
btu_hcif_read_rmt_ext_features_comp_evt(p, hci_evt_len);
break;
- case HCI_READ_RMT_VERSION_COMP_EVT:
- btm_read_remote_version_complete_raw(p);
- break;
case HCI_COMMAND_COMPLETE_EVT:
LOG_ERROR(
"%s should not have received a command complete event. "
@@ -434,6 +428,8 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
// Events now captured by gd::hci_layer module
case HCI_CONNECTION_COMP_EVT: // EventCode::CONNECTION_COMPLETE
+ case HCI_READ_RMT_FEATURES_COMP_EVT: // EventCode::READ_REMOTE_SUPPORTED_FEATURES_COMPLETE
+ case HCI_READ_RMT_VERSION_COMP_EVT: // EventCode::READ_REMOTE_VERSION_INFORMATION_COMPLETE
default:
LOG_ERROR(
"Unexpectedly received event_code:0x%02x that should not be "
diff --git a/system/stack/include/acl_hci_link_interface.h b/system/stack/include/acl_hci_link_interface.h
index 006025184b..781c7bd4e0 100644
--- a/system/stack/include/acl_hci_link_interface.h
+++ b/system/stack/include/acl_hci_link_interface.h
@@ -57,9 +57,7 @@ void btm_read_remote_ext_features_complete_raw(uint8_t* p, uint8_t evt_len);
void btm_read_remote_ext_features_complete(uint16_t handle, uint8_t page_num,
uint8_t max_page, uint8_t* features);
void btm_read_remote_ext_features_failed(uint8_t status, uint16_t handle);
-void btm_read_remote_features_complete_raw(uint8_t* p);
void btm_read_remote_features_complete(uint16_t handle, uint8_t* features);
-void btm_read_remote_version_complete_raw(uint8_t* p);
void btm_read_remote_version_complete(tHCI_STATUS status, uint16_t handle,
uint8_t lmp_version,
uint16_t manufacturer,
diff --git a/system/test/mock/mock_stack_acl.cc b/system/test/mock/mock_stack_acl.cc
index d7332a8058..278f951b5e 100644
--- a/system/test/mock/mock_stack_acl.cc
+++ b/system/test/mock/mock_stack_acl.cc
@@ -160,11 +160,7 @@ struct btm_read_remote_ext_features_complete_raw
btm_read_remote_ext_features_complete_raw;
struct btm_read_remote_ext_features_failed btm_read_remote_ext_features_failed;
struct btm_read_remote_features_complete btm_read_remote_features_complete;
-struct btm_read_remote_features_complete_raw
- btm_read_remote_features_complete_raw;
struct btm_read_remote_version_complete btm_read_remote_version_complete;
-struct btm_read_remote_version_complete_raw
- btm_read_remote_version_complete_raw;
struct btm_read_rssi_complete btm_read_rssi_complete;
struct btm_read_rssi_timeout btm_read_rssi_timeout;
struct btm_read_tx_power_complete btm_read_tx_power_complete;
@@ -661,10 +657,6 @@ void btm_read_remote_features_complete(uint16_t handle, uint8_t* features) {
mock_function_count_map[__func__]++;
test::mock::stack_acl::btm_read_remote_features_complete(handle, features);
}
-void btm_read_remote_features_complete_raw(uint8_t* p) {
- mock_function_count_map[__func__]++;
- test::mock::stack_acl::btm_read_remote_features_complete_raw(p);
-}
void btm_read_remote_version_complete(tHCI_STATUS status, uint16_t handle,
uint8_t lmp_version,
uint16_t manufacturer,
@@ -673,10 +665,6 @@ void btm_read_remote_version_complete(tHCI_STATUS status, uint16_t handle,
test::mock::stack_acl::btm_read_remote_version_complete(
status, handle, lmp_version, manufacturer, lmp_subversion);
}
-void btm_read_remote_version_complete_raw(uint8_t* p) {
- mock_function_count_map[__func__]++;
- test::mock::stack_acl::btm_read_remote_version_complete_raw(p);
-}
void btm_read_rssi_complete(uint8_t* p) {
mock_function_count_map[__func__]++;
test::mock::stack_acl::btm_read_rssi_complete(p);
diff --git a/system/test/mock/mock_stack_acl.h b/system/test/mock/mock_stack_acl.h
index ecf15753d9..d03d6383bc 100644
--- a/system/test/mock/mock_stack_acl.h
+++ b/system/test/mock/mock_stack_acl.h
@@ -1171,15 +1171,6 @@ struct btm_read_remote_features_complete {
};
extern struct btm_read_remote_features_complete
btm_read_remote_features_complete;
-// Name: btm_read_remote_features_complete_raw
-// Params: uint8_t* p
-// Returns: void
-struct btm_read_remote_features_complete_raw {
- std::function<void(uint8_t* p)> body{[](uint8_t* p) { ; }};
- void operator()(uint8_t* p) { body(p); };
-};
-extern struct btm_read_remote_features_complete_raw
- btm_read_remote_features_complete_raw;
// Name: btm_read_remote_version_complete
// Params: tHCI_STATUS status, uint16_t handle, uint8_t lmp_version, uint16_t
// manufacturer, uint16_t lmp_subversion Returns: void
@@ -1194,15 +1185,6 @@ struct btm_read_remote_version_complete {
};
};
extern struct btm_read_remote_version_complete btm_read_remote_version_complete;
-// Name: btm_read_remote_version_complete_raw
-// Params: uint8_t* p
-// Returns: void
-struct btm_read_remote_version_complete_raw {
- std::function<void(uint8_t* p)> body{[](uint8_t* p) { ; }};
- void operator()(uint8_t* p) { body(p); };
-};
-extern struct btm_read_remote_version_complete_raw
- btm_read_remote_version_complete_raw;
// Name: btm_read_rssi_complete
// Params: uint8_t* p
// Returns: void