diff options
author | RoboErik <epastern@google.com> | 2014-05-15 23:08:25 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-15 23:08:26 +0000 |
commit | 7e89723bb4204537ede2058b61b94c4e99444c03 (patch) | |
tree | 38796b8cee55e82974fba646971c739e1b7394e9 /media | |
parent | bc3376f1c28ebd03765127cb8351008ddb62fc19 (diff) | |
parent | 4646d288821d62fdfe481be67d8b7fed7d7eabd8 (diff) | |
download | frameworks_base-7e89723bb4204537ede2058b61b94c4e99444c03.zip frameworks_base-7e89723bb4204537ede2058b61b94c4e99444c03.tar.gz frameworks_base-7e89723bb4204537ede2058b61b94c4e99444c03.tar.bz2 |
Merge "Add UserRecords to separate user interactions"
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/session/ISession.aidl | 1 | ||||
-rw-r--r-- | media/java/android/media/session/ISessionCallback.aidl | 1 | ||||
-rw-r--r-- | media/java/android/media/session/Session.java | 71 |
3 files changed, 69 insertions, 4 deletions
diff --git a/media/java/android/media/session/ISession.aidl b/media/java/android/media/session/ISession.aidl index 3ff07d9..096550f 100644 --- a/media/java/android/media/session/ISession.aidl +++ b/media/java/android/media/session/ISession.aidl @@ -40,6 +40,7 @@ interface ISession { boolean setRoute(in RouteInfo route); void setRouteOptions(in List<RouteOptions> options); void connectToRoute(in RouteInfo route, in RouteOptions options); + void disconnectFromRoute(in RouteInfo route); void sendRouteCommand(in RouteCommand event, in ResultReceiver cb); // These commands are for the TransportPerformer diff --git a/media/java/android/media/session/ISessionCallback.aidl b/media/java/android/media/session/ISessionCallback.aidl index f04cbcc..1552513 100644 --- a/media/java/android/media/session/ISessionCallback.aidl +++ b/media/java/android/media/session/ISessionCallback.aidl @@ -31,6 +31,7 @@ oneway interface ISessionCallback { void onMediaButton(in Intent mediaButtonIntent); void onRequestRouteChange(in RouteInfo route); void onRouteConnected(in RouteInfo route, in RouteOptions options); + void onRouteDisconnected(in RouteInfo route, int reason); void onRouteStateChange(int state); void onRouteEvent(in RouteEvent event); diff --git a/media/java/android/media/session/Session.java b/media/java/android/media/session/Session.java index 194679e7..2ffced6 100644 --- a/media/java/android/media/session/Session.java +++ b/media/java/android/media/session/Session.java @@ -86,10 +86,39 @@ public final class Session { */ public static final int FLAG_EXCLUSIVE_GLOBAL_PRIORITY = 1 << 16; + /** + * Indicates the session was disconnected because the user that the session + * belonged to is stopping. + */ + public static final int DISCONNECT_REASON_USER_STOPPING = 1; + + /** + * Indicates the session was disconnected because the provider disconnected + * the route. + */ + public static final int DISCONNECT_REASON_PROVIDER_DISCONNECTED = 2; + + /** + * Indicates the session was disconnected because the route has changed. + */ + public static final int DISCONNECT_REASON_ROUTE_CHANGED = 3; + + /** + * Indicates the session was disconnected because the session owner + * requested it disconnect. + */ + public static final int DISCONNECT_REASON_SESSION_DISCONNECTED = 4; + + /** + * Indicates the session was disconnected because it was destroyed. + */ + public static final int DISCONNECT_REASON_SESSION_DESTROYED = 5; + private static final int MSG_MEDIA_BUTTON = 1; private static final int MSG_COMMAND = 2; private static final int MSG_ROUTE_CHANGE = 3; private static final int MSG_ROUTE_CONNECTED = 4; + private static final int MSG_ROUTE_DISCONNECTED = 5; private static final String KEY_COMMAND = "command"; private static final String KEY_EXTRAS = "extras"; @@ -302,11 +331,15 @@ public final class Session { /** * Disconnect from the current route. After calling you will be switched * back to the default route. - * - * @param route The route to disconnect from. */ - public void disconnect(RouteInfo route) { - // TODO + public void disconnect() { + if (mRoute != null) { + try { + mBinder.disconnectFromRoute(mRoute.getRouteInfo()); + } catch (RemoteException e) { + Log.wtf(TAG, "Error disconnecting from route"); + } + } } /** @@ -406,6 +439,16 @@ public final class Session { } } + private void postRouteDisconnected(RouteInfo route, int reason) { + synchronized (mLock) { + if (mRoute != null && TextUtils.equals(mRoute.getRouteInfo().getId(), route.getId())) { + for (int i = mCallbacks.size() - 1; i >= 0; i--) { + mCallbacks.get(i).post(MSG_ROUTE_DISCONNECTED, mRoute, reason); + } + } + } + } + /** * Receives commands or updates from controllers and routes. An app can * specify what commands and buttons it supports by setting them on the @@ -467,6 +510,11 @@ public final class Session { * <p> * Valid reasons are: * <ul> + * <li>{@link #DISCONNECT_REASON_USER_STOPPING}</li> + * <li>{@link #DISCONNECT_REASON_PROVIDER_DISCONNECTED}</li> + * <li>{@link #DISCONNECT_REASON_ROUTE_CHANGED}</li> + * <li>{@link #DISCONNECT_REASON_SESSION_DISCONNECTED}</li> + * <li>{@link #DISCONNECT_REASON_SESSION_DESTROYED}</li> * </ul> * * @param route The route that disconnected @@ -520,6 +568,14 @@ public final class Session { } @Override + public void onRouteDisconnected(RouteInfo route, int reason) { + Session session = mMediaSession.get(); + if (session != null) { + session.postRouteDisconnected(route, reason); + } + } + + @Override public void onPlay() throws RemoteException { Session session = mMediaSession.get(); if (session != null) { @@ -668,6 +724,9 @@ public final class Session { case MSG_ROUTE_CONNECTED: mCallback.onRouteConnected((Route) msg.obj); break; + case MSG_ROUTE_DISCONNECTED: + mCallback.onRouteDisconnected((Route) msg.obj, msg.arg1); + break; } } } @@ -675,6 +734,10 @@ public final class Session { public void post(int what, Object obj) { obtainMessage(what, obj).sendToTarget(); } + + public void post(int what, Object obj, int arg1) { + obtainMessage(what, arg1, 0, obj).sendToTarget(); + } } private static final class Command { |