Loading android/app/src/com/android/bluetooth/hfp/HeadsetService.java +18 −2 Original line number Diff line number Diff line Loading @@ -1393,6 +1393,9 @@ public class HeadsetService extends ProfileService { mActiveDevice = null; mNativeInterface.setActiveDevice(null); broadcastActiveDevice(null); if (Flags.updateActiveDeviceInBandRingtone()) { updateInbandRinging(null, true); } } } Loading Loading @@ -1469,6 +1472,9 @@ public class HeadsetService extends ProfileService { BluetoothProfileConnectionInfo.createHfpInfo()); } broadcastActiveDevice(mActiveDevice); if (Flags.updateActiveDeviceInBandRingtone()) { updateInbandRinging(device, true); } } else if (shouldPersistAudio()) { /* If HFP is getting active for a phonecall and there is LeAudio device active, * Lets inactive LeAudio device as soon as possible so there is no CISes connected Loading Loading @@ -1520,6 +1526,9 @@ public class HeadsetService extends ProfileService { BluetoothProfileConnectionInfo.createHfpInfo()); } broadcastActiveDevice(mActiveDevice); if (Flags.updateActiveDeviceInBandRingtone()) { updateInbandRinging(device, true); } } } return true; Loading Loading @@ -2206,8 +2215,13 @@ public class HeadsetService extends ProfileService { synchronized (mStateMachines) { final boolean inbandRingingRuntimeDisable = mInbandRingingRuntimeDisable; mInbandRingingRuntimeDisable = getConnectedDevices().size() > 1 || isHeadsetClientConnected(); if (getConnectedDevices().size() > 1 || isHeadsetClientConnected() || (Flags.updateActiveDeviceInBandRingtone() && mActiveDevice == null)) { mInbandRingingRuntimeDisable = true; } else { mInbandRingingRuntimeDisable = false; } final boolean updateAll = inbandRingingRuntimeDisable != mInbandRingingRuntimeDisable; Loading @@ -2216,6 +2230,8 @@ public class HeadsetService extends ProfileService { "updateInbandRinging():" + " Device=" + device + " ActiveDevice=" + mActiveDevice + " enabled=" + !mInbandRingingRuntimeDisable + " connected=" Loading android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -494,6 +494,28 @@ public class HeadsetServiceAndStateMachineTest { assertThat(mHeadsetService.isVirtualCallStarted()).isFalse(); } /** Test the value of isInbandRingingEnabled will be changed with the change of active device */ @Test public void testIsInbandRingingEnabled_SwitchActiveDevice() { mSetFlagsRule.enableFlags(Flags.FLAG_UPDATE_ACTIVE_DEVICE_IN_BAND_RINGTONE); BluetoothDevice device = TestUtils.getTestDevice(mAdapter, 0); connectTestDevice(device); assertThat(mHeadsetService.setActiveDevice(device)).isTrue(); mTestLooper.dispatchAll(); assertThat(mHeadsetService.isInbandRingingEnabled()).isTrue(); assertThat(mHeadsetService.setActiveDevice(null)).isTrue(); mTestLooper.dispatchAll(); verify(mNativeInterface, atLeastOnce()).sendBsir(eq(device), eq(false)); assertThat(mHeadsetService.isInbandRingingEnabled()).isFalse(); assertThat(mHeadsetService.setActiveDevice(device)).isTrue(); mTestLooper.dispatchAll(); verify(mNativeInterface, atLeastOnce()).sendBsir(eq(device), eq(true)); assertThat(mHeadsetService.isInbandRingingEnabled()).isTrue(); } /** Test the behavior when dialing outgoing call from the headset */ @Test public void testDialingOutCall_NormalDialingOut() throws RemoteException { Loading Loading
android/app/src/com/android/bluetooth/hfp/HeadsetService.java +18 −2 Original line number Diff line number Diff line Loading @@ -1393,6 +1393,9 @@ public class HeadsetService extends ProfileService { mActiveDevice = null; mNativeInterface.setActiveDevice(null); broadcastActiveDevice(null); if (Flags.updateActiveDeviceInBandRingtone()) { updateInbandRinging(null, true); } } } Loading Loading @@ -1469,6 +1472,9 @@ public class HeadsetService extends ProfileService { BluetoothProfileConnectionInfo.createHfpInfo()); } broadcastActiveDevice(mActiveDevice); if (Flags.updateActiveDeviceInBandRingtone()) { updateInbandRinging(device, true); } } else if (shouldPersistAudio()) { /* If HFP is getting active for a phonecall and there is LeAudio device active, * Lets inactive LeAudio device as soon as possible so there is no CISes connected Loading Loading @@ -1520,6 +1526,9 @@ public class HeadsetService extends ProfileService { BluetoothProfileConnectionInfo.createHfpInfo()); } broadcastActiveDevice(mActiveDevice); if (Flags.updateActiveDeviceInBandRingtone()) { updateInbandRinging(device, true); } } } return true; Loading Loading @@ -2206,8 +2215,13 @@ public class HeadsetService extends ProfileService { synchronized (mStateMachines) { final boolean inbandRingingRuntimeDisable = mInbandRingingRuntimeDisable; mInbandRingingRuntimeDisable = getConnectedDevices().size() > 1 || isHeadsetClientConnected(); if (getConnectedDevices().size() > 1 || isHeadsetClientConnected() || (Flags.updateActiveDeviceInBandRingtone() && mActiveDevice == null)) { mInbandRingingRuntimeDisable = true; } else { mInbandRingingRuntimeDisable = false; } final boolean updateAll = inbandRingingRuntimeDisable != mInbandRingingRuntimeDisable; Loading @@ -2216,6 +2230,8 @@ public class HeadsetService extends ProfileService { "updateInbandRinging():" + " Device=" + device + " ActiveDevice=" + mActiveDevice + " enabled=" + !mInbandRingingRuntimeDisable + " connected=" Loading
android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -494,6 +494,28 @@ public class HeadsetServiceAndStateMachineTest { assertThat(mHeadsetService.isVirtualCallStarted()).isFalse(); } /** Test the value of isInbandRingingEnabled will be changed with the change of active device */ @Test public void testIsInbandRingingEnabled_SwitchActiveDevice() { mSetFlagsRule.enableFlags(Flags.FLAG_UPDATE_ACTIVE_DEVICE_IN_BAND_RINGTONE); BluetoothDevice device = TestUtils.getTestDevice(mAdapter, 0); connectTestDevice(device); assertThat(mHeadsetService.setActiveDevice(device)).isTrue(); mTestLooper.dispatchAll(); assertThat(mHeadsetService.isInbandRingingEnabled()).isTrue(); assertThat(mHeadsetService.setActiveDevice(null)).isTrue(); mTestLooper.dispatchAll(); verify(mNativeInterface, atLeastOnce()).sendBsir(eq(device), eq(false)); assertThat(mHeadsetService.isInbandRingingEnabled()).isFalse(); assertThat(mHeadsetService.setActiveDevice(device)).isTrue(); mTestLooper.dispatchAll(); verify(mNativeInterface, atLeastOnce()).sendBsir(eq(device), eq(true)); assertThat(mHeadsetService.isInbandRingingEnabled()).isTrue(); } /** Test the behavior when dialing outgoing call from the headset */ @Test public void testDialingOutCall_NormalDialingOut() throws RemoteException { Loading