diff options
author | Eric Laurent <elaurent@google.com> | 2010-02-16 06:00:26 -0800 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2010-02-16 06:40:20 -0800 |
commit | 9ce379aef155e0c21b5d82d8dc713c62792e4f30 (patch) | |
tree | 4b73365410f0e0af6e4683171b6fc84d32157ea9 /media/java/android | |
parent | 103d53645c0b8ef532e8715da6c6cd33ad5f98e2 (diff) | |
download | frameworks_base-9ce379aef155e0c21b5d82d8dc713c62792e4f30.zip frameworks_base-9ce379aef155e0c21b5d82d8dc713c62792e4f30.tar.gz frameworks_base-9ce379aef155e0c21b5d82d8dc713c62792e4f30.tar.bz2 |
Fix issue 2440226: Car dock volume synchronization.
AudioService now sends intent AudioManager.VOLUME_CHANGED_ACTION when the volume is changed
on any stream type (previously the intent was sent only for STREAM_BLUETOOTH_SCO stream).
A new extra for previous volume value is added to the intent.
Diffstat (limited to 'media/java/android')
-rw-r--r-- | media/java/android/media/AudioManager.java | 9 | ||||
-rw-r--r-- | media/java/android/media/AudioService.java | 20 |
2 files changed, 20 insertions, 9 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 70c27c2..32c5c23 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -87,10 +87,11 @@ public class AudioManager { /** * @hide Broadcast intent when the volume for a particular stream type changes. - * Includes the stream and the new volume + * Includes the stream, the new volume and previous volumes * * @see #EXTRA_VOLUME_STREAM_TYPE * @see #EXTRA_VOLUME_STREAM_VALUE + * @see #EXTRA_PREV_VOLUME_STREAM_VALUE */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String VOLUME_CHANGED_ACTION = "android.media.VOLUME_CHANGED_ACTION"; @@ -126,6 +127,12 @@ public class AudioManager { public static final String EXTRA_VOLUME_STREAM_VALUE = "android.media.EXTRA_VOLUME_STREAM_VALUE"; + /** + * @hide The previous volume associated with the stream for the volume changed intent. + */ + public static final String EXTRA_PREV_VOLUME_STREAM_VALUE = + "android.media.EXTRA_PREV_VOLUME_STREAM_VALUE"; + /** The audio stream for phone calls */ public static final int STREAM_VOICE_CALL = AudioSystem.STREAM_VOICE_CALL; /** The audio stream for system sounds */ diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index bde8a47..668917e 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -403,30 +403,34 @@ public class AudioService extends IAudioService.Stub { // UI mVolumePanel.postVolumeChanged(streamType, flags); // Broadcast Intent - sendVolumeUpdate(streamType); + sendVolumeUpdate(streamType, oldIndex, streamState.mIndex); } /** @see AudioManager#setStreamVolume(int, int, int) */ public void setStreamVolume(int streamType, int index, int flags) { ensureValidStreamType(streamType); + + final int oldIndex = mStreamStates[STREAM_VOLUME_ALIAS[streamType]].mIndex; + index = rescaleIndex(index * 10, streamType, STREAM_VOLUME_ALIAS[streamType]); setStreamVolumeInt(STREAM_VOLUME_ALIAS[streamType], index, false, true); // UI, etc. mVolumePanel.postVolumeChanged(streamType, flags); // Broadcast Intent - sendVolumeUpdate(streamType); + sendVolumeUpdate(streamType, oldIndex, index); } - private void sendVolumeUpdate(int streamType) { + private void sendVolumeUpdate(int streamType, int oldIndex, int index) { + oldIndex = (oldIndex + 5) / 10; + index = (index + 5) / 10; + Intent intent = new Intent(AudioManager.VOLUME_CHANGED_ACTION); intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, streamType); - intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, getStreamVolume(streamType)); + intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, index); + intent.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex); - // Currently, sending the intent only when the stream is BLUETOOTH_SCO - if (streamType == AudioSystem.STREAM_BLUETOOTH_SCO) { - mContext.sendBroadcast(intent); - } + mContext.sendBroadcast(intent); } /** |