@@ -1737,7 +1737,8 @@ private void readAudioSettings(boolean userSwitch) {
17371737 streamState .readSettings ();
17381738
17391739 // unmute stream that was muted but is not affect by mute anymore
1740- if (streamState .muteCount () != 0 && !isStreamAffectedByMute (streamType )) {
1740+ if (streamState .muteCount () != 0 && !isStreamAffectedByMute (streamType ) &&
1741+ !isStreamMutedByRingerMode (streamType )) {
17411742 int size = streamState .mDeathHandlers .size ();
17421743 for (int i = 0 ; i < size ; i ++) {
17431744 streamState .mDeathHandlers .get (i ).mMuteCount = 1 ;
@@ -2591,6 +2592,18 @@ public String getSettingNameForDevice(boolean lastAudible, int device) {
25912592 public synchronized void readSettings () {
25922593 int remainingDevices = AudioSystem .DEVICE_OUT_ALL ;
25932594
2595+ // do not read system stream volume from settings: this stream is always aliased
2596+ // to another stream type and its volume is never persisted. Values in settings can
2597+ // only be stale values
2598+ if ((mStreamType == AudioSystem .STREAM_SYSTEM ) ||
2599+ (mStreamType == AudioSystem .STREAM_SYSTEM_ENFORCED )) {
2600+ mLastAudibleIndex .put (AudioSystem .DEVICE_OUT_DEFAULT ,
2601+ 10 * AudioManager .DEFAULT_STREAM_VOLUME [mStreamType ]);
2602+ mIndex .put (AudioSystem .DEVICE_OUT_DEFAULT ,
2603+ 10 * AudioManager .DEFAULT_STREAM_VOLUME [mStreamType ]);
2604+ return ;
2605+ }
2606+
25942607 for (int i = 0 ; remainingDevices != 0 ; i ++) {
25952608 int device = (1 << i );
25962609 if ((device & remainingDevices ) == 0 ) {
@@ -2621,11 +2634,8 @@ public synchronized void readSettings() {
26212634
26222635 // a last audible index of 0 should never be stored for ring and notification
26232636 // streams on phones (voice capable devices).
2624- // same for system stream on phones and tablets
2625- if ((lastAudibleIndex == 0 ) &&
2626- ((mVoiceCapable &&
2627- (mStreamVolumeAlias [mStreamType ] == AudioSystem .STREAM_RING )) ||
2628- (mStreamVolumeAlias [mStreamType ] == AudioSystem .STREAM_SYSTEM ))) {
2637+ if ((lastAudibleIndex == 0 ) && mVoiceCapable &&
2638+ (mStreamVolumeAlias [mStreamType ] == AudioSystem .STREAM_RING )) {
26292639 lastAudibleIndex = AudioManager .DEFAULT_STREAM_VOLUME [mStreamType ];
26302640 // Correct the data base
26312641 sendMsg (mAudioHandler ,
@@ -2639,11 +2649,9 @@ public synchronized void readSettings() {
26392649 mLastAudibleIndex .put (device , getValidIndex (10 * lastAudibleIndex ));
26402650 // the initial index should never be 0 for ring and notification streams on phones
26412651 // (voice capable devices) if not in silent or vibrate mode.
2642- // same for system stream on phones and tablets
26432652 if ((index == 0 ) && (mRingerMode == AudioManager .RINGER_MODE_NORMAL ) &&
2644- ((mVoiceCapable &&
2645- (mStreamVolumeAlias [mStreamType ] == AudioSystem .STREAM_RING )) ||
2646- (mStreamVolumeAlias [mStreamType ] == AudioSystem .STREAM_SYSTEM ))) {
2653+ mVoiceCapable &&
2654+ (mStreamVolumeAlias [mStreamType ] == AudioSystem .STREAM_RING )) {
26472655 index = lastAudibleIndex ;
26482656 // Correct the data base
26492657 sendMsg (mAudioHandler ,
0 commit comments