Loading packages/SettingsLib/src/com/android/settingslib/volume/domain/interactor/AudioVolumeInteractor.kt +7 −3 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import com.android.settingslib.volume.shared.model.RingerMode import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map /** Provides audio stream state and an ability to change it */ Loading Loading @@ -56,9 +55,14 @@ class AudioVolumeInteractor( /** Checks if the volume can be changed via the UI. */ fun canChangeVolume(audioStream: AudioStream): Flow<Boolean> { return if (audioStream.value == AudioManager.STREAM_NOTIFICATION) { getAudioStream(AudioStream(AudioManager.STREAM_RING)).map { !it.isMuted } combine( notificationsSoundPolicyInteractor.isZenMuted(audioStream), getAudioStream(AudioStream(AudioManager.STREAM_RING)).map { it.isMuted }, ) { isZenMuted, isRingMuted -> !isZenMuted && !isRingMuted } } else { flowOf(true) notificationsSoundPolicyInteractor.isZenMuted(audioStream).map { !it } } } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/volume/domain/interactor/AudioVolumeInteractorTest.kt +22 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,28 @@ class AudioVolumeInteractorTest : SysuiTestCase() { } } @Test fun zenMuted_cantChange() { with(kosmos) { testScope.runTest { notificationsSoundPolicyRepository.updateNotificationPolicy() notificationsSoundPolicyRepository.updateZenMode( ZenMode(Settings.Global.ZEN_MODE_NO_INTERRUPTIONS) ) val canChangeVolume by collectLastValue( underTest.canChangeVolume(AudioStream(AudioManager.STREAM_NOTIFICATION)) ) underTest.setMuted(AudioStream(AudioManager.STREAM_RING), true) runCurrent() assertThat(canChangeVolume).isFalse() } } } @Test fun streamIsMuted_getStream_volumeZero() { with(kosmos) { Loading packages/SystemUI/res/values/strings.xml +5 −1 Original line number Diff line number Diff line Loading @@ -1536,8 +1536,12 @@ <!-- Media device casting volume slider label [CHAR_LIMIT=20] --> <string name="media_device_cast">Cast</string> <!-- A message shown when the notification volume changing is disabled because of the muted ring stream [CHAR_LIMIT=40]--> <!-- A message shown when the notification volume changing is disabled because of the muted ring stream [CHAR_LIMIT=50]--> <string name="stream_notification_unavailable">Unavailable because ring is muted</string> <!-- A message shown when the alarm volume changing is disabled because of the don't disturb mode [CHAR_LIMIT=50]--> <string name="stream_alarm_unavailable">Unavailable because Do Not Disturb is on</string> <!-- A message shown when the media volume changing is disabled because of the don't disturb mode [CHAR_LIMIT=50]--> <string name="stream_media_unavailable">Unavailable because Do Not Disturb is on</string> <!-- Shown in the header of quick settings to indicate to the user that their phone ringer is on vibrate. [CHAR_LIMIT=NONE] --> <!-- Shown in the header of quick settings to indicate to the user that their phone ringer is on silent (muted). [CHAR_LIMIT=NONE] --> Loading packages/SystemUI/src/com/android/systemui/volume/panel/component/volume/slider/ui/viewmodel/AudioStreamSliderViewModel.kt +2 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ constructor( mapOf( AudioStream(AudioManager.STREAM_NOTIFICATION) to R.string.stream_notification_unavailable, AudioStream(AudioManager.STREAM_ALARM) to R.string.stream_alarm_unavailable, AudioStream(AudioManager.STREAM_MUSIC) to R.string.stream_media_unavailable, ) private var value = 0f Loading Loading
packages/SettingsLib/src/com/android/settingslib/volume/domain/interactor/AudioVolumeInteractor.kt +7 −3 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import com.android.settingslib.volume.shared.model.RingerMode import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map /** Provides audio stream state and an ability to change it */ Loading Loading @@ -56,9 +55,14 @@ class AudioVolumeInteractor( /** Checks if the volume can be changed via the UI. */ fun canChangeVolume(audioStream: AudioStream): Flow<Boolean> { return if (audioStream.value == AudioManager.STREAM_NOTIFICATION) { getAudioStream(AudioStream(AudioManager.STREAM_RING)).map { !it.isMuted } combine( notificationsSoundPolicyInteractor.isZenMuted(audioStream), getAudioStream(AudioStream(AudioManager.STREAM_RING)).map { it.isMuted }, ) { isZenMuted, isRingMuted -> !isZenMuted && !isRingMuted } } else { flowOf(true) notificationsSoundPolicyInteractor.isZenMuted(audioStream).map { !it } } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/volume/domain/interactor/AudioVolumeInteractorTest.kt +22 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,28 @@ class AudioVolumeInteractorTest : SysuiTestCase() { } } @Test fun zenMuted_cantChange() { with(kosmos) { testScope.runTest { notificationsSoundPolicyRepository.updateNotificationPolicy() notificationsSoundPolicyRepository.updateZenMode( ZenMode(Settings.Global.ZEN_MODE_NO_INTERRUPTIONS) ) val canChangeVolume by collectLastValue( underTest.canChangeVolume(AudioStream(AudioManager.STREAM_NOTIFICATION)) ) underTest.setMuted(AudioStream(AudioManager.STREAM_RING), true) runCurrent() assertThat(canChangeVolume).isFalse() } } } @Test fun streamIsMuted_getStream_volumeZero() { with(kosmos) { Loading
packages/SystemUI/res/values/strings.xml +5 −1 Original line number Diff line number Diff line Loading @@ -1536,8 +1536,12 @@ <!-- Media device casting volume slider label [CHAR_LIMIT=20] --> <string name="media_device_cast">Cast</string> <!-- A message shown when the notification volume changing is disabled because of the muted ring stream [CHAR_LIMIT=40]--> <!-- A message shown when the notification volume changing is disabled because of the muted ring stream [CHAR_LIMIT=50]--> <string name="stream_notification_unavailable">Unavailable because ring is muted</string> <!-- A message shown when the alarm volume changing is disabled because of the don't disturb mode [CHAR_LIMIT=50]--> <string name="stream_alarm_unavailable">Unavailable because Do Not Disturb is on</string> <!-- A message shown when the media volume changing is disabled because of the don't disturb mode [CHAR_LIMIT=50]--> <string name="stream_media_unavailable">Unavailable because Do Not Disturb is on</string> <!-- Shown in the header of quick settings to indicate to the user that their phone ringer is on vibrate. [CHAR_LIMIT=NONE] --> <!-- Shown in the header of quick settings to indicate to the user that their phone ringer is on silent (muted). [CHAR_LIMIT=NONE] --> Loading
packages/SystemUI/src/com/android/systemui/volume/panel/component/volume/slider/ui/viewmodel/AudioStreamSliderViewModel.kt +2 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ constructor( mapOf( AudioStream(AudioManager.STREAM_NOTIFICATION) to R.string.stream_notification_unavailable, AudioStream(AudioManager.STREAM_ALARM) to R.string.stream_alarm_unavailable, AudioStream(AudioManager.STREAM_MUSIC) to R.string.stream_media_unavailable, ) private var value = 0f Loading