diff options
author | RoboErik <epastern@google.com> | 2014-09-29 14:16:45 -0700 |
---|---|---|
committer | RoboErik <epastern@google.com> | 2014-09-29 14:43:10 -0700 |
commit | 165809b33198cd3926cc11e8cbc96b671d4c87d3 (patch) | |
tree | 42c21a6be92c5c0ce8df94f898009f169d6244e6 | |
parent | df382cada180033e5bbde82998b73ef19e541ed2 (diff) | |
download | frameworks_base-165809b33198cd3926cc11e8cbc96b671d4c87d3.zip frameworks_base-165809b33198cd3926cc11e8cbc96b671d4c87d3.tar.gz frameworks_base-165809b33198cd3926cc11e8cbc96b671d4c87d3.tar.bz2 |
Send volume keys to the default stream if not actually playing
This ensures that we'll only adjust volume on a session's stream if
that stream is actually in use.
bug:17690423
Change-Id: I5fce8265a015bbc5034afa16719d9a0bbf257598
-rw-r--r-- | services/core/java/com/android/server/media/MediaSessionRecord.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java index d9730aa..a0ec1d5 100644 --- a/services/core/java/com/android/server/media/MediaSessionRecord.java +++ b/services/core/java/com/android/server/media/MediaSessionRecord.java @@ -23,6 +23,7 @@ import android.content.Intent; import android.content.pm.ParceledListSlice; import android.media.AudioManager; import android.media.AudioManagerInternal; +import android.media.AudioSystem; import android.media.MediaDescription; import android.media.MediaMetadata; import android.media.Rating; @@ -237,6 +238,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { */ public void adjustVolume(int direction, int flags, String packageName, int uid, boolean useSuggested) { + int previousFlagPlaySound = flags & AudioManager.FLAG_PLAY_SOUND; if (isPlaybackActive(false) || hasFlag(MediaSession.FLAG_EXCLUSIVE_GLOBAL_PRIORITY)) { flags &= ~AudioManager.FLAG_PLAY_SOUND; } @@ -248,8 +250,15 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) { int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs); if (useSuggested) { - mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction, flags, - packageName, uid); + if (AudioSystem.isStreamActive(stream, 0)) { + mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction, + flags, packageName, uid); + } else { + flags |= previousFlagPlaySound; + mAudioManagerInternal.adjustSuggestedStreamVolumeForUid( + AudioManager.USE_DEFAULT_STREAM_TYPE, direction, flags, packageName, + uid); + } } else { mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags, packageName, uid); |