Merge "Hide the "play media to" option" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2152d0ce4f
@@ -120,14 +120,17 @@ public class MediaOutputIndicatorSlice implements CustomSliceable {
|
||||
return mWorker;
|
||||
}
|
||||
|
||||
private boolean isVisible() {
|
||||
@VisibleForTesting
|
||||
boolean isVisible() {
|
||||
// To decide Slice's visibility.
|
||||
// Return true if
|
||||
// 1. AudioMode is not in on-going call
|
||||
// 2. worker is not null
|
||||
// 3. Available devices are more than 0
|
||||
// 4. The local media session is active and the state is playing.
|
||||
return getWorker() != null
|
||||
&& !com.android.settingslib.Utils.isAudioModeOngoingCall(mContext)
|
||||
&& getWorker().getMediaDevices().size() > 0;
|
||||
&& getWorker().getMediaDevices().size() > 0
|
||||
&& getWorker().getActiveLocalMediaController() != null;
|
||||
}
|
||||
}
|
||||
|
@@ -120,6 +120,8 @@ public class MediaOutputIndicatorSliceTest {
|
||||
public void getSlice_withConnectedDevice_verifyMetadata() {
|
||||
mDevices.add(mDevice1);
|
||||
when(sMediaOutputIndicatorWorker.getMediaDevices()).thenReturn(mDevices);
|
||||
doReturn(mMediaController).when(sMediaOutputIndicatorWorker)
|
||||
.getActiveLocalMediaController();
|
||||
doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
|
||||
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
|
||||
@@ -215,6 +217,30 @@ public class MediaOutputIndicatorSliceTest {
|
||||
MediaOutputSliceConstants.KEY_MEDIA_SESSION_TOKEN) == null).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isVisible_allConditionMatched_returnTrue() {
|
||||
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
mDevices.add(mDevice1);
|
||||
|
||||
when(sMediaOutputIndicatorWorker.getMediaDevices()).thenReturn(mDevices);
|
||||
doReturn(mMediaController).when(sMediaOutputIndicatorWorker)
|
||||
.getActiveLocalMediaController();
|
||||
|
||||
assertThat(mMediaOutputIndicatorSlice.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isVisible_noActiveSession_returnFalse() {
|
||||
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
mDevices.add(mDevice1);
|
||||
|
||||
when(sMediaOutputIndicatorWorker.getMediaDevices()).thenReturn(mDevices);
|
||||
doReturn(null).when(sMediaOutputIndicatorWorker)
|
||||
.getActiveLocalMediaController();
|
||||
|
||||
assertThat(mMediaOutputIndicatorSlice.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Implements(SliceBackgroundWorker.class)
|
||||
public static class ShadowSliceBackgroundWorker {
|
||||
|
||||
|
Reference in New Issue
Block a user