From 560877d498b3b142bb0d555bb2fe48ead3fa9b0f Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Thu, 25 Jun 2015 17:38:35 -0700 Subject: [PATCH] Volume change intent carries stream alias Define a new extra, AudioManager.EXTRA_VOLUME_STREAM_TYPE_ALIAS, to be sent along with the volume change intent, VOLUME_CHANGED_ACTION. When sending VOLUME_CHANGED_ACTION, attach the stream type alias. Bug 17955277 Change-Id: I04fd279e223504e3ee1581086d7e9205344a6808 --- media/java/android/media/AudioManager.java | 11 +++++++++++ .../java/com/android/server/audio/AudioService.java | 2 ++ 2 files changed, 13 insertions(+) diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index b3b2b973bc377..2c28d8ec2fbb6 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -203,6 +203,17 @@ public class AudioManager { */ public static final String EXTRA_VOLUME_STREAM_TYPE = "android.media.EXTRA_VOLUME_STREAM_TYPE"; + /** + * @hide + * The stream type alias for the volume changed intent. + * For instance the intent may indicate a change of the {@link #STREAM_NOTIFICATION} stream + * type (as indicated by the {@link #EXTRA_VOLUME_STREAM_TYPE} extra), but this is also + * reflected by a change of the volume of its alias, {@link #STREAM_RING} on some devices, + * {@link #STREAM_MUSIC} on others (e.g. a television). + */ + public static final String EXTRA_VOLUME_STREAM_TYPE_ALIAS = + "android.media.EXTRA_VOLUME_STREAM_TYPE_ALIAS"; + /** * @hide The volume associated with the stream for the volume changed intent. */ diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 0dc4076b067d6..dd4111d593dcb 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -3791,6 +3791,8 @@ public class AudioService extends IAudioService.Stub { // fire changed intents for all streams mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, index); mVolumeChanged.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex); + mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE_ALIAS, + mStreamVolumeAlias[mStreamType]); sendBroadcastToAll(mVolumeChanged); } return changed;