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

Commit a83d5390 authored by Shinru Han's avatar Shinru Han Committed by Yu-Han Yang
Browse files

Fix GlonassAlmanac frequency channel range.

Frequency channel range should be -7..+6, not 0..31.

This is potentially a breaking change if the client mistakenly passes a negative number to the old API, which will lead to crashes. Therefore, the client must ensure check the flag fix_glonass_almanac_frequency_channel_range before using the API.

We are okay with this change because we are confident that no one has started to use this API yet.

Bug: 428050932
Bug: 358381377
Test: atest CtsLocationNoneTestCases
Flag: android.location.flags.fix_glonass_almanac_frequency_channel_range
Change-Id: I6cbe8ed011a70fd34e19a7d23920217b6fc850b8
parent 6a1aa798
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -313,7 +313,7 @@ package android.location {
    method @FloatRange(from=-3600.0F, to=3600.0f) public double getDeltaT();
    method @FloatRange(from=-0.004F, to=0.004f) public double getDeltaTDot();
    method @FloatRange(from=0.0f, to=0.03f) public double getEccentricity();
    method @IntRange(from=0, to=31) public int getFrequencyChannelNumber();
    method @IntRange(from=0xfffffff9, to=6) public int getFrequencyChannelNumber();
    method public int getHealthState();
    method @FloatRange(from=-1.0F, to=1.0f) public double getLambda();
    method @FloatRange(from=-1.0F, to=1.0f) public double getOmega();
@@ -333,7 +333,7 @@ package android.location {
    method @NonNull public android.location.GlonassAlmanac.GlonassSatelliteAlmanac.Builder setDeltaT(@FloatRange(from=-3600.0F, to=3600.0f) double);
    method @NonNull public android.location.GlonassAlmanac.GlonassSatelliteAlmanac.Builder setDeltaTDot(@FloatRange(from=-0.004F, to=0.004f) double);
    method @NonNull public android.location.GlonassAlmanac.GlonassSatelliteAlmanac.Builder setEccentricity(@FloatRange(from=0.0f, to=0.03f) double);
    method @NonNull public android.location.GlonassAlmanac.GlonassSatelliteAlmanac.Builder setFrequencyChannelNumber(@IntRange(from=0, to=31) int);
    method @NonNull public android.location.GlonassAlmanac.GlonassSatelliteAlmanac.Builder setFrequencyChannelNumber(@IntRange(from=0xfffffff9, to=6) int);
    method @NonNull public android.location.GlonassAlmanac.GlonassSatelliteAlmanac.Builder setGlonassM(boolean);
    method @NonNull public android.location.GlonassAlmanac.GlonassSatelliteAlmanac.Builder setHealthState(int);
    method @NonNull public android.location.GlonassAlmanac.GlonassSatelliteAlmanac.Builder setLambda(@FloatRange(from=-1.0F, to=1.0f) double);
+12 −7
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ public final class GlonassAlmanac implements Parcelable {
        /** Calendar day number within the four-year period beginning since the leap year. */
        private final int mCalendarDayNumber;

        /** Flag to indicates if the satellite is a GLONASS-M satellitee. */
        /** Flag to indicates if the satellite is a GLONASS-M satellite. */
        private final boolean mGlonassM;

        /** Coarse value of satellite time correction to GLONASS time in seconds. */
@@ -163,8 +163,13 @@ public final class GlonassAlmanac implements Parcelable {
            Preconditions.checkArgument(builder.mSlotNumber >= 1);
            // Allow healthState beyond the range to support potential future extensibility.
            Preconditions.checkArgument(builder.mHealthState >= 0);
            if (Flags.fixGlonassAlmanacFrequencyChannelRange()) {
                Preconditions.checkArgumentInRange(
                        builder.mFrequencyChannelNumber, -7, 6, "FrequencyChannelNumber");
            } else {
                Preconditions.checkArgumentInRange(
                        builder.mFrequencyChannelNumber, 0, 31, "FrequencyChannelNumber");
            }
            Preconditions.checkArgumentInRange(
                    builder.mCalendarDayNumber, 1, 1461, "CalendarDayNumber");
            Preconditions.checkArgumentInRange(builder.mTau, -1.9e-3f, 1.9e-3f, "Tau");
@@ -202,7 +207,7 @@ public final class GlonassAlmanac implements Parcelable {
        }

        /** Returns the frequency channel number. */
        @IntRange(from = 0, to = 31)
        @IntRange(from = -7, to = 6)
        public int getFrequencyChannelNumber() {
            return mFrequencyChannelNumber;
        }
@@ -216,7 +221,7 @@ public final class GlonassAlmanac implements Parcelable {
            return mCalendarDayNumber;
        }

        /** Returns true if the satellite is a GLONASS-M satellitee, false otherwise. */
        /** Returns true if the satellite is a GLONASS-M satellite, false otherwise. */
        public boolean isGlonassM() {
            return mGlonassM;
        }
@@ -375,7 +380,7 @@ public final class GlonassAlmanac implements Parcelable {
            /** Sets the frequency channel number. */
            @NonNull
            public Builder setFrequencyChannelNumber(
                    @IntRange(from = 0, to = 31) int frequencyChannelNumber) {
                    @IntRange(from = -7, to = 6) int frequencyChannelNumber) {
                mFrequencyChannelNumber = frequencyChannelNumber;
                return this;
            }
@@ -391,7 +396,7 @@ public final class GlonassAlmanac implements Parcelable {
                return this;
            }

            /** Sets to true if the satellite is a GLONASS-M satellitee, false otherwise. */
            /** Sets to true if the satellite is a GLONASS-M satellite, false otherwise. */
            @NonNull
            public Builder setGlonassM(boolean isGlonassM) {
                this.mGlonassM = isGlonassM;
+11 −1
Original line number Diff line number Diff line
@@ -212,3 +212,13 @@ flag {
    bug: "362287534"
    is_exported: true
}

flag {
    name: "fix_glonass_almanac_frequency_channel_range"
    namespace: "location"
    description: "Fix GLONASS almanac frequency channel range"
    bug: "428050932"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}