Hide the "play media to" option

This CL will hide the "play media to" option is there are no active
media session and media state is not playing.

Bug: 154457882
Test: manually test
Change-Id: If272a336f06b51e7a2e1605c8dc092b2ca134c25
This commit is contained in:
hughchen
2020-04-24 15:52:21 +08:00
parent db86b2ef2a
commit d02c31e693
2 changed files with 31 additions and 2 deletions

View File

@@ -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;
}
}