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

Commit f5365989 authored by Yu-Han Yang's avatar Yu-Han Yang
Browse files

Add enableFullTracking to registerGnssMeasurementsCallback

- Internal implementation is in ag/10109000.

Bug: 148284818
Bug: 147387008

Test: builds and existing tests pass.
Change-Id: Ic276dcc8170a24d132770703b33bfc9762bf6b4f
parent bf3e4555
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -3849,6 +3849,20 @@ package android.location {
    method @NonNull public android.location.GnssReflectingPlane.Builder setLongitudeDegrees(@FloatRange(from=-180.0F, to=180.0f) double);
    method @NonNull public android.location.GnssReflectingPlane.Builder setLongitudeDegrees(@FloatRange(from=-180.0F, to=180.0f) double);
  }
  }
  public final class GnssRequest implements android.os.Parcelable {
    method public int describeContents();
    method public boolean isFullTracking();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.location.GnssRequest> CREATOR;
  }
  public static final class GnssRequest.Builder {
    ctor public GnssRequest.Builder();
    ctor public GnssRequest.Builder(@NonNull android.location.GnssRequest);
    method @NonNull public android.location.GnssRequest build();
    method @NonNull public android.location.GnssRequest.Builder setFullTracking(boolean);
  }
  public final class GnssSingleSatCorrection implements android.os.Parcelable {
  public final class GnssSingleSatCorrection implements android.os.Parcelable {
    method public int describeContents();
    method public int describeContents();
    method @FloatRange(from=0.0f, fromInclusive=false) public float getCarrierFrequencyHz();
    method @FloatRange(from=0.0f, fromInclusive=false) public float getCarrierFrequencyHz();
@@ -4122,6 +4136,7 @@ package android.location {
    method public boolean isProviderEnabledForUser(@NonNull String, @NonNull android.os.UserHandle);
    method public boolean isProviderEnabledForUser(@NonNull String, @NonNull android.os.UserHandle);
    method @RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG) public boolean isProviderPackage(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG) public boolean isProviderPackage(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE) public boolean registerGnssBatchedLocationCallback(long, boolean, @NonNull android.location.BatchedLocationCallback, @Nullable android.os.Handler);
    method @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE) public boolean registerGnssBatchedLocationCallback(long, boolean, @NonNull android.location.BatchedLocationCallback, @Nullable android.os.Handler);
    method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.LOCATION_HARDWARE}) public boolean registerGnssMeasurementsCallback(@NonNull android.location.GnssRequest, @NonNull java.util.concurrent.Executor, @NonNull android.location.GnssMeasurementsEvent.Callback);
    method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@Nullable android.location.LocationRequest, @NonNull android.location.LocationListener, @Nullable android.os.Looper);
    method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@Nullable android.location.LocationRequest, @NonNull android.location.LocationListener, @Nullable android.os.Looper);
    method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@Nullable android.location.LocationRequest, @NonNull java.util.concurrent.Executor, @NonNull android.location.LocationListener);
    method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@Nullable android.location.LocationRequest, @NonNull java.util.concurrent.Executor, @NonNull android.location.LocationListener);
    method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@Nullable android.location.LocationRequest, @NonNull android.app.PendingIntent);
    method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@Nullable android.location.LocationRequest, @NonNull android.app.PendingIntent);
+22 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2020, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.location;

/**
 * @hide
 */
parcelable GnssRequest;
+147 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.location;

import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * This class contains extra parameters to pass to a GNSS provider implementation.
 * @hide
 */
@SystemApi
public final class GnssRequest implements Parcelable {
    private final boolean mFullTracking;

    /**
     * Creates a {@link GnssRequest} with a full list of parameters.
     */
    private GnssRequest(boolean fullTracking) {
        mFullTracking = fullTracking;
    }

