diff options
author | Hall Liu <hallliu@google.com> | 2019-03-07 18:13:07 -0800 |
---|---|---|
committer | Hall Liu <hallliu@google.com> | 2019-03-07 18:13:07 -0800 |
commit | b19c0d4384d044a4d565055ddcbd18bd5c0a8d0d (patch) | |
tree | c6b68d081fa1f411a74a05e5224c20c3b3014c65 /tests/src/com/android/server/telecom | |
parent | 21a04a3d9df6c3e9a5e944cada364407c71a9853 (diff) | |
download | android_packages_services_Telecomm-b19c0d4384d044a4d565055ddcbd18bd5c0a8d0d.tar.gz android_packages_services_Telecomm-b19c0d4384d044a4d565055ddcbd18bd5c0a8d0d.tar.bz2 android_packages_services_Telecomm-b19c0d4384d044a4d565055ddcbd18bd5c0a8d0d.zip |
Remove active devices when the BT profile disconnects
When we get a onServiceDisconnected call, remove the active devices from
the route manager cache so that we're not calling upon them later on.
Fixes: 112285293
Test: unit, manual
Change-Id: I177187116f10bb14b00d6e80cb38c81bbdc8fe7f
Diffstat (limited to 'tests/src/com/android/server/telecom')
-rw-r--r-- | tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java b/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java index 9fd97f86..2129ffa8 100644 --- a/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java +++ b/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java @@ -40,6 +40,7 @@ import org.mockito.Mock; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.never; @@ -161,6 +162,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device2, true)); serviceListenerUnderTest.onServiceDisconnected(BluetoothProfile.HEADSET); + verify(mRouteManager).onActiveDeviceChanged(isNull(), eq(false)); verify(mRouteManager).onDeviceLost(device1.getAddress()); verify(mRouteManager).onDeviceLost(device3.getAddress()); verify(mRouteManager, never()).onDeviceLost(device2.getAddress()); @@ -170,6 +172,25 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { @SmallTest @Test + public void testHearingAidServiceDisconnect() { + receiverUnderTest.onReceive(mContext, + buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device1, false)); + receiverUnderTest.onReceive(mContext, + buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device3, false)); + receiverUnderTest.onReceive(mContext, + buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device2, true)); + serviceListenerUnderTest.onServiceDisconnected(BluetoothProfile.HEARING_AID); + + verify(mRouteManager).onActiveDeviceChanged(isNull(), eq(true)); + verify(mRouteManager).onDeviceLost(device2.getAddress()); + verify(mRouteManager, never()).onDeviceLost(device1.getAddress()); + verify(mRouteManager, never()).onDeviceLost(device3.getAddress()); + assertNull(mBluetoothDeviceManager.getHearingAidService()); + assertEquals(2, mBluetoothDeviceManager.getNumConnectedDevices()); + } + + @SmallTest + @Test public void testConnectDisconnectAudioHeadset() { receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device1, false)); |