diff options
author | RoboErik <epastern@google.com> | 2014-09-05 11:39:29 -0700 |
---|---|---|
committer | RoboErik <epastern@google.com> | 2014-09-05 12:37:39 -0700 |
commit | 272e161c1a200900cb10b5b0cdab8ae1f123cabd (patch) | |
tree | fe9088a5125261fc4a4da466b68269aa8ac78556 /services/core/java/com/android/server/media | |
parent | 5dfa0a5f7a6365ddf3939f29227366172979e53e (diff) | |
download | frameworks_base-272e161c1a200900cb10b5b0cdab8ae1f123cabd.zip frameworks_base-272e161c1a200900cb10b5b0cdab8ae1f123cabd.tar.gz frameworks_base-272e161c1a200900cb10b5b0cdab8ae1f123cabd.tar.bz2 |
send volume button events to adjustSuggestedStream instead of adjustStream
This way the audio system can route the adjustments correctly when a bt
headset is connected.
bug:17281977
Change-Id: Ic41d038e47179baffc86e539562da285446148c7
Diffstat (limited to 'services/core/java/com/android/server/media')
-rw-r--r-- | services/core/java/com/android/server/media/MediaSessionRecord.java | 19 | ||||
-rw-r--r-- | services/core/java/com/android/server/media/MediaSessionService.java | 2 |
2 files changed, 16 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java index b936130d..5097927 100644 --- a/services/core/java/com/android/server/media/MediaSessionRecord.java +++ b/services/core/java/com/android/server/media/MediaSessionRecord.java @@ -229,8 +229,14 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { * {@link AudioManager#ADJUST_SAME}. * * @param direction The direction to adjust volume in. + * @param flags Any of the flags from {@link AudioManager}. + * @param packageName The package that made the original volume request. + * @param uid The uid that made the original volume request. + * @param useSuggested True to use adjustSuggestedStreamVolume instead of + * adjustStreamVolume. */ - public void adjustVolume(int direction, int flags, String packageName, int uid) { + public void adjustVolume(int direction, int flags, String packageName, int uid, + boolean useSuggested) { if (isPlaybackActive(false) || hasFlag(MediaSession.FLAG_EXCLUSIVE_GLOBAL_PRIORITY)) { flags &= ~AudioManager.FLAG_PLAY_SOUND; } @@ -241,8 +247,13 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { } if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) { int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs); - mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags, packageName, - uid); + if (useSuggested) { + mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction, flags, + packageName, uid); + } else { + mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags, + packageName, uid); + } } else { if (mVolumeControlType == VolumeProvider.VOLUME_CONTROL_FIXED) { // Nothing to do, the volume cannot be changed @@ -1020,7 +1031,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { int uid = Binder.getCallingUid(); final long token = Binder.clearCallingIdentity(); try { - MediaSessionRecord.this.adjustVolume(direction, flags, packageName, uid); + MediaSessionRecord.this.adjustVolume(direction, flags, packageName, uid, false); } finally { Binder.restoreCallingIdentity(token); } diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java index 0c6d46c..a12dd1c 100644 --- a/services/core/java/com/android/server/media/MediaSessionService.java +++ b/services/core/java/com/android/server/media/MediaSessionService.java @@ -814,7 +814,7 @@ public class MediaSessionService extends SystemService implements Monitor { } } else { session.adjustVolume(direction, flags, getContext().getPackageName(), - UserHandle.myUserId()); + UserHandle.myUserId(), true); if (session.getPlaybackType() == PlaybackInfo.PLAYBACK_TYPE_REMOTE && mRvc != null) { try { |