Merge "[Audiosharing] Avoid audio sharing dialogs in call" into main
This commit is contained in:
@@ -39,6 +39,7 @@ import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
||||
import android.bluetooth.BluetoothStatusCodes;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
@@ -113,6 +114,7 @@ public class AudioSharingDialogHandlerTest {
|
||||
@Mock private CachedBluetoothDeviceManager mCacheManager;
|
||||
@Mock private LocalBluetoothLeBroadcast mBroadcast;
|
||||
@Mock private LocalBluetoothLeBroadcastAssistant mAssistant;
|
||||
@Mock private AudioManager mAudioManager;
|
||||
@Mock private CachedBluetoothDevice mCachedDevice1;
|
||||
@Mock private CachedBluetoothDevice mCachedDevice2;
|
||||
@Mock private CachedBluetoothDevice mCachedDevice3;
|
||||
@@ -152,6 +154,8 @@ public class AudioSharingDialogHandlerTest {
|
||||
when(mLocalBtManager.getProfileManager()).thenReturn(mLocalBtProfileManager);
|
||||
when(mLocalBtProfileManager.getLeAudioBroadcastProfile()).thenReturn(mBroadcast);
|
||||
when(mLocalBtProfileManager.getLeAudioBroadcastAssistantProfile()).thenReturn(mAssistant);
|
||||
when(mContext.getSystemService(AudioManager.class)).thenReturn(mAudioManager);
|
||||
when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_NORMAL);
|
||||
List<Long> bisSyncState = new ArrayList<>();
|
||||
bisSyncState.add(1L);
|
||||
when(mState.getBisSyncState()).thenReturn(bisSyncState);
|
||||
@@ -187,6 +191,18 @@ public class AudioSharingDialogHandlerTest {
|
||||
ShadowBluetoothUtils.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleUserTriggeredDeviceConnected_inCall_setActive() {
|
||||
when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_IN_CALL);
|
||||
setUpBroadcast(true);
|
||||
ImmutableList<BluetoothDevice> deviceList = ImmutableList.of(mDevice1);
|
||||
when(mAssistant.getAllConnectedDevices()).thenReturn(deviceList);
|
||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||
mHandler.handleDeviceConnected(mCachedDevice1, /* userTriggered= */ true);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
verify(mCachedDevice1).setActive();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleUserTriggeredNonLeaDeviceConnected_noSharing_setActive() {
|
||||
setUpBroadcast(false);
|
||||
@@ -403,6 +419,18 @@ public class AudioSharingDialogHandlerTest {
|
||||
verify(mAssistant).addSource(mDevice1, mMetadata, /* isGroupOp= */ false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleDeviceConnected_inCall_doNothing() {
|
||||
when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_IN_CALL);
|
||||
setUpBroadcast(true);
|
||||
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of());
|
||||
mHandler.handleDeviceConnected(mCachedDevice2, /* userTriggered= */ false);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
verify(mCachedDevice2, never()).setActive();
|
||||
List<Fragment> childFragments = mParentFragment.getChildFragmentManager().getFragments();
|
||||
assertThat(childFragments).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleNonLeaDeviceConnected_noSharing_doNothing() {
|
||||
setUpBroadcast(false);
|
||||
|
Reference in New Issue
Block a user