summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--location/java/android/location/AbstractListenerManager.java12
-rw-r--r--location/java/android/location/LocationManager.java27
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 90e29df45e51..93f7b7e69efa 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -1762,6 +1762,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)
@@ -1781,10 +1782,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)
@@ -1853,6 +1856,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)
@@ -1874,6 +1879,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)
@@ -1946,6 +1954,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(
@@ -1966,6 +1977,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(
@@ -1983,6 +1998,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
@@ -2057,6 +2075,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(
@@ -2078,6 +2099,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(