Loading android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java +43 −16 Original line number Diff line number Diff line Loading @@ -614,13 +614,26 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac if (device != null) { setHearingAidActiveDevice(null, true); } if (Utils.isDualModeAudioEnabled() && mAdapterService.isAllSupportedClassicAudioProfilesActive(device)) { if (Utils.isDualModeAudioEnabled()) { if (device != null) { boolean isDualModeDevice = mAdapterService.isAllSupportedClassicAudioProfilesActive(device); if (isDualModeDevice) { setLeAudioActiveDevice(device); } } else { boolean wasDualModeDevice = mAdapterService.isAllSupportedClassicAudioProfilesActive( mA2dpActiveDevice); if (wasDualModeDevice) { // remove LE audio active device when it was actived as dual mode device // before setLeAudioActiveDevice(null, true); } } } } // Just assign locally the new value mA2dpActiveDevice = device; Loading Loading @@ -677,28 +690,42 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac + device + ", mHfpActiveDevice=" + mHfpActiveDevice); if (!Objects.equals(mHfpActiveDevice, device)) { if (device != null) { setHearingAidActiveDevice(null, true); } if (Utils.isDualModeAudioEnabled() && mAdapterService.isAllSupportedClassicAudioProfilesActive(device)) { if (Utils.isDualModeAudioEnabled()) { if (device != null) { boolean isDualModeDevice = mAdapterService.isAllSupportedClassicAudioProfilesActive(device); if (isDualModeDevice) { setLeAudioActiveDevice(device); } } else { if (device != null) { // remove LE audio active device when it is not null, and not dual mode boolean wasDualModeDevice = mAdapterService.isAllSupportedClassicAudioProfilesActive( mA2dpActiveDevice); if (wasDualModeDevice) { // remove LE audio active device when it was actived as dual mode device // before setLeAudioActiveDevice(null, true); } else { Log.d( TAG, "HFP active device is null. Try to fallback to le audio active" + " device"); } Log.d(TAG, "HFP active device is null. Try to fallback to le audio device"); synchronized (mLock) { setFallbackDeviceActiveLocked(device); setFallbackDeviceActiveLocked(null); } } } else { Log.d(TAG, "HFP active device is null. Try to fallback to le audio device"); synchronized (mLock) { setFallbackDeviceActiveLocked(null); } } } // Just assign locally the new value mHfpActiveDevice = device; Loading android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java +16 −3 Original line number Diff line number Diff line Loading @@ -644,6 +644,20 @@ public class ActiveDeviceManagerTest { verify(mHeadsetService, never()).setActiveDevice(any()); } @Test public void a2dpDeactivated_makeSureToNotRemoveLeAudioDevice() { a2dpActiveDeviceChanged(null); mTestLooper.dispatchAll(); verify(mLeAudioService, never()).removeActiveDevice(anyBoolean()); } @Test public void hfpDeactivated_makeSureToNotRemoveLeAudioDevice() { headsetActiveDeviceChanged(null); mTestLooper.dispatchAll(); verify(mLeAudioService, never()).removeActiveDevice(anyBoolean()); } @Test public void a2dpActivated_whileActivatingA2dpHeadset() { a2dpConnected(mA2dpDevice, false); Loading Loading @@ -1477,9 +1491,8 @@ public class ActiveDeviceManagerTest { headsetActiveDeviceChanged(mDualModeAudioDevice); mTestLooper.dispatchAll(); // When A2DP device is getting active, first LeAudio device is removed from active devices // and later added verify(mLeAudioService).removeActiveDevice(anyBoolean()); // When Hfp device is getting active and it is dual mode device LeAudioDevice will be added. verify(mLeAudioService, never()).removeActiveDevice(anyBoolean()); verify(mLeAudioService).setActiveDevice(mDualModeAudioDevice); Assert.assertEquals(mDualModeAudioDevice, mActiveDeviceManager.getA2dpActiveDevice()); Loading Loading
android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java +43 −16 Original line number Diff line number Diff line Loading @@ -614,13 +614,26 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac if (device != null) { setHearingAidActiveDevice(null, true); } if (Utils.isDualModeAudioEnabled() && mAdapterService.isAllSupportedClassicAudioProfilesActive(device)) { if (Utils.isDualModeAudioEnabled()) { if (device != null) { boolean isDualModeDevice = mAdapterService.isAllSupportedClassicAudioProfilesActive(device); if (isDualModeDevice) { setLeAudioActiveDevice(device); } } else { boolean wasDualModeDevice = mAdapterService.isAllSupportedClassicAudioProfilesActive( mA2dpActiveDevice); if (wasDualModeDevice) { // remove LE audio active device when it was actived as dual mode device // before setLeAudioActiveDevice(null, true); } } } } // Just assign locally the new value mA2dpActiveDevice = device; Loading Loading @@ -677,28 +690,42 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac + device + ", mHfpActiveDevice=" + mHfpActiveDevice); if (!Objects.equals(mHfpActiveDevice, device)) { if (device != null) { setHearingAidActiveDevice(null, true); } if (Utils.isDualModeAudioEnabled() && mAdapterService.isAllSupportedClassicAudioProfilesActive(device)) { if (Utils.isDualModeAudioEnabled()) { if (device != null) { boolean isDualModeDevice = mAdapterService.isAllSupportedClassicAudioProfilesActive(device); if (isDualModeDevice) { setLeAudioActiveDevice(device); } } else { if (device != null) { // remove LE audio active device when it is not null, and not dual mode boolean wasDualModeDevice = mAdapterService.isAllSupportedClassicAudioProfilesActive( mA2dpActiveDevice); if (wasDualModeDevice) { // remove LE audio active device when it was actived as dual mode device // before setLeAudioActiveDevice(null, true); } else { Log.d( TAG, "HFP active device is null. Try to fallback to le audio active" + " device"); } Log.d(TAG, "HFP active device is null. Try to fallback to le audio device"); synchronized (mLock) { setFallbackDeviceActiveLocked(device); setFallbackDeviceActiveLocked(null); } } } else { Log.d(TAG, "HFP active device is null. Try to fallback to le audio device"); synchronized (mLock) { setFallbackDeviceActiveLocked(null); } } } // Just assign locally the new value mHfpActiveDevice = device; Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java +16 −3 Original line number Diff line number Diff line Loading @@ -644,6 +644,20 @@ public class ActiveDeviceManagerTest { verify(mHeadsetService, never()).setActiveDevice(any()); } @Test public void a2dpDeactivated_makeSureToNotRemoveLeAudioDevice() { a2dpActiveDeviceChanged(null); mTestLooper.dispatchAll(); verify(mLeAudioService, never()).removeActiveDevice(anyBoolean()); } @Test public void hfpDeactivated_makeSureToNotRemoveLeAudioDevice() { headsetActiveDeviceChanged(null); mTestLooper.dispatchAll(); verify(mLeAudioService, never()).removeActiveDevice(anyBoolean()); } @Test public void a2dpActivated_whileActivatingA2dpHeadset() { a2dpConnected(mA2dpDevice, false); Loading Loading @@ -1477,9 +1491,8 @@ public class ActiveDeviceManagerTest { headsetActiveDeviceChanged(mDualModeAudioDevice); mTestLooper.dispatchAll(); // When A2DP device is getting active, first LeAudio device is removed from active devices // and later added verify(mLeAudioService).removeActiveDevice(anyBoolean()); // When Hfp device is getting active and it is dual mode device LeAudioDevice will be added. verify(mLeAudioService, never()).removeActiveDevice(anyBoolean()); verify(mLeAudioService).setActiveDevice(mDualModeAudioDevice); Assert.assertEquals(mDualModeAudioDevice, mActiveDeviceManager.getA2dpActiveDevice()); Loading