Loading android/app/src/com/android/bluetooth/bas/BatteryStateMachine.java +16 −7 Original line number Diff line number Diff line Loading @@ -223,14 +223,16 @@ public class BatteryStateMachine extends StateMachine { return false; } if (mBluetoothGatt == null) { if (mGattCallback == null) { mGattCallback = new GattCallback(); } 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()); } else { mBluetoothGatt.connect(); } return mBluetoothGatt != null; } Loading @@ -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, Loading Loading @@ -575,7 +582,9 @@ public class BatteryStateMachine extends StateMachine { int batteryLevel = value[0] & 0xFF; BatteryService service = mServiceRef.get(); if (service != null) { service.handleBatteryChanged(mDevice, batteryLevel); } } } } android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +1 −0 Original line number Diff line number Diff line Loading @@ -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; Loading android/app/tests/unit/src/com/android/bluetooth/bas/BatteryStateMachineTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading system/btif/src/btif_bqr.cc +1 −0 Original line number Diff line number Diff line Loading @@ -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) Loading system/btif/src/btif_dm.cc +3 −14 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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. Loading Loading
android/app/src/com/android/bluetooth/bas/BatteryStateMachine.java +16 −7 Original line number Diff line number Diff line Loading @@ -223,14 +223,16 @@ public class BatteryStateMachine extends StateMachine { return false; } if (mBluetoothGatt == null) { if (mGattCallback == null) { mGattCallback = new GattCallback(); } 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()); } else { mBluetoothGatt.connect(); } return mBluetoothGatt != null; } Loading @@ -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, Loading Loading @@ -575,7 +582,9 @@ public class BatteryStateMachine extends StateMachine { int batteryLevel = value[0] & 0xFF; BatteryService service = mServiceRef.get(); if (service != null) { service.handleBatteryChanged(mDevice, batteryLevel); } } } }
android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +1 −0 Original line number Diff line number Diff line Loading @@ -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; Loading
android/app/tests/unit/src/com/android/bluetooth/bas/BatteryStateMachineTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading
system/btif/src/btif_bqr.cc +1 −0 Original line number Diff line number Diff line Loading @@ -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) Loading
system/btif/src/btif_dm.cc +3 −14 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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. Loading