Merge "Show device in Media devices section if has LEA member connected" into main
This commit is contained in:
@@ -79,7 +79,8 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
|||||||
// If device is LE Audio, it is compatible with HFP and A2DP.
|
// If device is LE Audio, it is compatible with HFP and A2DP.
|
||||||
// It would show in Available Devices group if the audio sharing flag is disabled or
|
// It would show in Available Devices group if the audio sharing flag is disabled or
|
||||||
// the device is not in the audio sharing session.
|
// the device is not in the audio sharing session.
|
||||||
if (cachedDevice.isConnectedLeAudioDevice()) {
|
if (cachedDevice.isConnectedLeAudioDevice()
|
||||||
|
|| cachedDevice.hasConnectedLeAudioMemberDevice()) {
|
||||||
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)
|
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)
|
||||||
&& BluetoothUtils.hasConnectedBroadcastSource(
|
&& BluetoothUtils.hasConnectedBroadcastSource(
|
||||||
cachedDevice, mLocalBtManager)) {
|
cachedDevice, mLocalBtManager)) {
|
||||||
|
|||||||
@@ -77,7 +77,12 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
|
|||||||
// If device is Hearing Aid or LE Audio, it is compatible with HFP and A2DP.
|
// If device is Hearing Aid or LE Audio, it is compatible with HFP and A2DP.
|
||||||
// It would not show in Connected Devices group.
|
// It would not show in Connected Devices group.
|
||||||
if (cachedDevice.isConnectedAshaHearingAidDevice()
|
if (cachedDevice.isConnectedAshaHearingAidDevice()
|
||||||
|| cachedDevice.isConnectedLeAudioDevice()) {
|
|| cachedDevice.isConnectedLeAudioDevice()
|
||||||
|
|| cachedDevice.hasConnectedLeAudioMemberDevice()) {
|
||||||
|
if (DBG) {
|
||||||
|
Log.d(TAG, "isFilterMatched() device : " + cachedDevice.getName()
|
||||||
|
+ ", isFilterMatched : false, ha or lea device");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// According to the current audio profile type,
|
// According to the current audio profile type,
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ public class AudioSharingBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
|||||||
// If device is LE audio device and has a broadcast source,
|
// If device is LE audio device and has a broadcast source,
|
||||||
// it would show in audio sharing devices group.
|
// it would show in audio sharing devices group.
|
||||||
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)
|
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)
|
||||||
&& cachedDevice.isConnectedLeAudioDevice()
|
&& (cachedDevice.isConnectedLeAudioDevice()
|
||||||
|
|| cachedDevice.hasConnectedLeAudioMemberDevice())
|
||||||
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mLocalBtManager)) {
|
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mLocalBtManager)) {
|
||||||
isFilterMatched = true;
|
isFilterMatched = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ public class AudioSharingDeviceVolumeControlUpdater extends BluetoothDeviceUpdat
|
|||||||
if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) {
|
if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) {
|
||||||
// If device is LE audio device and in a sharing session on current sharing device,
|
// If device is LE audio device and in a sharing session on current sharing device,
|
||||||
// it would show in volume control group.
|
// it would show in volume control group.
|
||||||
if (cachedDevice.isConnectedLeAudioDevice()
|
if ((cachedDevice.isConnectedLeAudioDevice()
|
||||||
|
|| cachedDevice.hasConnectedLeAudioMemberDevice())
|
||||||
&& BluetoothUtils.isBroadcasting(mBtManager)
|
&& BluetoothUtils.isBroadcasting(mBtManager)
|
||||||
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mBtManager)) {
|
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mBtManager)) {
|
||||||
isFilterMatched = true;
|
isFilterMatched = true;
|
||||||
|
|||||||
@@ -282,6 +282,28 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
|||||||
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
|
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void
|
||||||
|
onProfileConnectionStateChanged_hasLeaMemberConnected_notInCallFlagOff_addPref() {
|
||||||
|
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||||
|
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||||
|
when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
|
||||||
|
.thenReturn(true);
|
||||||
|
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||||
|
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||||
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mBroadcastReceiveState));
|
||||||
|
List<Long> bisSyncState = new ArrayList<>();
|
||||||
|
bisSyncState.add(1L);
|
||||||
|
when(mBroadcastReceiveState.getBisSyncState()).thenReturn(bisSyncState);
|
||||||
|
|
||||||
|
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
|
||||||
|
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaConnected_notInCallNotInSharing_addPref() {
|
public void onProfileConnectionStateChanged_leaConnected_notInCallNotInSharing_addPref() {
|
||||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||||
@@ -299,6 +321,25 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
|||||||
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
|
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void
|
||||||
|
onProfileConnectionStateChanged_hasLeaMemberConnected_notInCallNotInSharing_addPref() {
|
||||||
|
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||||
|
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||||
|
when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
|
||||||
|
.thenReturn(true);
|
||||||
|
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||||
|
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||||
|
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||||
|
|
||||||
|
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
|
||||||
|
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaConnected_inCallSharingFlagOff_addPref() {
|
public void onProfileConnectionStateChanged_leaConnected_inCallSharingFlagOff_addPref() {
|
||||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||||
|
|||||||
@@ -269,6 +269,20 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
|||||||
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onProfileConnectionStateChanged_hasLeaMemberConnected_inCall_removesPreference() {
|
||||||
|
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_IN_CALL);
|
||||||
|
when(mBluetoothDeviceUpdater
|
||||||
|
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||||
|
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||||
|
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||||
|
|
||||||
|
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
|
||||||
|
|
||||||
|
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_removesPreference()
|
public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_removesPreference()
|
||||||
{
|
{
|
||||||
@@ -282,6 +296,22 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
|||||||
|
|
||||||
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void
|
||||||
|
onProfileConnectionStateChanged_hasLeaMemberConnected_notInCall_removesPreference() {
|
||||||
|
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||||
|
when(mBluetoothDeviceUpdater
|
||||||
|
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||||
|
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||||
|
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||||
|
|
||||||
|
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
|
||||||
|
|
||||||
|
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_deviceIsNotInList_inCall_invokesRemovesPreference()
|
public void onProfileConnectionStateChanged_deviceIsNotInList_inCall_invokesRemovesPreference()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -153,6 +153,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaDeviceConnected_flagOff_removesPref() {
|
public void onProfileConnectionStateChanged_leaDeviceConnected_flagOff_removesPref() {
|
||||||
setupPreferenceMapWithDevice(false);
|
setupPreferenceMapWithDevice(false);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
@@ -172,6 +177,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaConnected_flagOff_hysteresisMode_removesPref() {
|
public void onProfileConnectionStateChanged_leaConnected_flagOff_hysteresisMode_removesPref() {
|
||||||
setupPreferenceMapWithDevice(true);
|
setupPreferenceMapWithDevice(true);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
@@ -191,6 +201,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaConnected_noSource_removesPref() {
|
public void onProfileConnectionStateChanged_leaConnected_noSource_removesPref() {
|
||||||
setupPreferenceMapWithDevice(false);
|
setupPreferenceMapWithDevice(false);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
@@ -210,6 +225,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaConnected_noSource_hysteresisMode_removesPref() {
|
public void onProfileConnectionStateChanged_leaConnected_noSource_hysteresisMode_removesPref() {
|
||||||
setupPreferenceMapWithDevice(true);
|
setupPreferenceMapWithDevice(true);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
@@ -229,6 +249,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_deviceIsNotInList_removesPref() {
|
public void onProfileConnectionStateChanged_deviceIsNotInList_removesPref() {
|
||||||
setupPreferenceMapWithDevice(false);
|
setupPreferenceMapWithDevice(false);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
mCachedDevices.clear();
|
mCachedDevices.clear();
|
||||||
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
||||||
@@ -249,6 +274,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_deviceIsNotInList_hysteresisMode_removesPref() {
|
public void onProfileConnectionStateChanged_deviceIsNotInList_hysteresisMode_removesPref() {
|
||||||
setupPreferenceMapWithDevice(true);
|
setupPreferenceMapWithDevice(true);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
mCachedDevices.clear();
|
mCachedDevices.clear();
|
||||||
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
||||||
@@ -269,6 +299,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaDisconnected_removesPref() {
|
public void onProfileConnectionStateChanged_leaDisconnected_removesPref() {
|
||||||
setupPreferenceMapWithDevice(false);
|
setupPreferenceMapWithDevice(false);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
|
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
@@ -288,6 +323,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaDisconnected_hysteresisMode_removesPref() {
|
public void onProfileConnectionStateChanged_leaDisconnected_hysteresisMode_removesPref() {
|
||||||
setupPreferenceMapWithDevice(true);
|
setupPreferenceMapWithDevice(true);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
|
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
@@ -307,6 +347,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaDisconnecting_removesPref() {
|
public void onProfileConnectionStateChanged_leaDisconnecting_removesPref() {
|
||||||
setupPreferenceMapWithDevice(false);
|
setupPreferenceMapWithDevice(false);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
doReturn(false).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
|
doReturn(false).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
|
|
||||||
@@ -325,6 +370,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaDisconnecting_hysteresisMode_removesPref() {
|
public void onProfileConnectionStateChanged_leaDisconnecting_hysteresisMode_removesPref() {
|
||||||
setupPreferenceMapWithDevice(true);
|
setupPreferenceMapWithDevice(true);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
doReturn(false).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
|
doReturn(false).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
|
|
||||||
@@ -344,6 +394,29 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
public void onProfileConnectionStateChanged_leaConnected_hasSource_addsPref() {
|
public void onProfileConnectionStateChanged_leaConnected_hasSource_addsPref() {
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
setupPreferenceMapWithDevice(false);
|
setupPreferenceMapWithDevice(false);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
|
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||||
|
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
|
||||||
|
assertThat(((BluetoothDevicePreference) captor.getValue()).getBluetoothDevice())
|
||||||
|
.isEqualTo(mCachedBluetoothDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onProfileConnectionStateChanged_hasLeaMemberConnected_hasSource_addsPref() {
|
||||||
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
|
setupPreferenceMapWithDevice(false);
|
||||||
|
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||||
|
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||||
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
|
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
|
||||||
@@ -355,6 +428,30 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
public void onProfileConnectionStateChanged_leaConnected_hasSource_hysteresisMode_addsPref() {
|
public void onProfileConnectionStateChanged_leaConnected_hasSource_hysteresisMode_addsPref() {
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
setupPreferenceMapWithDevice(true);
|
setupPreferenceMapWithDevice(true);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
|
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||||
|
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
|
||||||
|
assertThat(((BluetoothDevicePreference) captor.getValue()).getBluetoothDevice())
|
||||||
|
.isEqualTo(mCachedBluetoothDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void
|
||||||
|
onProfileConnectionStateChanged_hasLeaMemberConnected_hasSource_hysteresis_addsPref() {
|
||||||
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
|
setupPreferenceMapWithDevice(true);
|
||||||
|
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||||
|
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||||
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
|
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
|
||||||
@@ -397,10 +494,5 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of(mState));
|
||||||
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||||
doReturn(true).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
|
doReturn(true).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
|
||||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
|
||||||
mCachedBluetoothDevice,
|
|
||||||
BluetoothProfile.STATE_CONNECTED,
|
|
||||||
BluetoothProfile.LE_AUDIO);
|
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaDeviceConnected_noSharing_removesPref() {
|
public void onProfileConnectionStateChanged_leaDeviceConnected_noSharing_removesPref() {
|
||||||
setupPreferenceMapWithDevice();
|
setupPreferenceMapWithDevice();
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
when(mBroadcast.isEnabled(null)).thenReturn(false);
|
when(mBroadcast.isEnabled(null)).thenReturn(false);
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
@@ -146,6 +151,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaDeviceConnected_noSource_removesPref() {
|
public void onProfileConnectionStateChanged_leaDeviceConnected_noSource_removesPref() {
|
||||||
setupPreferenceMapWithDevice();
|
setupPreferenceMapWithDevice();
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
|
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
@@ -165,6 +175,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_deviceIsNotInList_removesPref() {
|
public void onProfileConnectionStateChanged_deviceIsNotInList_removesPref() {
|
||||||
setupPreferenceMapWithDevice();
|
setupPreferenceMapWithDevice();
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
mCachedDevices.clear();
|
mCachedDevices.clear();
|
||||||
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
||||||
@@ -185,6 +200,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaDeviceDisconnected_removesPref() {
|
public void onProfileConnectionStateChanged_leaDeviceDisconnected_removesPref() {
|
||||||
setupPreferenceMapWithDevice();
|
setupPreferenceMapWithDevice();
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
|
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
@@ -204,6 +224,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaDeviceDisconnecting_removesPref() {
|
public void onProfileConnectionStateChanged_leaDeviceDisconnecting_removesPref() {
|
||||||
setupPreferenceMapWithDevice();
|
setupPreferenceMapWithDevice();
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
@@ -224,6 +249,29 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
|||||||
public void onProfileConnectionStateChanged_leaDeviceConnected_hasSource_addsPreference() {
|
public void onProfileConnectionStateChanged_leaDeviceConnected_hasSource_addsPreference() {
|
||||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
setupPreferenceMapWithDevice();
|
setupPreferenceMapWithDevice();
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
|
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||||
|
assertThat(captor.getValue() instanceof AudioSharingDeviceVolumePreference).isTrue();
|
||||||
|
assertThat(((AudioSharingDeviceVolumePreference) captor.getValue()).getCachedDevice())
|
||||||
|
.isEqualTo(mCachedBluetoothDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onProfileConnectionStateChanged_hasLeaMemberConnected_hasSource_addsPreference() {
|
||||||
|
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||||
|
setupPreferenceMapWithDevice();
|
||||||
|
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||||
|
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||||
assertThat(captor.getValue() instanceof AudioSharingDeviceVolumePreference).isTrue();
|
assertThat(captor.getValue() instanceof AudioSharingDeviceVolumePreference).isTrue();
|
||||||
@@ -262,6 +310,12 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
|||||||
@Test
|
@Test
|
||||||
public void refreshPreference_doNothing() {
|
public void refreshPreference_doNothing() {
|
||||||
setupPreferenceMapWithDevice();
|
setupPreferenceMapWithDevice();
|
||||||
|
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||||
|
mCachedBluetoothDevice,
|
||||||
|
BluetoothProfile.STATE_CONNECTED,
|
||||||
|
BluetoothProfile.LE_AUDIO);
|
||||||
|
shadowOf(Looper.getMainLooper()).idle();
|
||||||
|
|
||||||
verify(mDevicePreferenceCallback).onDeviceAdded(any(Preference.class));
|
verify(mDevicePreferenceCallback).onDeviceAdded(any(Preference.class));
|
||||||
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(ImmutableList.of());
|
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(ImmutableList.of());
|
||||||
mDeviceUpdater.refreshPreference();
|
mDeviceUpdater.refreshPreference();
|
||||||
@@ -276,10 +330,5 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
|||||||
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of(mState));
|
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of(mState));
|
||||||
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||||
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
|
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
|
||||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
|
||||||
mCachedBluetoothDevice,
|
|
||||||
BluetoothProfile.STATE_CONNECTED,
|
|
||||||
BluetoothProfile.LE_AUDIO);
|
|
||||||
shadowOf(Looper.getMainLooper()).idle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user