Use isConnected in CachedBluetoothDevice

This method check whether it has connected profile, not physical
connection between devices.

It make more sense to use it in settings:
1. We only care about whether it has active profile(i.e. A2dp, hfp..)
2. Sometime when profile is disconnected, BluetoothDevice.isConnected()
still return true. This may make UI flaky.

Bug: 79947085
Test: RunSettingsRoboTests
Change-Id: I44039704508a742c7a8aef0a035afcf169b08939
This commit is contained in:
jackqdyulei
2018-09-24 18:09:01 -07:00
parent b152e6dd1b
commit 8800b9e1ff
4 changed files with 8 additions and 8 deletions

View File

@@ -77,7 +77,7 @@ public class SavedBluetoothDeviceUpdaterTest {
@Test
public void update_filterMatch_addPreference() {
doReturn(BluetoothDevice.BOND_BONDED).when(mBluetoothDevice).getBondState();
doReturn(false).when(mBluetoothDevice).isConnected();
doReturn(false).when(mCachedBluetoothDevice).isConnected();
mBluetoothDeviceUpdater.update(mCachedBluetoothDevice);
@@ -87,7 +87,7 @@ public class SavedBluetoothDeviceUpdaterTest {
@Test
public void update_filterNotMatch_removePreference() {
doReturn(BluetoothDevice.BOND_NONE).when(mBluetoothDevice).getBondState();
doReturn(true).when(mBluetoothDevice).isConnected();
doReturn(true).when(mCachedBluetoothDevice).isConnected();
mBluetoothDeviceUpdater.update(mCachedBluetoothDevice);
@@ -96,7 +96,7 @@ public class SavedBluetoothDeviceUpdaterTest {
@Test
public void onProfileConnectionStateChanged_deviceConnected_removePreference() {
when(mBluetoothDevice.isConnected()).thenReturn(true);
when(mCachedBluetoothDevice.isConnected()).thenReturn(true);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
@@ -106,7 +106,7 @@ public class SavedBluetoothDeviceUpdaterTest {
@Test
public void onProfileConnectionStateChanged_deviceDisconnected_addPreference() {
when(mBluetoothDevice.isConnected()).thenReturn(false);
when(mCachedBluetoothDevice.isConnected()).thenReturn(false);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.A2DP);