Loading packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt +2 −9 Original line number Diff line number Diff line Loading @@ -79,8 +79,6 @@ interface AudioRepository { suspend fun setMuted(audioStream: AudioStream, isMuted: Boolean): Boolean suspend fun setRingerMode(audioStream: AudioStream, mode: RingerMode) suspend fun isAffectedByMute(audioStream: AudioStream): Boolean } class AudioRepositoryImpl( Loading Loading @@ -152,8 +150,9 @@ class AudioRepositoryImpl( minVolume = getMinVolume(audioStream), maxVolume = audioManager.getStreamMaxVolume(audioStream.value), volume = audioManager.getStreamVolume(audioStream.value), isAffectedByMute = audioManager.isStreamAffectedByMute(audioStream.value), isAffectedByRingerMode = audioManager.isStreamAffectedByRingerMode(audioStream.value), isMuted = audioManager.isStreamMute(audioStream.value) isMuted = audioManager.isStreamMute(audioStream.value), ) } Loading Loading @@ -187,12 +186,6 @@ class AudioRepositoryImpl( withContext(backgroundCoroutineContext) { audioManager.ringerMode = mode.value } } override suspend fun isAffectedByMute(audioStream: AudioStream): Boolean { return withContext(backgroundCoroutineContext) { audioManager.isStreamAffectedByMute(audioStream.value) } } private fun getMinVolume(stream: AudioStream): Int = try { audioManager.getStreamMinVolume(stream.value) Loading packages/SettingsLib/src/com/android/settingslib/volume/domain/interactor/AudioVolumeInteractor.kt +7 −8 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ class AudioVolumeInteractor( suspend fun setVolume(audioStream: AudioStream, volume: Int) { val streamModel = getAudioStream(audioStream).first() val oldVolume = streamModel.volume if (volume != oldVolume) { audioRepository.setVolume(audioStream, volume) when { volume == streamModel.minVolume -> setMuted(audioStream, true) Loading @@ -57,6 +58,7 @@ class AudioVolumeInteractor( setMuted(audioStream, false) } } } suspend fun setMuted(audioStream: AudioStream, isMuted: Boolean) { if (audioStream.value == AudioManager.STREAM_RING) { Loading Loading @@ -90,9 +92,6 @@ class AudioVolumeInteractor( } } suspend fun isAffectedByMute(audioStream: AudioStream): Boolean = audioRepository.isAffectedByMute(audioStream) private suspend fun processVolume( audioStreamModel: AudioStreamModel, ringerMode: RingerMode, Loading packages/SettingsLib/src/com/android/settingslib/volume/shared/model/AudioStreamModel.kt +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ data class AudioStreamModel( val volume: Int, val minVolume: Int, val maxVolume: Int, val isAffectedByMute: Boolean, val isAffectedByRingerMode: Boolean, val isMuted: Boolean, ) packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioRepositoryTest.kt +3 −0 Original line number Diff line number Diff line Loading @@ -173,6 +173,7 @@ class AudioRepositoryTest { volume = 50, minVolume = MIN_VOLUME, maxVolume = MAX_VOLUME, isAffectedByMute = false, isAffectedByRingerMode = false, isMuted = false, ) Loading Loading @@ -201,6 +202,7 @@ class AudioRepositoryTest { volume = 0, minVolume = MIN_VOLUME, maxVolume = MAX_VOLUME, isAffectedByMute = false, isAffectedByRingerMode = false, isMuted = true, ) Loading Loading @@ -230,6 +232,7 @@ class AudioRepositoryTest { volume = 0, minVolume = MIN_VOLUME, maxVolume = MAX_VOLUME, isAffectedByMute = false, isAffectedByRingerMode = false, isMuted = false, ) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/volume/domain/interactor/AudioVolumeInteractorTest.kt +6 −3 Original line number Diff line number Diff line Loading @@ -192,10 +192,12 @@ class AudioVolumeInteractorTest : SysuiTestCase() { fun streamNotAffectedByMute_isNotMutable() { with(kosmos) { testScope.runTest { audioRepository.setIsAffectedByMute(audioStream, false) val isMutable = underTest.isAffectedByMute(audioStream) val audioStreamModel by collectLastValue(underTest.getAudioStream(audioStream)) audioRepository.setAudioStreamModel( audioStreamModel!!.copy(isAffectedByMute = false) ) assertThat(isMutable).isFalse() assertThat(audioStreamModel!!.isAffectedByMute).isFalse() } } } Loading Loading @@ -230,6 +232,7 @@ class AudioVolumeInteractorTest : SysuiTestCase() { testScope.runTest { val audioStreamModel by collectLastValue(audioRepository.getAudioStream(audioStream)) underTest.setVolume(audioStream, audioStreamModel!!.maxVolume) runCurrent() underTest.setVolume(audioStream, audioStreamModel!!.minVolume) Loading Loading
packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt +2 −9 Original line number Diff line number Diff line Loading @@ -79,8 +79,6 @@ interface AudioRepository { suspend fun setMuted(audioStream: AudioStream, isMuted: Boolean): Boolean suspend fun setRingerMode(audioStream: AudioStream, mode: RingerMode) suspend fun isAffectedByMute(audioStream: AudioStream): Boolean } class AudioRepositoryImpl( Loading Loading @@ -152,8 +150,9 @@ class AudioRepositoryImpl( minVolume = getMinVolume(audioStream), maxVolume = audioManager.getStreamMaxVolume(audioStream.value), volume = audioManager.getStreamVolume(audioStream.value), isAffectedByMute = audioManager.isStreamAffectedByMute(audioStream.value), isAffectedByRingerMode = audioManager.isStreamAffectedByRingerMode(audioStream.value), isMuted = audioManager.isStreamMute(audioStream.value) isMuted = audioManager.isStreamMute(audioStream.value), ) } Loading Loading @@ -187,12 +186,6 @@ class AudioRepositoryImpl( withContext(backgroundCoroutineContext) { audioManager.ringerMode = mode.value } } override suspend fun isAffectedByMute(audioStream: AudioStream): Boolean { return withContext(backgroundCoroutineContext) { audioManager.isStreamAffectedByMute(audioStream.value) } } private fun getMinVolume(stream: AudioStream): Int = try { audioManager.getStreamMinVolume(stream.value) Loading
packages/SettingsLib/src/com/android/settingslib/volume/domain/interactor/AudioVolumeInteractor.kt +7 −8 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ class AudioVolumeInteractor( suspend fun setVolume(audioStream: AudioStream, volume: Int) { val streamModel = getAudioStream(audioStream).first() val oldVolume = streamModel.volume if (volume != oldVolume) { audioRepository.setVolume(audioStream, volume) when { volume == streamModel.minVolume -> setMuted(audioStream, true) Loading @@ -57,6 +58,7 @@ class AudioVolumeInteractor( setMuted(audioStream, false) } } } suspend fun setMuted(audioStream: AudioStream, isMuted: Boolean) { if (audioStream.value == AudioManager.STREAM_RING) { Loading Loading @@ -90,9 +92,6 @@ class AudioVolumeInteractor( } } suspend fun isAffectedByMute(audioStream: AudioStream): Boolean = audioRepository.isAffectedByMute(audioStream) private suspend fun processVolume( audioStreamModel: AudioStreamModel, ringerMode: RingerMode, Loading
packages/SettingsLib/src/com/android/settingslib/volume/shared/model/AudioStreamModel.kt +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ data class AudioStreamModel( val volume: Int, val minVolume: Int, val maxVolume: Int, val isAffectedByMute: Boolean, val isAffectedByRingerMode: Boolean, val isMuted: Boolean, )
packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioRepositoryTest.kt +3 −0 Original line number Diff line number Diff line Loading @@ -173,6 +173,7 @@ class AudioRepositoryTest { volume = 50, minVolume = MIN_VOLUME, maxVolume = MAX_VOLUME, isAffectedByMute = false, isAffectedByRingerMode = false, isMuted = false, ) Loading Loading @@ -201,6 +202,7 @@ class AudioRepositoryTest { volume = 0, minVolume = MIN_VOLUME, maxVolume = MAX_VOLUME, isAffectedByMute = false, isAffectedByRingerMode = false, isMuted = true, ) Loading Loading @@ -230,6 +232,7 @@ class AudioRepositoryTest { volume = 0, minVolume = MIN_VOLUME, maxVolume = MAX_VOLUME, isAffectedByMute = false, isAffectedByRingerMode = false, isMuted = false, ) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/volume/domain/interactor/AudioVolumeInteractorTest.kt +6 −3 Original line number Diff line number Diff line Loading @@ -192,10 +192,12 @@ class AudioVolumeInteractorTest : SysuiTestCase() { fun streamNotAffectedByMute_isNotMutable() { with(kosmos) { testScope.runTest { audioRepository.setIsAffectedByMute(audioStream, false) val isMutable = underTest.isAffectedByMute(audioStream) val audioStreamModel by collectLastValue(underTest.getAudioStream(audioStream)) audioRepository.setAudioStreamModel( audioStreamModel!!.copy(isAffectedByMute = false) ) assertThat(isMutable).isFalse() assertThat(audioStreamModel!!.isAffectedByMute).isFalse() } } } Loading Loading @@ -230,6 +232,7 @@ class AudioVolumeInteractorTest : SysuiTestCase() { testScope.runTest { val audioStreamModel by collectLastValue(audioRepository.getAudioStream(audioStream)) underTest.setVolume(audioStream, audioStreamModel!!.maxVolume) runCurrent() underTest.setVolume(audioStream, audioStreamModel!!.minVolume) Loading