Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +13 −5 Original line number Diff line number Diff line Loading @@ -1026,21 +1026,29 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> return mDevice.getBluetoothClass(); } /** * Returns a list of {@link LocalBluetoothProfile} supported by the device. */ public List<LocalBluetoothProfile> getProfiles() { return new ArrayList<>(mProfiles); } public List<LocalBluetoothProfile> getConnectableProfiles() { List<LocalBluetoothProfile> connectableProfiles = new ArrayList<LocalBluetoothProfile>(); /** * Returns a list of {@link LocalBluetoothProfile} that are user-accessible from UI to * initiate a connection. * * Note: Use {@link #getProfiles()} to retrieve all supported profiles on the device. */ public List<LocalBluetoothProfile> getUiAccessibleProfiles() { List<LocalBluetoothProfile> accessibleProfiles = new ArrayList<>(); synchronized (mProfileLock) { for (LocalBluetoothProfile profile : mProfiles) { if (profile.accessProfileEnabled()) { connectableProfiles.add(profile); accessibleProfiles.add(profile); } } } return connectableProfiles; return accessibleProfiles; } public List<LocalBluetoothProfile> getRemovedProfiles() { Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -261,9 +261,9 @@ public class CsipDeviceManager { } CachedBluetoothDevice dualModeDevice = groupDevicesList.stream() .filter(cachedDevice -> cachedDevice.getConnectableProfiles().stream() .filter(cachedDevice -> cachedDevice.getUiAccessibleProfiles().stream() .anyMatch(profile -> profile instanceof LeAudioProfile)) .filter(cachedDevice -> cachedDevice.getConnectableProfiles().stream() .filter(cachedDevice -> cachedDevice.getUiAccessibleProfiles().stream() .anyMatch(profile -> profile instanceof A2dpProfile || profile instanceof HeadsetProfile)) .findFirst().orElse(null); Loading packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -634,7 +634,7 @@ public class LocalMediaManager implements BluetoothCallback { } private boolean isMediaDevice(CachedBluetoothDevice device) { for (LocalBluetoothProfile profile : device.getConnectableProfiles()) { for (LocalBluetoothProfile profile : device.getUiAccessibleProfiles()) { if (profile instanceof A2dpProfile || profile instanceof HearingAidProfile || profile instanceof LeAudioProfile) { return true; Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CsipDeviceManagerTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -145,18 +145,18 @@ public class CsipDeviceManagerTest { profiles.add(mHfpProfile); profiles.add(mA2dpProfile); profiles.add(mLeAudioProfile); when(mCachedDevice1.getConnectableProfiles()).thenReturn(profiles); when(mCachedDevice1.getUiAccessibleProfiles()).thenReturn(profiles); when(mCachedDevice1.isConnected()).thenReturn(true); profiles.clear(); profiles.add(mLeAudioProfile); when(mCachedDevice2.getConnectableProfiles()).thenReturn(profiles); when(mCachedDevice2.getUiAccessibleProfiles()).thenReturn(profiles); when(mCachedDevice2.isConnected()).thenReturn(true); profiles.clear(); profiles.add(mHfpProfile); profiles.add(mA2dpProfile); when(mCachedDevice3.getConnectableProfiles()).thenReturn(profiles); when(mCachedDevice3.getUiAccessibleProfiles()).thenReturn(profiles); when(mCachedDevice3.isConnected()).thenReturn(true); } Loading Loading @@ -253,7 +253,7 @@ public class CsipDeviceManagerTest { when(mDevice2.isConnected()).thenReturn(false); List<LocalBluetoothProfile> profiles = new ArrayList<LocalBluetoothProfile>(); profiles.add(mLeAudioProfile); when(mCachedDevice1.getConnectableProfiles()).thenReturn(profiles); when(mCachedDevice1.getUiAccessibleProfiles()).thenReturn(profiles); CachedBluetoothDevice expectedDevice = mCachedDevice1; assertThat( Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/LocalMediaManagerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -470,7 +470,7 @@ public class LocalMediaManagerTest { when(cachedManager.findDevice(bluetoothDevice)).thenReturn(cachedDevice); when(cachedDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED); when(cachedDevice.isConnected()).thenReturn(false); when(cachedDevice.getConnectableProfiles()).thenReturn(profiles); when(cachedDevice.getUiAccessibleProfiles()).thenReturn(profiles); when(cachedDevice.getDevice()).thenReturn(bluetoothDevice); when(cachedDevice.getAddress()).thenReturn(TEST_ADDRESS); when(mA2dpProfile.getActiveDevice()).thenReturn(bluetoothDevice); Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +13 −5 Original line number Diff line number Diff line Loading @@ -1026,21 +1026,29 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> return mDevice.getBluetoothClass(); } /** * Returns a list of {@link LocalBluetoothProfile} supported by the device. */ public List<LocalBluetoothProfile> getProfiles() { return new ArrayList<>(mProfiles); } public List<LocalBluetoothProfile> getConnectableProfiles() { List<LocalBluetoothProfile> connectableProfiles = new ArrayList<LocalBluetoothProfile>(); /** * Returns a list of {@link LocalBluetoothProfile} that are user-accessible from UI to * initiate a connection. * * Note: Use {@link #getProfiles()} to retrieve all supported profiles on the device. */ public List<LocalBluetoothProfile> getUiAccessibleProfiles() { List<LocalBluetoothProfile> accessibleProfiles = new ArrayList<>(); synchronized (mProfileLock) { for (LocalBluetoothProfile profile : mProfiles) { if (profile.accessProfileEnabled()) { connectableProfiles.add(profile); accessibleProfiles.add(profile); } } } return connectableProfiles; return accessibleProfiles; } public List<LocalBluetoothProfile> getRemovedProfiles() { Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -261,9 +261,9 @@ public class CsipDeviceManager { } CachedBluetoothDevice dualModeDevice = groupDevicesList.stream() .filter(cachedDevice -> cachedDevice.getConnectableProfiles().stream() .filter(cachedDevice -> cachedDevice.getUiAccessibleProfiles().stream() .anyMatch(profile -> profile instanceof LeAudioProfile)) .filter(cachedDevice -> cachedDevice.getConnectableProfiles().stream() .filter(cachedDevice -> cachedDevice.getUiAccessibleProfiles().stream() .anyMatch(profile -> profile instanceof A2dpProfile || profile instanceof HeadsetProfile)) .findFirst().orElse(null); Loading
packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -634,7 +634,7 @@ public class LocalMediaManager implements BluetoothCallback { } private boolean isMediaDevice(CachedBluetoothDevice device) { for (LocalBluetoothProfile profile : device.getConnectableProfiles()) { for (LocalBluetoothProfile profile : device.getUiAccessibleProfiles()) { if (profile instanceof A2dpProfile || profile instanceof HearingAidProfile || profile instanceof LeAudioProfile) { return true; Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CsipDeviceManagerTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -145,18 +145,18 @@ public class CsipDeviceManagerTest { profiles.add(mHfpProfile); profiles.add(mA2dpProfile); profiles.add(mLeAudioProfile); when(mCachedDevice1.getConnectableProfiles()).thenReturn(profiles); when(mCachedDevice1.getUiAccessibleProfiles()).thenReturn(profiles); when(mCachedDevice1.isConnected()).thenReturn(true); profiles.clear(); profiles.add(mLeAudioProfile); when(mCachedDevice2.getConnectableProfiles()).thenReturn(profiles); when(mCachedDevice2.getUiAccessibleProfiles()).thenReturn(profiles); when(mCachedDevice2.isConnected()).thenReturn(true); profiles.clear(); profiles.add(mHfpProfile); profiles.add(mA2dpProfile); when(mCachedDevice3.getConnectableProfiles()).thenReturn(profiles); when(mCachedDevice3.getUiAccessibleProfiles()).thenReturn(profiles); when(mCachedDevice3.isConnected()).thenReturn(true); } Loading Loading @@ -253,7 +253,7 @@ public class CsipDeviceManagerTest { when(mDevice2.isConnected()).thenReturn(false); List<LocalBluetoothProfile> profiles = new ArrayList<LocalBluetoothProfile>(); profiles.add(mLeAudioProfile); when(mCachedDevice1.getConnectableProfiles()).thenReturn(profiles); when(mCachedDevice1.getUiAccessibleProfiles()).thenReturn(profiles); CachedBluetoothDevice expectedDevice = mCachedDevice1; assertThat( Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/LocalMediaManagerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -470,7 +470,7 @@ public class LocalMediaManagerTest { when(cachedManager.findDevice(bluetoothDevice)).thenReturn(cachedDevice); when(cachedDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED); when(cachedDevice.isConnected()).thenReturn(false); when(cachedDevice.getConnectableProfiles()).thenReturn(profiles); when(cachedDevice.getUiAccessibleProfiles()).thenReturn(profiles); when(cachedDevice.getDevice()).thenReturn(bluetoothDevice); when(cachedDevice.getAddress()).thenReturn(TEST_ADDRESS); when(mA2dpProfile.getActiveDevice()).thenReturn(bluetoothDevice); Loading