    /**
     * Represents whether to enable full GNSS tracking.
     *
     * <p>If true, GNSS chipset switches off duty cycling. In such a mode, no clock
     * discontinuities are expected, and when supported, carrier phase should be continuous in
     * good signal conditions. All non-blacklisted, healthy constellations, satellites and
     * frequency bands that the chipset supports must be reported in this mode. The GNSS chipset
     * is allowed to consume more power in this mode. If false, GNSS chipset optimizes power via
     * duty cycling, constellations and frequency limits, etc.
     */
    public boolean isFullTracking() {
        return mFullTracking;
    }

    @NonNull
    public static final Creator<GnssRequest> CREATOR =
            new Creator<GnssRequest>() {
                @Override
                @NonNull
                public GnssRequest createFromParcel(@NonNull Parcel parcel) {
                    return new GnssRequest(parcel.readBoolean());
                }

                @Override
                public GnssRequest[] newArray(int i) {
                    return new GnssRequest[i];
                }
            };

    @NonNull
    @Override
    public String toString() {
        StringBuilder s = new StringBuilder();
        s.append("GnssRequest[");
        s.append("FullTracking=").append(mFullTracking);
        s.append(']');
        return s.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (!(obj instanceof GnssRequest)) return false;

        GnssRequest other = (GnssRequest) obj;
        if (mFullTracking != other.mFullTracking) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return mFullTracking ? 1 : 0;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel parcel, int flags) {
        parcel.writeBoolean(mFullTracking);
    }

    /** Builder for {@link GnssRequest} */
    public static final class Builder {
        private boolean mFullTracking;

        /**
         * Constructs a {@link Builder} instance.
         */
        public Builder() {
        }

        /**
         * Constructs a {@link Builder} instance by copying a {@link GnssRequest}.
         */
        public Builder(@NonNull GnssRequest request) {
            mFullTracking = request.isFullTracking();
        }

        /**
         * Set the value of whether to enable full GNSS tracking, which is false by default.
         *
         * <p>If true, GNSS chipset switches off duty cycling. In such a mode, no clock
         * discontinuities are expected, and when supported, carrier phase should be continuous in
         * good signal conditions. All non-blacklisted, healthy constellations, satellites and
         * frequency bands that the chipset supports must be reported in this mode. The GNSS chipset
         * is allowed to consume more power in this mode. If false, GNSS chipset optimizes power via
         * duty cycling, constellations and frequency limits, etc.
         *
         * <p>Full tracking requests always override non-full tracking requests. If any full
         * tracking request occurs, all listeners on the device will receive full tracking GNSS
         * measurements.
         */
        @NonNull public Builder setFullTracking(boolean value) {
            mFullTracking = value;
            return this;
        }

        /** Builds a {@link GnssRequest} instance as specified by this builder. */
        @NonNull
        public GnssRequest build() {
            return new GnssRequest(mFullTracking);
        }
    }
}
+24 −0
Original line number Original line Diff line number Diff line
@@ -2161,6 +2161,30 @@ public class LocationManager {
        }
        }
    }
    }


    /**
     * Registers a GNSS Measurement callback.
     *
     * @param request  extra parameters to pass to GNSS measurement provider. For example, if {@link
     *                 GnssRequest#isFullTrackingEnabled()} is true, GNSS chipset switches off duty
     *                 cycling.
     * @param executor the executor that the callback runs on.
     * @param callback a {@link GnssMeasurementsEvent.Callback} object to register.
     * @return {@code true} if the callback was added successfully, {@code false} otherwise.
     * @throws IllegalArgumentException if request is null
     * @throws IllegalArgumentException if executor is null
     * @throws IllegalArgumentException if callback is null
     * @throws SecurityException        if the ACCESS_FINE_LOCATION permission is not present
     * @hide
     */
    @SystemApi
    @RequiresPermission(allOf = {ACCESS_FINE_LOCATION, LOCATION_HARDWARE})
    public boolean registerGnssMeasurementsCallback(
            @NonNull GnssRequest request,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull GnssMeasurementsEvent.Callback callback) {
        throw new RuntimeException();
    }

    /**
    /**
     * Injects GNSS measurement corrections into the GNSS chipset.
     * Injects GNSS measurement corrections into the GNSS chipset.
     *
     *