diff options
author | P.Y. Laligand <pylaligand@google.com> | 2015-04-16 16:22:35 -0700 |
---|---|---|
committer | P.Y. Laligand <pylaligand@google.com> | 2015-04-16 16:22:35 -0700 |
commit | 9d93a378c5158d14f80d46af70433234330ec568 (patch) | |
tree | bebd40322cb638d8def833c37b8f3241e6b5fa12 /media | |
parent | 2eabe5b7a9c396b1d6baebca7505a4e921312fc2 (diff) | |
download | frameworks_base-9d93a378c5158d14f80d46af70433234330ec568.zip frameworks_base-9d93a378c5158d14f80d46af70433234330ec568.tar.gz frameworks_base-9d93a378c5158d14f80d46af70433234330ec568.tar.bz2 |
Consistent null-checking in MediaRouter.
b/19747094
Change-Id: I5f8d086f717a11a9d03874e633471efed787a6c3
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaRouter.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java index c227eb7..a046512 100644 --- a/media/java/android/media/MediaRouter.java +++ b/media/java/android/media/MediaRouter.java @@ -18,6 +18,7 @@ package android.media; import android.Manifest; import android.annotation.DrawableRes; +import android.annotation.NonNull; import android.app.ActivityThread; import android.content.BroadcastReceiver; import android.content.Context; @@ -882,8 +883,12 @@ public class MediaRouter { * @param types type flags indicating which types this route should be used for. * The route must support at least a subset. * @param route Route to select + * @throws IllegalArgumentException if the given route is {@code null} */ - public void selectRoute(int types, RouteInfo route) { + public void selectRoute(int types, @NonNull RouteInfo route) { + if (route == null) { + throw new IllegalArgumentException("Route cannot be null."); + } selectRouteStatic(types, route, true); } @@ -894,7 +899,8 @@ public class MediaRouter { selectRouteStatic(types, route, explicit); } - static void selectRouteStatic(int types, RouteInfo route, boolean explicit) { + static void selectRouteStatic(int types, @NonNull RouteInfo route, boolean explicit) { + assert(route != null); final RouteInfo oldRoute = sStatic.mSelectedRoute; if (oldRoute == route) return; if (!route.matchesTypes(types)) { @@ -917,7 +923,7 @@ public class MediaRouter { final WifiDisplay activeDisplay = sStatic.mDisplayService.getWifiDisplayStatus().getActiveDisplay(); final boolean oldRouteHasAddress = oldRoute != null && oldRoute.mDeviceAddress != null; - final boolean newRouteHasAddress = route != null && route.mDeviceAddress != null; + final boolean newRouteHasAddress = route.mDeviceAddress != null; if (activeDisplay != null || oldRouteHasAddress || newRouteHasAddress) { if (newRouteHasAddress && !matchesDeviceAddress(activeDisplay, route)) { if (sStatic.mCanConfigureWifiDisplays) { |