Merge "[Audiosharing] Fix hysteresis mode" into main
This commit is contained in:
@@ -110,7 +110,10 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
||||
|
||||
@Override
|
||||
public void onSourceAdded(
|
||||
@NonNull BluetoothDevice sink, int sourceId, int reason) {}
|
||||
@NonNull BluetoothDevice sink, int sourceId, int reason) {
|
||||
Log.d(TAG, "onSourceAdded: updateSummary");
|
||||
updateSummary();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSourceAddFailed(
|
||||
@@ -138,12 +141,7 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
||||
public void onReceiveStateChanged(
|
||||
@NonNull BluetoothDevice sink,
|
||||
int sourceId,
|
||||
@NonNull BluetoothLeBroadcastReceiveState state) {
|
||||
if (BluetoothUtils.isConnected(state)) {
|
||||
Log.d(TAG, "onReceiveStateChanged: synced, updateSummary");
|
||||
updateSummary();
|
||||
}
|
||||
}
|
||||
@NonNull BluetoothLeBroadcastReceiveState state) {}
|
||||
};
|
||||
|
||||
public AudioSharingCallAudioPreferenceController(Context context) {
|
||||
|
@@ -116,7 +116,18 @@ public class AudioSharingDevicePreferenceController extends BasePreferenceContro
|
||||
|
||||
@Override
|
||||
public void onSourceAdded(
|
||||
@NonNull BluetoothDevice sink, int sourceId, int reason) {}
|
||||
@NonNull BluetoothDevice sink, int sourceId, int reason) {
|
||||
Log.d(TAG, "onSourceAdded: update sharing device list.");
|
||||
if (mBluetoothDeviceUpdater != null) {
|
||||
mBluetoothDeviceUpdater.forceUpdate();
|
||||
}
|
||||
if (mDeviceManager != null && mDialogHandler != null) {
|
||||
CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(sink);
|
||||
if (cachedDevice != null) {
|
||||
mDialogHandler.closeOpeningDialogsForLeaDevice(cachedDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSourceAddFailed(
|
||||
@@ -173,20 +184,7 @@ public class AudioSharingDevicePreferenceController extends BasePreferenceContro
|
||||
public void onReceiveStateChanged(
|
||||
@NonNull BluetoothDevice sink,
|
||||
int sourceId,
|
||||
@NonNull BluetoothLeBroadcastReceiveState state) {
|
||||
if (BluetoothUtils.isConnected(state)) {
|
||||
Log.d(TAG, "onSourceAdded: update sharing device list.");
|
||||
if (mBluetoothDeviceUpdater != null) {
|
||||
mBluetoothDeviceUpdater.forceUpdate();
|
||||
}
|
||||
if (mDeviceManager != null && mDialogHandler != null) {
|
||||
CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(sink);
|
||||
if (cachedDevice != null) {
|
||||
mDialogHandler.closeOpeningDialogsForLeaDevice(cachedDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@NonNull BluetoothLeBroadcastReceiveState state) {}
|
||||
};
|
||||
|
||||
public AudioSharingDevicePreferenceController(Context context) {
|
||||
|
@@ -132,7 +132,12 @@ public class AudioSharingDeviceVolumeGroupController extends AudioSharingBasePre
|
||||
|
||||
@Override
|
||||
public void onSourceAdded(
|
||||
@NonNull BluetoothDevice sink, int sourceId, int reason) {}
|
||||
@NonNull BluetoothDevice sink, int sourceId, int reason) {
|
||||
Log.d(TAG, "onSourceAdded: update volume list.");
|
||||
if (mBluetoothDeviceUpdater != null) {
|
||||
mBluetoothDeviceUpdater.forceUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSourceAddFailed(
|
||||
@@ -165,14 +170,7 @@ public class AudioSharingDeviceVolumeGroupController extends AudioSharingBasePre
|
||||
public void onReceiveStateChanged(
|
||||
@NonNull BluetoothDevice sink,
|
||||
int sourceId,
|
||||
@NonNull BluetoothLeBroadcastReceiveState state) {
|
||||
if (BluetoothUtils.isConnected(state)) {
|
||||
Log.d(TAG, "onReceiveStateChanged: synced, update volume list.");
|
||||
if (mBluetoothDeviceUpdater != null) {
|
||||
mBluetoothDeviceUpdater.forceUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@NonNull BluetoothLeBroadcastReceiveState state) {}
|
||||
};
|
||||
|
||||
public AudioSharingDeviceVolumeGroupController(Context context) {
|
||||
|
@@ -177,6 +177,20 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
||||
+ broadcastId
|
||||
+ ", metadata = "
|
||||
+ metadata.getBroadcastName());
|
||||
if (mAssistant == null
|
||||
|| mAssistant.getAllConnectedDevices().stream()
|
||||
.anyMatch(
|
||||
device -> BluetoothUtils
|
||||
.hasActiveLocalBroadcastSourceForBtDevice(
|
||||
device, mBtManager))) {
|
||||
Log.d(
|
||||
TAG,
|
||||
"Skip handleOnBroadcastReady: null assistant or "
|
||||
+ "sink has active local source.");
|
||||
cleanUpStatesForStartSharing();
|
||||
return;
|
||||
}
|
||||
handleOnBroadcastReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,20 +235,6 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
||||
+ reason
|
||||
+ ", broadcastId = "
|
||||
+ broadcastId);
|
||||
if (mAssistant == null
|
||||
|| mAssistant.getAllConnectedDevices().stream()
|
||||
.anyMatch(
|
||||
device -> BluetoothUtils
|
||||
.hasActiveLocalBroadcastSourceForBtDevice(
|
||||
device, mBtManager))) {
|
||||
Log.d(
|
||||
TAG,
|
||||
"Skip handleOnBroadcastReady: null assistant or "
|
||||
+ "sink has active local source.");
|
||||
cleanUpStatesForStartSharing();
|
||||
return;
|
||||
}
|
||||
handleOnBroadcastReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,7 +261,30 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
||||
|
||||
@Override
|
||||
public void onSourceAdded(
|
||||
@NonNull BluetoothDevice sink, int sourceId, int reason) {}
|
||||
@NonNull BluetoothDevice sink, int sourceId, int reason) {
|
||||
if (mSinksInAdding.contains(sink)) {
|
||||
mSinksInAdding.remove(sink);
|
||||
}
|
||||
dismissProgressDialogIfNeeded();
|
||||
Log.d(TAG, "onSourceAdded(), sink = " + sink + ", remaining sinks = "
|
||||
+ mSinksInAdding);
|
||||
if (mSinksToWaitFor.contains(sink)) {
|
||||
mSinksToWaitFor.remove(sink);
|
||||
if (mSinksToWaitFor.isEmpty()) {
|
||||
// To avoid users advance to share then pair flow before the
|
||||
// primary/active sinks successfully join the audio sharing,
|
||||
// popup dialog till adding source complete for mSinksToWaitFor.
|
||||
Pair<Integer, Object>[] eventData =
|
||||
AudioSharingUtils.buildAudioSharingDialogEventData(
|
||||
SettingsEnums.AUDIO_SHARING_SETTINGS,
|
||||
SettingsEnums.DIALOG_AUDIO_SHARING_ADD_DEVICE,
|
||||
/* userTriggered= */ false,
|
||||
/* deviceCountInSharing= */ 1,
|
||||
/* candidateDeviceCount= */ 0);
|
||||
showAudioSharingDialog(eventData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSourceAddFailed(
|
||||
@@ -307,34 +330,9 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
||||
@NonNull BluetoothDevice sink,
|
||||
int sourceId,
|
||||
@NonNull BluetoothLeBroadcastReceiveState state) {
|
||||
if (mStoppingSharing.get()) {
|
||||
Log.d(TAG, "Skip onReceiveStateChanged, stopping broadcast");
|
||||
return;
|
||||
}
|
||||
if (BluetoothUtils.isConnected(state)) {
|
||||
if (mSinksInAdding.contains(sink)) {
|
||||
mSinksInAdding.remove(sink);
|
||||
}
|
||||
dismissProgressDialogIfNeeded();
|
||||
Log.d(TAG, "onReceiveStateChanged() connected, sink = " + sink
|
||||
+ ", remaining sinks = " + mSinksInAdding);
|
||||
if (mSinksToWaitFor.contains(sink)) {
|
||||
mSinksToWaitFor.remove(sink);
|
||||
if (mSinksToWaitFor.isEmpty()) {
|
||||
// To avoid users advance to share then pair flow before the
|
||||
// primary/active sinks successfully join the audio sharing,
|
||||
// popup dialog till adding source complete for mSinksToWaitFor.
|
||||
Pair<Integer, Object>[] eventData =
|
||||
AudioSharingUtils.buildAudioSharingDialogEventData(
|
||||
SettingsEnums.AUDIO_SHARING_SETTINGS,
|
||||
SettingsEnums.DIALOG_AUDIO_SHARING_ADD_DEVICE,
|
||||
/* userTriggered= */ false,
|
||||
/* deviceCountInSharing= */ 1,
|
||||
/* candidateDeviceCount= */ 0);
|
||||
showAudioSharingDialog(eventData);
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.d(TAG,
|
||||
"onReceiveStateChanged(), sink = " + sink + ", sourceId = " + sourceId
|
||||
+ ", state = " + state);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -527,12 +527,12 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
assertThat(mPreference.getSummary().toString()).isEmpty();
|
||||
|
||||
// onReceiveStateChanged will update summary
|
||||
// onSourceAdded will update summary
|
||||
Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID1);
|
||||
when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1));
|
||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
|
||||
mController.mBroadcastAssistantCallback.onReceiveStateChanged(
|
||||
mDevice1, /* sourceId= */ 1, mState);
|
||||
mController.mBroadcastAssistantCallback.onSourceAdded(mDevice1, /* sourceId= */
|
||||
1, /* reason= */ 1);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
assertThat(mPreference.getSummary().toString())
|
||||
.isEqualTo(
|
||||
@@ -557,8 +557,6 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
||||
mController.mBroadcastAssistantCallback.onSearchStartFailed(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSearchStopped(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSearchStopFailed(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSourceAdded(
|
||||
mDevice1, /* sourceId= */ 1, /* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSourceAddFailed(
|
||||
mDevice1, mSource, /* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSourceRemoved(
|
||||
@@ -572,6 +570,8 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
||||
mController.mBroadcastAssistantCallback.onSourceFound(mSource);
|
||||
mController.mBroadcastAssistantCallback.onSourceLost(/* broadcastId= */ 1);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
mController.mBroadcastAssistantCallback.onReceiveStateChanged(mDevice1, /* sourceId= */ 1,
|
||||
mState);
|
||||
|
||||
// Above callbacks won't update summary.
|
||||
assertThat(mPreference.getSummary().toString()).isEmpty();
|
||||
|
@@ -521,21 +521,9 @@ public class AudioSharingDevicePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testBluetoothLeBroadcastAssistantCallbacks_updateGroup() {
|
||||
// onReceiveStateChanged with unconnected state will do nothing
|
||||
when(mState.getBisSyncState()).thenReturn(new ArrayList<>());
|
||||
mController.mBroadcastAssistantCallback.onReceiveStateChanged(
|
||||
mDevice, /* sourceId= */ 1, mState);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
verify(mBluetoothDeviceUpdater, never()).forceUpdate();
|
||||
verify(mDialogHandler, never()).closeOpeningDialogsForLeaDevice(mCachedDevice);
|
||||
|
||||
// onReceiveStateChanged with connected state will update group preference and handle
|
||||
// stale dialogs
|
||||
List<Long> bisSyncState = new ArrayList<>();
|
||||
bisSyncState.add(1L);
|
||||
when(mState.getBisSyncState()).thenReturn(bisSyncState);
|
||||
mController.mBroadcastAssistantCallback.onReceiveStateChanged(
|
||||
mDevice, /* sourceId= */ 1, mState);
|
||||
// onSourceAdded will update group preference and handle stale dialogs
|
||||
mController.mBroadcastAssistantCallback.onSourceAdded(mDevice, /* sourceId= */
|
||||
1, /* reason= */ 1);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
verify(mBluetoothDeviceUpdater).forceUpdate();
|
||||
verify(mDialogHandler).closeOpeningDialogsForLeaDevice(mCachedDevice);
|
||||
@@ -572,8 +560,13 @@ public class AudioSharingDevicePreferenceControllerTest {
|
||||
mController.mBroadcastAssistantCallback.onSearchStartFailed(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSearchStopped(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSearchStopFailed(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSourceAdded(
|
||||
mDevice, /* sourceId= */ 1, /* reason= */ 1);
|
||||
List<Long> bisSyncState = new ArrayList<>();
|
||||
bisSyncState.add(1L);
|
||||
when(mState.getBisSyncState()).thenReturn(bisSyncState);
|
||||
when(mBroadcast.getLatestBroadcastId()).thenReturn(1);
|
||||
when(mState.getBroadcastId()).thenReturn(1);
|
||||
mController.mBroadcastAssistantCallback.onReceiveStateChanged(mDevice, /* sourceId= */ 1,
|
||||
mState);
|
||||
mController.mBroadcastAssistantCallback.onSourceModified(
|
||||
mDevice, /* sourceId= */ 1, /* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSourceModifyFailed(
|
||||
|
@@ -461,18 +461,9 @@ public class AudioSharingDeviceVolumeGroupControllerTest {
|
||||
|
||||
@Test
|
||||
public void testBluetoothLeBroadcastAssistantCallbacks_updateGroup() {
|
||||
when(mState.getBisSyncState()).thenReturn(new ArrayList<>());
|
||||
// onReceiveStateChanged with unconnected state will do nothing
|
||||
mController.mBroadcastAssistantCallback.onReceiveStateChanged(
|
||||
mDevice1, /* sourceId= */ 1, mState);
|
||||
verify(mDeviceUpdater, never()).forceUpdate();
|
||||
|
||||
// onReceiveStateChanged with connected state will update group preference
|
||||
List<Long> bisSyncState = new ArrayList<>();
|
||||
bisSyncState.add(1L);
|
||||
when(mState.getBisSyncState()).thenReturn(bisSyncState);
|
||||
mController.mBroadcastAssistantCallback.onReceiveStateChanged(
|
||||
mDevice1, /* sourceId= */ 1, mState);
|
||||
// onSourceAdded will update group preference
|
||||
mController.mBroadcastAssistantCallback.onSourceAdded(mDevice1, /* sourceId= */
|
||||
1, /* reason= */ 1);
|
||||
verify(mDeviceUpdater).forceUpdate();
|
||||
|
||||
// onSourceRemoved will update group preference
|
||||
@@ -487,8 +478,13 @@ public class AudioSharingDeviceVolumeGroupControllerTest {
|
||||
mController.mBroadcastAssistantCallback.onSearchStartFailed(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSearchStopped(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSearchStopFailed(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSourceAdded(
|
||||
mDevice1, /* sourceId= */ 1, /* reason= */ 1);
|
||||
List<Long> bisSyncState = new ArrayList<>();
|
||||
bisSyncState.add(1L);
|
||||
when(mState.getBisSyncState()).thenReturn(bisSyncState);
|
||||
when(mBroadcast.getLatestBroadcastId()).thenReturn(1);
|
||||
when(mState.getBroadcastId()).thenReturn(1);
|
||||
mController.mBroadcastAssistantCallback.onReceiveStateChanged(mDevice1, /* sourceId= */ 1,
|
||||
mState);
|
||||
mController.mBroadcastAssistantCallback.onSourceAddFailed(
|
||||
mDevice1, mSource, /* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSourceRemoveFailed(
|
||||
|
@@ -476,7 +476,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPlaybackStarted_notInit_noDialog() {
|
||||
public void onBroadcastMetadataChanged_notInit_noDialog() {
|
||||
FeatureFlagUtils.setEnabled(
|
||||
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
||||
when(mBtnView.isEnabled()).thenReturn(true);
|
||||
@@ -503,7 +503,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
// No progress dialog.
|
||||
assertThat(childFragments).isEmpty();
|
||||
|
||||
mController.mBroadcastCallback.onPlaybackStarted(0, 0);
|
||||
mController.mBroadcastCallback.onBroadcastMetadataChanged(/* reason= */ 1, mMetadata);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mFeatureFactory.metricsFeatureProvider)
|
||||
@@ -515,7 +515,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPlaybackStarted_hasLocalSource_noDialog() {
|
||||
public void onBroadcastMetadataChanged_hasLocalSource_noDialog() {
|
||||
FeatureFlagUtils.setEnabled(
|
||||
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
||||
when(mBtnView.isEnabled()).thenReturn(true);
|
||||
@@ -533,7 +533,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
assertThat(childFragments).comparingElementsUsing(CLAZZNAME_EQUALS).containsExactly(
|
||||
AudioSharingProgressDialogFragment.class.getName());
|
||||
|
||||
mController.mBroadcastCallback.onPlaybackStarted(0, 0);
|
||||
mController.mBroadcastCallback.onBroadcastMetadataChanged(/* reason= */ 1, mMetadata);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mAssistant, never()).addSource(any(), any(), anyBoolean());
|
||||
@@ -549,7 +549,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPlaybackStarted_singleActiveDevice_showJoinAudioSharingDialog() {
|
||||
public void onBroadcastMetadataChanged_singleActiveDevice_showJoinAudioSharingDialog() {
|
||||
FeatureFlagUtils.setEnabled(
|
||||
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
||||
when(mBtnView.isEnabled()).thenReturn(true);
|
||||
@@ -566,15 +566,15 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
|
||||
when(mBroadcast.isEnabled(null)).thenReturn(true);
|
||||
when(mBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn(mMetadata);
|
||||
mController.mBroadcastCallback.onPlaybackStarted(0, 0);
|
||||
mController.mBroadcastCallback.onBroadcastMetadataChanged(/* reason= */ 1, mMetadata);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mFeatureFactory.metricsFeatureProvider)
|
||||
.action(any(Context.class), eq(SettingsEnums.ACTION_AUTO_JOIN_AUDIO_SHARING));
|
||||
|
||||
when(mState.getBisSyncState()).thenReturn(ImmutableList.of(1L));
|
||||
mController.mBroadcastAssistantCallback.onReceiveStateChanged(mDevice2, /* sourceId= */ 1,
|
||||
mState);
|
||||
mController.mBroadcastAssistantCallback.onSourceAdded(mDevice2, /* sourceId= */
|
||||
1, /* reason= */ 1);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
childFragments = mParentFragment.getChildFragmentManager().getFragments();
|
||||
@@ -613,7 +613,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPlaybackStarted_oneActiveOnConnected_showJoinAudioSharingDialog() {
|
||||
public void onBroadcastMetadataChanged_oneActiveOnConnected_showJoinAudioSharingDialog() {
|
||||
FeatureFlagUtils.setEnabled(
|
||||
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
||||
when(mBtnView.isEnabled()).thenReturn(true);
|
||||
@@ -635,7 +635,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
|
||||
when(mBroadcast.isEnabled(null)).thenReturn(true);
|
||||
when(mBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn(mMetadata);
|
||||
mController.mBroadcastCallback.onPlaybackStarted(0, 0);
|
||||
mController.mBroadcastCallback.onBroadcastMetadataChanged(/* reason= */ 1, mMetadata);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mFeatureFactory.metricsFeatureProvider)
|
||||
@@ -681,7 +681,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPlaybackStarted_oneActiveOnConnected_clickShareBtnOnDialog_addSource() {
|
||||
public void onBroadcastMetadataChanged_oneActiveOnConnected_clickShareBtnOnDialog_addSource() {
|
||||
FeatureFlagUtils.setEnabled(
|
||||
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
||||
when(mBtnView.isEnabled()).thenReturn(true);
|
||||
@@ -694,7 +694,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
verify(mBroadcast).startPrivateBroadcast();
|
||||
when(mBroadcast.isEnabled(null)).thenReturn(true);
|
||||
when(mBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn(mMetadata);
|
||||
mController.mBroadcastCallback.onPlaybackStarted(0, 0);
|
||||
mController.mBroadcastCallback.onBroadcastMetadataChanged(/* reason= */ 1, mMetadata);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mAssistant).addSource(mDevice2, mMetadata, /* isGroupOp= */ false);
|
||||
@@ -722,7 +722,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPlaybackStarted_oneActiveOnConnected_clickCancelBtnOnDialog_doNothing() {
|
||||
public void onBroadcastMetadataChanged_oneActiveOnConnected_clickCancelBtnOnDialog_doNothing() {
|
||||
FeatureFlagUtils.setEnabled(
|
||||
mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true);
|
||||
when(mBtnView.isEnabled()).thenReturn(true);
|
||||
@@ -735,7 +735,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
verify(mBroadcast).startPrivateBroadcast();
|
||||
when(mBroadcast.isEnabled(null)).thenReturn(true);
|
||||
when(mBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn(mMetadata);
|
||||
mController.mBroadcastCallback.onPlaybackStarted(0, 0);
|
||||
mController.mBroadcastCallback.onBroadcastMetadataChanged(/* reason= */ 1, mMetadata);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mAssistant).addSource(mDevice2, mMetadata, /* isGroupOp= */ false);
|
||||
@@ -835,7 +835,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
|
||||
when(mBroadcast.isEnabled(null)).thenReturn(true);
|
||||
when(mBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn(mMetadata);
|
||||
mController.mBroadcastCallback.onPlaybackStarted(0, 0);
|
||||
mController.mBroadcastCallback.onBroadcastMetadataChanged(/* reason= */ 1, mMetadata);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mAssistant).addSource(mDevice2, mMetadata, /* isGroupOp= */ false);
|
||||
@@ -868,16 +868,15 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAssistantCallbacks_onReceiveStateChanged_dismissProgressDialog() {
|
||||
public void testAssistantCallbacks_onSourceAdded_dismissProgressDialog() {
|
||||
AudioSharingProgressDialogFragment.show(mParentFragment, TEST_DEVICE_NAME1);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
List<Fragment> childFragments = mParentFragment.getChildFragmentManager().getFragments();
|
||||
assertThat(childFragments).comparingElementsUsing(CLAZZNAME_EQUALS).containsExactly(
|
||||
AudioSharingProgressDialogFragment.class.getName());
|
||||
|
||||
when(mState.getBisSyncState()).thenReturn(ImmutableList.of(1L));
|
||||
mController.mBroadcastAssistantCallback.onReceiveStateChanged(mDevice1, /* sourceId= */ 1,
|
||||
mState);
|
||||
mController.mBroadcastAssistantCallback.onSourceAdded(mDevice1, /* sourceId= */
|
||||
1, /* reason= */ 1);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
childFragments = mParentFragment.getChildFragmentManager().getFragments();
|
||||
assertThat(childFragments).isEmpty();
|
||||
@@ -892,8 +891,6 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
mController.mBroadcastAssistantCallback.onSearchStartFailed(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSearchStopped(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSearchStopFailed(/* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSourceAdded(
|
||||
mDevice1, /* sourceId= */ 1, /* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSourceRemoved(
|
||||
mDevice1, /* sourceId= */ 1, /* reason= */ 1);
|
||||
mController.mBroadcastAssistantCallback.onSourceRemoveFailed(
|
||||
@@ -1013,7 +1010,7 @@ public class AudioSharingSwitchBarControllerTest {
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mBroadcast).startPrivateBroadcast();
|
||||
mController.mBroadcastCallback.onPlaybackStarted(0, 0);
|
||||
mController.mBroadcastCallback.onBroadcastMetadataChanged(/* reason= */ 1, mMetadata);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mFeatureFactory.metricsFeatureProvider)
|
||||
|
Reference in New Issue
Block a user