Merge "Rethrow RemoteExceptions from MediaRouter2 instead of logging them"

This commit is contained in:
Alex Dadukin
2022-11-22 14:52:23 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 6 deletions

View File

@@ -305,7 +305,7 @@ public final class MediaRouter2 {
currentSystemRoutes = mMediaRouterService.getSystemRoutes();
currentSystemSessionInfo = mMediaRouterService.getSystemSessionInfo();
} catch (RemoteException ex) {
Log.e(TAG, "Unable to get current system's routes / session info", ex);
ex.rethrowFromSystemServer();
}
if (currentSystemRoutes == null || currentSystemRoutes.isEmpty()) {
@@ -407,14 +407,14 @@ public final class MediaRouter2 {
mMediaRouterService.registerRouter2(stub, mPackageName);
mStub = stub;
} catch (RemoteException ex) {
Log.e(TAG, "registerRouteCallback: Unable to register MediaRouter2.", ex);
ex.rethrowFromSystemServer();
}
}
if (mStub != null && updateDiscoveryPreferenceIfNeededLocked()) {
try {
mMediaRouterService.setDiscoveryRequestWithRouter2(mStub, mDiscoveryPreference);
} catch (RemoteException ex) {
Log.e(TAG, "registerRouteCallback: Unable to set discovery request.", ex);
ex.rethrowFromSystemServer();
}
}
}
@@ -454,7 +454,7 @@ public final class MediaRouter2 {
try {
mMediaRouterService.unregisterRouter2(mStub);
} catch (RemoteException ex) {
Log.e(TAG, "Unable to unregister media router.", ex);
ex.rethrowFromSystemServer();
}
mStub = null;
}
@@ -1769,7 +1769,7 @@ public final class MediaRouter2 {
try {
mMediaRouterService.releaseSessionWithRouter2(mStub, getId());
} catch (RemoteException ex) {
Log.e(TAG, "Unable to release session", ex);
ex.rethrowFromSystemServer();
}
}
@@ -1787,7 +1787,7 @@ public final class MediaRouter2 {
try {
mMediaRouterService.unregisterRouter2(mStub);
} catch (RemoteException ex) {
Log.e(TAG, "releaseInternal: Unable to unregister media router.", ex);
ex.rethrowFromSystemServer();
}
mStub = null;
}

View File

@@ -348,6 +348,9 @@ class MediaRouter2ServiceImpl {
@NonNull String uniqueSessionId, int volume) {
Objects.requireNonNull(router, "router must not be null");
Objects.requireNonNull(uniqueSessionId, "uniqueSessionId must not be null");
if (TextUtils.isEmpty(uniqueSessionId)) {
throw new IllegalArgumentException("uniqueSessionId must not be empty");
}
final long token = Binder.clearCallingIdentity();
try {