diff options
Diffstat (limited to 'media')
34 files changed, 366 insertions, 167 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 87c0750..575667d 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -428,7 +428,6 @@ public class AudioManager { public static final int USE_DEFAULT_STREAM_TYPE = Integer.MIN_VALUE; private static IAudioService sService; - private MediaSessionLegacyHelper mSessionHelper; /** * @hide @@ -439,9 +438,6 @@ public class AudioManager { com.android.internal.R.bool.config_useMasterVolume); mUseVolumeKeySounds = mContext.getResources().getBoolean( com.android.internal.R.bool.config_useVolumeKeySounds); - if (USE_SESSIONS) { - mSessionHelper = MediaSessionLegacyHelper.getHelper(context); - } } private static IAudioService getService() @@ -478,11 +474,16 @@ public class AudioManager { * or {@link KeyEvent#KEYCODE_MEDIA_AUDIO_TRACK}. */ public void dispatchMediaKeyEvent(KeyEvent keyEvent) { - IAudioService service = getService(); - try { - service.dispatchMediaKeyEvent(keyEvent); - } catch (RemoteException e) { - Log.e(TAG, "dispatchMediaKeyEvent threw exception ", e); + if (USE_SESSIONS) { + MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); + helper.sendMediaButtonEvent(keyEvent, false); + } else { + IAudioService service = getService(); + try { + service.dispatchMediaKeyEvent(keyEvent); + } catch (RemoteException e) { + Log.e(TAG, "dispatchMediaKeyEvent threw exception ", e); + } } } @@ -2178,7 +2179,8 @@ public class AudioManager { Log.e(TAG, "Dead object in registerMediaButtonIntent"+e); } if (USE_SESSIONS) { - mSessionHelper.addMediaButtonListener(pi, mContext); + MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); + helper.addMediaButtonListener(pi, mContext); } } @@ -2254,7 +2256,8 @@ public class AudioManager { Log.e(TAG, "Dead object in unregisterMediaButtonIntent"+e); } if (USE_SESSIONS) { - mSessionHelper.removeMediaButtonListener(pi); + MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); + helper.removeMediaButtonListener(pi); } } @@ -2281,7 +2284,7 @@ public class AudioManager { Log.e(TAG, "Dead object in registerRemoteControlClient"+e); } if (USE_SESSIONS) { - rcClient.registerWithSession(mSessionHelper); + rcClient.registerWithSession(MediaSessionLegacyHelper.getHelper(mContext)); } } @@ -2303,7 +2306,7 @@ public class AudioManager { Log.e(TAG, "Dead object in unregisterRemoteControlClient"+e); } if (USE_SESSIONS) { - rcClient.unregisterWithSession(mSessionHelper); + rcClient.unregisterWithSession(MediaSessionLegacyHelper.getHelper(mContext)); } } diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index a7423e2..6e623a5 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -46,6 +46,7 @@ import android.database.ContentObserver; import android.hardware.usb.UsbManager; import android.media.MediaPlayer.OnCompletionListener; import android.media.MediaPlayer.OnErrorListener; +import android.media.session.MediaSessionLegacyHelper; import android.os.Binder; import android.os.Build; import android.os.Environment; @@ -108,6 +109,10 @@ public class AudioService extends IAudioService.Stub { /** Debug volumes */ protected static final boolean DEBUG_VOL = false; + /** Reroute calls to media session apis */ + private static final boolean USE_SESSIONS = true; + private static final boolean DEBUG_SESSIONS = true; + /** How long to delay before persisting a change in volume/ringer mode. */ private static final int PERSIST_DELAY = 500; @@ -3472,7 +3477,7 @@ public class AudioService extends IAudioService.Stub { if (volume < 0) { volFloat = (float)Math.pow(10, (float)sSoundEffectVolumeDb/20); } else { - volFloat = (float) volume / 1000.0f; + volFloat = volume / 1000.0f; } if (SOUND_EFFECT_FILES_MAP[effectType][1] > 0) { @@ -3554,7 +3559,7 @@ public class AudioService extends IAudioService.Stub { } Settings.System.putFloatForUser(mContentResolver, Settings.System.VOLUME_MASTER, - (float)msg.arg1 / (float)1000.0, + msg.arg1 / (float)1000.0, UserHandle.USER_CURRENT); break; @@ -4325,11 +4330,27 @@ public class AudioService extends IAudioService.Stub { } public void dispatchMediaKeyEvent(KeyEvent keyEvent) { - mMediaFocusControl.dispatchMediaKeyEvent(keyEvent); + if (USE_SESSIONS) { + if (DEBUG_SESSIONS) { + int pid = getCallingPid(); + Log.w(TAG, "Call to dispatchMediaKeyEvent from " + pid); + } + MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, false); + } else { + mMediaFocusControl.dispatchMediaKeyEvent(keyEvent); + } } public void dispatchMediaKeyEventUnderWakelock(KeyEvent keyEvent) { - mMediaFocusControl.dispatchMediaKeyEventUnderWakelock(keyEvent); + if (USE_SESSIONS) { + if (DEBUG_SESSIONS) { + int pid = getCallingPid(); + Log.w(TAG, "Call to dispatchMediaKeyEventUnderWakelock from " + pid); + } + MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, true); + } else { + mMediaFocusControl.dispatchMediaKeyEventUnderWakelock(keyEvent); + } } //========================================================================================== diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index 34c5520..c7b3fc9 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -212,6 +212,7 @@ final public class MediaCodec { * <li>"video/x-vnd.on2.vp8" - VP8 video (i.e. video in .webm) * <li>"video/x-vnd.on2.vp9" - VP9 video (i.e. video in .webm) * <li>"video/avc" - H.264/AVC video + * <li>"video/hevc" - H.265/HEVC video * <li>"video/mp4v-es" - MPEG4 video * <li>"video/3gpp" - H.263 video * <li>"audio/3gpp" - AMR narrowband audio diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java index 90c12c6..b5d0a57 100644 --- a/media/java/android/media/MediaCodecInfo.java +++ b/media/java/android/media/MediaCodecInfo.java @@ -264,6 +264,37 @@ public final class MediaCodecInfo { // from OMX_VIDEO_VP8PROFILETYPE public static final int VP8ProfileMain = 0x01; + // from OMX_VIDEO_HEVCPROFILETYPE + public static final int HEVCProfileMain = 0x01; + public static final int HEVCProfileMain10 = 0x02; + + // from OMX_VIDEO_HEVCLEVELTYPE + public static final int HEVCMainTierLevel1 = 0x1; + public static final int HEVCHighTierLevel1 = 0x2; + public static final int HEVCMainTierLevel2 = 0x4; + public static final int HEVCHighTierLevel2 = 0x8; + public static final int HEVCMainTierLevel21 = 0x10; + public static final int HEVCHighTierLevel21 = 0x20; + public static final int HEVCMainTierLevel3 = 0x40; + public static final int HEVCHighTierLevel3 = 0x80; + public static final int HEVCMainTierLevel31 = 0x100; + public static final int HEVCHighTierLevel31 = 0x200; + public static final int HEVCMainTierLevel4 = 0x400; + public static final int HEVCHighTierLevel4 = 0x800; + public static final int HEVCMainTierLevel41 = 0x1000; + public static final int HEVCHighTierLevel41 = 0x2000; + public static final int HEVCMainTierLevel5 = 0x4000; + public static final int HEVCHighTierLevel5 = 0x8000; + public static final int HEVCMainTierLevel51 = 0x10000; + public static final int HEVCHighTierLevel51 = 0x20000; + public static final int HEVCMainTierLevel52 = 0x40000; + public static final int HEVCHighTierLevel52 = 0x80000; + public static final int HEVCMainTierLevel6 = 0x100000; + public static final int HEVCHighTierLevel6 = 0x200000; + public static final int HEVCMainTierLevel61 = 0x400000; + public static final int HEVCHighTierLevel61 = 0x800000; + public static final int HEVCMainTierLevel62 = 0x1000000; + public static final int HEVCHighTierLevel62 = 0x2000000; /** * Defined in the OpenMAX IL specs, depending on the type of media diff --git a/media/java/android/media/session/SessionToken.aidl b/media/java/android/media/MediaMetadata.aidl index db35f85..66ee483 100644 --- a/media/java/android/media/session/SessionToken.aidl +++ b/media/java/android/media/MediaMetadata.aidl @@ -13,6 +13,6 @@ ** limitations under the License. */ -package android.media.session; +package android.media; -parcelable SessionToken; +parcelable MediaMetadata; diff --git a/media/java/android/media/session/MediaMetadata.java b/media/java/android/media/MediaMetadata.java index 8a8af45..ff73a10 100644 --- a/media/java/android/media/session/MediaMetadata.java +++ b/media/java/android/media/MediaMetadata.java @@ -13,12 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.media.session; +package android.media; import android.graphics.Bitmap; -import android.media.MediaMetadataEditor; -import android.media.MediaMetadataRetriever; -import android.media.Rating; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; diff --git a/media/java/android/media/MediaMetadataEditor.java b/media/java/android/media/MediaMetadataEditor.java index 1a4e8da..ca44e9d 100644 --- a/media/java/android/media/MediaMetadataEditor.java +++ b/media/java/android/media/MediaMetadataEditor.java @@ -17,7 +17,6 @@ package android.media; import android.graphics.Bitmap; -import android.media.session.MediaMetadata; import android.os.Bundle; import android.os.Parcelable; import android.util.Log; diff --git a/media/java/android/media/RemoteControlClient.java b/media/java/android/media/RemoteControlClient.java index 8368df9..26ae3cc 100644 --- a/media/java/android/media/RemoteControlClient.java +++ b/media/java/android/media/RemoteControlClient.java @@ -24,10 +24,9 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RectF; -import android.media.session.MediaMetadata; import android.media.session.MediaSessionLegacyHelper; import android.media.session.PlaybackState; -import android.media.session.Session; +import android.media.session.MediaSession; import android.media.session.TransportPerformer; import android.os.Bundle; import android.os.Handler; @@ -341,7 +340,7 @@ public class RemoteControlClient */ public final static int FLAG_INFORMATION_REQUEST_ALBUM_ART = 1 << 3; - private Session mSession; + private MediaSession mSession; /** * Class constructor. @@ -408,6 +407,19 @@ public class RemoteControlClient } /** + * Get a {@link MediaSession} associated with this RCC. It will only have a + * session while it is registered with + * {@link AudioManager#registerRemoteControlClient}. The session returned + * should not be modified directly by the application but may be used with + * other APIs that require a session. + * + * @return A media session object or null. + */ + public MediaSession getMediaSession() { + return mSession; + } + + /** * Class used to modify metadata in a {@link RemoteControlClient} object. * Use {@link RemoteControlClient#editMetadata(boolean)} to create an instance of an editor, * on which you set the metadata for the RemoteControlClient instance. Once all the information diff --git a/media/java/android/media/routeprovider/RouteConnection.java b/media/java/android/media/routeprovider/RouteConnection.java index 9214ff8..43692c1 100644 --- a/media/java/android/media/routeprovider/RouteConnection.java +++ b/media/java/android/media/routeprovider/RouteConnection.java @@ -40,6 +40,7 @@ import java.util.List; * interfaces. Use {@link #addRouteInterface(String)} to add an interface and * {@link #getRouteInterface(String)} to retrieve the interface's handle anytime * after it has been added. + * @hide */ public final class RouteConnection { private static final String TAG = "RouteConnection"; diff --git a/media/java/android/media/routeprovider/RouteInterfaceHandler.java b/media/java/android/media/routeprovider/RouteInterfaceHandler.java index 9693dc6..e7f8bbf 100644 --- a/media/java/android/media/routeprovider/RouteInterfaceHandler.java +++ b/media/java/android/media/routeprovider/RouteInterfaceHandler.java @@ -16,7 +16,7 @@ package android.media.routeprovider; import android.media.session.Route; -import android.media.session.Session; +import android.media.session.MediaSession; import android.media.session.RouteInterface; import android.os.Bundle; import android.os.Handler; @@ -33,7 +33,7 @@ import java.util.ArrayList; * connected media route. * <p> * A {@link RouteProviderService} may expose multiple interfaces on a - * {@link RouteConnection} for a {@link Session} to interact with. A + * {@link RouteConnection} for a {@link MediaSession} to interact with. A * provider creates an interface with * {@link RouteConnection#addRouteInterface(String)} to allow messages to be * routed appropriately. Events are then sent through a specific interface and @@ -47,6 +47,7 @@ import java.util.ArrayList; * It is recommended you wrap this interface with a standard implementation to * avoid errors, but for simple interfaces this class may be used directly. TODO * add link to sample code. + * @hide */ public final class RouteInterfaceHandler { private static final String TAG = "RouteInterfaceHandler"; @@ -184,7 +185,7 @@ public final class RouteInterfaceHandler { public abstract static class CommandListener { /** * This is called when a command is received that matches this - * interface. Commands are sent by a {@link Session} that is + * interface. Commands are sent by a {@link MediaSession} that is * connected to the route this interface is registered with. * * @param iface The interface the command was received on. @@ -197,7 +198,7 @@ public final class RouteInterfaceHandler { * true may be returned if the command will be handled * asynchronously. * @see Route - * @see Session + * @see MediaSession */ public abstract boolean onCommand(RouteInterfaceHandler iface, String command, Bundle args, ResultReceiver cb); diff --git a/media/java/android/media/routeprovider/RoutePlaybackControlsHandler.java b/media/java/android/media/routeprovider/RoutePlaybackControlsHandler.java index dcef79a..f2c40d2 100644 --- a/media/java/android/media/routeprovider/RoutePlaybackControlsHandler.java +++ b/media/java/android/media/routeprovider/RoutePlaybackControlsHandler.java @@ -28,6 +28,7 @@ import android.util.Log; * Standard wrapper for using playback controls over a {@link RouteInterfaceHandler}. * This is the provider half of the interface. Sessions should use * {@link RoutePlaybackControls} to interact with this interface. + * @hide */ public final class RoutePlaybackControlsHandler { private static final String TAG = "RoutePlaybackControls"; diff --git a/media/java/android/media/routeprovider/RouteProviderService.java b/media/java/android/media/routeprovider/RouteProviderService.java index 6ebfb5b..a6ef0bb 100644 --- a/media/java/android/media/routeprovider/RouteProviderService.java +++ b/media/java/android/media/routeprovider/RouteProviderService.java @@ -64,6 +64,7 @@ import java.util.List; * </intent-filter> * </service> * </pre> + * @hide */ public abstract class RouteProviderService extends Service { private static final String TAG = "RouteProvider"; diff --git a/media/java/android/media/routeprovider/RouteRequest.java b/media/java/android/media/routeprovider/RouteRequest.java index 68475c0..2ba75de 100644 --- a/media/java/android/media/routeprovider/RouteRequest.java +++ b/media/java/android/media/routeprovider/RouteRequest.java @@ -16,7 +16,7 @@ package android.media.routeprovider; import android.media.session.RouteOptions; -import android.media.session.SessionInfo; +import android.media.session.MediaSessionInfo; import android.os.Parcel; import android.os.Parcelable; @@ -30,16 +30,17 @@ import java.io.PrintWriter; * provides the full set of connection parameters they would like to use for a * connection. An app that can connect in multiple ways will be represented by * multiple requests. + * @hide */ public final class RouteRequest implements Parcelable { - private final SessionInfo mSessionInfo; + private final MediaSessionInfo mSessionInfo; private final RouteOptions mOptions; private final boolean mActive; /** * @hide */ - public RouteRequest(SessionInfo info, RouteOptions connRequest, + public RouteRequest(MediaSessionInfo info, RouteOptions connRequest, boolean active) { mSessionInfo = info; mOptions = connRequest; @@ -47,7 +48,7 @@ public final class RouteRequest implements Parcelable { } private RouteRequest(Parcel in) { - mSessionInfo = SessionInfo.CREATOR.createFromParcel(in); + mSessionInfo = MediaSessionInfo.CREATOR.createFromParcel(in); mOptions = RouteOptions.CREATOR.createFromParcel(in); mActive = in.readInt() != 0; } @@ -57,7 +58,7 @@ public final class RouteRequest implements Parcelable { * * @return Info on the session making the request */ - public SessionInfo getSessionInfo() { + public MediaSessionInfo getSessionInfo() { return mSessionInfo; } diff --git a/media/java/android/media/session/ISession.aidl b/media/java/android/media/session/ISession.aidl index 096550f..c4233c3 100644 --- a/media/java/android/media/session/ISession.aidl +++ b/media/java/android/media/session/ISession.aidl @@ -15,8 +15,8 @@ package android.media.session; +import android.media.MediaMetadata; import android.media.session.ISessionController; -import android.media.session.MediaMetadata; import android.media.session.RouteOptions; import android.media.session.RouteCommand; import android.media.session.RouteInfo; diff --git a/media/java/android/media/session/ISessionCallback.aidl b/media/java/android/media/session/ISessionCallback.aidl index 1552513..7b0412e 100644 --- a/media/java/android/media/session/ISessionCallback.aidl +++ b/media/java/android/media/session/ISessionCallback.aidl @@ -28,7 +28,7 @@ import android.os.ResultReceiver; */ oneway interface ISessionCallback { void onCommand(String command, in Bundle extras, in ResultReceiver cb); - void onMediaButton(in Intent mediaButtonIntent); + void onMediaButton(in Intent mediaButtonIntent, in ResultReceiver cb); void onRequestRouteChange(in RouteInfo route); void onRouteConnected(in RouteInfo route, in RouteOptions options); void onRouteDisconnected(in RouteInfo route, int reason); diff --git a/media/java/android/media/session/ISessionController.aidl b/media/java/android/media/session/ISessionController.aidl index e2e046f..5ddb6db 100644 --- a/media/java/android/media/session/ISessionController.aidl +++ b/media/java/android/media/session/ISessionController.aidl @@ -16,9 +16,9 @@ package android.media.session; import android.content.Intent; +import android.media.MediaMetadata; import android.media.Rating; import android.media.session.ISessionControllerCallback; -import android.media.session.MediaMetadata; import android.media.session.PlaybackState; import android.os.Bundle; import android.os.ResultReceiver; diff --git a/media/java/android/media/session/ISessionControllerCallback.aidl b/media/java/android/media/session/ISessionControllerCallback.aidl index bc1ae05..e823153 100644 --- a/media/java/android/media/session/ISessionControllerCallback.aidl +++ b/media/java/android/media/session/ISessionControllerCallback.aidl @@ -15,7 +15,7 @@ package android.media.session; -import android.media.session.MediaMetadata; +import android.media.MediaMetadata; import android.media.session.RouteInfo; import android.media.session.PlaybackState; import android.os.Bundle; diff --git a/media/java/android/media/session/ISessionManager.aidl b/media/java/android/media/session/ISessionManager.aidl index e341647..38b9293 100644 --- a/media/java/android/media/session/ISessionManager.aidl +++ b/media/java/android/media/session/ISessionManager.aidl @@ -19,6 +19,7 @@ import android.content.ComponentName; import android.media.session.ISession; import android.media.session.ISessionCallback; import android.os.Bundle; +import android.view.KeyEvent; /** * Interface to the MediaSessionManagerService @@ -27,4 +28,5 @@ import android.os.Bundle; interface ISessionManager { ISession createSession(String packageName, in ISessionCallback cb, String tag, int userId); List<IBinder> getSessions(in ComponentName compName, int userId); + void dispatchMediaKeyEvent(in KeyEvent keyEvent, boolean needWakeLock); }
\ No newline at end of file diff --git a/media/java/android/media/session/SessionController.java b/media/java/android/media/session/MediaController.java index dc4f7d9..642ac2f 100644 --- a/media/java/android/media/session/SessionController.java +++ b/media/java/android/media/session/MediaController.java @@ -16,6 +16,7 @@ package android.media.session; +import android.media.MediaMetadata; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -34,13 +35,13 @@ import java.util.ArrayList; * other commands can be sent to the session. A callback may be registered to * receive updates from the session, such as metadata and play state changes. * <p> - * A MediaController can be created through {@link SessionManager} if you + * A MediaController can be created through {@link MediaSessionManager} if you * hold the "android.permission.MEDIA_CONTENT_CONTROL" permission or directly if - * you have a {@link SessionToken} from the session owner. + * you have a {@link MediaSessionToken} from the session owner. * <p> * MediaController objects are thread-safe. */ -public final class SessionController { +public final class MediaController { private static final String TAG = "SessionController"; private static final int MSG_EVENT = 1; @@ -58,15 +59,15 @@ public final class SessionController { private TransportController mTransportController; - private SessionController(ISessionController sessionBinder) { + private MediaController(ISessionController sessionBinder) { mSessionBinder = sessionBinder; } /** * @hide */ - public static SessionController fromBinder(ISessionController sessionBinder) { - SessionController controller = new SessionController(sessionBinder); + public static MediaController fromBinder(ISessionController sessionBinder) { + MediaController controller = new MediaController(sessionBinder); try { controller.mSessionBinder.registerCallbackListener(controller.mCbStub); if (controller.mSessionBinder.isTransportControlEnabled()) { @@ -87,7 +88,7 @@ public final class SessionController { * @param token The session token to use * @return A controller for the session or null */ - public static SessionController fromToken(SessionToken token) { + public static MediaController fromToken(MediaSessionToken token) { return fromBinder(token.getBinder()); } @@ -184,6 +185,8 @@ public final class SessionController { /** * Request that the route picker be shown for this session. This should * generally be called in response to a user action. + * + * @hide */ public void showRoutePicker() { try { @@ -285,22 +288,23 @@ public final class SessionController { /** * Override to handle route changes for this session. * - * @param route + * @param route The new route + * @hide */ public void onRouteChanged(RouteInfo route) { } } private final static class CallbackStub extends ISessionControllerCallback.Stub { - private final WeakReference<SessionController> mController; + private final WeakReference<MediaController> mController; - public CallbackStub(SessionController controller) { - mController = new WeakReference<SessionController>(controller); + public CallbackStub(MediaController controller) { + mController = new WeakReference<MediaController>(controller); } @Override public void onEvent(String event, Bundle extras) { - SessionController controller = mController.get(); + MediaController controller = mController.get(); if (controller != null) { controller.postEvent(event, extras); } @@ -308,7 +312,7 @@ public final class SessionController { @Override public void onRouteChanged(RouteInfo route) { - SessionController controller = mController.get(); + MediaController controller = mController.get(); if (controller != null) { controller.postRouteChanged(route); } @@ -316,7 +320,7 @@ public final class SessionController { @Override public void onPlaybackStateChanged(PlaybackState state) { - SessionController controller = mController.get(); + MediaController controller = mController.get(); if (controller != null) { TransportController tc = controller.getTransportController(); if (tc != null) { @@ -327,7 +331,7 @@ public final class SessionController { @Override public void onMetadataChanged(MediaMetadata metadata) { - SessionController controller = mController.get(); + MediaController controller = mController.get(); if (controller != null) { TransportController tc = controller.getTransportController(); if (tc != null) { @@ -339,9 +343,9 @@ public final class SessionController { } private final static class MessageHandler extends Handler { - private final SessionController.Callback mCallback; + private final MediaController.Callback mCallback; - public MessageHandler(Looper looper, SessionController.Callback cb) { + public MessageHandler(Looper looper, MediaController.Callback cb) { super(looper, null, true); mCallback = cb; } diff --git a/media/java/android/media/session/Session.java b/media/java/android/media/session/MediaSession.java index 2ffced6..5b9adaa 100644 --- a/media/java/android/media/session/Session.java +++ b/media/java/android/media/session/MediaSession.java @@ -36,21 +36,21 @@ import java.util.ArrayList; import java.util.List; /** - * Allows interaction with media controllers, media routes, volume keys, media - * buttons, and transport controls. + * Allows interaction with media controllers, volume keys, media buttons, and + * transport controls. * <p> * A MediaSession should be created when an app wants to publish media playback - * information or negotiate with a media route. In general an app only needs one - * session for all playback, though multiple sessions can be created for sending - * media to multiple routes or to provide finer grain controls of media. + * information or handle media keys. In general an app only needs one session + * for all playback, though multiple sessions can be created to provide finer + * grain controls of media. * <p> * A MediaSession is created by calling - * {@link SessionManager#createSession(String)}. Once a session is created apps - * that have the MEDIA_CONTENT_CONTROL permission can interact with the session - * through - * {@link SessionManager#getActiveSessions(android.content.ComponentName)}. The - * owner of the session may also use {@link #getSessionToken()} to allow apps - * without this permission to create a {@link SessionController} to interact + * {@link MediaSessionManager#createSession(String)}. Once a session is created + * apps that have the MEDIA_CONTENT_CONTROL permission can interact with the + * session through + * {@link MediaSessionManager#getActiveSessions(android.content.ComponentName)}. + * The owner of the session may also use {@link #getSessionToken()} to allow + * apps without this permission to create a {@link MediaController} to interact * with this session. * <p> * To receive commands, media keys, and other events a Callback must be set with @@ -61,7 +61,7 @@ import java.util.List; * <p> * MediaSession objects are thread safe */ -public final class Session { +public final class MediaSession { private static final String TAG = "Session"; /** @@ -89,31 +89,43 @@ public final class Session { /** * Indicates the session was disconnected because the user that the session * belonged to is stopping. + * @hide */ public static final int DISCONNECT_REASON_USER_STOPPING = 1; /** * Indicates the session was disconnected because the provider disconnected * the route. + * @hide */ public static final int DISCONNECT_REASON_PROVIDER_DISCONNECTED = 2; /** * Indicates the session was disconnected because the route has changed. + * @hide */ public static final int DISCONNECT_REASON_ROUTE_CHANGED = 3; /** * Indicates the session was disconnected because the session owner * requested it disconnect. + * @hide */ public static final int DISCONNECT_REASON_SESSION_DISCONNECTED = 4; /** * Indicates the session was disconnected because it was destroyed. + * @hide */ public static final int DISCONNECT_REASON_SESSION_DESTROYED = 5; + /** + * Status code indicating the call was handled. + * + * @hide + */ + public static final int RESULT_SUCCESS = 0; + private static final int MSG_MEDIA_BUTTON = 1; private static final int MSG_COMMAND = 2; private static final int MSG_ROUTE_CHANGE = 3; @@ -126,7 +138,7 @@ public final class Session { private final Object mLock = new Object(); - private final SessionToken mSessionToken; + private final MediaSessionToken mSessionToken; private final ISession mBinder; private final CallbackStub mCbStub; @@ -143,7 +155,7 @@ public final class Session { /** * @hide */ - public Session(ISession binder, CallbackStub cbStub) { + public MediaSession(ISession binder, CallbackStub cbStub) { mBinder = binder; mCbStub = cbStub; ISessionController controllerBinder = null; @@ -152,7 +164,7 @@ public final class Session { } catch (RemoteException e) { throw new RuntimeException("Dead object in MediaSessionController constructor: ", e); } - mSessionToken = new SessionToken(controllerBinder); + mSessionToken = new MediaSessionToken(controllerBinder); mPerformer = new TransportPerformer(mBinder); } @@ -167,7 +179,7 @@ public final class Session { /** * Add a callback to receive updates for the MediaSession. This includes - * events like route updates, media buttons, and focus changes. + * media button and volume events. * * @param callback The callback to receive updates on. * @param handler The handler that events should be posted on. @@ -288,13 +300,13 @@ public final class Session { /** * Retrieve a token object that can be used by apps to create a - * {@link SessionController} for interacting with this session. The owner of + * {@link MediaController} for interacting with this session. The owner of * the session is responsible for deciding how to distribute these tokens. * * @return A token that can be used to create a MediaController for this * session */ - public SessionToken getSessionToken() { + public MediaSessionToken getSessionToken() { return mSessionToken; } @@ -304,8 +316,8 @@ public final class Session { * Connection updates will be sent to the callback's * {@link Callback#onRouteConnected(Route)} and * {@link Callback#onRouteDisconnected(Route, int)} methods. If the - * connection fails {@link Callback#onRouteDisconnected(Route, int)} - * will be called. + * connection fails {@link Callback#onRouteDisconnected(Route, int)} will be + * called. * <p> * If you already have a connection to this route it will be disconnected * before the new connection is established. TODO add an easy way to compare @@ -313,6 +325,7 @@ public final class Session { * * @param route The route the app is trying to connect to. * @param request The connection request to use. + * @hide */ public void connect(RouteInfo route, RouteOptions request) { if (route == null) { @@ -331,6 +344,8 @@ public final class Session { /** * Disconnect from the current route. After calling you will be switched * back to the default route. + * + * @hide */ public void disconnect() { if (mRoute != null) { @@ -347,6 +362,7 @@ public final class Session { * will be used for picking valid routes. * * @param options The set of route options your app may use to connect. + * @hide */ public void setRouteOptions(List<RouteOptions> options) { try { @@ -491,6 +507,7 @@ public final class Session { * ongoing playback if necessary. * * @param route + * @hide */ public void onRequestRouteChange(RouteInfo route) { } @@ -500,6 +517,7 @@ public final class Session { * are now valid. * * @param route The route that was connected + * @hide */ public void onRouteConnected(Route route) { } @@ -519,6 +537,7 @@ public final class Session { * * @param route The route that disconnected * @param reason The reason for the disconnect + * @hide */ public void onRouteDisconnected(Route route, int reason) { } @@ -528,32 +547,36 @@ public final class Session { * @hide */ public static class CallbackStub extends ISessionCallback.Stub { - private WeakReference<Session> mMediaSession; + private WeakReference<MediaSession> mMediaSession; - public void setMediaSession(Session session) { - mMediaSession = new WeakReference<Session>(session); + public void setMediaSession(MediaSession session) { + mMediaSession = new WeakReference<MediaSession>(session); } @Override public void onCommand(String command, Bundle extras, ResultReceiver cb) throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { session.postCommand(command, extras, cb); } } @Override - public void onMediaButton(Intent mediaButtonIntent) throws RemoteException { - Session session = mMediaSession.get(); + public void onMediaButton(Intent mediaButtonIntent, ResultReceiver cb) + throws RemoteException { + MediaSession session = mMediaSession.get(); if (session != null) { session.postMediaButton(mediaButtonIntent); } + if (cb != null) { + cb.send(RESULT_SUCCESS, null); + } } @Override public void onRequestRouteChange(RouteInfo route) throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { session.postRequestRouteChange(route); } @@ -561,7 +584,7 @@ public final class Session { @Override public void onRouteConnected(RouteInfo route, RouteOptions options) { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { session.postRouteConnected(route, options); } @@ -569,7 +592,7 @@ public final class Session { @Override public void onRouteDisconnected(RouteInfo route, int reason) { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { session.postRouteDisconnected(route, reason); } @@ -577,7 +600,7 @@ public final class Session { @Override public void onPlay() throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { TransportPerformer tp = session.getTransportPerformer(); if (tp != null) { @@ -588,7 +611,7 @@ public final class Session { @Override public void onPause() throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { TransportPerformer tp = session.getTransportPerformer(); if (tp != null) { @@ -599,7 +622,7 @@ public final class Session { @Override public void onStop() throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { TransportPerformer tp = session.getTransportPerformer(); if (tp != null) { @@ -610,7 +633,7 @@ public final class Session { @Override public void onNext() throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { TransportPerformer tp = session.getTransportPerformer(); if (tp != null) { @@ -621,7 +644,7 @@ public final class Session { @Override public void onPrevious() throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { TransportPerformer tp = session.getTransportPerformer(); if (tp != null) { @@ -632,7 +655,7 @@ public final class Session { @Override public void onFastForward() throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { TransportPerformer tp = session.getTransportPerformer(); if (tp != null) { @@ -643,7 +666,7 @@ public final class Session { @Override public void onRewind() throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { TransportPerformer tp = session.getTransportPerformer(); if (tp != null) { @@ -654,7 +677,7 @@ public final class Session { @Override public void onSeekTo(long pos) throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { TransportPerformer tp = session.getTransportPerformer(); if (tp != null) { @@ -665,7 +688,7 @@ public final class Session { @Override public void onRate(Rating rating) throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { TransportPerformer tp = session.getTransportPerformer(); if (tp != null) { @@ -676,7 +699,7 @@ public final class Session { @Override public void onRouteEvent(RouteEvent event) throws RemoteException { - Session session = mMediaSession.get(); + MediaSession session = mMediaSession.get(); if (session != null) { RouteInterface.EventListener iface = session.mInterfaceListeners.get(event.getIface()); @@ -697,9 +720,9 @@ public final class Session { } private class MessageHandler extends Handler { - private Session.Callback mCallback; + private MediaSession.Callback mCallback; - public MessageHandler(Looper looper, Session.Callback callback) { + public MessageHandler(Looper looper, MediaSession.Callback callback) { super(looper, null, true); mCallback = callback; } diff --git a/media/java/android/media/session/SessionInfo.java b/media/java/android/media/session/MediaSessionInfo.java index 2b65528..3d8d33f 100644 --- a/media/java/android/media/session/SessionInfo.java +++ b/media/java/android/media/session/MediaSessionInfo.java @@ -21,19 +21,19 @@ import android.os.Parcelable; /** * Information about a media session, including the owner's package name. */ -public final class SessionInfo implements Parcelable { +public final class MediaSessionInfo implements Parcelable { private final String mId; private final String mPackageName; /** * @hide */ - public SessionInfo(String id, String packageName) { + public MediaSessionInfo(String id, String packageName) { mId = id; mPackageName = packageName; } - private SessionInfo(Parcel in) { + private MediaSessionInfo(Parcel in) { mId = in.readString(); mPackageName = in.readString(); } @@ -72,16 +72,16 @@ public final class SessionInfo implements Parcelable { dest.writeString(mPackageName); } - public static final Parcelable.Creator<SessionInfo> CREATOR - = new Parcelable.Creator<SessionInfo>() { + public static final Parcelable.Creator<MediaSessionInfo> CREATOR + = new Parcelable.Creator<MediaSessionInfo>() { @Override - public SessionInfo createFromParcel(Parcel in) { - return new SessionInfo(in); + public MediaSessionInfo createFromParcel(Parcel in) { + return new MediaSessionInfo(in); } @Override - public SessionInfo[] newArray(int size) { - return new SessionInfo[size]; + public MediaSessionInfo[] newArray(int size) { + return new MediaSessionInfo[size]; } }; } diff --git a/media/java/android/media/session/MediaSessionLegacyHelper.java b/media/java/android/media/session/MediaSessionLegacyHelper.java index c07229d..2e02a66 100644 --- a/media/java/android/media/session/MediaSessionLegacyHelper.java +++ b/media/java/android/media/session/MediaSessionLegacyHelper.java @@ -35,11 +35,12 @@ import android.view.KeyEvent; */ public class MediaSessionLegacyHelper { private static final String TAG = "MediaSessionHelper"; + private static final boolean DEBUG = true; private static final Object sLock = new Object(); private static MediaSessionLegacyHelper sInstance; - private SessionManager mSessionManager; + private MediaSessionManager mSessionManager; private Handler mHandler = new Handler(Looper.getMainLooper()); // The legacy APIs use PendingIntents to register/unregister media button // receivers and these are associated with RCC. @@ -47,11 +48,14 @@ public class MediaSessionLegacyHelper { = new ArrayMap<PendingIntent, SessionHolder>(); private MediaSessionLegacyHelper(Context context) { - mSessionManager = (SessionManager) context + mSessionManager = (MediaSessionManager) context .getSystemService(Context.MEDIA_SESSION_SERVICE); } public static MediaSessionLegacyHelper getHelper(Context context) { + if (DEBUG) { + Log.d(TAG, "Attempting to get helper with context " + context); + } synchronized (sLock) { if (sInstance == null) { sInstance = new MediaSessionLegacyHelper(context); @@ -60,17 +64,30 @@ public class MediaSessionLegacyHelper { return sInstance; } - public Session getSession(PendingIntent pi) { + public MediaSession getSession(PendingIntent pi) { SessionHolder holder = mSessions.get(pi); return holder == null ? null : holder.mSession; } - public void addRccListener(PendingIntent pi, TransportPerformer.Listener listener) { + public void sendMediaButtonEvent(KeyEvent keyEvent, boolean needWakeLock) { + mSessionManager.dispatchMediaKeyEvent(keyEvent, needWakeLock); + if (DEBUG) { + Log.d(TAG, "dispatched media key " + keyEvent); + } + } + public void addRccListener(PendingIntent pi, TransportPerformer.Listener listener) { + if (pi == null) { + Log.w(TAG, "Pending intent was null, can't add rcc listener."); + return; + } SessionHolder holder = getHolder(pi, true); TransportPerformer performer = holder.mSession.getTransportPerformer(); if (holder.mRccListener != null) { if (holder.mRccListener == listener) { + if (DEBUG) { + Log.d(TAG, "addRccListener listener already added."); + } // This is already the registered listener, ignore return; } @@ -79,50 +96,82 @@ public class MediaSessionLegacyHelper { } performer.addListener(listener, mHandler); holder.mRccListener = listener; - holder.mFlags |= Session.FLAG_HANDLES_TRANSPORT_CONTROLS; + holder.mFlags |= MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS; holder.mSession.setFlags(holder.mFlags); holder.update(); + if (DEBUG) { + Log.d(TAG, "Added rcc listener for " + pi + "."); + } } public void removeRccListener(PendingIntent pi) { + if (pi == null) { + return; + } SessionHolder holder = getHolder(pi, false); if (holder != null && holder.mRccListener != null) { holder.mSession.getTransportPerformer().removeListener(holder.mRccListener); holder.mRccListener = null; - holder.mFlags &= ~Session.FLAG_HANDLES_TRANSPORT_CONTROLS; + holder.mFlags &= ~MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS; holder.mSession.setFlags(holder.mFlags); holder.update(); + if (DEBUG) { + Log.d(TAG, "Removed rcc listener for " + pi + "."); + } } } public void addMediaButtonListener(PendingIntent pi, Context context) { + if (pi == null) { + Log.w(TAG, "Pending intent was null, can't addMediaButtonListener."); + return; + } SessionHolder holder = getHolder(pi, true); if (holder.mMediaButtonListener != null) { - // Already have this listener registered + // Already have this listener registered, but update it anyway as + // the extras may have changed. + if (DEBUG) { + Log.d(TAG, "addMediaButtonListener already added " + pi); + } return; } holder.mMediaButtonListener = new MediaButtonListener(pi, context); - holder.mFlags |= Session.FLAG_HANDLES_MEDIA_BUTTONS; + holder.mFlags |= MediaSession.FLAG_HANDLES_MEDIA_BUTTONS; holder.mSession.setFlags(holder.mFlags); holder.mSession.getTransportPerformer().addListener(holder.mMediaButtonListener, mHandler); + + holder.mMediaButtonReceiver = new MediaButtonReceiver(pi, context); + holder.mSession.addCallback(holder.mMediaButtonReceiver, mHandler); + if (DEBUG) { + Log.d(TAG, "addMediaButtonListener added " + pi); + } } public void removeMediaButtonListener(PendingIntent pi) { + if (pi == null) { + return; + } SessionHolder holder = getHolder(pi, false); if (holder != null && holder.mMediaButtonListener != null) { holder.mSession.getTransportPerformer().removeListener(holder.mMediaButtonListener); - holder.mFlags &= ~Session.FLAG_HANDLES_MEDIA_BUTTONS; + holder.mFlags &= ~MediaSession.FLAG_HANDLES_MEDIA_BUTTONS; holder.mSession.setFlags(holder.mFlags); holder.mMediaButtonListener = null; + + holder.mSession.removeCallback(holder.mMediaButtonReceiver); + holder.mMediaButtonReceiver = null; holder.update(); + if (DEBUG) { + Log.d(TAG, "removeMediaButtonListener removed " + pi); + } } } private SessionHolder getHolder(PendingIntent pi, boolean createIfMissing) { SessionHolder holder = mSessions.get(pi); if (holder == null && createIfMissing) { - Session session = mSessionManager.createSession(TAG); + MediaSession session = mSessionManager.createSession(TAG); session.setActive(true); holder = new SessionHolder(session, pi); mSessions.put(pi, holder); @@ -130,7 +179,32 @@ public class MediaSessionLegacyHelper { return holder; } - public static class MediaButtonListener extends TransportPerformer.Listener { + private static void sendKeyEvent(PendingIntent pi, Context context, Intent intent) { + try { + pi.send(context, 0, intent); + } catch (CanceledException e) { + Log.e(TAG, "Error sending media key down event:", e); + // Don't bother sending up if down failed + return; + } + } + + private static final class MediaButtonReceiver extends MediaSession.Callback { + private final PendingIntent mPendingIntent; + private final Context mContext; + + public MediaButtonReceiver(PendingIntent pi, Context context) { + mPendingIntent = pi; + mContext = context; + } + + @Override + public void onMediaButton(Intent mediaButtonIntent) { + MediaSessionLegacyHelper.sendKeyEvent(mPendingIntent, mContext, mediaButtonIntent); + } + } + + private static final class MediaButtonListener extends TransportPerformer.Listener { private final PendingIntent mPendingIntent; private final Context mContext; @@ -179,32 +253,27 @@ public class MediaSessionLegacyHelper { Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON); intent.putExtra(Intent.EXTRA_KEY_EVENT, ke); - try { - mPendingIntent.send(mContext, 0, intent); - } catch (CanceledException e) { - Log.e(TAG, "Error sending media key down event:", e); - // Don't bother sending up if down failed - return; - } + MediaSessionLegacyHelper.sendKeyEvent(mPendingIntent, mContext, intent); ke = new KeyEvent(KeyEvent.ACTION_UP, keyCode); intent.putExtra(Intent.EXTRA_KEY_EVENT, ke); - try { - mPendingIntent.send(mContext, 0, intent); - } catch (CanceledException e) { - Log.e(TAG, "Error sending media key up event:", e); + MediaSessionLegacyHelper.sendKeyEvent(mPendingIntent, mContext, intent); + + if (DEBUG) { + Log.d(TAG, "Sent " + keyCode + " to pending intent " + mPendingIntent); } } } private class SessionHolder { - public final Session mSession; + public final MediaSession mSession; public final PendingIntent mPi; public MediaButtonListener mMediaButtonListener; + public MediaButtonReceiver mMediaButtonReceiver; public TransportPerformer.Listener mRccListener; public int mFlags; - public SessionHolder(Session session, PendingIntent pi) { + public SessionHolder(MediaSession session, PendingIntent pi) { mSession = session; mPi = pi; } @@ -213,10 +282,6 @@ public class MediaSessionLegacyHelper { if (mMediaButtonListener == null && mRccListener == null) { mSession.release(); mSessions.remove(mPi); - } else if (mMediaButtonListener != null && mRccListener != null) { - // TODO set session to active - } else { - // TODO set session to inactive } } } diff --git a/media/java/android/media/session/SessionManager.java b/media/java/android/media/session/MediaSessionManager.java index 1eb3b7a..0589a7d 100644 --- a/media/java/android/media/session/SessionManager.java +++ b/media/java/android/media/session/MediaSessionManager.java @@ -25,6 +25,7 @@ import android.os.ServiceManager; import android.os.UserHandle; import android.service.notification.NotificationListenerService; import android.util.Log; +import android.view.KeyEvent; import java.util.ArrayList; import java.util.List; @@ -38,10 +39,10 @@ import java.util.List; * get an instance of this class. * <p> * - * @see Session - * @see SessionController + * @see MediaSession + * @see MediaController */ -public final class SessionManager { +public final class MediaSessionManager { private static final String TAG = "SessionManager"; private final ISessionManager mService; @@ -51,7 +52,7 @@ public final class SessionManager { /** * @hide */ - public SessionManager(Context context) { + public MediaSessionManager(Context context) { // Consider rewriting like DisplayManagerGlobal // Decide if we need context mContext = context; @@ -63,9 +64,9 @@ public final class SessionManager { * Creates a new session. * * @param tag A short name for debugging purposes - * @return a {@link Session} for the new session + * @return a {@link MediaSession} for the new session */ - public Session createSession(String tag) { + public MediaSession createSession(String tag) { return createSessionAsUser(tag, UserHandle.myUserId()); } @@ -77,13 +78,13 @@ public final class SessionManager { * * @param tag A short name for debugging purposes * @param userId The user id to create the session as. - * @return a {@link Session} for the new session + * @return a {@link MediaSession} for the new session * @hide */ - public Session createSessionAsUser(String tag, int userId) { + public MediaSession createSessionAsUser(String tag, int userId) { try { - Session.CallbackStub cbStub = new Session.CallbackStub(); - Session session = new Session(mService + MediaSession.CallbackStub cbStub = new MediaSession.CallbackStub(); + MediaSession session = new MediaSession(mService .createSession(mContext.getPackageName(), cbStub, tag, userId), cbStub); cbStub.setMediaSession(session); @@ -106,7 +107,7 @@ public final class SessionManager { * May be null. * @return A list of controllers for ongoing sessions */ - public List<SessionController> getActiveSessions(ComponentName notificationListener) { + public List<MediaController> getActiveSessions(ComponentName notificationListener) { return getActiveSessionsForUser(notificationListener, UserHandle.myUserId()); } @@ -123,13 +124,13 @@ public final class SessionManager { * @return A list of controllers for ongoing sessions. * @hide */ - public List<SessionController> getActiveSessionsForUser(ComponentName notificationListener, + public List<MediaController> getActiveSessionsForUser(ComponentName notificationListener, int userId) { - ArrayList<SessionController> controllers = new ArrayList<SessionController>(); + ArrayList<MediaController> controllers = new ArrayList<MediaController>(); try { List<IBinder> binders = mService.getSessions(notificationListener, userId); for (int i = binders.size() - 1; i >= 0; i--) { - SessionController controller = SessionController.fromBinder(ISessionController.Stub + MediaController controller = MediaController.fromBinder(ISessionController.Stub .asInterface(binders.get(i))); controllers.add(controller); } @@ -138,4 +139,30 @@ public final class SessionManager { } return controllers; } + + /** + * Send a media key event. The receiver will be selected automatically. + * + * @param keyEvent The KeyEvent to send. + * @hide + */ + public void dispatchMediaKeyEvent(KeyEvent keyEvent) { + dispatchMediaKeyEvent(keyEvent, false); + } + + /** + * Send a media key event. The receiver will be selected automatically. + * + * @param keyEvent The KeyEvent to send + * @param needWakeLock true if a wake lock should be held while sending the + * key + * @hide + */ + public void dispatchMediaKeyEvent(KeyEvent keyEvent, boolean needWakeLock) { + try { + mService.dispatchMediaKeyEvent(keyEvent, needWakeLock); + } catch (RemoteException e) { + Log.e(TAG, "Failed to send key event.", e); + } + } } diff --git a/media/java/android/media/session/MediaMetadata.aidl b/media/java/android/media/session/MediaSessionToken.aidl index 4431d9d..5812682 100644 --- a/media/java/android/media/session/MediaMetadata.aidl +++ b/media/java/android/media/session/MediaSessionToken.aidl @@ -15,4 +15,4 @@ package android.media.session; -parcelable MediaMetadata; +parcelable MediaSessionToken; diff --git a/media/java/android/media/session/SessionToken.java b/media/java/android/media/session/MediaSessionToken.java index 59486f6..f5569a4 100644 --- a/media/java/android/media/session/SessionToken.java +++ b/media/java/android/media/session/MediaSessionToken.java @@ -20,17 +20,17 @@ import android.media.session.ISessionController; import android.os.Parcel; import android.os.Parcelable; -public class SessionToken implements Parcelable { +public class MediaSessionToken implements Parcelable { private ISessionController mBinder; /** * @hide */ - SessionToken(ISessionController binder) { + MediaSessionToken(ISessionController binder) { mBinder = binder; } - private SessionToken(Parcel in) { + private MediaSessionToken(Parcel in) { mBinder = ISessionController.Stub.asInterface(in.readStrongBinder()); } @@ -51,16 +51,16 @@ public class SessionToken implements Parcelable { dest.writeStrongBinder(mBinder.asBinder()); } - public static final Parcelable.Creator<SessionToken> CREATOR - = new Parcelable.Creator<SessionToken>() { + public static final Parcelable.Creator<MediaSessionToken> CREATOR + = new Parcelable.Creator<MediaSessionToken>() { @Override - public SessionToken createFromParcel(Parcel in) { - return new SessionToken(in); + public MediaSessionToken createFromParcel(Parcel in) { + return new MediaSessionToken(in); } @Override - public SessionToken[] newArray(int size) { - return new SessionToken[size]; + public MediaSessionToken[] newArray(int size) { + return new MediaSessionToken[size]; } }; } diff --git a/media/java/android/media/session/PlaybackState.java b/media/java/android/media/session/PlaybackState.java index 3254e5d..7ef38eaa 100644 --- a/media/java/android/media/session/PlaybackState.java +++ b/media/java/android/media/session/PlaybackState.java @@ -21,7 +21,7 @@ import android.os.Parcelable; import android.os.SystemClock; /** - * Playback state for a {@link Session}. This includes a state like + * Playback state for a {@link MediaSession}. This includes a state like * {@link PlaybackState#PLAYSTATE_PLAYING}, the current playback position, * and the current control capabilities. */ @@ -160,6 +160,7 @@ public final class PlaybackState implements Parcelable { * route. Depending on the implementation you may return to the previous * state when the connection finishes or enter {@link #PLAYSTATE_NONE}. If * the connection failed {@link #PLAYSTATE_ERROR} should be used. + * @hide */ public final static int PLAYSTATE_CONNECTING = 8; diff --git a/media/java/android/media/session/Route.java b/media/java/android/media/session/Route.java index c9530a6..935eb5b 100644 --- a/media/java/android/media/session/Route.java +++ b/media/java/android/media/session/Route.java @@ -28,17 +28,18 @@ import java.util.List; * to. The MediaRoute must be used to get {@link RouteInterface} * instances which can be used to communicate over a specific interface on the * route. + * @hide */ public final class Route { private static final String TAG = "Route"; private final RouteInfo mInfo; - private final Session mSession; + private final MediaSession mSession; private final RouteOptions mOptions; /** * @hide */ - public Route(RouteInfo info, RouteOptions options, Session session) { + public Route(RouteInfo info, RouteOptions options, MediaSession session) { if (info == null || options == null) { throw new IllegalStateException("Route info was not valid!"); } @@ -93,7 +94,7 @@ public final class Route { /** * @hide */ - Session getSession() { + MediaSession getSession() { return mSession; } } diff --git a/media/java/android/media/session/RouteInfo.java b/media/java/android/media/session/RouteInfo.java index 17df969..02f78f9 100644 --- a/media/java/android/media/session/RouteInfo.java +++ b/media/java/android/media/session/RouteInfo.java @@ -25,6 +25,7 @@ import java.util.List; /** * Information about a route, including its display name, a way to identify it, * and the ways it can be connected to. + * @hide */ public final class RouteInfo implements Parcelable { private final String mName; diff --git a/media/java/android/media/session/RouteInterface.java b/media/java/android/media/session/RouteInterface.java index e9c9fd3..8de4d89 100644 --- a/media/java/android/media/session/RouteInterface.java +++ b/media/java/android/media/session/RouteInterface.java @@ -25,7 +25,7 @@ import android.util.Log; import java.util.ArrayList; /** - * A route can support multiple interfaces for a {@link Session} to + * A route can support multiple interfaces for a {@link MediaSession} to * interact with. To use a specific interface with a route a * MediaSessionRouteInterface needs to be retrieved from the route. An * implementation of the specific interface, like @@ -33,6 +33,7 @@ import java.util.ArrayList; * and reduce errors on that interface. * * @see RoutePlaybackControls for an example + * @hide */ public final class RouteInterface { private static final String TAG = "RouteInterface"; @@ -67,7 +68,7 @@ public final class RouteInterface { private final Route mRoute; private final String mIface; - private final Session mSession; + private final MediaSession mSession; private final Object mLock = new Object(); private final ArrayList<EventHandler> mListeners = new ArrayList<EventHandler>(); @@ -75,7 +76,7 @@ public final class RouteInterface { /** * @hide */ - RouteInterface(Route route, String iface, Session session) { + RouteInterface(Route route, String iface, MediaSession session) { mRoute = route; mIface = iface; mSession = session; diff --git a/media/java/android/media/session/RouteOptions.java b/media/java/android/media/session/RouteOptions.java index 5105867..b4fb341 100644 --- a/media/java/android/media/session/RouteOptions.java +++ b/media/java/android/media/session/RouteOptions.java @@ -34,6 +34,7 @@ import java.util.List; * appropriate route options when it is ready to connect to the route. Each * route options instance must specify a complete set of capabilities to request * when the connection is established. + * @hide */ public final class RouteOptions implements Parcelable { private static final String TAG = "RouteOptions"; diff --git a/media/java/android/media/session/RoutePlaybackControls.java b/media/java/android/media/session/RoutePlaybackControls.java index a3ffb58..8211983 100644 --- a/media/java/android/media/session/RoutePlaybackControls.java +++ b/media/java/android/media/session/RoutePlaybackControls.java @@ -15,6 +15,7 @@ */ package android.media.session; +import android.media.MediaMetadata; import android.os.Bundle; import android.os.Handler; import android.os.ResultReceiver; @@ -23,6 +24,7 @@ import android.os.ResultReceiver; * A standard media control interface for Routes that support queueing and * transport controls. Routes may support multiple interfaces for MediaSessions * to interact with. + * @hide */ public final class RoutePlaybackControls { private static final String TAG = "RoutePlaybackControls"; diff --git a/media/java/android/media/session/TransportController.java b/media/java/android/media/session/TransportController.java index 9574df6..090489b 100644 --- a/media/java/android/media/session/TransportController.java +++ b/media/java/android/media/session/TransportController.java @@ -15,6 +15,7 @@ */ package android.media.session; +import android.media.MediaMetadata; import android.media.Rating; import android.os.Handler; import android.os.Looper; diff --git a/media/java/android/media/session/TransportPerformer.java b/media/java/android/media/session/TransportPerformer.java index 187f48d..1588d8f 100644 --- a/media/java/android/media/session/TransportPerformer.java +++ b/media/java/android/media/session/TransportPerformer.java @@ -16,6 +16,7 @@ package android.media.session; import android.media.AudioManager; +import android.media.MediaMetadata; import android.media.Rating; import android.os.Handler; import android.os.Looper; diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp index 84028b7..d21b442 100644 --- a/media/jni/android_media_MediaScanner.cpp +++ b/media/jni/android_media_MediaScanner.cpp @@ -351,7 +351,7 @@ android_media_MediaScanner_extractAlbumArt( if (!data) { return NULL; } - long len = *((long*)data); + jsize len = *((uint32_t*)data); jbyteArray array = env->NewByteArray(len); if (array != NULL) { |