Loading packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt +5 −5 Original line number Original line Diff line number Diff line Loading @@ -161,11 +161,11 @@ class AudioRepositoryImpl( override suspend fun setMuted(audioStream: AudioStream, isMuted: Boolean) = override suspend fun setMuted(audioStream: AudioStream, isMuted: Boolean) = withContext(backgroundCoroutineContext) { withContext(backgroundCoroutineContext) { if (isMuted) { audioManager.adjustStreamVolume( audioManager.adjustStreamVolume(audioStream.value, 0, AudioManager.ADJUST_MUTE) audioStream.value, } else { if (isMuted) AudioManager.ADJUST_MUTE else AudioManager.ADJUST_UNMUTE, audioManager.adjustStreamVolume(audioStream.value, 0, AudioManager.ADJUST_UNMUTE) 0, } ) } } private fun getMinVolume(stream: AudioStream): Int = private fun getMinVolume(stream: AudioStream): Int = Loading packages/SettingsLib/src/com/android/settingslib/volume/domain/interactor/AudioVolumeInteractor.kt +2 −2 Original line number Original line Diff line number Diff line Loading @@ -84,10 +84,10 @@ class AudioVolumeInteractor( (audioStreamModel.audioStream.value == AudioManager.STREAM_NOTIFICATION && (audioStreamModel.audioStream.value == AudioManager.STREAM_NOTIFICATION && audioStreamModel.isMuted) audioStreamModel.isMuted) ) { ) { return 0 return audioStreamModel.minVolume } } } else if (audioStreamModel.isMuted) { } else if (audioStreamModel.isMuted) { return 0 return audioStreamModel.minVolume } } return audioStreamModel.volume return audioStreamModel.volume } } Loading packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioRepositoryTest.kt +3 −3 Original line number Original line Diff line number Diff line Loading @@ -77,13 +77,13 @@ class AudioRepositoryTest { `when`(audioManager.getStreamMaxVolume(anyInt())).thenReturn(MAX_VOLUME) `when`(audioManager.getStreamMaxVolume(anyInt())).thenReturn(MAX_VOLUME) `when`(audioManager.ringerModeInternal).thenReturn(AudioManager.RINGER_MODE_NORMAL) `when`(audioManager.ringerModeInternal).thenReturn(AudioManager.RINGER_MODE_NORMAL) `when`(audioManager.setStreamVolume(anyInt(), anyInt(), anyInt())).then { `when`(audioManager.setStreamVolume(anyInt(), anyInt(), anyInt())).then { val streamType = it.arguments[1] as Int val streamType = it.arguments[0] as Int volumeByStream[it.arguments[0] as Int] = streamType volumeByStream[it.arguments[0] as Int] = it.arguments[1] as Int triggerEvent(AudioManagerEvent.StreamVolumeChanged(AudioStream(streamType))) triggerEvent(AudioManagerEvent.StreamVolumeChanged(AudioStream(streamType))) } } `when`(audioManager.adjustStreamVolume(anyInt(), anyInt(), anyInt())).then { `when`(audioManager.adjustStreamVolume(anyInt(), anyInt(), anyInt())).then { val streamType = it.arguments[0] as Int val streamType = it.arguments[0] as Int isMuteByStream[streamType] = it.arguments[2] == AudioManager.ADJUST_MUTE isMuteByStream[streamType] = it.arguments[1] == AudioManager.ADJUST_MUTE triggerEvent(AudioManagerEvent.StreamMuteChanged(AudioStream(streamType))) triggerEvent(AudioManagerEvent.StreamMuteChanged(AudioStream(streamType))) } } `when`(audioManager.getStreamVolume(anyInt())).thenAnswer { `when`(audioManager.getStreamVolume(anyInt())).thenAnswer { Loading packages/SystemUI/AndroidManifest.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -911,7 +911,7 @@ <activity <activity android:name=".volume.panel.ui.activity.VolumePanelActivity" android:name=".volume.panel.ui.activity.VolumePanelActivity" android:label="@string/sound_settings" android:label="@string/accessibility_volume_settings" android:excludeFromRecents="true" android:excludeFromRecents="true" android:exported="false" android:exported="false" android:launchMode="singleInstance" android:launchMode="singleInstance" Loading packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ButtonComponent.kt +13 −2 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,11 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.clearAndSetSemantics import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.role import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp import com.android.compose.animation.Expandable import com.android.compose.animation.Expandable Loading @@ -52,6 +57,7 @@ class ButtonComponent( override fun VolumePanelComposeScope.Content(modifier: Modifier) { override fun VolumePanelComposeScope.Content(modifier: Modifier) { val viewModelByState by viewModelFlow.collectAsState() val viewModelByState by viewModelFlow.collectAsState() val viewModel = viewModelByState ?: return val viewModel = viewModelByState ?: return val label = viewModel.label.toString() Column( Column( modifier = modifier, modifier = modifier, Loading @@ -59,7 +65,11 @@ class ButtonComponent( horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally, ) { ) { Expandable( Expandable( modifier = Modifier.height(64.dp).fillMaxWidth(), modifier = Modifier.height(64.dp).fillMaxWidth().semantics { role = Role.Button contentDescription = label }, color = MaterialTheme.colorScheme.primaryContainer, color = MaterialTheme.colorScheme.primaryContainer, shape = RoundedCornerShape(28.dp), shape = RoundedCornerShape(28.dp), contentColor = MaterialTheme.colorScheme.onPrimaryContainer, contentColor = MaterialTheme.colorScheme.onPrimaryContainer, Loading @@ -71,7 +81,8 @@ class ButtonComponent( } } } } Text( Text( text = viewModel.label.toString(), modifier = Modifier.clearAndSetSemantics {}, text = label, style = MaterialTheme.typography.labelMedium, style = MaterialTheme.typography.labelMedium, maxLines = 1, maxLines = 1, overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis, Loading Loading
packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt +5 −5 Original line number Original line Diff line number Diff line Loading @@ -161,11 +161,11 @@ class AudioRepositoryImpl( override suspend fun setMuted(audioStream: AudioStream, isMuted: Boolean) = override suspend fun setMuted(audioStream: AudioStream, isMuted: Boolean) = withContext(backgroundCoroutineContext) { withContext(backgroundCoroutineContext) { if (isMuted) { audioManager.adjustStreamVolume( audioManager.adjustStreamVolume(audioStream.value, 0, AudioManager.ADJUST_MUTE) audioStream.value, } else { if (isMuted) AudioManager.ADJUST_MUTE else AudioManager.ADJUST_UNMUTE, audioManager.adjustStreamVolume(audioStream.value, 0, AudioManager.ADJUST_UNMUTE) 0, } ) } } private fun getMinVolume(stream: AudioStream): Int = private fun getMinVolume(stream: AudioStream): Int = Loading
packages/SettingsLib/src/com/android/settingslib/volume/domain/interactor/AudioVolumeInteractor.kt +2 −2 Original line number Original line Diff line number Diff line Loading @@ -84,10 +84,10 @@ class AudioVolumeInteractor( (audioStreamModel.audioStream.value == AudioManager.STREAM_NOTIFICATION && (audioStreamModel.audioStream.value == AudioManager.STREAM_NOTIFICATION && audioStreamModel.isMuted) audioStreamModel.isMuted) ) { ) { return 0 return audioStreamModel.minVolume } } } else if (audioStreamModel.isMuted) { } else if (audioStreamModel.isMuted) { return 0 return audioStreamModel.minVolume } } return audioStreamModel.volume return audioStreamModel.volume } } Loading
packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioRepositoryTest.kt +3 −3 Original line number Original line Diff line number Diff line Loading @@ -77,13 +77,13 @@ class AudioRepositoryTest { `when`(audioManager.getStreamMaxVolume(anyInt())).thenReturn(MAX_VOLUME) `when`(audioManager.getStreamMaxVolume(anyInt())).thenReturn(MAX_VOLUME) `when`(audioManager.ringerModeInternal).thenReturn(AudioManager.RINGER_MODE_NORMAL) `when`(audioManager.ringerModeInternal).thenReturn(AudioManager.RINGER_MODE_NORMAL) `when`(audioManager.setStreamVolume(anyInt(), anyInt(), anyInt())).then { `when`(audioManager.setStreamVolume(anyInt(), anyInt(), anyInt())).then { val streamType = it.arguments[1] as Int val streamType = it.arguments[0] as Int volumeByStream[it.arguments[0] as Int] = streamType volumeByStream[it.arguments[0] as Int] = it.arguments[1] as Int triggerEvent(AudioManagerEvent.StreamVolumeChanged(AudioStream(streamType))) triggerEvent(AudioManagerEvent.StreamVolumeChanged(AudioStream(streamType))) } } `when`(audioManager.adjustStreamVolume(anyInt(), anyInt(), anyInt())).then { `when`(audioManager.adjustStreamVolume(anyInt(), anyInt(), anyInt())).then { val streamType = it.arguments[0] as Int val streamType = it.arguments[0] as Int isMuteByStream[streamType] = it.arguments[2] == AudioManager.ADJUST_MUTE isMuteByStream[streamType] = it.arguments[1] == AudioManager.ADJUST_MUTE triggerEvent(AudioManagerEvent.StreamMuteChanged(AudioStream(streamType))) triggerEvent(AudioManagerEvent.StreamMuteChanged(AudioStream(streamType))) } } `when`(audioManager.getStreamVolume(anyInt())).thenAnswer { `when`(audioManager.getStreamVolume(anyInt())).thenAnswer { Loading
packages/SystemUI/AndroidManifest.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -911,7 +911,7 @@ <activity <activity android:name=".volume.panel.ui.activity.VolumePanelActivity" android:name=".volume.panel.ui.activity.VolumePanelActivity" android:label="@string/sound_settings" android:label="@string/accessibility_volume_settings" android:excludeFromRecents="true" android:excludeFromRecents="true" android:exported="false" android:exported="false" android:launchMode="singleInstance" android:launchMode="singleInstance" Loading
packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ButtonComponent.kt +13 −2 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,11 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.clearAndSetSemantics import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.role import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp import com.android.compose.animation.Expandable import com.android.compose.animation.Expandable Loading @@ -52,6 +57,7 @@ class ButtonComponent( override fun VolumePanelComposeScope.Content(modifier: Modifier) { override fun VolumePanelComposeScope.Content(modifier: Modifier) { val viewModelByState by viewModelFlow.collectAsState() val viewModelByState by viewModelFlow.collectAsState() val viewModel = viewModelByState ?: return val viewModel = viewModelByState ?: return val label = viewModel.label.toString() Column( Column( modifier = modifier, modifier = modifier, Loading @@ -59,7 +65,11 @@ class ButtonComponent( horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally, ) { ) { Expandable( Expandable( modifier = Modifier.height(64.dp).fillMaxWidth(), modifier = Modifier.height(64.dp).fillMaxWidth().semantics { role = Role.Button contentDescription = label }, color = MaterialTheme.colorScheme.primaryContainer, color = MaterialTheme.colorScheme.primaryContainer, shape = RoundedCornerShape(28.dp), shape = RoundedCornerShape(28.dp), contentColor = MaterialTheme.colorScheme.onPrimaryContainer, contentColor = MaterialTheme.colorScheme.onPrimaryContainer, Loading @@ -71,7 +81,8 @@ class ButtonComponent( } } } } Text( Text( text = viewModel.label.toString(), modifier = Modifier.clearAndSetSemantics {}, text = label, style = MaterialTheme.typography.labelMedium, style = MaterialTheme.typography.labelMedium, maxLines = 1, maxLines = 1, overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis, Loading