Loading src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java +4 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,10 @@ public class BluetoothStateReceiver extends BroadcastReceiver { if (device == null) { mBluetoothRouteManager.sendMessage(BT_AUDIO_LOST, args); } else { if (!mIsInCall) { Log.i(LOG_TAG, "Ignoring hearing aid audio on since we're not in a call"); return; } args.arg2 = device.getAddress(); mBluetoothRouteManager.sendMessage(BT_AUDIO_IS_ON, args); } Loading tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java +17 −3 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { BluetoothDeviceManager mBluetoothDeviceManager; BluetoothProfile.ServiceListener serviceListenerUnderTest; BroadcastReceiver receiverUnderTest; BluetoothStateReceiver receiverUnderTest; private BluetoothDevice device1; private BluetoothDevice device2; Loading Loading @@ -90,8 +90,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { serviceCaptor.capture(), eq(BluetoothProfile.HEADSET)); serviceListenerUnderTest = serviceCaptor.getValue(); receiverUnderTest = new BluetoothStateReceiver(mBluetoothDeviceManager, null /* route mgr not needed here */); receiverUnderTest = new BluetoothStateReceiver(mBluetoothDeviceManager, mRouteManager); mBluetoothDeviceManager.setHeadsetServiceForTesting(mHeadsetProxy); mBluetoothDeviceManager.setHearingAidServiceForTesting(mBluetoothHearingAid); Loading Loading @@ -196,6 +195,21 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { assertEquals(2, mBluetoothDeviceManager.getNumConnectedDevices()); } @SmallTest @Test public void testHearingAidChangesIgnoredWhenNotInCall() { receiverUnderTest.setIsInCall(false); receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device2, true)); Intent activeDeviceChangedIntent = new Intent(BluetoothHearingAid.ACTION_ACTIVE_DEVICE_CHANGED); activeDeviceChangedIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device2); receiverUnderTest.onReceive(mContext, activeDeviceChangedIntent); verify(mRouteManager).onActiveDeviceChanged(device2, true); verify(mRouteManager, never()).sendMessage(BluetoothRouteManager.BT_AUDIO_IS_ON); } @SmallTest @Test public void testConnectDisconnectAudioHeadset() { Loading Loading
src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java +4 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,10 @@ public class BluetoothStateReceiver extends BroadcastReceiver { if (device == null) { mBluetoothRouteManager.sendMessage(BT_AUDIO_LOST, args); } else { if (!mIsInCall) { Log.i(LOG_TAG, "Ignoring hearing aid audio on since we're not in a call"); return; } args.arg2 = device.getAddress(); mBluetoothRouteManager.sendMessage(BT_AUDIO_IS_ON, args); } Loading
tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java +17 −3 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { BluetoothDeviceManager mBluetoothDeviceManager; BluetoothProfile.ServiceListener serviceListenerUnderTest; BroadcastReceiver receiverUnderTest; BluetoothStateReceiver receiverUnderTest; private BluetoothDevice device1; private BluetoothDevice device2; Loading Loading @@ -90,8 +90,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { serviceCaptor.capture(), eq(BluetoothProfile.HEADSET)); serviceListenerUnderTest = serviceCaptor.getValue(); receiverUnderTest = new BluetoothStateReceiver(mBluetoothDeviceManager, null /* route mgr not needed here */); receiverUnderTest = new BluetoothStateReceiver(mBluetoothDeviceManager, mRouteManager); mBluetoothDeviceManager.setHeadsetServiceForTesting(mHeadsetProxy); mBluetoothDeviceManager.setHearingAidServiceForTesting(mBluetoothHearingAid); Loading Loading @@ -196,6 +195,21 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { assertEquals(2, mBluetoothDeviceManager.getNumConnectedDevices()); } @SmallTest @Test public void testHearingAidChangesIgnoredWhenNotInCall() { receiverUnderTest.setIsInCall(false); receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device2, true)); Intent activeDeviceChangedIntent = new Intent(BluetoothHearingAid.ACTION_ACTIVE_DEVICE_CHANGED); activeDeviceChangedIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device2); receiverUnderTest.onReceive(mContext, activeDeviceChangedIntent); verify(mRouteManager).onActiveDeviceChanged(device2, true); verify(mRouteManager, never()).sendMessage(BluetoothRouteManager.BT_AUDIO_IS_ON); } @SmallTest @Test public void testConnectDisconnectAudioHeadset() { Loading