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

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

Expose enableFullTracking API to public

Changes include
- Rename GnssRequest to GnssMeasurementRequest
- Remove LOCATION_HARDWARE permission check for fullTracking mode

Bug: 175631328
Bug: 162977669
Test: on device
Change-Id: I253318fe0a6f92523de7564cd9086e8d96c2393b
parent 12f7e5a7
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -19069,6 +19069,20 @@ package android.location {
    field public static final int STATE_UNKNOWN = 0; // 0x0
  }
  public final class GnssMeasurementRequest 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.GnssMeasurementRequest> CREATOR;
  }
  public static final class GnssMeasurementRequest.Builder {
    ctor public GnssMeasurementRequest.Builder();
    ctor public GnssMeasurementRequest.Builder(@NonNull android.location.GnssMeasurementRequest);
    method @NonNull public android.location.GnssMeasurementRequest build();
    method @NonNull public android.location.GnssMeasurementRequest.Builder setFullTracking(boolean);
  }
  public final class GnssMeasurementsEvent implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public android.location.GnssClock getClock();
@@ -19295,6 +19309,7 @@ package android.location {
    method @Deprecated @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback(@NonNull android.location.GnssMeasurementsEvent.Callback);
    method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback(@NonNull android.location.GnssMeasurementsEvent.Callback, @Nullable android.os.Handler);
    method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback(@NonNull java.util.concurrent.Executor, @NonNull android.location.GnssMeasurementsEvent.Callback);
    method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback(@NonNull android.location.GnssMeasurementRequest, @NonNull java.util.concurrent.Executor, @NonNull android.location.GnssMeasurementsEvent.Callback);
    method @Deprecated public boolean registerGnssNavigationMessageCallback(@NonNull android.location.GnssNavigationMessage.Callback);
    method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssNavigationMessageCallback(@NonNull android.location.GnssNavigationMessage.Callback, @Nullable android.os.Handler);
    method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssNavigationMessageCallback(@NonNull java.util.concurrent.Executor, @NonNull android.location.GnssNavigationMessage.Callback);
+1 −1
Original line number Diff line number Diff line
@@ -4312,7 +4312,7 @@ package android.location {
    method @Deprecated @RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG) public boolean isProviderPackage(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG) public boolean isProviderPackage(@Nullable String, @NonNull String);
    method @Deprecated @RequiresPermission(allOf={android.Manifest.permission.LOCATION_HARDWARE, android.Manifest.permission.UPDATE_APP_OPS_STATS}) 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 @Deprecated @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback(@NonNull android.location.GnssRequest, @NonNull java.util.concurrent.Executor, @NonNull android.location.GnssMeasurementsEvent.Callback);
    method @Deprecated @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 @Deprecated @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 @Deprecated @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);
+19 −0
Original line number 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;

parcelable GnssMeasurementRequest;
+152 −0
Original line number 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.os.Parcel;
import android.os.Parcelable;

/**
 * This class contains extra parameters to pass in a GNSS measurement request.
 */
public final class GnssMeasurementRequest implements Parcelable {
    private final boolean mFullTracking;

    /**
     * Creates a {@link GnssMeasurementRequest} with a full list of parameters.
     */
    private GnssMeasurementRequest(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-blocklisted, healthy constellations, satellites and
     * frequency bands that the chipset supports must be reported in this mode. The GNSS chipset
     * will consume more power in full tracking mode than in duty cycling mode. If false, GNSS
     * chipset optimizes power via duty cycling, constellations and frequency limits, etc.
     *
     * <p>Full GNSS tracking mode affects GnssMeasurement and other GNSS functionalities
     * including GNSS location.
     */
    public boolean isFullTracking() {
        return mFullTracking;
    }

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

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

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

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

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

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

        return true;
    }

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

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

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

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

        /**
         * Constructs a {@link Builder} instance by copying a {@link GnssMeasurementRequest}.
         */
        public Builder(@NonNull GnssMeasurementRequest 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-blocklisted, healthy constellations, satellites and
         * frequency bands that the chipset supports must be reported in this mode. The GNSS chipset
         * will consume more power in full tracking mode than in duty cycling mode. If false,
         * GNSS chipset optimizes power via duty cycling, constellations and frequency limits, etc.
         *
         * <p>Full GNSS tracking mode affects GnssMeasurement and other GNSS functionalities
         * including GNSS location.
         *
         * <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 GnssMeasurementRequest} instance as specified by this builder. */
        @NonNull
        public GnssMeasurementRequest build() {
            return new GnssMeasurementRequest(mFullTracking);
        }
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -45,11 +45,23 @@ public final class GnssRequest implements Parcelable {
     * 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 GNSS tracking mode affects GnssMeasurement and other GNSS functionalities
     * including GNSS location.
     */
    public boolean isFullTracking() {
        return mFullTracking;
    }

    /**
     * Converts the {@link GnssRequest} into a {@link GnssMeasurementRequest}.
     * @hide
     */
    @NonNull
    public GnssMeasurementRequest toGnssMeasurementRequest() {
        return new GnssMeasurementRequest.Builder().setFullTracking(isFullTracking()).build();
    }

    @NonNull
    public static final Creator<GnssRequest> CREATOR =
            new Creator<GnssRequest>() {
@@ -131,6 +143,9 @@ public final class GnssRequest implements Parcelable {
         * 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 GNSS tracking mode affects GnssMeasurement and other GNSS functionalities
         * including GNSS location.
         *
         * <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.
Loading