Merge changes from topic "cherrypicker-L70100000956505250:N87500001297085156" into tm-qpr-dev
* changes: Add mediaroutertest to frameworks/base/media/TEST_MAPPING Rethrow MediaRouter2Manager RemoteExceptions Guard MediaDeviceManager.Entry against successive stop calls
This commit is contained in:
committed by
Android (Google) Code Review
commit
dbf6151114
@@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"presubmit": [
|
"presubmit": [
|
||||||
|
{
|
||||||
|
"name": "mediaroutertest"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "CtsCameraTestCases",
|
"name": "CtsCameraTestCases",
|
||||||
"options" : [
|
"options" : [
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ public final class MediaRouter2Manager {
|
|||||||
try {
|
try {
|
||||||
mMediaRouterService.startScan(client);
|
mMediaRouterService.startScan(client);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "Unable to get sessions. Service probably died.", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ public final class MediaRouter2Manager {
|
|||||||
try {
|
try {
|
||||||
mMediaRouterService.stopScan(client);
|
mMediaRouterService.stopScan(client);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "Unable to get sessions. Service probably died.", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,9 +361,8 @@ public final class MediaRouter2Manager {
|
|||||||
return mMediaRouterService.getSystemSessionInfoForPackage(
|
return mMediaRouterService.getSystemSessionInfoForPackage(
|
||||||
getOrCreateClient(), packageName);
|
getOrCreateClient(), packageName);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "Unable to get current system session info", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -429,7 +428,7 @@ public final class MediaRouter2Manager {
|
|||||||
try {
|
try {
|
||||||
return mMediaRouterService.getRemoteSessions(client);
|
return mMediaRouterService.getRemoteSessions(client);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "Unable to get sessions. Service probably died.", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@@ -521,7 +520,7 @@ public final class MediaRouter2Manager {
|
|||||||
int requestId = mNextRequestId.getAndIncrement();
|
int requestId = mNextRequestId.getAndIncrement();
|
||||||
mMediaRouterService.setRouteVolumeWithManager(client, requestId, route, volume);
|
mMediaRouterService.setRouteVolumeWithManager(client, requestId, route, volume);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "Unable to set route volume.", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -551,7 +550,7 @@ public final class MediaRouter2Manager {
|
|||||||
mMediaRouterService.setSessionVolumeWithManager(
|
mMediaRouterService.setSessionVolumeWithManager(
|
||||||
client, requestId, sessionInfo.getId(), volume);
|
client, requestId, sessionInfo.getId(), volume);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "Unable to set session volume.", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -816,7 +815,7 @@ public final class MediaRouter2Manager {
|
|||||||
mMediaRouterService.selectRouteWithManager(
|
mMediaRouterService.selectRouteWithManager(
|
||||||
client, requestId, sessionInfo.getId(), route);
|
client, requestId, sessionInfo.getId(), route);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "selectRoute: Failed to send a request.", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -858,7 +857,7 @@ public final class MediaRouter2Manager {
|
|||||||
mMediaRouterService.deselectRouteWithManager(
|
mMediaRouterService.deselectRouteWithManager(
|
||||||
client, requestId, sessionInfo.getId(), route);
|
client, requestId, sessionInfo.getId(), route);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "deselectRoute: Failed to send a request.", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -883,7 +882,7 @@ public final class MediaRouter2Manager {
|
|||||||
mMediaRouterService.releaseSessionWithManager(
|
mMediaRouterService.releaseSessionWithManager(
|
||||||
client, requestId, sessionInfo.getId());
|
client, requestId, sessionInfo.getId());
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "releaseSession: Failed to send a request", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -903,7 +902,7 @@ public final class MediaRouter2Manager {
|
|||||||
mMediaRouterService.transferToRouteWithManager(
|
mMediaRouterService.transferToRouteWithManager(
|
||||||
client, requestId, session.getId(), route);
|
client, requestId, session.getId(), route);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "transferToRoute: Failed to send a request.", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -923,7 +922,7 @@ public final class MediaRouter2Manager {
|
|||||||
mMediaRouterService.requestCreateSessionWithManager(
|
mMediaRouterService.requestCreateSessionWithManager(
|
||||||
client, requestId, oldSession, route);
|
client, requestId, oldSession, route);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "requestCreateSession: Failed to send a request", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -979,10 +978,9 @@ public final class MediaRouter2Manager {
|
|||||||
mClient = client;
|
mClient = client;
|
||||||
return client;
|
return client;
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "Unable to register media router manager.", ex);
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ android_test {
|
|||||||
"testng",
|
"testng",
|
||||||
"truth-prebuilt",
|
"truth-prebuilt",
|
||||||
],
|
],
|
||||||
|
test_suites: ["general-tests"],
|
||||||
platform_apis: true,
|
platform_apis: true,
|
||||||
certificate: "platform",
|
certificate: "platform",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,24 +188,28 @@ class MediaDeviceManager @Inject constructor(
|
|||||||
|
|
||||||
@AnyThread
|
@AnyThread
|
||||||
fun start() = bgExecutor.execute {
|
fun start() = bgExecutor.execute {
|
||||||
localMediaManager.registerCallback(this)
|
if (!started) {
|
||||||
localMediaManager.startScan()
|
localMediaManager.registerCallback(this)
|
||||||
muteAwaitConnectionManager?.startListening()
|
localMediaManager.startScan()
|
||||||
playbackType = controller?.playbackInfo?.playbackType ?: PLAYBACK_TYPE_UNKNOWN
|
muteAwaitConnectionManager?.startListening()
|
||||||
controller?.registerCallback(this)
|
playbackType = controller?.playbackInfo?.playbackType ?: PLAYBACK_TYPE_UNKNOWN
|
||||||
updateCurrent()
|
controller?.registerCallback(this)
|
||||||
started = true
|
updateCurrent()
|
||||||
configurationController.addCallback(configListener)
|
started = true
|
||||||
|
configurationController.addCallback(configListener)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AnyThread
|
@AnyThread
|
||||||
fun stop() = bgExecutor.execute {
|
fun stop() = bgExecutor.execute {
|
||||||
started = false
|
if (started) {
|
||||||
controller?.unregisterCallback(this)
|
started = false
|
||||||
localMediaManager.stopScan()
|
controller?.unregisterCallback(this)
|
||||||
localMediaManager.unregisterCallback(this)
|
localMediaManager.stopScan()
|
||||||
muteAwaitConnectionManager?.stopListening()
|
localMediaManager.unregisterCallback(this)
|
||||||
configurationController.removeCallback(configListener)
|
muteAwaitConnectionManager?.stopListening()
|
||||||
|
configurationController.removeCallback(configListener)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dump(pw: PrintWriter) {
|
fun dump(pw: PrintWriter) {
|
||||||
|
|||||||
Reference in New Issue
Block a user