MediaRouter2: Refactor internal classes
This CL introduces following changes:
- Remove ambiguous 'client' word usages
- Clarify AIDL file names and related classes/methods/fields
- Reorder AIDL methods
Bug: 149642195
Test: CTS and atest mediaroutertest
Change-Id: I53656c3be52ab8deb3fbf96bf7caf9a3476d7af6
diff --git a/media/java/android/media/IMediaRoute2Provider.aidl b/media/java/android/media/IMediaRoute2ProviderService.aidl
similarity index 79%
rename from media/java/android/media/IMediaRoute2Provider.aidl
rename to media/java/android/media/IMediaRoute2ProviderService.aidl
index 7097166..cd0def3 100644
--- a/media/java/android/media/IMediaRoute2Provider.aidl
+++ b/media/java/android/media/IMediaRoute2ProviderService.aidl
@@ -17,24 +17,25 @@
package android.media;
import android.content.Intent;
-import android.media.IMediaRoute2ProviderClient;
+import android.media.IMediaRoute2ProviderServiceCallback;
import android.media.RouteDiscoveryPreference;
import android.os.Bundle;
/**
* {@hide}
*/
-oneway interface IMediaRoute2Provider {
- void setClient(IMediaRoute2ProviderClient client);
+oneway interface IMediaRoute2ProviderService {
+ // Note: When changing this file, match the order of methods below with
+ // MediaRoute2ProviderService#MediaRoute2ProviderServiceStub for readability.
+ void setCallback(IMediaRoute2ProviderServiceCallback callback);
+ void updateDiscoveryPreference(in RouteDiscoveryPreference discoveryPreference);
+ void setRouteVolume(String routeId, int volume);
+
void requestCreateSession(String packageName, String routeId, long requestId,
in @nullable Bundle sessionHints);
- void releaseSession(String sessionId);
- void updateDiscoveryPreference(in RouteDiscoveryPreference discoveryPreference);
-
void selectRoute(String sessionId, String routeId);
void deselectRoute(String sessionId, String routeId);
void transferToRoute(String sessionId, String routeId);
-
- void setRouteVolume(String routeId, int volume);
void setSessionVolume(String sessionId, int volume);
+ void releaseSession(String sessionId);
}
diff --git a/media/java/android/media/IMediaRoute2ProviderClient.aidl b/media/java/android/media/IMediaRoute2ProviderServiceCallback.aidl
similarity index 95%
rename from media/java/android/media/IMediaRoute2ProviderClient.aidl
rename to media/java/android/media/IMediaRoute2ProviderServiceCallback.aidl
index 0fccb3a..e35b0c4 100644
--- a/media/java/android/media/IMediaRoute2ProviderClient.aidl
+++ b/media/java/android/media/IMediaRoute2ProviderServiceCallback.aidl
@@ -24,7 +24,7 @@
/**
* @hide
*/
-oneway interface IMediaRoute2ProviderClient {
+oneway interface IMediaRoute2ProviderServiceCallback {
// TODO: Change it to updateRoutes?
void updateState(in MediaRoute2ProviderInfo providerInfo);
void notifySessionCreated(in RoutingSessionInfo sessionInfo, long requestId);
diff --git a/media/java/android/media/IMediaRouter2Client.aidl b/media/java/android/media/IMediaRouter2.aidl
similarity index 96%
rename from media/java/android/media/IMediaRouter2Client.aidl
rename to media/java/android/media/IMediaRouter2.aidl
index bc7ebea..550ecfd 100644
--- a/media/java/android/media/IMediaRouter2Client.aidl
+++ b/media/java/android/media/IMediaRouter2.aidl
@@ -23,7 +23,7 @@
/**
* @hide
*/
-oneway interface IMediaRouter2Client {
+oneway interface IMediaRouter2 {
void notifyRestoreRoute();
void notifyRoutesAdded(in List<MediaRoute2Info> routes);
void notifyRoutesRemoved(in List<MediaRoute2Info> routes);
diff --git a/media/java/android/media/IMediaRouterService.aidl b/media/java/android/media/IMediaRouterService.aidl
index 8be2884..cbec323 100644
--- a/media/java/android/media/IMediaRouterService.aidl
+++ b/media/java/android/media/IMediaRouterService.aidl
@@ -17,7 +17,7 @@
package android.media;
import android.content.Intent;
-import android.media.IMediaRouter2Client;
+import android.media.IMediaRouter2;
import android.media.IMediaRouter2Manager;
import android.media.IMediaRouterClient;
import android.media.MediaRoute2Info;
@@ -44,40 +44,43 @@
void requestSetVolume(IMediaRouterClient client, String routeId, int volume);
void requestUpdateVolume(IMediaRouterClient client, String routeId, int direction);
- // Methods for media router 2
+ // Note: When changing this file, match the order of methods below with
+ // MediaRouterService.java for readability.
+
+ // Methods for MediaRouter2
List<MediaRoute2Info> getSystemRoutes();
RoutingSessionInfo getSystemSessionInfo();
- void registerClient2(IMediaRouter2Client client, String packageName);
- void unregisterClient2(IMediaRouter2Client client);
- void setRouteVolume2(IMediaRouter2Client client, in MediaRoute2Info route, int volume);
- void setSessionVolume2(IMediaRouter2Client client, String sessionId, int volume);
- void requestCreateSession(IMediaRouter2Client client, in MediaRoute2Info route, int requestId,
- in @nullable Bundle sessionHints);
- void setDiscoveryRequest2(IMediaRouter2Client client, in RouteDiscoveryPreference preference);
- void selectRoute(IMediaRouter2Client client, String sessionId, in MediaRoute2Info route);
- void deselectRoute(IMediaRouter2Client client, String sessionId, in MediaRoute2Info route);
- void transferToRoute(IMediaRouter2Client client, String sessionId, in MediaRoute2Info route);
- void releaseSession(IMediaRouter2Client client, String sessionId);
+ void registerRouter2(IMediaRouter2 router, String packageName);
+ void unregisterRouter2(IMediaRouter2 router);
+ void setDiscoveryRequestWithRouter2(IMediaRouter2 router,
+ in RouteDiscoveryPreference preference);
+ void setRouteVolumeWithRouter2(IMediaRouter2 router, in MediaRoute2Info route, int volume);
+ void requestCreateSessionWithRouter2(IMediaRouter2 router, in MediaRoute2Info route,
+ int requestId, in @nullable Bundle sessionHints);
+ void selectRouteWithRouter2(IMediaRouter2 router, String sessionId, in MediaRoute2Info route);
+ void deselectRouteWithRouter2(IMediaRouter2 router, String sessionId, in MediaRoute2Info route);
+ void transferToRouteWithRouter2(IMediaRouter2 router, String sessionId,
+ in MediaRoute2Info route);
+ void setSessionVolumeWithRouter2(IMediaRouter2 router, String sessionId, int volume);
+ void releaseSessionWithRouter2(IMediaRouter2 router, String sessionId);
+
+ // Methods for MediaRouter2Manager
+ List<RoutingSessionInfo> getActiveSessions(IMediaRouter2Manager manager);
void registerManager(IMediaRouter2Manager manager, String packageName);
void unregisterManager(IMediaRouter2Manager manager);
+ void setRouteVolumeWithManager(IMediaRouter2Manager manager, in MediaRoute2Info route,
+ int volume);
- void requestCreateClientSession(IMediaRouter2Manager manager, String packageName,
- in @nullable MediaRoute2Info route, int requestId);
-
- void setRouteVolume2Manager(IMediaRouter2Manager manager,
- in MediaRoute2Info route, int volume);
- void setSessionVolume2Manager(IMediaRouter2Manager manager,
- String sessionId, int volume);
-
- List<RoutingSessionInfo> getActiveSessions(IMediaRouter2Manager manager);
- void selectClientRoute(IMediaRouter2Manager manager,
- String sessionId, in MediaRoute2Info route);
- void deselectClientRoute(IMediaRouter2Manager manager,
- String sessionId, in MediaRoute2Info route);
- void transferToClientRoute(IMediaRouter2Manager manager,
- String sessionId, in MediaRoute2Info route);
- void releaseClientSession(IMediaRouter2Manager manager, String sessionId);
-
+ void requestCreateSessionWithManager(IMediaRouter2Manager manager, String packageName,
+ in @nullable MediaRoute2Info route, int requestId);
+ void selectRouteWithManager(IMediaRouter2Manager manager, String sessionId,
+ in MediaRoute2Info route);
+ void deselectRouteWithManager(IMediaRouter2Manager manager, String sessionId,
+ in MediaRoute2Info route);
+ void transferToRouteWithManager(IMediaRouter2Manager manager, String sessionId,
+ in MediaRoute2Info route);
+ void setSessionVolumeWithManager(IMediaRouter2Manager manager, String sessionId, int volume);
+ void releaseSessionWithManager(IMediaRouter2Manager manager, String sessionId);
}
diff --git a/media/java/android/media/MediaRoute2ProviderService.java b/media/java/android/media/MediaRoute2ProviderService.java
index 7d72b1c..e205bbb 100644
--- a/media/java/android/media/MediaRoute2ProviderService.java
+++ b/media/java/android/media/MediaRoute2ProviderService.java
@@ -84,8 +84,8 @@
private final Handler mHandler;
private final Object mSessionLock = new Object();
private final AtomicBoolean mStatePublishScheduled = new AtomicBoolean(false);
- private ProviderStub mStub;
- private IMediaRoute2ProviderClient mClient;
+ private MediaRoute2ProviderServiceStub mStub;
+ private IMediaRoute2ProviderServiceCallback mRemoteCallback;
private MediaRoute2ProviderInfo mProviderInfo;
@GuardedBy("mSessionLock")
@@ -107,7 +107,7 @@
//TODO: Allow binding from media router service only?
if (SERVICE_INTERFACE.equals(intent.getAction())) {
if (mStub == null) {
- mStub = new ProviderStub();
+ mStub = new MediaRoute2ProviderServiceStub();
}
return mStub;
}
@@ -185,14 +185,14 @@
mSessionInfo.put(sessionInfo.getId(), sessionInfo);
}
- if (mClient == null) {
+ if (mRemoteCallback == null) {
return;
}
try {
// TODO: Calling binder calls in multiple thread may cause timing issue.
// Consider to change implementations to avoid the problems.
// For example, post binder calls, always send all sessions at once, etc.
- mClient.notifySessionCreated(sessionInfo, requestId);
+ mRemoteCallback.notifySessionCreated(sessionInfo, requestId);
} catch (RemoteException ex) {
Log.w(TAG, "Failed to notify session created.");
}
@@ -206,11 +206,11 @@
* @see #onCreateSession(String, String, long, Bundle)
*/
public final void notifySessionCreationFailed(long requestId) {
- if (mClient == null) {
+ if (mRemoteCallback == null) {
return;
}
try {
- mClient.notifySessionCreationFailed(requestId);
+ mRemoteCallback.notifySessionCreationFailed(requestId);
} catch (RemoteException ex) {
Log.w(TAG, "Failed to notify session creation failed.");
}
@@ -233,11 +233,11 @@
}
}
- if (mClient == null) {
+ if (mRemoteCallback == null) {
return;
}
try {
- mClient.notifySessionUpdated(sessionInfo);
+ mRemoteCallback.notifySessionUpdated(sessionInfo);
} catch (RemoteException ex) {
Log.w(TAG, "Failed to notify session info changed.");
}
@@ -263,11 +263,11 @@
return;
}
- if (mClient == null) {
+ if (mRemoteCallback == null) {
return;
}
try {
- mClient.notifySessionReleased(sessionInfo);
+ mRemoteCallback.notifySessionReleased(sessionInfo);
} catch (RemoteException ex) {
Log.w(TAG, "Failed to notify session info changed.");
}
@@ -382,8 +382,8 @@
schedulePublishState();
}
- void setClient(IMediaRoute2ProviderClient client) {
- mClient = client;
+ void setCallback(IMediaRoute2ProviderServiceCallback callback) {
+ mRemoteCallback = callback;
schedulePublishState();
}
@@ -398,7 +398,7 @@
return;
}
- if (mClient == null) {
+ if (mRemoteCallback == null) {
return;
}
@@ -407,26 +407,45 @@
sessionInfos = new ArrayList<>(mSessionInfo.values());
}
try {
- mClient.updateState(mProviderInfo);
+ mRemoteCallback.updateState(mProviderInfo);
} catch (RemoteException ex) {
Log.w(TAG, "Failed to send onProviderInfoUpdated");
}
}
- final class ProviderStub extends IMediaRoute2Provider.Stub {
- ProviderStub() { }
+ final class MediaRoute2ProviderServiceStub extends IMediaRoute2ProviderService.Stub {
+ MediaRoute2ProviderServiceStub() { }
boolean checkCallerisSystem() {
return Binder.getCallingUid() == Process.SYSTEM_UID;
}
@Override
- public void setClient(IMediaRoute2ProviderClient client) {
+ public void setCallback(IMediaRoute2ProviderServiceCallback callback) {
if (!checkCallerisSystem()) {
return;
}
- mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::setClient,
- MediaRoute2ProviderService.this, client));
+ mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::setCallback,
+ MediaRoute2ProviderService.this, callback));
+ }
+
+ @Override
+ public void updateDiscoveryPreference(RouteDiscoveryPreference discoveryPreference) {
+ if (!checkCallerisSystem()) {
+ return;
+ }
+ mHandler.sendMessage(obtainMessage(
+ MediaRoute2ProviderService::onDiscoveryPreferenceChanged,
+ MediaRoute2ProviderService.this, discoveryPreference));
+ }
+
+ @Override
+ public void setRouteVolume(String routeId, int volume) {
+ if (!checkCallerisSystem()) {
+ return;
+ }
+ mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::onSetRouteVolume,
+ MediaRoute2ProviderService.this, routeId, volume));
}
@Override
@@ -441,29 +460,6 @@
}
@Override
- public void releaseSession(@NonNull String sessionId) {
- if (!checkCallerisSystem()) {
- return;
- }
- if (TextUtils.isEmpty(sessionId)) {
- Log.w(TAG, "releaseSession: Ignoring empty sessionId from system service.");
- return;
- }
- mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::onReleaseSession,
- MediaRoute2ProviderService.this, sessionId));
- }
-
- @Override
- public void updateDiscoveryPreference(RouteDiscoveryPreference discoveryPreference) {
- if (!checkCallerisSystem()) {
- return;
- }
- mHandler.sendMessage(obtainMessage(
- MediaRoute2ProviderService::onDiscoveryPreferenceChanged,
- MediaRoute2ProviderService.this, discoveryPreference));
- }
-
- @Override
public void selectRoute(@NonNull String sessionId, String routeId) {
if (!checkCallerisSystem()) {
return;
@@ -503,15 +499,6 @@
}
@Override
- public void setRouteVolume(String routeId, int volume) {
- if (!checkCallerisSystem()) {
- return;
- }
- mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::onSetRouteVolume,
- MediaRoute2ProviderService.this, routeId, volume));
- }
-
- @Override
public void setSessionVolume(String sessionId, int volume) {
if (!checkCallerisSystem()) {
return;
@@ -519,5 +506,18 @@
mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::onSetSessionVolume,
MediaRoute2ProviderService.this, sessionId, volume));
}
+
+ @Override
+ public void releaseSession(@NonNull String sessionId) {
+ if (!checkCallerisSystem()) {
+ return;
+ }
+ if (TextUtils.isEmpty(sessionId)) {
+ Log.w(TAG, "releaseSession: Ignoring empty sessionId from system service.");
+ return;
+ }
+ mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::onReleaseSession,
+ MediaRoute2ProviderService.this, sessionId));
+ }
}
}
diff --git a/media/java/android/media/MediaRouter2.java b/media/java/android/media/MediaRouter2.java
index 274169c..5111411 100644
--- a/media/java/android/media/MediaRouter2.java
+++ b/media/java/android/media/MediaRouter2.java
@@ -83,7 +83,7 @@
// TODO: Make MediaRouter2 is always connected to the MediaRouterService.
@GuardedBy("sRouterLock")
- Client2 mClient;
+ MediaRouter2Stub mStub;
@GuardedBy("sRouterLock")
private Map<String, RoutingController> mRoutingControllers = new ArrayMap<>();
@@ -177,18 +177,18 @@
mRouteCallbackRecords.addIfAbsent(record);
synchronized (sRouterLock) {
- if (mClient == null) {
- Client2 client = new Client2();
+ if (mStub == null) {
+ MediaRouter2Stub stub = new MediaRouter2Stub();
try {
- mMediaRouterService.registerClient2(client, mPackageName);
- mClient = client;
+ mMediaRouterService.registerRouter2(stub, mPackageName);
+ mStub = stub;
} catch (RemoteException ex) {
- Log.e(TAG, "registerRouteCallback: Unable to register client.", ex);
+ Log.e(TAG, "registerRouteCallback: Unable to register MediaRouter2.", ex);
}
}
- if (mClient != null && updateDiscoveryPreferenceIfNeededLocked()) {
+ if (mStub != null && updateDiscoveryPreferenceIfNeededLocked()) {
try {
- mMediaRouterService.setDiscoveryRequest2(mClient, mDiscoveryPreference);
+ mMediaRouterService.setDiscoveryRequestWithRouter2(mStub, mDiscoveryPreference);
} catch (RemoteException ex) {
Log.e(TAG, "registerRouteCallback: Unable to set discovery request.");
}
@@ -213,24 +213,26 @@
}
synchronized (sRouterLock) {
- if (mClient != null) {
- if (updateDiscoveryPreferenceIfNeededLocked()) {
- try {
- mMediaRouterService.setDiscoveryRequest2(mClient, mDiscoveryPreference);
- } catch (RemoteException ex) {
- Log.e(TAG, "unregisterRouteCallback: Unable to set discovery request.");
- }
- }
- if (mRouteCallbackRecords.size() == 0) {
- try {
- mMediaRouterService.unregisterClient2(mClient);
- } catch (RemoteException ex) {
- Log.e(TAG, "Unable to unregister media router.", ex);
- }
- }
- mShouldUpdateRoutes = true;
- mClient = null;
+ if (mStub == null) {
+ return;
}
+ if (updateDiscoveryPreferenceIfNeededLocked()) {
+ try {
+ mMediaRouterService.setDiscoveryRequestWithRouter2(
+ mStub, mDiscoveryPreference);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "unregisterRouteCallback: Unable to set discovery request.");
+ }
+ }
+ if (mRouteCallbackRecords.size() == 0) {
+ try {
+ mMediaRouterService.unregisterRouter2(mStub);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Unable to unregister media router.", ex);
+ }
+ }
+ mShouldUpdateRoutes = true;
+ mStub = null;
}
}
@@ -360,13 +362,14 @@
}
}
- Client2 client;
+ MediaRouter2Stub stub;
synchronized (sRouterLock) {
- client = mClient;
+ stub = mStub;
}
- if (client != null) {
+ if (stub != null) {
try {
- mMediaRouterService.requestCreateSession(client, route, requestId, controllerHints);
+ mMediaRouterService.requestCreateSessionWithRouter2(
+ stub, route, requestId, controllerHints);
} catch (RemoteException ex) {
Log.e(TAG, "Unable to request to create controller.", ex);
mHandler.sendMessage(obtainMessage(MediaRouter2::createControllerOnHandler,
@@ -422,13 +425,13 @@
public void setRouteVolume(@NonNull MediaRoute2Info route, int volume) {
Objects.requireNonNull(route, "route must not be null");
- Client2 client;
+ MediaRouter2Stub stub;
synchronized (sRouterLock) {
- client = mClient;
+ stub = mStub;
}
- if (client != null) {
+ if (stub != null) {
try {
- mMediaRouterService.setRouteVolume2(client, route, volume);
+ mMediaRouterService.setRouteVolumeWithRouter2(stub, route, volume);
} catch (RemoteException ex) {
Log.e(TAG, "Unable to send control request.", ex);
}
@@ -941,13 +944,13 @@
return;
}
- Client2 client;
+ MediaRouter2Stub stub;
synchronized (sRouterLock) {
- client = mClient;
+ stub = mStub;
}
- if (client != null) {
+ if (stub != null) {
try {
- mMediaRouterService.selectRoute(client, getId(), route);
+ mMediaRouterService.selectRouteWithRouter2(stub, getId(), route);
} catch (RemoteException ex) {
Log.e(TAG, "Unable to select route for session.", ex);
}
@@ -988,13 +991,13 @@
return;
}
- Client2 client;
+ MediaRouter2Stub stub;
synchronized (sRouterLock) {
- client = mClient;
+ stub = mStub;
}
- if (client != null) {
+ if (stub != null) {
try {
- mMediaRouterService.deselectRoute(client, getId(), route);
+ mMediaRouterService.deselectRouteWithRouter2(stub, getId(), route);
} catch (RemoteException ex) {
Log.e(TAG, "Unable to remove route from session.", ex);
}
@@ -1036,13 +1039,13 @@
return;
}
- Client2 client;
+ MediaRouter2Stub stub;
synchronized (sRouterLock) {
- client = mClient;
+ stub = mStub;
}
- if (client != null) {
+ if (stub != null) {
try {
- mMediaRouterService.transferToRoute(client, getId(), route);
+ mMediaRouterService.transferToRouteWithRouter2(stub, getId(), route);
} catch (RemoteException ex) {
Log.e(TAG, "Unable to transfer to route for session.", ex);
}
@@ -1072,13 +1075,13 @@
return;
}
}
- Client2 client;
+ MediaRouter2Stub stub;
synchronized (sRouterLock) {
- client = mClient;
+ stub = mStub;
}
- if (client != null) {
+ if (stub != null) {
try {
- mMediaRouterService.setSessionVolume2(client, getId(), volume);
+ mMediaRouterService.setSessionVolumeWithRouter2(stub, getId(), volume);
} catch (RemoteException ex) {
Log.e(TAG, "setVolume: Failed to deliver request.", ex);
}
@@ -1100,20 +1103,20 @@
mIsReleased = true;
}
- Client2 client;
+ MediaRouter2Stub stub;
boolean removed;
synchronized (sRouterLock) {
removed = mRoutingControllers.remove(getId(), this);
- client = mClient;
+ stub = mStub;
}
if (removed) {
mHandler.post(() -> notifyControllerReleased(RoutingController.this));
}
- if (client != null) {
+ if (stub != null) {
try {
- mMediaRouterService.releaseSession(client, getId());
+ mMediaRouterService.releaseSessionWithRouter2(stub, getId());
} catch (RemoteException ex) {
Log.e(TAG, "Unable to notify of controller release", ex);
}
@@ -1269,7 +1272,7 @@
}
}
- class Client2 extends IMediaRouter2Client.Stub {
+ class MediaRouter2Stub extends IMediaRouter2.Stub {
@Override
public void notifyRestoreRoute() throws RemoteException {}
diff --git a/media/java/android/media/MediaRouter2Manager.java b/media/java/android/media/MediaRouter2Manager.java
index 4801d44..8a08d14 100644
--- a/media/java/android/media/MediaRouter2Manager.java
+++ b/media/java/android/media/MediaRouter2Manager.java
@@ -293,7 +293,7 @@
if (client != null) {
try {
int requestId = mNextRequestId.getAndIncrement();
- mMediaRouterService.requestCreateClientSession(
+ mMediaRouterService.requestCreateSessionWithManager(
client, packageName, route, requestId);
//TODO: release the previous session?
} catch (RemoteException ex) {
@@ -337,7 +337,7 @@
}
if (client != null) {
try {
- mMediaRouterService.setRouteVolume2Manager(client, route, volume);
+ mMediaRouterService.setRouteVolumeWithManager(client, route, volume);
} catch (RemoteException ex) {
Log.e(TAG, "Unable to send control request.", ex);
}
@@ -368,7 +368,7 @@
}
if (client != null) {
try {
- mMediaRouterService.setSessionVolume2Manager(
+ mMediaRouterService.setSessionVolumeWithManager(
client, sessionInfo.getId(), volume);
} catch (RemoteException ex) {
Log.e(TAG, "Unable to send control request.", ex);
@@ -589,7 +589,7 @@
}
if (client != null) {
try {
- mMediaRouterService.selectClientRoute(mClient, getSessionId(), route);
+ mMediaRouterService.selectRouteWithManager(mClient, getSessionId(), route);
} catch (RemoteException ex) {
Log.e(TAG, "Unable to select route for session.", ex);
}
@@ -631,7 +631,7 @@
}
if (client != null) {
try {
- mMediaRouterService.deselectClientRoute(mClient, getSessionId(), route);
+ mMediaRouterService.deselectRouteWithManager(mClient, getSessionId(), route);
} catch (RemoteException ex) {
Log.e(TAG, "Unable to remove route from session.", ex);
}
@@ -674,7 +674,7 @@
}
if (client != null) {
try {
- mMediaRouterService.transferToClientRoute(mClient, getSessionId(), route);
+ mMediaRouterService.transferToRouteWithManager(mClient, getSessionId(), route);
} catch (RemoteException ex) {
Log.e(TAG, "Unable to transfer to route for session.", ex);
}
@@ -692,7 +692,7 @@
}
if (client != null) {
try {
- mMediaRouterService.releaseClientSession(mClient, getSessionId());
+ mMediaRouterService.releaseSessionWithManager(mClient, getSessionId());
} catch (RemoteException ex) {
Log.e(TAG, "Unable to notify of controller release", ex);
}
diff --git a/services/core/java/com/android/server/media/MediaRoute2Provider.java b/services/core/java/com/android/server/media/MediaRoute2Provider.java
index 477122c..9b1824f 100644
--- a/services/core/java/com/android/server/media/MediaRoute2Provider.java
+++ b/services/core/java/com/android/server/media/MediaRoute2Provider.java
@@ -47,7 +47,7 @@
mUniqueId = componentName.flattenToShortString();
}
- public void setCallback(MediaRoute2ProviderProxy.Callback callback) {
+ public void setCallback(MediaRoute2ProviderServiceProxy.Callback callback) {
mCallback = callback;
}
diff --git a/services/core/java/com/android/server/media/MediaRoute2ProviderProxy.java b/services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java
similarity index 88%
rename from services/core/java/com/android/server/media/MediaRoute2ProviderProxy.java
rename to services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java
index 252855e..60934e0 100644
--- a/services/core/java/com/android/server/media/MediaRoute2ProviderProxy.java
+++ b/services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java
@@ -21,8 +21,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.media.IMediaRoute2Provider;
-import android.media.IMediaRoute2ProviderClient;
+import android.media.IMediaRoute2ProviderService;
+import android.media.IMediaRoute2ProviderServiceCallback;
import android.media.MediaRoute2ProviderInfo;
import android.media.MediaRoute2ProviderService;
import android.media.RouteDiscoveryPreference;
@@ -31,6 +31,7 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder.DeathRecipient;
+import android.os.Looper;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
@@ -41,11 +42,12 @@
import java.util.Objects;
/**
- * Maintains a connection to a particular media route provider service.
+ * Maintains a connection to a particular {@link MediaRoute2ProviderService}.
*/
// TODO: Need to revisit the bind/unbind/connect/disconnect logic in this class.
-final class MediaRoute2ProviderProxy extends MediaRoute2Provider implements ServiceConnection {
- private static final String TAG = "MR2ProviderProxy";
+final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider
+ implements ServiceConnection {
+ private static final String TAG = "MR2ProviderSvcProxy";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private final Context mContext;
@@ -58,12 +60,12 @@
private Connection mActiveConnection;
private boolean mConnectionReady;
- MediaRoute2ProviderProxy(@NonNull Context context, @NonNull ComponentName componentName,
+ MediaRoute2ProviderServiceProxy(@NonNull Context context, @NonNull ComponentName componentName,
int userId) {
super(componentName);
mContext = Objects.requireNonNull(context, "Context must not be null.");
mUserId = userId;
- mHandler = new Handler();
+ mHandler = new Handler(Looper.myLooper());
}
public void dump(PrintWriter pw, String prefix) {
@@ -79,8 +81,7 @@
public void requestCreateSession(String packageName, String routeId, long requestId,
Bundle sessionHints) {
if (mConnectionReady) {
- mActiveConnection.requestCreateSession(
- packageName, routeId, requestId, sessionHints);
+ mActiveConnection.requestCreateSession(packageName, routeId, requestId, sessionHints);
updateBinding();
}
}
@@ -229,10 +230,10 @@
if (mBound) {
disconnect();
-
- IMediaRoute2Provider provider = IMediaRoute2Provider.Stub.asInterface(service);
- if (provider != null) {
- Connection connection = new Connection(provider);
+ IMediaRoute2ProviderService serviceBinder =
+ IMediaRoute2ProviderService.Stub.asInterface(service);
+ if (serviceBinder != null) {
+ Connection connection = new Connection(serviceBinder);
if (connection.register()) {
mActiveConnection = connection;
} else {
@@ -241,7 +242,7 @@
}
}
} else {
- Slog.e(TAG, this + ": Service returned invalid remote display provider binder");
+ Slog.e(TAG, this + ": Service returned invalid binder");
}
}
}
@@ -426,18 +427,18 @@
}
private final class Connection implements DeathRecipient {
- private final IMediaRoute2Provider mProvider;
- private final ProviderClient mClient;
+ private final IMediaRoute2ProviderService mService;
+ private final ServiceCallbackStub mCallbackStub;
- Connection(IMediaRoute2Provider provider) {
- mProvider = provider;
- mClient = new ProviderClient(this);
+ Connection(IMediaRoute2ProviderService serviceBinder) {
+ mService = serviceBinder;
+ mCallbackStub = new ServiceCallbackStub(this);
}
public boolean register() {
try {
- mProvider.asBinder().linkToDeath(this, 0);
- mProvider.setClient(mClient);
+ mService.asBinder().linkToDeath(this, 0);
+ mService.setCallback(mCallbackStub);
mHandler.post(() -> onConnectionReady(Connection.this));
return true;
} catch (RemoteException ex) {
@@ -447,14 +448,14 @@
}
public void dispose() {
- mProvider.asBinder().unlinkToDeath(this, 0);
- mClient.dispose();
+ mService.asBinder().unlinkToDeath(this, 0);
+ mCallbackStub.dispose();
}
public void requestCreateSession(String packageName, String routeId, long requestId,
Bundle sessionHints) {
try {
- mProvider.requestCreateSession(packageName, routeId, requestId, sessionHints);
+ mService.requestCreateSession(packageName, routeId, requestId, sessionHints);
} catch (RemoteException ex) {
Slog.e(TAG, "requestCreateSession: Failed to deliver request.");
}
@@ -462,7 +463,7 @@
public void releaseSession(String sessionId) {
try {
- mProvider.releaseSession(sessionId);
+ mService.releaseSession(sessionId);
} catch (RemoteException ex) {
Slog.e(TAG, "releaseSession: Failed to deliver request.");
}
@@ -470,7 +471,7 @@
public void updateDiscoveryPreference(RouteDiscoveryPreference discoveryPreference) {
try {
- mProvider.updateDiscoveryPreference(discoveryPreference);
+ mService.updateDiscoveryPreference(discoveryPreference);
} catch (RemoteException ex) {
Slog.e(TAG, "updateDiscoveryPreference: Failed to deliver request.");
}
@@ -478,7 +479,7 @@
public void selectRoute(String sessionId, String routeId) {
try {
- mProvider.selectRoute(sessionId, routeId);
+ mService.selectRoute(sessionId, routeId);
} catch (RemoteException ex) {
Slog.e(TAG, "selectRoute: Failed to deliver request.", ex);
}
@@ -486,7 +487,7 @@
public void deselectRoute(String sessionId, String routeId) {
try {
- mProvider.deselectRoute(sessionId, routeId);
+ mService.deselectRoute(sessionId, routeId);
} catch (RemoteException ex) {
Slog.e(TAG, "deselectRoute: Failed to deliver request.", ex);
}
@@ -494,7 +495,7 @@
public void transferToRoute(String sessionId, String routeId) {
try {
- mProvider.transferToRoute(sessionId, routeId);
+ mService.transferToRoute(sessionId, routeId);
} catch (RemoteException ex) {
Slog.e(TAG, "transferToRoute: Failed to deliver request.", ex);
}
@@ -502,7 +503,7 @@
public void setRouteVolume(String routeId, int volume) {
try {
- mProvider.setRouteVolume(routeId, volume);
+ mService.setRouteVolume(routeId, volume);
} catch (RemoteException ex) {
Slog.e(TAG, "setRouteVolume: Failed to deliver request.", ex);
}
@@ -510,7 +511,7 @@
public void setSessionVolume(String sessionId, int volume) {
try {
- mProvider.setSessionVolume(sessionId, volume);
+ mService.setSessionVolume(sessionId, volume);
} catch (RemoteException ex) {
Slog.e(TAG, "setSessionVolume: Failed to deliver request.", ex);
}
@@ -542,10 +543,11 @@
}
}
- private static final class ProviderClient extends IMediaRoute2ProviderClient.Stub {
+ private static final class ServiceCallbackStub extends
+ IMediaRoute2ProviderServiceCallback.Stub {
private final WeakReference<Connection> mConnectionRef;
- ProviderClient(Connection connection) {
+ ServiceCallbackStub(Connection connection) {
mConnectionRef = new WeakReference<>(connection);
}
diff --git a/services/core/java/com/android/server/media/MediaRoute2ProviderWatcher.java b/services/core/java/com/android/server/media/MediaRoute2ProviderWatcher.java
index c95119d..efb9515 100644
--- a/services/core/java/com/android/server/media/MediaRoute2ProviderWatcher.java
+++ b/services/core/java/com/android/server/media/MediaRoute2ProviderWatcher.java
@@ -47,7 +47,7 @@
private final int mUserId;
private final PackageManager mPackageManager;
- private final ArrayList<MediaRoute2ProviderProxy> mProviders = new ArrayList<>();
+ private final ArrayList<MediaRoute2ProviderServiceProxy> mProxies = new ArrayList<>();
private boolean mRunning;
MediaRoute2ProviderWatcher(Context context,
@@ -63,7 +63,7 @@
pw.println(prefix + "Watcher");
pw.println(prefix + " mUserId=" + mUserId);
pw.println(prefix + " mRunning=" + mRunning);
- pw.println(prefix + " mProviders.size()=" + mProviders.size());
+ pw.println(prefix + " mProxies.size()=" + mProxies.size());
}
public void start() {
@@ -94,8 +94,8 @@
mHandler.removeCallbacks(mScanPackagesRunnable);
// Stop all providers.
- for (int i = mProviders.size() - 1; i >= 0; i--) {
- mProviders.get(i).stop();
+ for (int i = mProxies.size() - 1; i >= 0; i--) {
+ mProxies.get(i).stop();
}
}
}
@@ -115,38 +115,38 @@
if (serviceInfo != null) {
int sourceIndex = findProvider(serviceInfo.packageName, serviceInfo.name);
if (sourceIndex < 0) {
- MediaRoute2ProviderProxy provider =
- new MediaRoute2ProviderProxy(mContext,
+ MediaRoute2ProviderServiceProxy proxy =
+ new MediaRoute2ProviderServiceProxy(mContext,
new ComponentName(serviceInfo.packageName, serviceInfo.name),
mUserId);
- provider.start();
- mProviders.add(targetIndex++, provider);
- mCallback.onAddProvider(provider);
+ proxy.start();
+ mProxies.add(targetIndex++, proxy);
+ mCallback.onAddProviderService(proxy);
} else if (sourceIndex >= targetIndex) {
- MediaRoute2ProviderProxy provider = mProviders.get(sourceIndex);
- provider.start(); // restart the provider if needed
- provider.rebindIfDisconnected();
- Collections.swap(mProviders, sourceIndex, targetIndex++);
+ MediaRoute2ProviderServiceProxy proxy = mProxies.get(sourceIndex);
+ proxy.start(); // restart the proxy if needed
+ proxy.rebindIfDisconnected();
+ Collections.swap(mProxies, sourceIndex, targetIndex++);
}
}
}
// Remove providers for missing services.
- if (targetIndex < mProviders.size()) {
- for (int i = mProviders.size() - 1; i >= targetIndex; i--) {
- MediaRoute2ProviderProxy provider = mProviders.get(i);
- mCallback.onRemoveProvider(provider);
- mProviders.remove(provider);
- provider.stop();
+ if (targetIndex < mProxies.size()) {
+ for (int i = mProxies.size() - 1; i >= targetIndex; i--) {
+ MediaRoute2ProviderServiceProxy proxy = mProxies.get(i);
+ mCallback.onRemoveProviderService(proxy);
+ mProxies.remove(proxy);
+ proxy.stop();
}
}
}
private int findProvider(String packageName, String className) {
- int count = mProviders.size();
+ int count = mProxies.size();
for (int i = 0; i < count; i++) {
- MediaRoute2ProviderProxy provider = mProviders.get(i);
- if (provider.hasComponentName(packageName, className)) {
+ MediaRoute2ProviderServiceProxy proxy = mProxies.get(i);
+ if (proxy.hasComponentName(packageName, className)) {
return i;
}
}
@@ -171,7 +171,7 @@
};
public interface Callback {
- void onAddProvider(MediaRoute2ProviderProxy provider);
- void onRemoveProvider(MediaRoute2ProviderProxy provider);
+ void onAddProviderService(MediaRoute2ProviderServiceProxy proxy);
+ void onRemoveProviderService(MediaRoute2ProviderServiceProxy proxy);
}
}
diff --git a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java
index c5320b6..a268720 100644
--- a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java
+++ b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java
@@ -26,7 +26,7 @@
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.PackageManager;
-import android.media.IMediaRouter2Client;
+import android.media.IMediaRouter2;
import android.media.IMediaRouter2Manager;
import android.media.MediaRoute2Info;
import android.media.MediaRoute2ProviderInfo;
@@ -72,12 +72,12 @@
private final Context mContext;
private final Object mLock = new Object();
- final AtomicInteger mNextClientId = new AtomicInteger(1);
+ final AtomicInteger mNextRouterOrManagerId = new AtomicInteger(1);
@GuardedBy("mLock")
private final SparseArray<UserRecord> mUserRecords = new SparseArray<>();
@GuardedBy("mLock")
- private final ArrayMap<IBinder, Client2Record> mAllClientRecords = new ArrayMap<>();
+ private final ArrayMap<IBinder, RouterRecord> mAllRouterRecords = new ArrayMap<>();
@GuardedBy("mLock")
private final ArrayMap<IBinder, ManagerRecord> mAllManagerRecords = new ArrayMap<>();
@GuardedBy("mLock")
@@ -135,9 +135,9 @@
}
}
- public void registerClient(@NonNull IMediaRouter2Client client,
+ public void registerRouter2(@NonNull IMediaRouter2 router,
@NonNull String packageName) {
- Objects.requireNonNull(client, "client must not be null");
+ Objects.requireNonNull(router, "router must not be null");
final int uid = Binder.getCallingUid();
final int pid = Binder.getCallingPid();
@@ -148,20 +148,20 @@
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- registerClient2Locked(client, uid, pid, packageName, userId, trusted);
+ registerRouter2Locked(router, uid, pid, packageName, userId, trusted);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
- public void unregisterClient(@NonNull IMediaRouter2Client client) {
- Objects.requireNonNull(client, "client must not be null");
+ public void unregisterRouter2(@NonNull IMediaRouter2 router) {
+ Objects.requireNonNull(router, "router must not be null");
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- unregisterClient2Locked(client, false);
+ unregisterRouter2Locked(router, false);
}
} finally {
Binder.restoreCallingIdentity(token);
@@ -201,24 +201,24 @@
}
}
- public void requestCreateSession(IMediaRouter2Client client, MediaRoute2Info route,
+ public void requestCreateSessionWithRouter2(IMediaRouter2 router, MediaRoute2Info route,
int requestId, Bundle sessionHints) {
- Objects.requireNonNull(client, "client must not be null");
+ Objects.requireNonNull(router, "router must not be null");
Objects.requireNonNull(route, "route must not be null");
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- requestCreateSessionLocked(client, route, requestId, sessionHints);
+ requestCreateSessionLocked(router, route, requestId, sessionHints);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
- public void selectRoute(IMediaRouter2Client client, String uniqueSessionId,
+ public void selectRouteWithRouter2(IMediaRouter2 router, String uniqueSessionId,
MediaRoute2Info route) {
- Objects.requireNonNull(client, "client must not be null");
+ Objects.requireNonNull(router, "router must not be null");
Objects.requireNonNull(route, "route must not be null");
if (TextUtils.isEmpty(uniqueSessionId)) {
throw new IllegalArgumentException("uniqueSessionId must not be empty");
@@ -227,7 +227,7 @@
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- selectRouteLocked(client, uniqueSessionId, route);
+ selectRouteLocked(router, uniqueSessionId, route);
}
} finally {
Binder.restoreCallingIdentity(token);
@@ -235,9 +235,9 @@
}
- public void deselectRoute(IMediaRouter2Client client, String uniqueSessionId,
+ public void deselectRouteWithRouter2(IMediaRouter2 router, String uniqueSessionId,
MediaRoute2Info route) {
- Objects.requireNonNull(client, "client must not be null");
+ Objects.requireNonNull(router, "router must not be null");
Objects.requireNonNull(route, "route must not be null");
if (TextUtils.isEmpty(uniqueSessionId)) {
throw new IllegalArgumentException("uniqueSessionId must not be empty");
@@ -246,16 +246,16 @@
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- deselectRouteLocked(client, uniqueSessionId, route);
+ deselectRouteLocked(router, uniqueSessionId, route);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
- public void transferToRoute(IMediaRouter2Client client, String uniqueSessionId,
+ public void transferToRouteWithRouter2(IMediaRouter2 router, String uniqueSessionId,
MediaRoute2Info route) {
- Objects.requireNonNull(client, "client must not be null");
+ Objects.requireNonNull(router, "router must not be null");
Objects.requireNonNull(route, "route must not be null");
if (TextUtils.isEmpty(uniqueSessionId)) {
throw new IllegalArgumentException("uniqueSessionId must not be empty");
@@ -264,15 +264,15 @@
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- transferToRouteLocked(client, uniqueSessionId, route);
+ transferToRouteWithRouter2Locked(router, uniqueSessionId, route);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
- public void releaseSession(IMediaRouter2Client client, String uniqueSessionId) {
- Objects.requireNonNull(client, "client must not be null");
+ public void releaseSessionWithRouter2(IMediaRouter2 router, String uniqueSessionId) {
+ Objects.requireNonNull(router, "router must not be null");
if (TextUtils.isEmpty(uniqueSessionId)) {
throw new IllegalArgumentException("uniqueSessionId must not be empty");
}
@@ -280,59 +280,59 @@
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- releaseSessionLocked(client, uniqueSessionId);
+ releaseSessionLocked(router, uniqueSessionId);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
- public void setDiscoveryRequest2(@NonNull IMediaRouter2Client client,
- @NonNull RouteDiscoveryPreference preference) {
- Objects.requireNonNull(client, "client must not be null");
+ public void setDiscoveryRequestWithRouter2(IMediaRouter2 router,
+ RouteDiscoveryPreference preference) {
+ Objects.requireNonNull(router, "router must not be null");
Objects.requireNonNull(preference, "preference must not be null");
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- Client2Record clientRecord = mAllClientRecords.get(client.asBinder());
- setDiscoveryRequestLocked(clientRecord, preference);
+ RouterRecord routerRecord = mAllRouterRecords.get(router.asBinder());
+ setDiscoveryRequestLocked(routerRecord, preference);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
- public void setRouteVolume2(IMediaRouter2Client client,
+ public void setRouteVolumeWithRouter2(IMediaRouter2 router,
MediaRoute2Info route, int volume) {
- Objects.requireNonNull(client, "client must not be null");
+ Objects.requireNonNull(router, "router must not be null");
Objects.requireNonNull(route, "route must not be null");
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- setRouteVolumeLocked(client, route, volume);
+ setRouteVolumeLocked(router, route, volume);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
- public void setSessionVolume2(IMediaRouter2Client client, String sessionId, int volume) {
- Objects.requireNonNull(client, "client must not be null");
+ public void setSessionVolumeWithRouter2(IMediaRouter2 router, String sessionId, int volume) {
+ Objects.requireNonNull(router, "router must not be null");
Objects.requireNonNull(sessionId, "sessionId must not be null");
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- setSessionVolumeLocked(client, sessionId, volume);
+ setSessionVolumeLocked(router, sessionId, volume);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
- public void requestCreateClientSession(IMediaRouter2Manager manager, String packageName,
+ public void requestCreateSessionWithManager(IMediaRouter2Manager manager, String packageName,
MediaRoute2Info route, int requestId) {
final long token = Binder.clearCallingIdentity();
try {
@@ -344,7 +344,7 @@
}
}
- public void setRouteVolume2Manager(IMediaRouter2Manager manager,
+ public void setRouteVolumeWithManager(IMediaRouter2Manager manager,
MediaRoute2Info route, int volume) {
Objects.requireNonNull(manager, "manager must not be null");
Objects.requireNonNull(route, "route must not be null");
@@ -359,7 +359,7 @@
}
}
- public void setSessionVolume2Manager(IMediaRouter2Manager manager,
+ public void setSessionVolumeWithManager(IMediaRouter2Manager manager,
String sessionId, int volume) {
Objects.requireNonNull(manager, "manager must not be null");
Objects.requireNonNull(sessionId, "sessionId must not be null");
@@ -386,47 +386,47 @@
}
}
- public void selectClientRoute(IMediaRouter2Manager manager, String sessionId,
+ public void selectRouteWithManager(IMediaRouter2Manager manager, String sessionId,
MediaRoute2Info route) {
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- selectClientRouteLocked(manager, sessionId, route);
+ selectRouteWithManagerLocked(manager, sessionId, route);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
- public void deselectClientRoute(IMediaRouter2Manager manager, String sessionId,
+ public void deselectRouteWithManager(IMediaRouter2Manager manager, String sessionId,
MediaRoute2Info route) {
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- deselectClientRouteLocked(manager, sessionId, route);
+ deselectRouteWithManagerLocked(manager, sessionId, route);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
- public void transferToClientRoute(IMediaRouter2Manager manager, String sessionId,
+ public void transferToRouteWithManager(IMediaRouter2Manager manager, String sessionId,
MediaRoute2Info route) {
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- transferClientRouteLocked(manager, sessionId, route);
+ transferToRouteWithManagerLocked(manager, sessionId, route);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
- public void releaseClientSession(IMediaRouter2Manager manager, String sessionId) {
+ public void releaseSessionWithManager(IMediaRouter2Manager manager, String sessionId) {
final long token = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- releaseClientSessionLocked(manager, sessionId);
+ releaseSessionWithManagerLocked(manager, sessionId);
}
} finally {
Binder.restoreCallingIdentity(token);
@@ -457,9 +457,9 @@
}
}
- void clientDied(Client2Record clientRecord) {
+ void routerDied(RouterRecord routerRecord) {
synchronized (mLock) {
- unregisterClient2Locked(clientRecord.mClient, true);
+ unregisterRouter2Locked(routerRecord.mRouter, true);
}
}
@@ -469,146 +469,146 @@
}
}
- private void registerClient2Locked(IMediaRouter2Client client,
+ private void registerRouter2Locked(IMediaRouter2 router,
int uid, int pid, String packageName, int userId, boolean trusted) {
- final IBinder binder = client.asBinder();
- if (mAllClientRecords.get(binder) == null) {
+ final IBinder binder = router.asBinder();
+ if (mAllRouterRecords.get(binder) == null) {
UserRecord userRecord = getOrCreateUserRecordLocked(userId);
- Client2Record clientRecord = new Client2Record(userRecord, client, uid, pid,
+ RouterRecord routerRecord = new RouterRecord(userRecord, router, uid, pid,
packageName, trusted);
try {
- binder.linkToDeath(clientRecord, 0);
+ binder.linkToDeath(routerRecord, 0);
} catch (RemoteException ex) {
- throw new RuntimeException("Media router client died prematurely.", ex);
+ throw new RuntimeException("NediaRouter2 died prematurely.", ex);
}
- userRecord.mClientRecords.add(clientRecord);
- mAllClientRecords.put(binder, clientRecord);
+ userRecord.mRouterRecords.add(routerRecord);
+ mAllRouterRecords.put(binder, routerRecord);
userRecord.mHandler.sendMessage(
- obtainMessage(UserHandler::notifyRoutesToClient, userRecord.mHandler, client));
+ obtainMessage(UserHandler::notifyRoutesToRouter, userRecord.mHandler, router));
}
}
- private void unregisterClient2Locked(IMediaRouter2Client client, boolean died) {
- Client2Record clientRecord = mAllClientRecords.remove(client.asBinder());
- if (clientRecord != null) {
- UserRecord userRecord = clientRecord.mUserRecord;
- userRecord.mClientRecords.remove(clientRecord);
+ private void unregisterRouter2Locked(IMediaRouter2 router, boolean died) {
+ RouterRecord routerRecord = mAllRouterRecords.remove(router.asBinder());
+ if (routerRecord != null) {
+ UserRecord userRecord = routerRecord.mUserRecord;
+ userRecord.mRouterRecords.remove(routerRecord);
//TODO: update discovery request
- clientRecord.dispose();
- disposeUserIfNeededLocked(userRecord); // since client removed from user
+ routerRecord.dispose();
+ disposeUserIfNeededLocked(userRecord); // since router removed from user
}
}
- private void requestCreateSessionLocked(@NonNull IMediaRouter2Client client,
+ private void requestCreateSessionLocked(@NonNull IMediaRouter2 router,
@NonNull MediaRoute2Info route, long requestId, @Nullable Bundle sessionHints) {
- final IBinder binder = client.asBinder();
- final Client2Record clientRecord = mAllClientRecords.get(binder);
+ final IBinder binder = router.asBinder();
+ final RouterRecord routerRecord = mAllRouterRecords.get(binder);
- // client id is not assigned yet
- if (toClientId(requestId) == 0) {
- requestId = toUniqueRequestId(clientRecord.mClientId, toClientRequestId(requestId));
+ // router id is not assigned yet
+ if (toRouterOrManagerId(requestId) == 0) {
+ requestId = toUniqueRequestId(routerRecord.mRouterId, toOriginalRequestId(requestId));
}
- if (clientRecord != null) {
- clientRecord.mUserRecord.mHandler.sendMessage(
+ if (routerRecord != null) {
+ routerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::requestCreateSessionOnHandler,
- clientRecord.mUserRecord.mHandler,
- clientRecord, route, requestId, sessionHints));
+ routerRecord.mUserRecord.mHandler,
+ routerRecord, route, requestId, sessionHints));
}
}
- private void selectRouteLocked(@NonNull IMediaRouter2Client client, String uniqueSessionId,
+ private void selectRouteLocked(@NonNull IMediaRouter2 router, String uniqueSessionId,
@NonNull MediaRoute2Info route) {
- final IBinder binder = client.asBinder();
- final Client2Record clientRecord = mAllClientRecords.get(binder);
+ final IBinder binder = router.asBinder();
+ final RouterRecord routerRecord = mAllRouterRecords.get(binder);
- if (clientRecord != null) {
- clientRecord.mUserRecord.mHandler.sendMessage(
+ if (routerRecord != null) {
+ routerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::selectRouteOnHandler,
- clientRecord.mUserRecord.mHandler,
- clientRecord, uniqueSessionId, route));
+ routerRecord.mUserRecord.mHandler,
+ routerRecord, uniqueSessionId, route));
}
}
- private void deselectRouteLocked(@NonNull IMediaRouter2Client client, String uniqueSessionId,
+ private void deselectRouteLocked(@NonNull IMediaRouter2 router, String uniqueSessionId,
@NonNull MediaRoute2Info route) {
- final IBinder binder = client.asBinder();
- final Client2Record clientRecord = mAllClientRecords.get(binder);
+ final IBinder binder = router.asBinder();
+ final RouterRecord routerRecord = mAllRouterRecords.get(binder);
- if (clientRecord != null) {
- clientRecord.mUserRecord.mHandler.sendMessage(
+ if (routerRecord != null) {
+ routerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::deselectRouteOnHandler,
- clientRecord.mUserRecord.mHandler,
- clientRecord, uniqueSessionId, route));
+ routerRecord.mUserRecord.mHandler,
+ routerRecord, uniqueSessionId, route));
}
}
- private void transferToRouteLocked(@NonNull IMediaRouter2Client client, String uniqueSessionId,
- @NonNull MediaRoute2Info route) {
- final IBinder binder = client.asBinder();
- final Client2Record clientRecord = mAllClientRecords.get(binder);
+ private void transferToRouteWithRouter2Locked(@NonNull IMediaRouter2 router,
+ String uniqueSessionId, @NonNull MediaRoute2Info route) {
+ final IBinder binder = router.asBinder();
+ final RouterRecord routerRecord = mAllRouterRecords.get(binder);
- if (clientRecord != null) {
- clientRecord.mUserRecord.mHandler.sendMessage(
+ if (routerRecord != null) {
+ routerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::transferToRouteOnHandler,
- clientRecord.mUserRecord.mHandler,
- clientRecord, uniqueSessionId, route));
+ routerRecord.mUserRecord.mHandler,
+ routerRecord, uniqueSessionId, route));
}
}
- private void releaseSessionLocked(@NonNull IMediaRouter2Client client, String uniqueSessionId) {
- final IBinder binder = client.asBinder();
- final Client2Record clientRecord = mAllClientRecords.get(binder);
+ private void releaseSessionLocked(@NonNull IMediaRouter2 router, String uniqueSessionId) {
+ final IBinder binder = router.asBinder();
+ final RouterRecord routerRecord = mAllRouterRecords.get(binder);
- if (clientRecord != null) {
- clientRecord.mUserRecord.mHandler.sendMessage(
+ if (routerRecord != null) {
+ routerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::releaseSessionOnHandler,
- clientRecord.mUserRecord.mHandler,
- clientRecord, uniqueSessionId));
+ routerRecord.mUserRecord.mHandler,
+ routerRecord, uniqueSessionId));
}
}
- private void setDiscoveryRequestLocked(Client2Record clientRecord,
+ private void setDiscoveryRequestLocked(RouterRecord routerRecord,
RouteDiscoveryPreference discoveryRequest) {
- if (clientRecord != null) {
- if (clientRecord.mDiscoveryPreference.equals(discoveryRequest)) {
+ if (routerRecord != null) {
+ if (routerRecord.mDiscoveryPreference.equals(discoveryRequest)) {
return;
}
- clientRecord.mDiscoveryPreference = discoveryRequest;
- clientRecord.mUserRecord.mHandler.sendMessage(
- obtainMessage(UserHandler::updateClientUsage,
- clientRecord.mUserRecord.mHandler, clientRecord));
- clientRecord.mUserRecord.mHandler.sendMessage(
+ routerRecord.mDiscoveryPreference = discoveryRequest;
+ routerRecord.mUserRecord.mHandler.sendMessage(
+ obtainMessage(UserHandler::notifyPreferredFeaturesChangedToManagers,
+ routerRecord.mUserRecord.mHandler, routerRecord));
+ routerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::updateDiscoveryPreference,
- clientRecord.mUserRecord.mHandler));
+ routerRecord.mUserRecord.mHandler));
}
}
- private void setRouteVolumeLocked(IMediaRouter2Client client, MediaRoute2Info route,
+ private void setRouteVolumeLocked(IMediaRouter2 router, MediaRoute2Info route,
int volume) {
- final IBinder binder = client.asBinder();
- Client2Record clientRecord = mAllClientRecords.get(binder);
+ final IBinder binder = router.asBinder();
+ RouterRecord routerRecord = mAllRouterRecords.get(binder);
- if (clientRecord != null) {
- clientRecord.mUserRecord.mHandler.sendMessage(
+ if (routerRecord != null) {
+ routerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::setRouteVolume,
- clientRecord.mUserRecord.mHandler, route, volume));
+ routerRecord.mUserRecord.mHandler, route, volume));
}
}
- private void setSessionVolumeLocked(IMediaRouter2Client client, String sessionId,
+ private void setSessionVolumeLocked(IMediaRouter2 router, String sessionId,
int volume) {
- final IBinder binder = client.asBinder();
- Client2Record clientRecord = mAllClientRecords.get(binder);
+ final IBinder binder = router.asBinder();
+ RouterRecord routerRecord = mAllRouterRecords.get(binder);
- if (clientRecord != null) {
- clientRecord.mUserRecord.mHandler.sendMessage(
+ if (routerRecord != null) {
+ routerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::setSessionVolume,
- clientRecord.mUserRecord.mHandler, sessionId, volume));
+ routerRecord.mUserRecord.mHandler, sessionId, volume));
}
}
@@ -632,15 +632,15 @@
obtainMessage(UserHandler::notifyRoutesToManager,
userRecord.mHandler, manager));
- for (Client2Record clientRecord : userRecord.mClientRecords) {
- // TODO: Do not use updateClientUsage since it updates all managers.
- // Instead, Notify only to the manager that is currently being registered.
+ for (RouterRecord routerRecord : userRecord.mRouterRecords) {
+ // TODO: Do not use notifyPreferredFeaturesChangedToManagers since it updates all
+ // managers. Instead, Notify only to the manager that is currently being registered.
- // TODO: UserRecord <-> ClientRecord, why do they reference each other?
- // How about removing mUserRecord from clientRecord?
- clientRecord.mUserRecord.mHandler.sendMessage(
- obtainMessage(UserHandler::updateClientUsage,
- clientRecord.mUserRecord.mHandler, clientRecord));
+ // TODO: UserRecord <-> routerRecord, why do they reference each other?
+ // How about removing mUserRecord from routerRecord?
+ routerRecord.mUserRecord.mHandler.sendMessage(
+ obtainMessage(UserHandler::notifyPreferredFeaturesChangedToManagers,
+ routerRecord.mUserRecord.mHandler, routerRecord));
}
}
}
@@ -659,15 +659,15 @@
String packageName, MediaRoute2Info route, int requestId) {
ManagerRecord managerRecord = mAllManagerRecords.get(manager.asBinder());
if (managerRecord != null) {
- Client2Record clientRecord =
- managerRecord.mUserRecord.findClientRecordLocked(packageName);
- if (clientRecord == null) {
- Slog.w(TAG, "Ignoring session creation for unknown client.");
+ RouterRecord routerRecord =
+ managerRecord.mUserRecord.findRouterRecordLocked(packageName);
+ if (routerRecord == null) {
+ Slog.w(TAG, "Ignoring session creation for unknown router.");
}
- long uniqueRequestId = toUniqueRequestId(managerRecord.mClientId, requestId);
- if (clientRecord != null && managerRecord.mTrusted) {
- //TODO: Use client's OnCreateSessionListener to send proper session hints.
- requestCreateSessionLocked(clientRecord.mClient, route,
+ long uniqueRequestId = toUniqueRequestId(managerRecord.mManagerId, requestId);
+ if (routerRecord != null && managerRecord.mTrusted) {
+ //TODO: Use MediaRouter2's OnCreateSessionListener to send proper session hints.
+ requestCreateSessionLocked(routerRecord.mRouter, route,
uniqueRequestId, null /* sessionHints */);
}
}
@@ -726,43 +726,43 @@
return userRecord;
}
- private void selectClientRouteLocked(IMediaRouter2Manager manager, String sessionId,
+ private void selectRouteWithManagerLocked(IMediaRouter2Manager manager, String sessionId,
MediaRoute2Info route) {
final IBinder binder = manager.asBinder();
ManagerRecord managerRecord = mAllManagerRecords.get(binder);
if (managerRecord == null) {
- Slog.w(TAG, "selectClientRouteLocked: Ignoring unknown manager.");
+ Slog.w(TAG, "selectRouteWithManagerLocked: Ignoring unknown manager.");
return;
}
- Client2Record clientRecord = managerRecord.mUserRecord.mHandler
- .findClientforSessionLocked(sessionId);
+ RouterRecord routerRecord = managerRecord.mUserRecord.mHandler
+ .findRouterforSessionLocked(sessionId);
managerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::selectRouteOnHandler,
managerRecord.mUserRecord.mHandler,
- clientRecord, sessionId, route));
+ routerRecord, sessionId, route));
}
- private void deselectClientRouteLocked(IMediaRouter2Manager manager, String sessionId,
+ private void deselectRouteWithManagerLocked(IMediaRouter2Manager manager, String sessionId,
MediaRoute2Info route) {
final IBinder binder = manager.asBinder();
ManagerRecord managerRecord = mAllManagerRecords.get(binder);
if (managerRecord == null) {
- Slog.w(TAG, "deselectClientRouteLocked: Ignoring unknown manager.");
+ Slog.w(TAG, "deselectRouteWithManagerLocked: Ignoring unknown manager.");
return;
}
- Client2Record clientRecord = managerRecord.mUserRecord.mHandler
- .findClientforSessionLocked(sessionId);
+ RouterRecord routerRecord = managerRecord.mUserRecord.mHandler
+ .findRouterforSessionLocked(sessionId);
managerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::deselectRouteOnHandler,
managerRecord.mUserRecord.mHandler,
- clientRecord, sessionId, route));
+ routerRecord, sessionId, route));
}
- private void transferClientRouteLocked(IMediaRouter2Manager manager, String sessionId,
+ private void transferToRouteWithManagerLocked(IMediaRouter2Manager manager, String sessionId,
MediaRoute2Info route) {
final IBinder binder = manager.asBinder();
ManagerRecord managerRecord = mAllManagerRecords.get(binder);
@@ -771,31 +771,31 @@
Slog.w(TAG, "transferClientRouteLocked: Ignoring unknown manager.");
return;
}
- Client2Record clientRecord = managerRecord.mUserRecord.mHandler
- .findClientforSessionLocked(sessionId);
+ RouterRecord routerRecord = managerRecord.mUserRecord.mHandler
+ .findRouterforSessionLocked(sessionId);
managerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::transferToRouteOnHandler,
managerRecord.mUserRecord.mHandler,
- clientRecord, sessionId, route));
+ routerRecord, sessionId, route));
}
- private void releaseClientSessionLocked(IMediaRouter2Manager manager, String sessionId) {
+ private void releaseSessionWithManagerLocked(IMediaRouter2Manager manager, String sessionId) {
final IBinder binder = manager.asBinder();
ManagerRecord managerRecord = mAllManagerRecords.get(binder);
if (managerRecord == null) {
- Slog.w(TAG, "releaseClientSessionLocked: Ignoring unknown manager.");
+ Slog.w(TAG, "releaseSessionWithManagerLocked: Ignoring unknown manager.");
return;
}
- Client2Record clientRecord = managerRecord.mUserRecord.mHandler
- .findClientforSessionLocked(sessionId);
+ RouterRecord routerRecord = managerRecord.mUserRecord.mHandler
+ .findRouterforSessionLocked(sessionId);
managerRecord.mUserRecord.mHandler.sendMessage(
obtainMessage(UserHandler::releaseSessionOnHandler,
managerRecord.mUserRecord.mHandler,
- clientRecord, sessionId));
+ routerRecord, sessionId));
}
private void disposeUserIfNeededLocked(UserRecord userRecord) {
@@ -804,7 +804,7 @@
// then leave it alone since we might be connected to a route or want to query
// the same route information again soon.
if (userRecord.mUserId != mCurrentUserId
- && userRecord.mClientRecords.isEmpty()
+ && userRecord.mRouterRecords.isEmpty()
&& userRecord.mManagerRecords.isEmpty()) {
if (DEBUG) {
Slog.d(TAG, userRecord + ": Disposed");
@@ -814,22 +814,22 @@
}
}
- static long toUniqueRequestId(int clientId, int requestId) {
- return ((long) clientId << 32) | requestId;
+ static long toUniqueRequestId(int routerOrManagerId, int originalRequestId) {
+ return ((long) routerOrManagerId << 32) | originalRequestId;
}
- static int toClientId(long uniqueRequestId) {
+ static int toRouterOrManagerId(long uniqueRequestId) {
return (int) (uniqueRequestId >> 32);
}
- static int toClientRequestId(long uniqueRequestId) {
+ static int toOriginalRequestId(long uniqueRequestId) {
return (int) uniqueRequestId;
}
final class UserRecord {
public final int mUserId;
//TODO: make records private for thread-safety
- final ArrayList<Client2Record> mClientRecords = new ArrayList<>();
+ final ArrayList<RouterRecord> mRouterRecords = new ArrayList<>();
final ArrayList<ManagerRecord> mManagerRecords = new ArrayList<>();
RouteDiscoveryPreference mCompositeDiscoveryPreference = RouteDiscoveryPreference.EMPTY;
final UserHandler mHandler;
@@ -839,50 +839,50 @@
mHandler = new UserHandler(MediaRouter2ServiceImpl.this, this);
}
- // TODO: This assumes that only one client exists in a package. Is it true?
- Client2Record findClientRecordLocked(String packageName) {
- for (Client2Record clientRecord : mClientRecords) {
- if (TextUtils.equals(clientRecord.mPackageName, packageName)) {
- return clientRecord;
+ // TODO: This assumes that only one router exists in a package. Is it true?
+ RouterRecord findRouterRecordLocked(String packageName) {
+ for (RouterRecord routerRecord : mRouterRecords) {
+ if (TextUtils.equals(routerRecord.mPackageName, packageName)) {
+ return routerRecord;
}
}
return null;
}
}
- final class Client2Record implements IBinder.DeathRecipient {
+ final class RouterRecord implements IBinder.DeathRecipient {
public final UserRecord mUserRecord;
public final String mPackageName;
public final List<Integer> mSelectRouteSequenceNumbers;
- public final IMediaRouter2Client mClient;
+ public final IMediaRouter2 mRouter;
public final int mUid;
public final int mPid;
public final boolean mTrusted;
- public final int mClientId;
+ public final int mRouterId;
public RouteDiscoveryPreference mDiscoveryPreference;
public MediaRoute2Info mSelectedRoute;
- Client2Record(UserRecord userRecord, IMediaRouter2Client client,
+ RouterRecord(UserRecord userRecord, IMediaRouter2 router,
int uid, int pid, String packageName, boolean trusted) {
mUserRecord = userRecord;
mPackageName = packageName;
mSelectRouteSequenceNumbers = new ArrayList<>();
mDiscoveryPreference = RouteDiscoveryPreference.EMPTY;
- mClient = client;
+ mRouter = router;
mUid = uid;
mPid = pid;
mTrusted = trusted;
- mClientId = mNextClientId.getAndIncrement();
+ mRouterId = mNextRouterOrManagerId.getAndIncrement();
}
public void dispose() {
- mClient.asBinder().unlinkToDeath(this, 0);
+ mRouter.asBinder().unlinkToDeath(this, 0);
}
@Override
public void binderDied() {
- clientDied(this);
+ routerDied(this);
}
}
@@ -893,7 +893,7 @@
public final int mPid;
public final String mPackageName;
public final boolean mTrusted;
- public final int mClientId;
+ public final int mManagerId;
ManagerRecord(UserRecord userRecord, IMediaRouter2Manager manager,
int uid, int pid, String packageName, boolean trusted) {
@@ -903,7 +903,7 @@
mPid = pid;
mPackageName = packageName;
mTrusted = trusted;
- mClientId = mNextClientId.getAndIncrement();
+ mManagerId = mNextRouterOrManagerId.getAndIncrement();
}
public void dispose() {
@@ -944,7 +944,7 @@
private final List<MediaRoute2ProviderInfo> mLastProviderInfos = new ArrayList<>();
private final CopyOnWriteArrayList<SessionCreationRequest> mSessionCreationRequests =
new CopyOnWriteArrayList<>();
- private final Map<String, Client2Record> mSessionToClientMap = new ArrayMap<>();
+ private final Map<String, RouterRecord> mSessionToRouterMap = new ArrayMap<>();
private boolean mRunning;
@@ -974,15 +974,15 @@
}
@Override
- public void onAddProvider(MediaRoute2ProviderProxy provider) {
- provider.setCallback(this);
- mMediaProviders.add(provider);
- provider.updateDiscoveryPreference(mUserRecord.mCompositeDiscoveryPreference);
+ public void onAddProviderService(MediaRoute2ProviderServiceProxy proxy) {
+ proxy.setCallback(this);
+ mMediaProviders.add(proxy);
+ proxy.updateDiscoveryPreference(mUserRecord.mCompositeDiscoveryPreference);
}
@Override
- public void onRemoveProvider(MediaRoute2ProviderProxy provider) {
- mMediaProviders.remove(provider);
+ public void onRemoveProviderService(MediaRoute2ProviderServiceProxy proxy) {
+ mMediaProviders.remove(proxy);
}
@Override
@@ -1019,8 +1019,8 @@
}
@Nullable
- public Client2Record findClientforSessionLocked(@NonNull String sessionId) {
- return mSessionToClientMap.get(sessionId);
+ public RouterRecord findRouterforSessionLocked(@NonNull String sessionId) {
+ return mSessionToRouterMap.get(sessionId);
}
//TODO: notify session info updates
@@ -1036,16 +1036,16 @@
mLastProviderInfos.add(providerInfo);
Collection<MediaRoute2Info> addedRoutes = providerInfo.getRoutes();
if (addedRoutes.size() > 0) {
- sendMessage(PooledLambda.obtainMessage(UserHandler::notifyRoutesAddedToClients,
- this, getClients(), new ArrayList<>(addedRoutes)));
+ sendMessage(PooledLambda.obtainMessage(UserHandler::notifyRoutesAddedToRouters,
+ this, getRouters(), new ArrayList<>(addedRoutes)));
}
} else if (providerInfo == null) {
mLastProviderInfos.remove(prevInfo);
Collection<MediaRoute2Info> removedRoutes = prevInfo.getRoutes();
if (removedRoutes.size() > 0) {
sendMessage(PooledLambda.obtainMessage(
- UserHandler::notifyRoutesRemovedToClients,
- this, getClients(), new ArrayList<>(removedRoutes)));
+ UserHandler::notifyRoutesRemovedToRouters,
+ this, getRouters(), new ArrayList<>(removedRoutes)));
}
} else {
mLastProviderInfos.set(providerIndex, providerInfo);
@@ -1079,18 +1079,18 @@
}
}
- List<IMediaRouter2Client> clients = getClients();
+ List<IMediaRouter2> routers = getRouters();
List<IMediaRouter2Manager> managers = getManagers();
if (addedRoutes.size() > 0) {
- notifyRoutesAddedToClients(clients, addedRoutes);
+ notifyRoutesAddedToRouters(routers, addedRoutes);
notifyRoutesAddedToManagers(managers, addedRoutes);
}
if (removedRoutes.size() > 0) {
- notifyRoutesRemovedToClients(clients, removedRoutes);
+ notifyRoutesRemovedToRouters(routers, removedRoutes);
notifyRoutesRemovedToManagers(managers, removedRoutes);
}
if (changedRoutes.size() > 0) {
- notifyRoutesChangedToClients(clients, changedRoutes);
+ notifyRoutesChangedToRouters(routers, changedRoutes);
notifyRoutesChangedToManagers(managers, changedRoutes);
}
}
@@ -1106,29 +1106,29 @@
return -1;
}
- private void requestCreateSessionOnHandler(Client2Record clientRecord,
+ private void requestCreateSessionOnHandler(RouterRecord routerRecord,
MediaRoute2Info route, long requestId, @Nullable Bundle sessionHints) {
final MediaRoute2Provider provider = findProvider(route.getProviderId());
if (provider == null) {
Slog.w(TAG, "Ignoring session creation request since no provider found for"
+ " given route=" + route);
- notifySessionCreationFailed(clientRecord, toClientRequestId(requestId));
+ notifySessionCreationFailed(routerRecord, toOriginalRequestId(requestId));
return;
}
// TODO: Apply timeout for each request (How many seconds should we wait?)
SessionCreationRequest request =
- new SessionCreationRequest(clientRecord, route, requestId);
+ new SessionCreationRequest(routerRecord, route, requestId);
mSessionCreationRequests.add(request);
- provider.requestCreateSession(clientRecord.mPackageName, route.getOriginalId(),
+ provider.requestCreateSession(routerRecord.mPackageName, route.getOriginalId(),
requestId, sessionHints);
}
- private void selectRouteOnHandler(@Nullable Client2Record clientRecord,
+ private void selectRouteOnHandler(@Nullable RouterRecord routerRecord,
String uniqueSessionId, MediaRoute2Info route) {
- if (!checkArgumentsForSessionControl(clientRecord, uniqueSessionId, route,
+ if (!checkArgumentsForSessionControl(routerRecord, uniqueSessionId, route,
"selecting")) {
return;
}
@@ -1142,9 +1142,9 @@
provider.selectRoute(getOriginalId(uniqueSessionId), route.getOriginalId());
}
- private void deselectRouteOnHandler(@Nullable Client2Record clientRecord,
+ private void deselectRouteOnHandler(@Nullable RouterRecord routerRecord,
String uniqueSessionId, MediaRoute2Info route) {
- if (!checkArgumentsForSessionControl(clientRecord, uniqueSessionId, route,
+ if (!checkArgumentsForSessionControl(routerRecord, uniqueSessionId, route,
"deselecting")) {
return;
}
@@ -1158,9 +1158,9 @@
provider.deselectRoute(getOriginalId(uniqueSessionId), route.getOriginalId());
}
- private void transferToRouteOnHandler(Client2Record clientRecord,
+ private void transferToRouteOnHandler(RouterRecord routerRecord,
String uniqueSessionId, MediaRoute2Info route) {
- if (!checkArgumentsForSessionControl(clientRecord, uniqueSessionId, route,
+ if (!checkArgumentsForSessionControl(routerRecord, uniqueSessionId, route,
"transferring to")) {
return;
}
@@ -1175,7 +1175,7 @@
route.getOriginalId());
}
- private boolean checkArgumentsForSessionControl(@Nullable Client2Record clientRecord,
+ private boolean checkArgumentsForSessionControl(@Nullable RouterRecord routerRecord,
String uniqueSessionId, MediaRoute2Info route, @NonNull String description) {
if (route == null) {
Slog.w(TAG, "Ignoring " + description + " null route");
@@ -1196,21 +1196,21 @@
return false;
}
- // Bypass checking client if it's the system session (clientRecord should be null)
+ // Bypass checking router if it's the system session (routerRecord should be null)
if (TextUtils.equals(getProviderId(uniqueSessionId), mSystemProvider.getUniqueId())) {
return true;
}
//TODO: Handle RCN case.
- if (clientRecord == null) {
- Slog.w(TAG, "Ignoring " + description + " route from unknown client.");
+ if (routerRecord == null) {
+ Slog.w(TAG, "Ignoring " + description + " route from unknown router.");
return false;
}
- Client2Record matchingRecord = mSessionToClientMap.get(uniqueSessionId);
- if (matchingRecord != clientRecord) {
- Slog.w(TAG, "Ignoring " + description + " route from non-matching client. "
- + "packageName=" + clientRecord.mPackageName + " route=" + route);
+ RouterRecord matchingRecord = mSessionToRouterMap.get(uniqueSessionId);
+ if (matchingRecord != routerRecord) {
+ Slog.w(TAG, "Ignoring " + description + " route from non-matching router. "
+ + "packageName=" + routerRecord.mPackageName + " route=" + route);
return false;
}
@@ -1224,17 +1224,17 @@
return true;
}
- private void releaseSessionOnHandler(@NonNull Client2Record clientRecord,
+ private void releaseSessionOnHandler(@NonNull RouterRecord routerRecord,
String uniqueSessionId) {
if (TextUtils.isEmpty(uniqueSessionId)) {
Slog.w(TAG, "Ignoring releasing session with empty unique session ID.");
return;
}
- final Client2Record matchingRecord = mSessionToClientMap.get(uniqueSessionId);
- if (matchingRecord != clientRecord) {
- Slog.w(TAG, "Ignoring releasing session from non-matching client."
- + " packageName=" + clientRecord.mPackageName
+ final RouterRecord matchingRecord = mSessionToRouterMap.get(uniqueSessionId);
+ if (matchingRecord != routerRecord) {
+ Slog.w(TAG, "Ignoring releasing session from non-matching router."
+ + " packageName=" + routerRecord.mPackageName
+ " uniqueSessionId=" + uniqueSessionId);
return;
}
@@ -1294,27 +1294,27 @@
if (sessionInfo == null) {
// Failed
- notifySessionCreationFailed(matchingRequest.mClientRecord,
- toClientRequestId(requestId));
+ notifySessionCreationFailed(matchingRequest.mRouterRecord,
+ toOriginalRequestId(requestId));
return;
}
String originalRouteId = matchingRequest.mRoute.getId();
- Client2Record client2Record = matchingRequest.mClientRecord;
+ RouterRecord routerRecord = matchingRequest.mRouterRecord;
if (!sessionInfo.getSelectedRoutes().contains(originalRouteId)) {
Slog.w(TAG, "Created session doesn't match the original request."
+ " originalRouteId=" + originalRouteId
+ ", requestId=" + requestId + ", sessionInfo=" + sessionInfo);
- notifySessionCreationFailed(matchingRequest.mClientRecord,
- toClientRequestId(requestId));
+ notifySessionCreationFailed(matchingRequest.mRouterRecord,
+ toOriginalRequestId(requestId));
return;
}
// Succeeded
- notifySessionCreated(matchingRequest.mClientRecord,
- sessionInfo, toClientRequestId(requestId));
- mSessionToClientMap.put(sessionInfo.getId(), client2Record);
+ notifySessionCreated(matchingRequest.mRouterRecord,
+ sessionInfo, toOriginalRequestId(requestId));
+ mSessionToRouterMap.put(sessionInfo.getId(), routerRecord);
}
private void onSessionCreationFailedOnHandler(@NonNull MediaRoute2Provider provider,
@@ -1337,8 +1337,8 @@
}
mSessionCreationRequests.remove(matchingRequest);
- notifySessionCreationFailed(matchingRequest.mClientRecord,
- toClientRequestId(requestId));
+ notifySessionCreationFailed(matchingRequest.mRouterRecord,
+ toOriginalRequestId(requestId));
}
private void onSessionInfoChangedOnHandler(@NonNull MediaRoute2Provider provider,
@@ -1346,23 +1346,22 @@
List<IMediaRouter2Manager> managers = getManagers();
notifySessionInfosChangedToManagers(managers);
- // For system provider, notify all clients.
+ // For system provider, notify all routers.
if (provider == mSystemProvider) {
MediaRouter2ServiceImpl service = mServiceRef.get();
if (service == null) {
return;
}
- notifySessionInfoChangedToClients(getClients(), sessionInfo);
+ notifySessionInfoChangedToRouters(getRouters(), sessionInfo);
return;
}
- Client2Record client2Record = mSessionToClientMap.get(
- sessionInfo.getId());
- if (client2Record == null) {
- Slog.w(TAG, "No matching client found for session=" + sessionInfo);
+ RouterRecord routerRecord = mSessionToRouterMap.get(sessionInfo.getId());
+ if (routerRecord == null) {
+ Slog.w(TAG, "No matching router found for session=" + sessionInfo);
return;
}
- notifySessionInfoChanged(client2Record, sessionInfo);
+ notifySessionInfoChanged(routerRecord, sessionInfo);
}
private void onSessionReleasedOnHandler(@NonNull MediaRoute2Provider provider,
@@ -1370,50 +1369,50 @@
List<IMediaRouter2Manager> managers = getManagers();
notifySessionInfosChangedToManagers(managers);
- Client2Record client2Record = mSessionToClientMap.get(sessionInfo.getId());
- if (client2Record == null) {
- Slog.w(TAG, "No matching client found for session=" + sessionInfo);
+ RouterRecord routerRecord = mSessionToRouterMap.get(sessionInfo.getId());
+ if (routerRecord == null) {
+ Slog.w(TAG, "No matching router found for session=" + sessionInfo);
return;
}
- notifySessionReleased(client2Record, sessionInfo);
+ notifySessionReleased(routerRecord, sessionInfo);
}
- private void notifySessionCreated(Client2Record clientRecord,
+ private void notifySessionCreated(RouterRecord routerRecord,
RoutingSessionInfo sessionInfo, int requestId) {
try {
- clientRecord.mClient.notifySessionCreated(sessionInfo, requestId);
+ routerRecord.mRouter.notifySessionCreated(sessionInfo, requestId);
} catch (RemoteException ex) {
- Slog.w(TAG, "Failed to notify client of the session creation."
- + " Client probably died.", ex);
+ Slog.w(TAG, "Failed to notify router of the session creation."
+ + " Router probably died.", ex);
}
}
- private void notifySessionCreationFailed(Client2Record clientRecord, int requestId) {
+ private void notifySessionCreationFailed(RouterRecord routerRecord, int requestId) {
try {
- clientRecord.mClient.notifySessionCreated(/* sessionInfo= */ null, requestId);
+ routerRecord.mRouter.notifySessionCreated(/* sessionInfo= */ null, requestId);
} catch (RemoteException ex) {
- Slog.w(TAG, "Failed to notify client of the session creation failure."
- + " Client probably died.", ex);
+ Slog.w(TAG, "Failed to notify router of the session creation failure."
+ + " Router probably died.", ex);
}
}
- private void notifySessionInfoChanged(Client2Record clientRecord,
+ private void notifySessionInfoChanged(RouterRecord routerRecord,
RoutingSessionInfo sessionInfo) {
try {
- clientRecord.mClient.notifySessionInfoChanged(sessionInfo);
+ routerRecord.mRouter.notifySessionInfoChanged(sessionInfo);
} catch (RemoteException ex) {
- Slog.w(TAG, "Failed to notify client of the session info change."
- + " Client probably died.", ex);
+ Slog.w(TAG, "Failed to notify router of the session info change."
+ + " Router probably died.", ex);
}
}
- private void notifySessionReleased(Client2Record clientRecord,
+ private void notifySessionReleased(RouterRecord routerRecord,
RoutingSessionInfo sessionInfo) {
try {
- clientRecord.mClient.notifySessionReleased(sessionInfo);
+ routerRecord.mRouter.notifySessionReleased(sessionInfo);
} catch (RemoteException ex) {
- Slog.w(TAG, "Failed to notify client of the session release."
- + " Client probably died.", ex);
+ Slog.w(TAG, "Failed to notify router of the session release."
+ + " Router probably died.", ex);
}
}
@@ -1434,18 +1433,18 @@
provider.setSessionVolume(getOriginalId(sessionId), volume);
}
- private List<IMediaRouter2Client> getClients() {
- final List<IMediaRouter2Client> clients = new ArrayList<>();
+ private List<IMediaRouter2> getRouters() {
+ final List<IMediaRouter2> routers = new ArrayList<>();
MediaRouter2ServiceImpl service = mServiceRef.get();
if (service == null) {
- return clients;
+ return routers;
}
synchronized (service.mLock) {
- for (Client2Record clientRecord : mUserRecord.mClientRecords) {
- clients.add(clientRecord.mClient);
+ for (RouterRecord routerRecord : mUserRecord.mRouterRecords) {
+ routers.add(routerRecord.mRouter);
}
}
- return clients;
+ return routers;
}
private List<IMediaRouter2Manager> getManagers() {
@@ -1462,7 +1461,7 @@
return managers;
}
- private void notifyRoutesToClient(IMediaRouter2Client client) {
+ private void notifyRoutesToRouter(IMediaRouter2 router) {
List<MediaRoute2Info> routes = new ArrayList<>();
for (MediaRoute2ProviderInfo providerInfo : mLastProviderInfos) {
routes.addAll(providerInfo.getRoutes());
@@ -1471,52 +1470,52 @@
return;
}
try {
- client.notifyRoutesAdded(routes);
+ router.notifyRoutesAdded(routes);
} catch (RemoteException ex) {
- Slog.w(TAG, "Failed to notify all routes. Client probably died.", ex);
+ Slog.w(TAG, "Failed to notify all routes. Router probably died.", ex);
}
}
- private void notifyRoutesAddedToClients(List<IMediaRouter2Client> clients,
+ private void notifyRoutesAddedToRouters(List<IMediaRouter2> routers,
List<MediaRoute2Info> routes) {
- for (IMediaRouter2Client client : clients) {
+ for (IMediaRouter2 router : routers) {
try {
- client.notifyRoutesAdded(routes);
+ router.notifyRoutesAdded(routes);
} catch (RemoteException ex) {
- Slog.w(TAG, "Failed to notify routes added. Client probably died.", ex);
+ Slog.w(TAG, "Failed to notify routes added. Router probably died.", ex);
}
}
}
- private void notifyRoutesRemovedToClients(List<IMediaRouter2Client> clients,
+ private void notifyRoutesRemovedToRouters(List<IMediaRouter2> routers,
List<MediaRoute2Info> routes) {
- for (IMediaRouter2Client client : clients) {
+ for (IMediaRouter2 router : routers) {
try {
- client.notifyRoutesRemoved(routes);
+ router.notifyRoutesRemoved(routes);
} catch (RemoteException ex) {
- Slog.w(TAG, "Failed to notify routes removed. Client probably died.", ex);
+ Slog.w(TAG, "Failed to notify routes removed. Router probably died.", ex);
}
}
}
- private void notifyRoutesChangedToClients(List<IMediaRouter2Client> clients,
+ private void notifyRoutesChangedToRouters(List<IMediaRouter2> routers,
List<MediaRoute2Info> routes) {
- for (IMediaRouter2Client client : clients) {
+ for (IMediaRouter2 router : routers) {
try {
- client.notifyRoutesChanged(routes);
+ router.notifyRoutesChanged(routes);
} catch (RemoteException ex) {
- Slog.w(TAG, "Failed to notify routes changed. Client probably died.", ex);
+ Slog.w(TAG, "Failed to notify routes changed. Router probably died.", ex);
}
}
}
- private void notifySessionInfoChangedToClients(List<IMediaRouter2Client> clients,
+ private void notifySessionInfoChangedToRouters(List<IMediaRouter2> routers,
RoutingSessionInfo sessionInfo) {
- for (IMediaRouter2Client client : clients) {
+ for (IMediaRouter2 router : routers) {
try {
- client.notifySessionInfoChanged(sessionInfo);
+ router.notifySessionInfoChanged(sessionInfo);
} catch (RemoteException ex) {
- Slog.w(TAG, "Failed to notify session info changed. Client probably died.", ex);
+ Slog.w(TAG, "Failed to notify session info changed. Router probably died.", ex);
}
}
}
@@ -1592,7 +1591,7 @@
}
}
- private void updateClientUsage(Client2Record clientRecord) {
+ private void notifyPreferredFeaturesChangedToManagers(RouterRecord routerRecord) {
MediaRouter2ServiceImpl service = mServiceRef.get();
if (service == null) {
return;
@@ -1605,10 +1604,11 @@
}
for (IMediaRouter2Manager manager : managers) {
try {
- manager.notifyPreferredFeaturesChanged(clientRecord.mPackageName,
- clientRecord.mDiscoveryPreference.getPreferredFeatures());
+ manager.notifyPreferredFeaturesChanged(routerRecord.mPackageName,
+ routerRecord.mDiscoveryPreference.getPreferredFeatures());
} catch (RemoteException ex) {
- Slog.w(TAG, "Failed to update client usage. Manager probably died.", ex);
+ Slog.w(TAG, "Failed to notify preferred features changed."
+ + " Manager probably died.", ex);
}
}
}
@@ -1620,8 +1620,8 @@
}
List<RouteDiscoveryPreference> discoveryPreferences = new ArrayList<>();
synchronized (service.mLock) {
- for (Client2Record clientRecord : mUserRecord.mClientRecords) {
- discoveryPreferences.add(clientRecord.mDiscoveryPreference);
+ for (RouterRecord routerRecord : mUserRecord.mRouterRecords) {
+ discoveryPreferences.add(routerRecord.mDiscoveryPreference);
}
mUserRecord.mCompositeDiscoveryPreference =
new RouteDiscoveryPreference.Builder(discoveryPreferences)
@@ -1642,13 +1642,13 @@
}
final class SessionCreationRequest {
- public final Client2Record mClientRecord;
+ public final RouterRecord mRouterRecord;
public final MediaRoute2Info mRoute;
public final long mRequestId;
- SessionCreationRequest(@NonNull Client2Record clientRecord,
+ SessionCreationRequest(@NonNull RouterRecord routerRecord,
@NonNull MediaRoute2Info route, long requestId) {
- mClientRecord = clientRecord;
+ mRouterRecord = routerRecord;
mRoute = route;
mRequestId = requestId;
}
diff --git a/services/core/java/com/android/server/media/MediaRouterService.java b/services/core/java/com/android/server/media/MediaRouterService.java
index 83cc894..580fc52 100644
--- a/services/core/java/com/android/server/media/MediaRouterService.java
+++ b/services/core/java/com/android/server/media/MediaRouterService.java
@@ -30,7 +30,7 @@
import android.media.AudioSystem;
import android.media.IAudioRoutesObserver;
import android.media.IAudioService;
-import android.media.IMediaRouter2Client;
+import android.media.IMediaRouter2;
import android.media.IMediaRouter2Manager;
import android.media.IMediaRouterClient;
import android.media.IMediaRouterService;
@@ -450,50 +450,78 @@
// Binder call
@Override
- public void registerClient2(IMediaRouter2Client client, String packageName) {
+ public void registerRouter2(IMediaRouter2 router, String packageName) {
final int uid = Binder.getCallingUid();
if (!validatePackageName(uid, packageName)) {
throw new SecurityException("packageName must match the calling uid");
}
- mService2.registerClient(client, packageName);
+ mService2.registerRouter2(router, packageName);
}
// Binder call
@Override
- public void unregisterClient2(IMediaRouter2Client client) {
- mService2.unregisterClient(client);
+ public void unregisterRouter2(IMediaRouter2 router) {
+ mService2.unregisterRouter2(router);
}
// Binder call
@Override
- public void requestCreateSession(IMediaRouter2Client client, MediaRoute2Info route,
+ public void setDiscoveryRequestWithRouter2(IMediaRouter2 router,
+ RouteDiscoveryPreference request) {
+ mService2.setDiscoveryRequestWithRouter2(router, request);
+ }
+
+ // Binder call
+ @Override
+ public void setRouteVolumeWithRouter2(IMediaRouter2 router,
+ MediaRoute2Info route, int volume) {
+ mService2.setRouteVolumeWithRouter2(router, route, volume);
+ }
+
+ // Binder call
+ @Override
+ public void requestCreateSessionWithRouter2(IMediaRouter2 router, MediaRoute2Info route,
int requestId, Bundle sessionHints) {
- mService2.requestCreateSession(client, route, requestId, sessionHints);
+ mService2.requestCreateSessionWithRouter2(router, route, requestId, sessionHints);
}
// Binder call
@Override
- public void selectRoute(IMediaRouter2Client client, String sessionId, MediaRoute2Info route) {
- mService2.selectRoute(client, sessionId, route);
- }
-
- // Binder call
- @Override
- public void deselectRoute(IMediaRouter2Client client, String sessionId, MediaRoute2Info route) {
- mService2.deselectRoute(client, sessionId, route);
- }
-
- // Binder call
- @Override
- public void transferToRoute(IMediaRouter2Client client, String sessionId,
+ public void selectRouteWithRouter2(IMediaRouter2 router, String sessionId,
MediaRoute2Info route) {
- mService2.transferToRoute(client, sessionId, route);
+ mService2.selectRouteWithRouter2(router, sessionId, route);
}
// Binder call
@Override
- public void releaseSession(IMediaRouter2Client client, String sessionId) {
- mService2.releaseSession(client, sessionId);
+ public void deselectRouteWithRouter2(IMediaRouter2 router, String sessionId,
+ MediaRoute2Info route) {
+ mService2.deselectRouteWithRouter2(router, sessionId, route);
+ }
+
+ // Binder call
+ @Override
+ public void transferToRouteWithRouter2(IMediaRouter2 router, String sessionId,
+ MediaRoute2Info route) {
+ mService2.transferToRouteWithRouter2(router, sessionId, route);
+ }
+
+ // Binder call
+ @Override
+ public void setSessionVolumeWithRouter2(IMediaRouter2 router, String sessionId, int volume) {
+ mService2.setSessionVolumeWithRouter2(router, sessionId, volume);
+ }
+
+ // Binder call
+ @Override
+ public void releaseSessionWithRouter2(IMediaRouter2 router, String sessionId) {
+ mService2.releaseSessionWithRouter2(router, sessionId);
+ }
+
+ // Binder call
+ @Override
+ public List<RoutingSessionInfo> getActiveSessions(IMediaRouter2Manager manager) {
+ return mService2.getActiveSessions(manager);
}
// Binder call
@@ -514,74 +542,50 @@
// Binder call
@Override
- public void requestCreateClientSession(IMediaRouter2Manager manager, String packageName,
+ public void setRouteVolumeWithManager(IMediaRouter2Manager manager,
+ MediaRoute2Info route, int volume) {
+ mService2.setRouteVolumeWithManager(manager, route, volume);
+ }
+
+ // Binder call
+ @Override
+ public void requestCreateSessionWithManager(IMediaRouter2Manager manager, String packageName,
MediaRoute2Info route, int requestId) {
- mService2.requestCreateClientSession(manager, packageName, route, requestId);
- }
- // Binder call
- @Override
- public void setDiscoveryRequest2(IMediaRouter2Client client, RouteDiscoveryPreference request) {
- mService2.setDiscoveryRequest2(client, request);
+ mService2.requestCreateSessionWithManager(manager, packageName, route, requestId);
}
// Binder call
@Override
- public void setRouteVolume2(IMediaRouter2Client client,
- MediaRoute2Info route, int volume) {
- mService2.setRouteVolume2(client, route, volume);
+ public void selectRouteWithManager(IMediaRouter2Manager manager, String sessionId,
+ MediaRoute2Info route) {
+ mService2.selectRouteWithManager(manager, sessionId, route);
}
// Binder call
@Override
- public void setSessionVolume2(IMediaRouter2Client client, String sessionId, int volume) {
- mService2.setSessionVolume2(client, sessionId, volume);
+ public void deselectRouteWithManager(IMediaRouter2Manager manager, String sessionId,
+ MediaRoute2Info route) {
+ mService2.deselectRouteWithManager(manager, sessionId, route);
}
// Binder call
@Override
- public void setRouteVolume2Manager(IMediaRouter2Manager manager,
- MediaRoute2Info route, int volume) {
- mService2.setRouteVolume2Manager(manager, route, volume);
+ public void transferToRouteWithManager(IMediaRouter2Manager manager, String sessionId,
+ MediaRoute2Info route) {
+ mService2.transferToRouteWithManager(manager, sessionId, route);
}
// Binder call
@Override
- public void setSessionVolume2Manager(IMediaRouter2Manager manager,
+ public void setSessionVolumeWithManager(IMediaRouter2Manager manager,
String sessionId, int volume) {
- mService2.setSessionVolume2Manager(manager, sessionId, volume);
+ mService2.setSessionVolumeWithManager(manager, sessionId, volume);
}
// Binder call
@Override
- public List<RoutingSessionInfo> getActiveSessions(IMediaRouter2Manager manager) {
- return mService2.getActiveSessions(manager);
- }
-
- // Binder call
- @Override
- public void selectClientRoute(IMediaRouter2Manager manager, String sessionId,
- MediaRoute2Info route) {
- mService2.selectClientRoute(manager, sessionId, route);
- }
-
- // Binder call
- @Override
- public void deselectClientRoute(IMediaRouter2Manager manager, String sessionId,
- MediaRoute2Info route) {
- mService2.deselectClientRoute(manager, sessionId, route);
- }
-
- // Binder call
- @Override
- public void transferToClientRoute(IMediaRouter2Manager manager, String sessionId,
- MediaRoute2Info route) {
- mService2.transferToClientRoute(manager, sessionId, route);
- }
-
- // Binder call
- @Override
- public void releaseClientSession(IMediaRouter2Manager manager, String sessionId) {
- mService2.releaseClientSession(manager, sessionId);
+ public void releaseSessionWithManager(IMediaRouter2Manager manager, String sessionId) {
+ mService2.releaseSessionWithManager(manager, sessionId);
}
void restoreBluetoothA2dp() {