Loading android/app/src/com/android/bluetooth/hfp/HeadsetService.java +28 −11 Original line number Diff line number Diff line Loading @@ -1354,6 +1354,21 @@ public class HeadsetService extends ProfileService { } BluetoothDevice previousActiveDevice = mActiveDevice; mActiveDevice = device; /* If HFP is getting active for a phone call and there are active LE Audio devices, * Lets inactive LeAudio device as soon as possible so there is no CISes connected * when SCO is going to be created */ if (mSystemInterface.isInCall() || mSystemInterface.isRinging()) { LeAudioService leAudioService = mFactory.getLeAudioService(); if (leAudioService != null && !leAudioService.getConnectedDevices().isEmpty() && Flags.leaudioResumeActiveAfterHfpHandover()) { Log.i(TAG, "Make sure no le audio device active for HFP handover."); leAudioService.setInactiveForHfpHandover(mActiveDevice); } } if (getAudioState(previousActiveDevice) != BluetoothHeadset.STATE_AUDIO_DISCONNECTED) { int disconnectStatus = disconnectAudio(previousActiveDevice); if (disconnectStatus != BluetoothStatusCodes.SUCCESS) { Loading Loading @@ -1383,7 +1398,7 @@ public class HeadsetService extends ProfileService { * when SCO is created */ LeAudioService leAudioService = mFactory.getLeAudioService(); if (leAudioService != null) { if (leAudioService != null && !Flags.leaudioResumeActiveAfterHfpHandover()) { Log.i(TAG, "Make sure there is no le audio device active."); leAudioService.setInactiveForHfpHandover(mActiveDevice); } Loading Loading @@ -2151,21 +2166,23 @@ public class HeadsetService extends ProfileService { + "voice call"); } } // Unsuspend A2DP when SCO connection is gone and call state is idle if (mSystemInterface.isCallIdle()) { mSystemInterface.getAudioManager().setA2dpSuspended(false); if (isAtLeastU()) { mSystemInterface.getAudioManager().setLeAudioSuspended(false); // Resumes LE audio previous active device if HFP handover happened before. // Do it here because some controllers cannot handle SCO and CIS // co-existence see {@link LeAudioService#setInactiveForHfpHandover} if (Flags.leaudioResumeActiveAfterHfpHandover()) { LeAudioService leAudioService = mFactory.getLeAudioService(); if (leAudioService != null) { if (leAudioService != null && !leAudioService.getConnectedDevices().isEmpty() && leAudioService.getActiveDevices().get(0) == null) { leAudioService.setActiveAfterHfpHandover(); } } // Unsuspend A2DP when SCO connection is gone and call state is idle if (mSystemInterface.isCallIdle()) { mSystemInterface.getAudioManager().setA2dpSuspended(false); if (isAtLeastU()) { mSystemInterface.getAudioManager().setLeAudioSuspended(false); } } } Loading android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java +6 −1 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; Loading Loading @@ -1604,15 +1605,19 @@ public class HeadsetServiceAndStateMachineTest { @Test public void testHfpHandoverToLeAudioAfterScoDisconnect() { BluetoothDevice device = TestUtils.getTestDevice(mAdapter, 0); mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_RESUME_ACTIVE_AFTER_HFP_HANDOVER); Assert.assertNotNull(mHeadsetService.mFactory); doReturn(mLeAudioService).when(mServiceFactory).getLeAudioService(); doReturn(List.of(device)).when(mLeAudioService).getConnectedDevices(); List<BluetoothDevice> activeDeviceList = new ArrayList<>(); activeDeviceList.add(null); doReturn(activeDeviceList).when(mLeAudioService).getActiveDevices(); mHeadsetService.mFactory = mServiceFactory; doReturn(true).when(mSystemInterface).isCallIdle(); // Connect HF BluetoothDevice device = TestUtils.getTestDevice(mAdapter, 0); connectTestDevice(device); // Make device active Assert.assertTrue(mHeadsetService.setActiveDevice(device)); Loading android/app/src/com/android/bluetooth/le_audio/LeAudioService.java +1 −1 File changed.Contains only whitespace changes. Show changes Loading
android/app/src/com/android/bluetooth/hfp/HeadsetService.java +28 −11 Original line number Diff line number Diff line Loading @@ -1354,6 +1354,21 @@ public class HeadsetService extends ProfileService { } BluetoothDevice previousActiveDevice = mActiveDevice; mActiveDevice = device; /* If HFP is getting active for a phone call and there are active LE Audio devices, * Lets inactive LeAudio device as soon as possible so there is no CISes connected * when SCO is going to be created */ if (mSystemInterface.isInCall() || mSystemInterface.isRinging()) { LeAudioService leAudioService = mFactory.getLeAudioService(); if (leAudioService != null && !leAudioService.getConnectedDevices().isEmpty() && Flags.leaudioResumeActiveAfterHfpHandover()) { Log.i(TAG, "Make sure no le audio device active for HFP handover."); leAudioService.setInactiveForHfpHandover(mActiveDevice); } } if (getAudioState(previousActiveDevice) != BluetoothHeadset.STATE_AUDIO_DISCONNECTED) { int disconnectStatus = disconnectAudio(previousActiveDevice); if (disconnectStatus != BluetoothStatusCodes.SUCCESS) { Loading Loading @@ -1383,7 +1398,7 @@ public class HeadsetService extends ProfileService { * when SCO is created */ LeAudioService leAudioService = mFactory.getLeAudioService(); if (leAudioService != null) { if (leAudioService != null && !Flags.leaudioResumeActiveAfterHfpHandover()) { Log.i(TAG, "Make sure there is no le audio device active."); leAudioService.setInactiveForHfpHandover(mActiveDevice); } Loading Loading @@ -2151,21 +2166,23 @@ public class HeadsetService extends ProfileService { + "voice call"); } } // Unsuspend A2DP when SCO connection is gone and call state is idle if (mSystemInterface.isCallIdle()) { mSystemInterface.getAudioManager().setA2dpSuspended(false); if (isAtLeastU()) { mSystemInterface.getAudioManager().setLeAudioSuspended(false); // Resumes LE audio previous active device if HFP handover happened before. // Do it here because some controllers cannot handle SCO and CIS // co-existence see {@link LeAudioService#setInactiveForHfpHandover} if (Flags.leaudioResumeActiveAfterHfpHandover()) { LeAudioService leAudioService = mFactory.getLeAudioService(); if (leAudioService != null) { if (leAudioService != null && !leAudioService.getConnectedDevices().isEmpty() && leAudioService.getActiveDevices().get(0) == null) { leAudioService.setActiveAfterHfpHandover(); } } // Unsuspend A2DP when SCO connection is gone and call state is idle if (mSystemInterface.isCallIdle()) { mSystemInterface.getAudioManager().setA2dpSuspended(false); if (isAtLeastU()) { mSystemInterface.getAudioManager().setLeAudioSuspended(false); } } } Loading
android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java +6 −1 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; Loading Loading @@ -1604,15 +1605,19 @@ public class HeadsetServiceAndStateMachineTest { @Test public void testHfpHandoverToLeAudioAfterScoDisconnect() { BluetoothDevice device = TestUtils.getTestDevice(mAdapter, 0); mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_RESUME_ACTIVE_AFTER_HFP_HANDOVER); Assert.assertNotNull(mHeadsetService.mFactory); doReturn(mLeAudioService).when(mServiceFactory).getLeAudioService(); doReturn(List.of(device)).when(mLeAudioService).getConnectedDevices(); List<BluetoothDevice> activeDeviceList = new ArrayList<>(); activeDeviceList.add(null); doReturn(activeDeviceList).when(mLeAudioService).getActiveDevices(); mHeadsetService.mFactory = mServiceFactory; doReturn(true).when(mSystemInterface).isCallIdle(); // Connect HF BluetoothDevice device = TestUtils.getTestDevice(mAdapter, 0); connectTestDevice(device); // Make device active Assert.assertTrue(mHeadsetService.setActiveDevice(device)); Loading
android/app/src/com/android/bluetooth/le_audio/LeAudioService.java +1 −1 File changed.Contains only whitespace changes. Show changes