@@ -521,6 +521,9 @@ public void adjustStreamVolume(int streamType, int direction, int flags) {
521521 ensureValidDirection (direction );
522522 ensureValidStreamType (streamType );
523523
524+ // use stream type alias here so that streams with same alias have the same behavior,
525+ // including with regard to silent mode control (e.g the use of STREAM_RING below and in
526+ // checkForRingerModeChange() in place of STREAM_RING or STREAM_NOTIFICATION)
524527 int streamTypeAlias = STREAM_VOLUME_ALIAS [streamType ];
525528 VolumeStreamState streamState = mStreamStates [streamTypeAlias ];
526529 final int oldIndex = (streamState .muteCount () != 0 ) ? streamState .mLastAudibleIndex : streamState .mIndex ;
@@ -529,9 +532,8 @@ public void adjustStreamVolume(int streamType, int direction, int flags) {
529532 // If either the client forces allowing ringer modes for this adjustment,
530533 // or the stream type is one that is affected by ringer modes
531534 if (((flags & AudioManager .FLAG_ALLOW_RINGER_MODES ) != 0 ) ||
532- (!mVoiceCapable && streamType != AudioSystem .STREAM_VOICE_CALL &&
533- streamType != AudioSystem .STREAM_BLUETOOTH_SCO ) ||
534- (mVoiceCapable && streamTypeAlias == AudioSystem .STREAM_RING )) {
535+ streamTypeAlias == AudioSystem .STREAM_RING ||
536+ (!mVoiceCapable && streamTypeAlias == AudioSystem .STREAM_MUSIC )) {
535537 // do not vibrate if already in vibrate mode
536538 if (mRingerMode == AudioManager .RINGER_MODE_VIBRATE ) {
537539 flags &= ~AudioManager .FLAG_VIBRATE ;
@@ -545,10 +547,19 @@ public void adjustStreamVolume(int streamType, int direction, int flags) {
545547 int index ;
546548 if (streamState .muteCount () != 0 ) {
547549 if (adjustVolume ) {
548- streamState .adjustLastAudibleIndex (direction );
549- // Post a persist volume msg
550- sendMsg (mAudioHandler , MSG_PERSIST_VOLUME , streamType ,
551- SENDMSG_REPLACE , 0 , 1 , streamState , PERSIST_DELAY );
550+ // adjust volume on all stream types sharing the same alias otherwise a query
551+ // on last audible index for an alias would not give the correct value
552+ int numStreamTypes = AudioSystem .getNumStreamTypes ();
553+ for (int i = numStreamTypes - 1 ; i >= 0 ; i --) {
554+ if (STREAM_VOLUME_ALIAS [i ] == streamTypeAlias ) {
555+ VolumeStreamState s = mStreamStates [i ];
556+
557+ s .adjustLastAudibleIndex (direction );
558+ // Post a persist volume msg
559+ sendMsg (mAudioHandler , MSG_PERSIST_VOLUME , i ,
560+ SENDMSG_REPLACE , 0 , 1 , s , PERSIST_DELAY );
561+ }
562+ }
552563 }
553564 index = streamState .mLastAudibleIndex ;
554565 } else {
0 commit comments