Show connecting hearing devices in A11y hearing devices page

We only show connected hearing devices in the hearing devices page now.
When user pairing a device from pairing page and back to the hearing
devices page after the device is bonded, it's confusing no device shown
in the list because the device is still connecting to profiles. We
should show the connecting device to avoid confusion.

Bug: 283268686
Test: make RunSettingsRoboTests ROBOTEST_FILTER=DeviceListPreferenceFragmentTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AvailableHearingDeviceUpdaterTest
Change-Id: Id3b29c12b80c282736a3e6ca73bcf317e0652b89
Merged-In: Id3b29c12b80c282736a3e6ca73bcf317e0652b89
This commit is contained in:
Angela Wang
2023-06-13 06:18:55 +00:00
parent bdd072d1a1
commit 653ff8a485
3 changed files with 37 additions and 29 deletions

View File

@@ -18,7 +18,6 @@ package com.android.settings.accessibility;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
import android.bluetooth.BluetoothDevice;
@@ -80,8 +79,9 @@ public class AvailableHearingDeviceUpdaterTest {
@Test
public void isFilterMatch_connectedHearingDevice_returnTrue() {
CachedBluetoothDevice connectedHearingDevice = mCachedBluetoothDevice;
when(connectedHearingDevice.isConnectedHearingAidDevice()).thenReturn(true);
doReturn(BluetoothDevice.BOND_BONDED).when(mBluetoothDevice).getBondState();
when(connectedHearingDevice.isHearingAidDevice()).thenReturn(true);
when(mBluetoothDevice.isConnected()).thenReturn(true);
when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(
new ArrayList<>(List.of(connectedHearingDevice)));
@@ -91,8 +91,9 @@ public class AvailableHearingDeviceUpdaterTest {
@Test
public void isFilterMatch_nonConnectedHearingDevice_returnFalse() {
CachedBluetoothDevice nonConnectedHearingDevice = mCachedBluetoothDevice;
when(nonConnectedHearingDevice.isConnectedHearingAidDevice()).thenReturn(false);
doReturn(BluetoothDevice.BOND_BONDED).when(mBluetoothDevice).getBondState();
when(nonConnectedHearingDevice.isHearingAidDevice()).thenReturn(true);
when(mBluetoothDevice.isConnected()).thenReturn(false);
when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(
new ArrayList<>(List.of(nonConnectedHearingDevice)));
@@ -103,7 +104,8 @@ public class AvailableHearingDeviceUpdaterTest {
public void isFilterMatch_connectedBondingHearingDevice_returnFalse() {
CachedBluetoothDevice connectedBondingHearingDevice = mCachedBluetoothDevice;
when(connectedBondingHearingDevice.isHearingAidDevice()).thenReturn(true);
doReturn(BluetoothDevice.BOND_BONDING).when(mBluetoothDevice).getBondState();
when(mBluetoothDevice.isConnected()).thenReturn(true);
when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDING);
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(
new ArrayList<>(List.of(connectedBondingHearingDevice)));
@@ -114,8 +116,8 @@ public class AvailableHearingDeviceUpdaterTest {
public void isFilterMatch_hearingDeviceNotInCachedDevicesList_returnFalse() {
CachedBluetoothDevice notInCachedDevicesListDevice = mCachedBluetoothDevice;
when(notInCachedDevicesListDevice.isHearingAidDevice()).thenReturn(true);
doReturn(BluetoothDevice.BOND_BONDED).when(mBluetoothDevice).getBondState();
doReturn(false).when(mBluetoothDevice).isConnected();
when(mBluetoothDevice.isConnected()).thenReturn(true);
when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(new ArrayList<>());
assertThat(mUpdater.isFilterMatched(notInCachedDevicesListDevice)).isEqualTo(false);