Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +18 −9 Original line number Diff line number Diff line Loading @@ -322,16 +322,25 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> } private void updatePreferredTransport() { if (mProfiles.stream().noneMatch(p -> p instanceof LeAudioProfile) || mProfiles.stream().noneMatch(p -> p instanceof HidProfile)) { LeAudioProfile leAudioProfile = (LeAudioProfile) mProfiles.stream() .filter(p -> p instanceof LeAudioProfile) .findFirst() .orElse(null); HidProfile hidProfile = (HidProfile) mProfiles.stream() .filter(p -> p instanceof HidProfile) .findFirst() .orElse(null); if (leAudioProfile == null || hidProfile == null) { return; } // Both LeAudioProfile and HidProfile are connectable. if (!mProfileManager .getHidProfile() .setPreferredTransport( if (!hidProfile.setPreferredTransport( mDevice, mProfileManager.getLeAudioProfile().isEnabled(mDevice) leAudioProfile.isEnabled(mDevice) ? BluetoothDevice.TRANSPORT_LE : BluetoothDevice.TRANSPORT_BREDR)) { Log.w(TAG, "Fail to set preferred transport"); Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java +0 −5 Original line number Diff line number Diff line Loading @@ -1952,9 +1952,6 @@ public class CachedBluetoothDeviceTest { @Test public void leAudioHidDevice_leAudioEnabled_setPreferredTransportToLE() { when(mProfileManager.getHidProfile()).thenReturn(mHidProfile); when(mProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile); when(mLeAudioProfile.isEnabled(mDevice)).thenReturn(true); updateProfileStatus(mHidProfile, BluetoothProfile.STATE_CONNECTED); Loading @@ -1965,8 +1962,6 @@ public class CachedBluetoothDeviceTest { @Test public void leAudioHidDevice_leAudioDisabled_setPreferredTransportToBredr() { when(mProfileManager.getHidProfile()).thenReturn(mHidProfile); when(mProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile); when(mLeAudioProfile.isEnabled(mDevice)).thenReturn(false); updateProfileStatus(mLeAudioProfile, BluetoothProfile.STATE_CONNECTED); Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +18 −9 Original line number Diff line number Diff line Loading @@ -322,16 +322,25 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> } private void updatePreferredTransport() { if (mProfiles.stream().noneMatch(p -> p instanceof LeAudioProfile) || mProfiles.stream().noneMatch(p -> p instanceof HidProfile)) { LeAudioProfile leAudioProfile = (LeAudioProfile) mProfiles.stream() .filter(p -> p instanceof LeAudioProfile) .findFirst() .orElse(null); HidProfile hidProfile = (HidProfile) mProfiles.stream() .filter(p -> p instanceof HidProfile) .findFirst() .orElse(null); if (leAudioProfile == null || hidProfile == null) { return; } // Both LeAudioProfile and HidProfile are connectable. if (!mProfileManager .getHidProfile() .setPreferredTransport( if (!hidProfile.setPreferredTransport( mDevice, mProfileManager.getLeAudioProfile().isEnabled(mDevice) leAudioProfile.isEnabled(mDevice) ? BluetoothDevice.TRANSPORT_LE : BluetoothDevice.TRANSPORT_BREDR)) { Log.w(TAG, "Fail to set preferred transport"); Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java +0 −5 Original line number Diff line number Diff line Loading @@ -1952,9 +1952,6 @@ public class CachedBluetoothDeviceTest { @Test public void leAudioHidDevice_leAudioEnabled_setPreferredTransportToLE() { when(mProfileManager.getHidProfile()).thenReturn(mHidProfile); when(mProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile); when(mLeAudioProfile.isEnabled(mDevice)).thenReturn(true); updateProfileStatus(mHidProfile, BluetoothProfile.STATE_CONNECTED); Loading @@ -1965,8 +1962,6 @@ public class CachedBluetoothDeviceTest { @Test public void leAudioHidDevice_leAudioDisabled_setPreferredTransportToBredr() { when(mProfileManager.getHidProfile()).thenReturn(mHidProfile); when(mProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile); when(mLeAudioProfile.isEnabled(mDevice)).thenReturn(false); updateProfileStatus(mLeAudioProfile, BluetoothProfile.STATE_CONNECTED); Loading