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

Commit 839c1cd5 authored by Shinru Han's avatar Shinru Han Committed by Android (Google) Code Review
Browse files

Merge changes from topic "gnss-correlation-vector-aidl"

* changes:
  Add CorrelationVector AIDL (framework/base)
  Add CorrelationVector AIDL in JNI
parents bb8cea62 daffd228
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -3983,6 +3983,25 @@ package android.location {
    method public void onLocationBatch(java.util.List<android.location.Location>);
  }
  public final class CorrelationVector implements android.os.Parcelable {
    method public int describeContents();
    method @IntRange(from=0) public int getFrequencyOffsetMetersPerSecond();
    method @NonNull public int[] getMagnitude();
    method @FloatRange(from=0.0f) public double getSamplingStartMeters();
    method @FloatRange(from=0.0f, fromInclusive=false) public double getSamplingWidthMeters();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.location.CorrelationVector> CREATOR;
  }
  public static final class CorrelationVector.Builder {
    ctor public CorrelationVector.Builder();
    method @NonNull public android.location.CorrelationVector build();
    method @NonNull public android.location.CorrelationVector.Builder setFrequencyOffsetMetersPerSecond(@IntRange(from=0) int);
    method @NonNull public android.location.CorrelationVector.Builder setMagnitude(@NonNull int[]);
    method @NonNull public android.location.CorrelationVector.Builder setSamplingStartMeters(@FloatRange(from=0.0f) double);
    method @NonNull public android.location.CorrelationVector.Builder setSamplingWidthMeters(@FloatRange(from=0.0f, fromInclusive=false) double);
  }
  public final class GnssCapabilities implements android.os.Parcelable {
    method public boolean hasGeofencing();
    method public boolean hasLowPowerMode();
@@ -3991,6 +4010,7 @@ package android.location {
    method public boolean hasMeasurementCorrectionsLosSats();
    method @Deprecated public boolean hasMeasurementCorrectionsReflectingPane();
    method public boolean hasMeasurementCorrectionsReflectingPlane();
    method public boolean hasMeasurementCorrelationVectors();
    method @Deprecated public boolean hasNavMessages();
    method @Deprecated public boolean hasSatelliteBlacklist();
    method public boolean hasSatelliteBlocklist();
@@ -4004,12 +4024,15 @@ package android.location {
    method @NonNull public android.location.GnssCapabilities.Builder setHasMeasurementCorrectionsExcessPathLength(boolean);
    method @NonNull public android.location.GnssCapabilities.Builder setHasMeasurementCorrectionsLosSats(boolean);
    method @NonNull public android.location.GnssCapabilities.Builder setHasMeasurementCorrectionsReflectingPlane(boolean);
    method @NonNull public android.location.GnssCapabilities.Builder setHasMeasurementCorrelationVectors(boolean);
    method @NonNull public android.location.GnssCapabilities.Builder setHasSatelliteBlocklist(boolean);
    method @NonNull public android.location.GnssCapabilities.Builder setHasSatellitePvt(boolean);
  }
  public final class GnssMeasurement implements android.os.Parcelable {
    method @Nullable public java.util.Collection<android.location.CorrelationVector> getCorrelationVectors();
    method @Nullable public android.location.SatellitePvt getSatellitePvt();
    method public boolean hasCorrelationVectors();
    method public boolean hasSatellitePvt();
  }
@@ -4043,6 +4066,14 @@ package android.location {
    method @NonNull public android.location.GnssMeasurementCorrections.Builder setVerticalPositionUncertaintyMeters(@FloatRange(from=0.0f) double);
  }
  public final class GnssMeasurementRequest implements android.os.Parcelable {
    method public boolean isCorrelationVectorOutputsEnabled();
  }
  public static final class GnssMeasurementRequest.Builder {
    method @NonNull public android.location.GnssMeasurementRequest.Builder setCorrelationVectorOutputsEnabled(boolean);
  }
  public final class GnssReflectingPlane implements android.os.Parcelable {
    method public int describeContents();
    method @FloatRange(from=-1000.0F, to=10000.0f) public double getAltitudeMeters();
+2 −0
Original line number Diff line number Diff line
@@ -941,6 +941,7 @@ package android.location {
    method @Deprecated public void resetCarrierPhase();
    method @Deprecated public void resetCarrierPhaseUncertainty();
    method public void resetCodeType();
    method public void resetCorrelationVectors();
    method public void resetFullInterSignalBiasNanos();
    method public void resetFullInterSignalBiasUncertaintyNanos();
    method public void resetSatelliteInterSignalBiasNanos();
@@ -960,6 +961,7 @@ package android.location {
    method public void setCn0DbHz(double);
    method public void setCodeType(@NonNull String);
    method public void setConstellationType(int);
    method public void setCorrelationVectors(@Nullable java.util.Collection<android.location.CorrelationVector>);
    method public void setFullInterSignalBiasNanos(double);
    method public void setFullInterSignalBiasUncertaintyNanos(@FloatRange(from=0.0) double);
    method public void setMultipathIndicator(int);
+2 −0
Original line number Diff line number Diff line
@@ -469,6 +469,8 @@ GetterSetterNames: android.location.GnssMeasurement#setCarrierFrequencyHz(float)
    
GetterSetterNames: android.location.GnssMeasurement#setCodeType(String):

GetterSetterNames: android.location.GnssMeasurement#setCorrelationVectors(java.util.Collection<android.location.CorrelationVector>):
    
GetterSetterNames: android.location.GnssMeasurement#setFullInterSignalBiasNanos(double):
    
GetterSetterNames: android.location.GnssMeasurement#setFullInterSignalBiasUncertaintyNanos(double):
+228 −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.FloatRange;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

import com.android.internal.util.Preconditions;

import java.util.Arrays;
import java.util.Objects;

/**
 * Contains info about the correlation output of incoming GNSS signal and a local copy of
 * its corresponding spreading code at a given frequency offset.
 *
 * @hide
 */
@SystemApi
public final class CorrelationVector implements Parcelable {

    private final double mSamplingWidthMeters;
    private final double mSamplingStartMeters;
    private final int mFrequencyOffsetMetersPerSecond;
    @NonNull private final int[] mMagnitude;

    /**
     * Returns the space between correlation samples in meters.
     */
    @FloatRange(from = 0.0f, fromInclusive = false)
    public double getSamplingWidthMeters() {
        return mSamplingWidthMeters;
    }

    /**
     * Returns the offset of the first sampling bin in meters.
     *
     * <p>The following sampling bins are located at positive offsets from this value as follows:
     * samplingStartMeters, samplingStartMeters + samplingWidthMeters, ... , samplingStartMeters +
     * (magnitude.size-1) * samplingWidthMeters.
     *
     */
    @FloatRange(from = 0.0f)
    public double getSamplingStartMeters() {
        return mSamplingStartMeters;
    }

    /**
     * Returns the frequency offset from reported pseudorange rate for this CorrelationVector.
     */
    @IntRange(from = 0)
    public int getFrequencyOffsetMetersPerSecond() {
        return mFrequencyOffsetMetersPerSecond;
    }

    /**
     * Returns the data array representing normalized correlation magnitude values.
     *
     * <p>The data are normalized correlation magnitude values from -1 to 1, the reported value must
     * be encoded as signed 16 bit integer where 1 is represented by 32767 and -1 is represented
     * by -32768.
     *
     */
    @NonNull
    public int[] getMagnitude() {
        return mMagnitude.clone();
    }

    private CorrelationVector(Builder builder) {
        Preconditions.checkNotNull(builder.mMagnitude, "Magnitude array must not be null");
        Preconditions.checkArgumentPositive(builder.mMagnitude.length,
                "Magnitude array must have non-zero length");
        Preconditions.checkArgumentNonNegative(builder.mFrequencyOffsetMetersPerSecond,
                "FrequencyOffsetMetersPerSecond must be non-negative (greater than or equal to 0)");
        Preconditions.checkArgument(builder.mSamplingWidthMeters > 0.0,
                "SamplingWidthMeters must be positive (greater than 0)");
        Preconditions.checkArgument(builder.mSamplingStartMeters >= 0.0,
                "SamplingStartMeters must be non-negative (greater than or equal to 0)");
        mMagnitude = builder.mMagnitude;
        mFrequencyOffsetMetersPerSecond = builder.mFrequencyOffsetMetersPerSecond;
        mSamplingWidthMeters = builder.mSamplingWidthMeters;
        mSamplingStartMeters = builder.mSamplingStartMeters;
    }

    private CorrelationVector(Parcel in) {
        mSamplingWidthMeters = in.readDouble();
        mSamplingStartMeters = in.readDouble();
        mFrequencyOffsetMetersPerSecond = in.readInt();
        mMagnitude = new int[in.readInt()];
        in.readIntArray(mMagnitude);
    }

    /*
     * Method definitions to support Parcelable operations.
     */
    public static final @NonNull Parcelable.Creator<CorrelationVector> CREATOR =
            new Parcelable.Creator<CorrelationVector>() {
                @Override
                public CorrelationVector createFromParcel(Parcel parcel) {
                    return new CorrelationVector(parcel);
                }

                @Override
                public CorrelationVector[] newArray(int size) {
                    return new CorrelationVector[size];
                }
            };

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

    @NonNull
    @Override
    public String toString() {
        return "CorrelationVector{"
                + "FrequencyOffsetMetersPerSecond=" + mFrequencyOffsetMetersPerSecond
                + ", SamplingWidthMeters=" + mSamplingWidthMeters
                + ", SamplingStartMeters=" + mSamplingStartMeters
                + ", Magnitude=" + Arrays.toString(mMagnitude)
                + '}';
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeDouble(mSamplingWidthMeters);
        dest.writeDouble(mSamplingStartMeters);
        dest.writeInt(mFrequencyOffsetMetersPerSecond);
        dest.writeInt(mMagnitude.length);
        dest.writeIntArray(mMagnitude);
    }

    /**
     * Returns true if this {@link CorrelationVector} is equivalent to the given object.
     * Returns false otherwise.
     */
    @Override
    public boolean equals(Object object) {
        if (object == this) {
            return true;
        }
        if (!(object instanceof CorrelationVector)) {
            return false;
        }
        CorrelationVector c = (CorrelationVector) object;
        return Arrays.equals(mMagnitude, c.getMagnitude())
                && Double.compare(mSamplingWidthMeters, c.getSamplingWidthMeters()) == 0
                && Double.compare(mSamplingStartMeters, c.getSamplingStartMeters()) == 0
                && Integer.compare(mFrequencyOffsetMetersPerSecond,
                        c.getFrequencyOffsetMetersPerSecond()) == 0;
    }

    @Override
    public int hashCode() {
        return Objects.hash(mSamplingWidthMeters, mSamplingStartMeters,
                mFrequencyOffsetMetersPerSecond, Arrays.hashCode(mMagnitude));
    }

    /**
     * Builder class for CorrelationVector.
     */
    public static final class Builder {

        private double mSamplingWidthMeters;
        private double mSamplingStartMeters;
        private int mFrequencyOffsetMetersPerSecond;
        @NonNull private int[] mMagnitude;

        /** Sets the space between correlation samples in meters. */
        @NonNull
        public Builder setSamplingWidthMeters(
                @FloatRange(from = 0.0f, fromInclusive = false) double samplingWidthMeters) {
            mSamplingWidthMeters = samplingWidthMeters;
            return this;
        }

        /** Sets the offset of the first sampling bin in meters. */
        @NonNull
        public Builder setSamplingStartMeters(@FloatRange(from = 0.0f) double samplingStartMeters) {
            mSamplingStartMeters = samplingStartMeters;
            return this;
        }

        /** Sets the frequency offset from reported pseudorange rate for this CorrelationVector */
        @NonNull
        public Builder setFrequencyOffsetMetersPerSecond(
                @IntRange(from = 0) int frequencyOffsetMetersPerSecond) {
            mFrequencyOffsetMetersPerSecond = frequencyOffsetMetersPerSecond;
            return this;
        }

        /** Sets the data array representing normalized correlation magnitude values. */
        @NonNull
        public Builder setMagnitude(@NonNull int[] magnitude) {
            mMagnitude = magnitude;
            return this;
        }

        /**
         * Build CorrelationVector object.
         *
         * @return instance of CorrelationVector
         */
        @NonNull
        public CorrelationVector build() {
            return new CorrelationVector(this);
        }
    }
}
+29 −1
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@ public final class GnssCapabilities implements Parcelable {
    /** @hide */
    public static final int TOP_HAL_CAPABILITY_ANTENNA_INFO = 2048;
    /** @hide */
    public static final int TOP_HAL_CAPABILITY_CORRELATION_VECTOR = 4096;
    /** @hide */
    public static final int TOP_HAL_CAPABILITY_SATELLITE_PVT = 8192;

    /** @hide */
@@ -67,7 +69,8 @@ public final class GnssCapabilities implements Parcelable {
            TOP_HAL_CAPABILITY_MEASUREMENTS, TOP_HAL_CAPABILITY_NAV_MESSAGES,
            TOP_HAL_CAPABILITY_LOW_POWER_MODE, TOP_HAL_CAPABILITY_SATELLITE_BLOCKLIST,
            TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS, TOP_HAL_CAPABILITY_ANTENNA_INFO,
            TOP_HAL_CAPABILITY_SATELLITE_PVT})
            TOP_HAL_CAPABILITY_CORRELATION_VECTOR, TOP_HAL_CAPABILITY_SATELLITE_PVT})

    @Retention(RetentionPolicy.SOURCE)
    public @interface TopHalCapabilityFlags {}

@@ -336,6 +339,17 @@ public final class GnssCapabilities implements Parcelable {
        return (mTopFlags & TOP_HAL_CAPABILITY_ANTENNA_INFO) != 0;
    }

    /**
     * Returns {@code true} if GNSS chipset supports correlation vectors as part of measurements
     * outputs, {@code false} otherwise.
     *
     * @hide
     */
    @SystemApi
    public boolean hasMeasurementCorrelationVectors() {
        return (mTopFlags & TOP_HAL_CAPABILITY_CORRELATION_VECTOR) != 0;
    }

    /**
     * Returns {@code true} if GNSS chipset supports line-of-sight satellite identification
     * measurement corrections, {@code false} otherwise.
@@ -533,6 +547,9 @@ public final class GnssCapabilities implements Parcelable {
        if (hasAntennaInfo()) {
            builder.append("ANTENNA_INFO ");
        }
        if (hasMeasurementCorrelationVectors()) {
            builder.append("MEASUREMENT_CORRELATION_VECTORS ");
        }
        if (hasMeasurementCorrectionsLosSats()) {
            builder.append("LOS_SATS ");
        }
@@ -719,6 +736,17 @@ public final class GnssCapabilities implements Parcelable {
            return this;
        }

        /**
         * Sets correlation vector capability.
         *
         * @hide
         */
        @SystemApi
        public @NonNull Builder setHasMeasurementCorrelationVectors(boolean capable) {
            mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_CORRELATION_VECTOR, capable);
            return this;
        }

        /**
         * Sets measurement corrections line-of-sight satellites capabilitity.
         *
Loading