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