diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 05360141d9dd9..66e51d41b333a 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -4288,7 +4288,7 @@ package android.location { public final class CorrelationVector implements android.os.Parcelable { method public int describeContents(); - method @IntRange(from=0) public int getFrequencyOffsetMetersPerSecond(); + method @FloatRange(from=0.0f) public double getFrequencyOffsetMetersPerSecond(); method @NonNull public int[] getMagnitude(); method @FloatRange(from=0.0f) public double getSamplingStartMeters(); method @FloatRange(from=0.0f, fromInclusive=false) public double getSamplingWidthMeters(); @@ -4299,7 +4299,7 @@ package android.location { 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 setFrequencyOffsetMetersPerSecond(@FloatRange(from=0.0f) double); 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); diff --git a/location/java/android/location/CorrelationVector.java b/location/java/android/location/CorrelationVector.java index eca35dd69362f..4b6e6882b50ac 100644 --- a/location/java/android/location/CorrelationVector.java +++ b/location/java/android/location/CorrelationVector.java @@ -17,7 +17,6 @@ package android.location; import android.annotation.FloatRange; -import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.Parcel; @@ -39,7 +38,7 @@ public final class CorrelationVector implements Parcelable { private final double mSamplingWidthMeters; private final double mSamplingStartMeters; - private final int mFrequencyOffsetMetersPerSecond; + private final double mFrequencyOffsetMetersPerSecond; @NonNull private final int[] mMagnitude; /** @@ -66,8 +65,8 @@ public final class CorrelationVector implements Parcelable { /** * Returns the frequency offset from reported pseudorange rate for this CorrelationVector. */ - @IntRange(from = 0) - public int getFrequencyOffsetMetersPerSecond() { + @FloatRange(from = 0.0f) + public double getFrequencyOffsetMetersPerSecond() { return mFrequencyOffsetMetersPerSecond; } @@ -88,7 +87,7 @@ public final class CorrelationVector implements Parcelable { 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, + Preconditions.checkArgument(builder.mFrequencyOffsetMetersPerSecond >= 0.0, "FrequencyOffsetMetersPerSecond must be non-negative (greater than or equal to 0)"); Preconditions.checkArgument(builder.mSamplingWidthMeters > 0.0, "SamplingWidthMeters must be positive (greater than 0)"); @@ -103,7 +102,7 @@ public final class CorrelationVector implements Parcelable { private CorrelationVector(Parcel in) { mSamplingWidthMeters = in.readDouble(); mSamplingStartMeters = in.readDouble(); - mFrequencyOffsetMetersPerSecond = in.readInt(); + mFrequencyOffsetMetersPerSecond = in.readDouble(); mMagnitude = new int[in.readInt()]; in.readIntArray(mMagnitude); } @@ -144,7 +143,7 @@ public final class CorrelationVector implements Parcelable { public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeDouble(mSamplingWidthMeters); dest.writeDouble(mSamplingStartMeters); - dest.writeInt(mFrequencyOffsetMetersPerSecond); + dest.writeDouble(mFrequencyOffsetMetersPerSecond); dest.writeInt(mMagnitude.length); dest.writeIntArray(mMagnitude); } @@ -165,7 +164,7 @@ public final class CorrelationVector implements Parcelable { return Arrays.equals(mMagnitude, c.getMagnitude()) && Double.compare(mSamplingWidthMeters, c.getSamplingWidthMeters()) == 0 && Double.compare(mSamplingStartMeters, c.getSamplingStartMeters()) == 0 - && Integer.compare(mFrequencyOffsetMetersPerSecond, + && Double.compare(mFrequencyOffsetMetersPerSecond, c.getFrequencyOffsetMetersPerSecond()) == 0; } @@ -182,7 +181,7 @@ public final class CorrelationVector implements Parcelable { private double mSamplingWidthMeters; private double mSamplingStartMeters; - private int mFrequencyOffsetMetersPerSecond; + private double mFrequencyOffsetMetersPerSecond; @NonNull private int[] mMagnitude; /** Sets the space between correlation samples in meters. */ @@ -203,7 +202,7 @@ public final class CorrelationVector implements Parcelable { /** Sets the frequency offset from reported pseudorange rate for this CorrelationVector */ @NonNull public Builder setFrequencyOffsetMetersPerSecond( - @IntRange(from = 0) int frequencyOffsetMetersPerSecond) { + @FloatRange(from = 0.0f) double frequencyOffsetMetersPerSecond) { mFrequencyOffsetMetersPerSecond = frequencyOffsetMetersPerSecond; return this; } diff --git a/services/core/jni/gnss/GnssMeasurementCallback.cpp b/services/core/jni/gnss/GnssMeasurementCallback.cpp index 757381dff80af..945694649f920 100644 --- a/services/core/jni/gnss/GnssMeasurementCallback.cpp +++ b/services/core/jni/gnss/GnssMeasurementCallback.cpp @@ -131,7 +131,7 @@ void GnssMeasurement_class_init_once(JNIEnv* env, jclass& clazz) { "([I)Landroid/location/CorrelationVector$Builder;"); method_correlationVectorBuilderSetFrequencyOffsetMetersPerSecond = env->GetMethodID(class_correlationVectorBuilder, "setFrequencyOffsetMetersPerSecond", - "(I)Landroid/location/CorrelationVector$Builder;"); + "(D)Landroid/location/CorrelationVector$Builder;"); method_correlationVectorBuilderSetSamplingStartMeters = env->GetMethodID(class_correlationVectorBuilder, "setSamplingStartMeters", "(D)Landroid/location/CorrelationVector$Builder;");