From 3114ce3861f20f9a5c2c59dd2629197a1f4874a8 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Mon, 11 Jun 2012 15:03:52 -0700 Subject: Remote volume handling Extend RemoteControlClient class to enable an applicaton to specify more information about how it's playing media, now covering usecases where media playback happens "remotely". This playback information can be used to set the volume and maximum volume used remotely. Declare a new intent and associated extras in Intent, ACTION_VOLUME_UPDATE, so an application can be notified that the volume it handles should be updated. It can then use the new RemoteControlClient.setPlaybackInformation() method to notify AudioService what the volume is. Extend AudioService to maintain playback information associated with the RemoteControlClient information in the stack of media button event receivers (mRCStack). The information about the active remote is cached so the stack doesn't have to be iterated over in order to retrieve remote playback info. Events to "adjust" the remote volume based on hardware key presses cause the client application to be notified of volume updates, and the volume panel to display the volume set by the app. Revise which stream type is controlled when none is specified according to latest guidelines for remote playback. Update VolumePanel class to support a new pseudo stream type, AudioService.STREAM_REMOTE_MUSIC, that corresponds to the remote playback volume, and uses the new "media route" icon. Enable it to receive asynchronously new volume values for the remote that will be displayed if the UI is still up, and ignored otherwise. Now supports hiding/showing sliders dynamically so remote volume only appears when AudioService has a remote control client handling remote volume. Define new java symbols for the two media route icons. Modify lockscreen behavior: don't automatically control music volume when music is active, consider also remote playback. Still to do: - playback information set by RemoteControlClient should post a message for AudioService to update playback information instead of updating it synchronously Change-Id: I557aa687239f9acfe33a609f05876c67fa7eb967 --- core/java/android/content/Intent.java | 35 +++++++ core/java/android/view/VolumePanel.java | 172 ++++++++++++++++++++++++++++++-- 2 files changed, 197 insertions(+), 10 deletions(-) (limited to 'core/java') diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index edd509b..50972e8 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -27,6 +27,7 @@ import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Rect; +import android.media.RemoteControlClient; import android.net.Uri; import android.os.Bundle; import android.os.IBinder; @@ -2152,6 +2153,19 @@ public class Intent implements Parcelable, Cloneable { "android.intent.action.USB_AUDIO_DEVICE_PLUG"; /** + * @hide (to be un-hidden) + * Broadcast Action: the volume handled by the receiver should be updated based on the + * mutually exclusive extras, {@link #EXTRA_VOLUME_UPDATE_DIRECTION} + * and {@link #EXTRA_VOLUME_UPDATE_VALUE}. + * + * @see #EXTRA_VOLUME_UPDATE_DIRECTION + * @see #EXTRA_VOLUME_UPDATE_VALUE + * @see android.media.RemoteControlClient + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_VOLUME_UPDATE = "android.intent.action.VOLUME_UPDATE"; + + /** *

Broadcast Action: The user has switched on advanced settings in the settings app:

*