Loading src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -73,12 +73,14 @@ public class BluetoothDeviceManager { "Lost BluetoothHeadset service. " + "Removing all tracked devices."); lostServiceDevices = mHfpDevicesByAddress; mBluetoothRouteManager.onActiveDeviceChanged(null, false); } else if (profile == BluetoothProfile.HEARING_AID) { mBluetoothHearingAidService = null; Log.i(BluetoothDeviceManager.this, "Lost BluetoothHearingAid service. " + "Removing all tracked devices."); lostServiceDevices = mHearingAidDevicesByAddress; mBluetoothRouteManager.onActiveDeviceChanged(null, true); } else { return; } Loading tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); Loading @@ -168,6 +170,25 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { assertEquals(1, mBluetoothDeviceManager.getNumConnectedDevices()); } @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() { Loading Loading
src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -73,12 +73,14 @@ public class BluetoothDeviceManager { "Lost BluetoothHeadset service. " + "Removing all tracked devices."); lostServiceDevices = mHfpDevicesByAddress; mBluetoothRouteManager.onActiveDeviceChanged(null, false); } else if (profile == BluetoothProfile.HEARING_AID) { mBluetoothHearingAidService = null; Log.i(BluetoothDeviceManager.this, "Lost BluetoothHearingAid service. " + "Removing all tracked devices."); lostServiceDevices = mHearingAidDevicesByAddress; mBluetoothRouteManager.onActiveDeviceChanged(null, true); } else { return; } Loading
tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); Loading @@ -168,6 +170,25 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { assertEquals(1, mBluetoothDeviceManager.getNumConnectedDevices()); } @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() { Loading