Merge "Rename CachedBluetoothDevice.getConnectableProfiles()" into main

This commit is contained in:
Angela Wang
2024-08-07 09:52:32 +00:00
committed by Android (Google) Code Review
6 changed files with 14 additions and 14 deletions

View File

@@ -47,7 +47,7 @@ public class BluetoothDetailsHeaderController extends BluetoothDetailsController
@Override @Override
public boolean isAvailable() { public boolean isAvailable() {
boolean hasLeAudio = mCachedDevice.getConnectableProfiles() boolean hasLeAudio = mCachedDevice.getUiAccessibleProfiles()
.stream() .stream()
.anyMatch(profile -> profile.getProfileId() == BluetoothProfile.LE_AUDIO); .anyMatch(profile -> profile.getProfileId() == BluetoothProfile.LE_AUDIO);
return !BluetoothUtils.isAdvancedDetailsHeader(mCachedDevice.getDevice()) && !hasLeAudio; return !BluetoothUtils.isAdvancedDetailsHeader(mCachedDevice.getDevice()) && !hasLeAudio;

View File

@@ -314,7 +314,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
return result; return result;
} }
for (CachedBluetoothDevice cachedItem : mAllOfCachedDevices) { for (CachedBluetoothDevice cachedItem : mAllOfCachedDevices) {
List<LocalBluetoothProfile> tmpResult = cachedItem.getConnectableProfiles(); List<LocalBluetoothProfile> tmpResult = cachedItem.getUiAccessibleProfiles();
for (LocalBluetoothProfile profile : tmpResult) { for (LocalBluetoothProfile profile : tmpResult) {
if (mProfileDeviceMap.containsKey(profile.toString())) { if (mProfileDeviceMap.containsKey(profile.toString())) {
mProfileDeviceMap.get(profile.toString()).add(cachedItem); mProfileDeviceMap.get(profile.toString()).add(cachedItem);

View File

@@ -107,7 +107,7 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr
if (mCachedDevice == null || mProfileManager == null) { if (mCachedDevice == null || mProfileManager == null) {
return CONDITIONALLY_UNAVAILABLE; return CONDITIONALLY_UNAVAILABLE;
} }
boolean hasLeAudio = mCachedDevice.getConnectableProfiles() boolean hasLeAudio = mCachedDevice.getUiAccessibleProfiles()
.stream() .stream()
.anyMatch(profile -> profile.getProfileId() == BluetoothProfile.LE_AUDIO); .anyMatch(profile -> profile.getProfileId() == BluetoothProfile.LE_AUDIO);

View File

@@ -437,7 +437,7 @@ public class AudioSharingDevicePreferenceController extends BasePreferenceContro
} }
private boolean isMediaDevice(CachedBluetoothDevice cachedDevice) { private boolean isMediaDevice(CachedBluetoothDevice cachedDevice) {
return cachedDevice.getConnectableProfiles().stream() return cachedDevice.getUiAccessibleProfiles().stream()
.anyMatch( .anyMatch(
profile -> profile ->
profile instanceof A2dpProfile profile instanceof A2dpProfile

View File

@@ -114,7 +114,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
setUpMockProfiles(); setUpMockProfiles();
when(mCachedBluetoothDeviceManager.getCachedDevicesCopy()) when(mCachedBluetoothDeviceManager.getCachedDevicesCopy())
.thenReturn(ImmutableList.of(mCachedDevice)); .thenReturn(ImmutableList.of(mCachedDevice));
when(mCachedDevice.getConnectableProfiles()) when(mCachedDevice.getUiAccessibleProfiles())
.thenAnswer(invocation -> new ArrayList<>(mConnectableProfiles)); .thenAnswer(invocation -> new ArrayList<>(mConnectableProfiles));
when(mCachedDevice.getProfiles()) when(mCachedDevice.getProfiles())
.thenAnswer(invocation -> ImmutableList.of(mConnectableProfiles)); .thenAnswer(invocation -> ImmutableList.of(mConnectableProfiles));

View File

@@ -303,7 +303,7 @@ public class AudioSharingDevicePreferenceControllerTest {
@Test @Test
public void onProfileConnectionStateChanged_notMediaDevice_doNothing() { public void onProfileConnectionStateChanged_notMediaDevice_doNothing() {
doReturn(ImmutableList.of()).when(mCachedDevice).getConnectableProfiles(); doReturn(ImmutableList.of()).when(mCachedDevice).getUiAccessibleProfiles();
mController.onProfileConnectionStateChanged( mController.onProfileConnectionStateChanged(
mCachedDevice, BluetoothAdapter.STATE_CONNECTED, BluetoothProfile.HID_DEVICE); mCachedDevice, BluetoothAdapter.STATE_CONNECTED, BluetoothProfile.HID_DEVICE);
verifyNoInteractions(mDialogHandler); verifyNoInteractions(mDialogHandler);
@@ -313,7 +313,7 @@ public class AudioSharingDevicePreferenceControllerTest {
public void onProfileConnectionStateChanged_leaDeviceDisconnected_closeOpeningDialogsForIt() { public void onProfileConnectionStateChanged_leaDeviceDisconnected_closeOpeningDialogsForIt() {
// Test when LEA device LE_AUDIO_BROADCAST_ASSISTANT disconnected. // Test when LEA device LE_AUDIO_BROADCAST_ASSISTANT disconnected.
when(mDevice.isConnected()).thenReturn(true); when(mDevice.isConnected()).thenReturn(true);
doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getConnectableProfiles(); doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getUiAccessibleProfiles();
doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getProfiles(); doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getProfiles();
mController.onProfileConnectionStateChanged( mController.onProfileConnectionStateChanged(
mCachedDevice, mCachedDevice,
@@ -325,7 +325,7 @@ public class AudioSharingDevicePreferenceControllerTest {
@Test @Test
public void onProfileConnectionStateChanged_assistantProfileConnecting_doNothing() { public void onProfileConnectionStateChanged_assistantProfileConnecting_doNothing() {
// Test when LEA device LE_AUDIO_BROADCAST_ASSISTANT connecting // Test when LEA device LE_AUDIO_BROADCAST_ASSISTANT connecting
doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getConnectableProfiles(); doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getUiAccessibleProfiles();
doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getProfiles(); doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getProfiles();
mController.onProfileConnectionStateChanged( mController.onProfileConnectionStateChanged(
mCachedDevice, mCachedDevice,
@@ -338,7 +338,7 @@ public class AudioSharingDevicePreferenceControllerTest {
public void onProfileConnectionStateChanged_otherProfileConnected_doNothing() { public void onProfileConnectionStateChanged_otherProfileConnected_doNothing() {
// Test when LEA device other profile connected // Test when LEA device other profile connected
when(mDevice.isConnected()).thenReturn(true); when(mDevice.isConnected()).thenReturn(true);
doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getConnectableProfiles(); doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getUiAccessibleProfiles();
doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getProfiles(); doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getProfiles();
mController.onProfileConnectionStateChanged( mController.onProfileConnectionStateChanged(
mCachedDevice, BluetoothAdapter.STATE_CONNECTED, BluetoothProfile.A2DP); mCachedDevice, BluetoothAdapter.STATE_CONNECTED, BluetoothProfile.A2DP);
@@ -349,7 +349,7 @@ public class AudioSharingDevicePreferenceControllerTest {
public void onProfileConnectionStateChanged_otherProfileConnecting_doNothing() { public void onProfileConnectionStateChanged_otherProfileConnecting_doNothing() {
// Test when LEA device other profile connecting // Test when LEA device other profile connecting
when(mDevice.isConnected()).thenReturn(true); when(mDevice.isConnected()).thenReturn(true);
doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getConnectableProfiles(); doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getUiAccessibleProfiles();
doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getProfiles(); doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getProfiles();
mController.onProfileConnectionStateChanged( mController.onProfileConnectionStateChanged(
mCachedDevice, BluetoothAdapter.STATE_CONNECTING, BluetoothProfile.A2DP); mCachedDevice, BluetoothAdapter.STATE_CONNECTING, BluetoothProfile.A2DP);
@@ -360,7 +360,7 @@ public class AudioSharingDevicePreferenceControllerTest {
public void onProfileConnectionStateChanged_assistantProfileConnected_handle() { public void onProfileConnectionStateChanged_assistantProfileConnected_handle() {
// Test when LEA device LE_AUDIO_BROADCAST_ASSISTANT connected // Test when LEA device LE_AUDIO_BROADCAST_ASSISTANT connected
when(mDevice.isConnected()).thenReturn(true); when(mDevice.isConnected()).thenReturn(true);
doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getConnectableProfiles(); doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getUiAccessibleProfiles();
doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getProfiles(); doReturn(ImmutableList.of(mLeAudioProfile)).when(mCachedDevice).getProfiles();
mController.onProfileConnectionStateChanged( mController.onProfileConnectionStateChanged(
mCachedDevice, mCachedDevice,
@@ -374,7 +374,7 @@ public class AudioSharingDevicePreferenceControllerTest {
onProfileConnectionStateChanged_nonLeaDeviceDisconnected_closeOpeningDialogsForIt() { onProfileConnectionStateChanged_nonLeaDeviceDisconnected_closeOpeningDialogsForIt() {
// Test when non-LEA device totally disconnected // Test when non-LEA device totally disconnected
when(mLeAudioProfile.isEnabled(mDevice)).thenReturn(false); when(mLeAudioProfile.isEnabled(mDevice)).thenReturn(false);
doReturn(ImmutableList.of(mA2dpProfile)).when(mCachedDevice).getConnectableProfiles(); doReturn(ImmutableList.of(mA2dpProfile)).when(mCachedDevice).getUiAccessibleProfiles();
doReturn(ImmutableList.of(mLeAudioProfile, mA2dpProfile)).when(mCachedDevice).getProfiles(); doReturn(ImmutableList.of(mLeAudioProfile, mA2dpProfile)).when(mCachedDevice).getProfiles();
when(mCachedDevice.isConnected()).thenReturn(false); when(mCachedDevice.isConnected()).thenReturn(false);
mController.onProfileConnectionStateChanged( mController.onProfileConnectionStateChanged(
@@ -390,7 +390,7 @@ public class AudioSharingDevicePreferenceControllerTest {
.thenReturn(BluetoothAdapter.STATE_CONNECTED); .thenReturn(BluetoothAdapter.STATE_CONNECTED);
doReturn(ImmutableList.of(mA2dpProfile, mHeadsetProfile)) doReturn(ImmutableList.of(mA2dpProfile, mHeadsetProfile))
.when(mCachedDevice) .when(mCachedDevice)
.getConnectableProfiles(); .getUiAccessibleProfiles();
doReturn(ImmutableList.of(mA2dpProfile, mHeadsetProfile)).when(mCachedDevice).getProfiles(); doReturn(ImmutableList.of(mA2dpProfile, mHeadsetProfile)).when(mCachedDevice).getProfiles();
mController.onProfileConnectionStateChanged( mController.onProfileConnectionStateChanged(
mCachedDevice, BluetoothAdapter.STATE_CONNECTED, BluetoothProfile.A2DP); mCachedDevice, BluetoothAdapter.STATE_CONNECTED, BluetoothProfile.A2DP);
@@ -405,7 +405,7 @@ public class AudioSharingDevicePreferenceControllerTest {
.thenReturn(BluetoothAdapter.STATE_DISCONNECTED); .thenReturn(BluetoothAdapter.STATE_DISCONNECTED);
doReturn(ImmutableList.of(mA2dpProfile, mHeadsetProfile)) doReturn(ImmutableList.of(mA2dpProfile, mHeadsetProfile))
.when(mCachedDevice) .when(mCachedDevice)
.getConnectableProfiles(); .getUiAccessibleProfiles();
doReturn(ImmutableList.of(mA2dpProfile, mHeadsetProfile)).when(mCachedDevice).getProfiles(); doReturn(ImmutableList.of(mA2dpProfile, mHeadsetProfile)).when(mCachedDevice).getProfiles();
mController.onProfileConnectionStateChanged( mController.onProfileConnectionStateChanged(
mCachedDevice, BluetoothAdapter.STATE_CONNECTED, BluetoothProfile.A2DP); mCachedDevice, BluetoothAdapter.STATE_CONNECTED, BluetoothProfile.A2DP);