Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit acb8ee81 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Normalize null argument behavior for GNSS APIs"

parents eb64817a f4a93276
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -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) {
+26 −1
Original line number Diff line number Diff line
@@ -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(