Update the LE audio device into the media device category

Bug: 178981521
Test: make RunSettingsRoboTests
ROBOTEST_FILTER=AvailableMediaBluetoothDeviceUpdater
Test: make RunSettingsRoboTests
ROBOTEST_FILTER=ConnectedBluetoothDeviceUpdater

Change-Id: I094ba6beb66fdebd7f3ef0a7c12bbed0e5b870e8
This commit is contained in:
Alice Kuo
2021-03-03 17:08:36 +08:00
parent b69983414e
commit fa0aec49e3
4 changed files with 59 additions and 4 deletions

View File

@@ -70,9 +70,10 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater
if (DBG) { if (DBG) {
Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile); Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile);
} }
// If device is Hearing Aid, it is compatible with HFP and A2DP. // If device is Hearing Aid or LE Audio, it is compatible with HFP and A2DP.
// It would show in Available Devices group. // It would show in Available Devices group.
if (cachedDevice.isConnectedHearingAidDevice()) { if (cachedDevice.isConnectedHearingAidDevice()
|| cachedDevice.isConnectedLeAudioDevice()) {
return true; return true;
} }
// According to the current audio profile type, // According to the current audio profile type,

View File

@@ -70,9 +70,10 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
if (DBG) { if (DBG) {
Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile); Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile);
} }
// If device is Hearing Aid, 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.isConnectedHearingAidDevice()) { if (cachedDevice.isConnectedHearingAidDevice()
|| cachedDevice.isConnectedLeAudioDevice()) {
return false; return false;
} }
// According to the current audio profile type, // According to the current audio profile type,

View File

@@ -234,6 +234,32 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice); verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
} }
@Test
public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_addPreference() {
mAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
}
@Test
public void onProfileConnectionStateChanged_leAudioDeviceConnected_inCall_addPreference() {
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
when(mBluetoothDeviceUpdater
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
}
@Test @Test
public void onProfileConnectionStateChanged_deviceDisconnected_removePreference() { public void onProfileConnectionStateChanged_deviceDisconnected_removePreference() {
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice, mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,

View File

@@ -234,6 +234,33 @@ public class ConnectedBluetoothDeviceUpdaterTest {
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice); verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
} }
@Test
public void onProfileConnectionStateChanged_leAudioDeviceConnected_inCall_removePreference() {
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
when(mBluetoothDeviceUpdater
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
}
@Test
public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_removePreference()
{
mAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
}
@Test @Test
public void onProfileConnectionStateChanged_deviceDisconnected_removePreference() { public void onProfileConnectionStateChanged_deviceDisconnected_removePreference() {
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice, mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,