Fix incorrect summary for LE audio hearing aids

For LE audio lead device, the `CachedBluetoothDevice.isConnected()` will return true since `BluetoothLeAudio.getConnectionStatus(device)` will return STATE_CONNECTED even if the device is powered off. Changing to use `CachedBluetoothDevice.getDevice().isConnected()` can avoid the wrong value of the connection status of the device.

Bug: 325524694
Flag: EXEMPT bugfix
Test: atest AccessibilityHearingAidPreferenceControllerTest
Change-Id: If763c0861bb5796d9bc0511916b7077c784b49f5
This commit is contained in:
Angela Wang
2024-05-28 08:40:40 +00:00
parent 42b714f450
commit 5fef3c2bb0
2 changed files with 14 additions and 6 deletions

View File

@@ -134,7 +134,7 @@ public class AccessibilityHearingAidPreferenceController extends BasePreferenceC
// Check if another side of LE audio hearing aid is connected as a pair
final Set<CachedBluetoothDevice> memberDevices = device.getMemberDevice();
if (memberDevices.stream().anyMatch(m -> m.isConnected())) {
if (memberDevices.stream().anyMatch(m -> m.getDevice().isConnected())) {
return mContext.getString(
R.string.accessibility_hearingaid_left_and_right_side_device_summary,
name);
@@ -142,7 +142,7 @@ public class AccessibilityHearingAidPreferenceController extends BasePreferenceC
// Check if another side of ASHA hearing aid is connected as a pair
final CachedBluetoothDevice subDevice = device.getSubDevice();
if (subDevice != null && subDevice.isConnected()) {
if (subDevice != null && subDevice.getDevice().isConnected()) {
return mContext.getString(
R.string.accessibility_hearingaid_left_and_right_side_device_summary, name);
}