diff options
| author | 2019-10-16 06:08:08 +0000 | |
|---|---|---|
| committer | 2019-10-16 06:08:08 +0000 | |
| commit | acb8ee8122c3c5ce8e5acf0d6a4122267ff1d774 (patch) | |
| tree | 5d0b71630587b758e4ae555bc74fbcddd42ca4d2 /location/java/android | |
| parent | eb64817aad4482c8910104712856d9f2c6909edb (diff) | |
| parent | f4a93276a117504963bbef9487eaf3044f607e9b (diff) | |
Merge "Normalize null argument behavior for GNSS APIs"
Diffstat (limited to 'location/java/android')
| -rw-r--r-- | location/java/android/location/AbstractListenerManager.java | 12 | ||||
| -rw-r--r-- | location/java/android/location/LocationManager.java | 27 |
2 files changed, 33 insertions, 6 deletions
diff --git a/location/java/android/location/AbstractListenerManager.java b/location/java/android/location/AbstractListenerManager.java index c41023e31065..944ebf937dc8 100644 --- a/location/java/android/location/AbstractListenerManager.java +++ b/location/java/android/location/AbstractListenerManager.java @@ -42,8 +42,8 @@ abstract class AbstractListenerManager<T> { @Nullable private volatile T mListener; private Registration(Executor executor, T listener) { - Preconditions.checkArgument(listener != null); - Preconditions.checkArgument(executor != null); + Preconditions.checkArgument(listener != null, "invalid null listener/callback"); + Preconditions.checkArgument(executor != null, "invalid null executor"); mExecutor = executor; mListener = listener; } @@ -83,16 +83,18 @@ abstract class AbstractListenerManager<T> { return addInternal(listener, executor); } - protected final boolean addInternal(Object listener, Handler handler) throws RemoteException { + protected final boolean addInternal(@NonNull Object listener, @NonNull Handler handler) + throws RemoteException { return addInternal(listener, new HandlerExecutor(handler)); } - protected final boolean addInternal(Object listener, Executor executor) throws RemoteException { + protected final boolean addInternal(@NonNull Object listener, @NonNull Executor executor) + throws RemoteException { + Preconditions.checkArgument(listener != null, "invalid null listener/callback"); return addInternal(listener, new Registration<>(executor, convertKey(listener))); } private boolean addInternal(Object key, Registration<T> registration) throws RemoteException { - Preconditions.checkNotNull(key); Preconditions.checkNotNull(registration); synchronized (mListeners) { diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index 88848c5eb919..0b3e1c3f57d3 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -1800,6 +1800,7 @@ public class LocationManager { * @param handler a handler with a looper that the callback runs on * @return true if the listener was successfully added * + * @throws IllegalArgumentException if callback is null * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present */ @RequiresPermission(ACCESS_FINE_LOCATION) @@ -1819,10 +1820,12 @@ public class LocationManager { /** * Registers a GNSS status callback. * - * @param callback GNSS status callback object to register * @param executor the executor that the callback runs on + * @param callback GNSS status callback object to register * @return true if the listener was successfully added * + * @throws IllegalArgumentException if executor is null + * @throws IllegalArgumentException if callback is null * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present */ @RequiresPermission(ACCESS_FINE_LOCATION) @@ -1891,6 +1894,8 @@ public class LocationManager { * @param listener a {@link OnNmeaMessageListener} object to register * @param handler a handler with the looper that the listener runs on. * @return true if the listener was successfully added + * + * @throws IllegalArgumentException if listener is null * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present */ @RequiresPermission(ACCESS_FINE_LOCATION) @@ -1912,6 +1917,9 @@ public class LocationManager { * @param listener a {@link OnNmeaMessageListener} object to register * @param executor the {@link Executor} that the listener runs on. * @return true if the listener was successfully added + * + * @throws IllegalArgumentException if executor is null + * @throws IllegalArgumentException if listener is null * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present */ @RequiresPermission(ACCESS_FINE_LOCATION) @@ -1984,6 +1992,9 @@ public class LocationManager { * @param callback a {@link GnssMeasurementsEvent.Callback} object to register. * @param handler the handler that the callback runs on. * @return {@code true} if the callback was added successfully, {@code false} otherwise. + * + * @throws IllegalArgumentException if callback is null + * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present */ @RequiresPermission(ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback( @@ -2004,6 +2015,10 @@ public class LocationManager { * @param callback a {@link GnssMeasurementsEvent.Callback} object to register. * @param executor the executor that the callback runs on. * @return {@code true} if the callback was added successfully, {@code false} otherwise. + * + * @throws IllegalArgumentException if executor is null + * @throws IllegalArgumentException if callback is null + * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present */ @RequiresPermission(ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback( @@ -2021,6 +2036,9 @@ public class LocationManager { * * @param measurementCorrections a {@link GnssMeasurementCorrections} object with the GNSS * measurement corrections to be injected into the GNSS chipset. + * + * @throws IllegalArgumentException if measurementCorrections is null + * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present * @hide */ @SystemApi @@ -2095,6 +2113,9 @@ public class LocationManager { * @param callback a {@link GnssNavigationMessage.Callback} object to register. * @param handler the handler that the callback runs on. * @return {@code true} if the callback was added successfully, {@code false} otherwise. + * + * @throws IllegalArgumentException if callback is null + * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present */ @RequiresPermission(ACCESS_FINE_LOCATION) public boolean registerGnssNavigationMessageCallback( @@ -2116,6 +2137,10 @@ public class LocationManager { * @param callback a {@link GnssNavigationMessage.Callback} object to register. * @param executor the looper that the callback runs on. * @return {@code true} if the callback was added successfully, {@code false} otherwise. + * + * @throws IllegalArgumentException if executor is null + * @throws IllegalArgumentException if callback is null + * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present */ @RequiresPermission(ACCESS_FINE_LOCATION) public boolean registerGnssNavigationMessageCallback( |