diff options
author | gomo <gomo@google.com> | 2019-01-17 04:02:53 -0800 |
---|---|---|
committer | gomo <gomo@google.com> | 2019-01-18 11:16:01 -0800 |
commit | b4635ba90d873be4e2aa034c9de178a231b75427 (patch) | |
tree | c0303c065cfb72d720244cc571312df1e2cf05df | |
parent | 2b8e3132f5ed256aa39c57fa707fee73cf96fa1e (diff) |
Bluesky change LOS from bool to float prob
Change the field indicating that the GNSS satellite is line of sight
or not from boolean to a float representing hte probability of being
line of sight.
Bug: 111441283
Test: Existing tests pass.
Change-Id: I746d7b16dcbb7c8968163f512a70aac7511402b6
5 files changed, 47 insertions, 32 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 5b153f04945b..5306d1ec5ff2 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -2899,6 +2899,7 @@ package android.location { method public int getConstellationType(); method public float getExcessPathLengthMeters(); method public float getExcessPathLengthUncertaintyMeters(); + method public float getProbSatIsLos(); method public android.location.GnssReflectingPlane getReflectingPlane(); method public int getSatId(); method public int getSingleSatCorrectionFlags(); @@ -2906,13 +2907,12 @@ package android.location { method public boolean hasExcessPathLengthUncertainty(); method public boolean hasReflectingPlane(); method public boolean hasSatelliteLineOfSight(); - method public boolean isSatelliteLineOfSight(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.location.GnssSingleSatCorrection> CREATOR; field public static final int HAS_EXCESS_PATH_LENGTH_MASK = 2; // 0x2 field public static final int HAS_EXCESS_PATH_LENGTH_UNC_MASK = 4; // 0x4 + field public static final int HAS_PROB_SAT_IS_LOS_MASK = 1; // 0x1 field public static final int HAS_REFLECTING_PLANE_MASK = 8; // 0x8 - field public static final int HAS_SAT_IS_LOS_MASK = 1; // 0x1 } public static class GnssSingleSatCorrection.Builder { @@ -2922,9 +2922,9 @@ package android.location { method public android.location.GnssSingleSatCorrection.Builder setConstellationType(int); method public android.location.GnssSingleSatCorrection.Builder setExcessPathLengthMeters(float); method public android.location.GnssSingleSatCorrection.Builder setExcessPathLengthUncertaintyMeters(float); + method public android.location.GnssSingleSatCorrection.Builder setProbSatIsLos(float); method public android.location.GnssSingleSatCorrection.Builder setReflectingPlane(android.location.GnssReflectingPlane); method public android.location.GnssSingleSatCorrection.Builder setSatId(int); - method public android.location.GnssSingleSatCorrection.Builder setSatIsLos(boolean); method public android.location.GnssSingleSatCorrection.Builder setSingleSatCorrectionFlags(int); } diff --git a/location/java/android/location/GnssSingleSatCorrection.java b/location/java/android/location/GnssSingleSatCorrection.java index 6c757f949f19..3922d2f9f558 100644 --- a/location/java/android/location/GnssSingleSatCorrection.java +++ b/location/java/android/location/GnssSingleSatCorrection.java @@ -16,11 +16,14 @@ package android.location; +import android.annotation.FloatRange; import android.annotation.Nullable; import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; +import com.android.internal.util.Preconditions; + /** * A container with measurement corrections for a single visible satellite * @@ -31,9 +34,9 @@ public final class GnssSingleSatCorrection implements Parcelable { /** * Bit mask for {@link #mSingleSatCorrectionFlags} indicating the presence of {@link - * #mSatIsLos}. + * #mProbSatIsLos}. */ - public static final int HAS_SAT_IS_LOS_MASK = 1 << 0; + public static final int HAS_PROB_SAT_IS_LOS_MASK = 1 << 0; /** * Bit mask for {@link #mSingleSatCorrectionFlags} indicating the presence of {@link @@ -78,9 +81,11 @@ public final class GnssSingleSatCorrection implements Parcelable { private float mCarrierFrequencyHz; /** - * True if the satellite is estimated to be in Line-of-Sight condition at the given location. + * The probability that the satellite is estimated to be in Line-of-Sight condition at the given + * location. */ - private boolean mSatIsLos; + @FloatRange(from = 0f, to = 1f) + private float mProbSatIsLos; /** * Excess path length to be subtracted from pseudorange before using it in calculating location. @@ -103,7 +108,7 @@ public final class GnssSingleSatCorrection implements Parcelable { mSatId = builder.mSatId; mConstellationType = builder.mConstellationType; mCarrierFrequencyHz = builder.mCarrierFrequencyHz; - mSatIsLos = builder.mSatIsLos; + mProbSatIsLos = builder.mProbSatIsLos; mExcessPathLengthMeters = builder.mExcessPathLengthMeters; mExcessPathLengthUncertaintyMeters = builder.mExcessPathLengthUncertaintyMeters; mReflectingPlane = builder.mReflectingPlane; @@ -152,9 +157,13 @@ public final class GnssSingleSatCorrection implements Parcelable { return mCarrierFrequencyHz; } - /** True if the satellite is line-of-sight */ - public boolean isSatelliteLineOfSight() { - return mSatIsLos; + /** + * Returns the probability that the satellite is in line-of-sight condition at the given + * location. + */ + @FloatRange(from = 0f, to = 1f) + public float getProbSatIsLos() { + return mProbSatIsLos; } /** @@ -180,9 +189,9 @@ public final class GnssSingleSatCorrection implements Parcelable { return mReflectingPlane; } - /** Returns {@code true} if {@link #isSatelliteLineOfSight()} is valid. */ + /** Returns {@code true} if {@link #getProbSatIsLos()} is valid. */ public boolean hasSatelliteLineOfSight() { - return (mSingleSatCorrectionFlags & HAS_SAT_IS_LOS_MASK) != 0; + return (mSingleSatCorrectionFlags & HAS_PROB_SAT_IS_LOS_MASK) != 0; } /** Returns {@code true} if {@link #getExcessPathLengthMeters()} is valid. */ @@ -215,7 +224,7 @@ public final class GnssSingleSatCorrection implements Parcelable { .setConstellationType(parcel.readInt()) .setSatId(parcel.readInt()) .setCarrierFrequencyHz(parcel.readFloat()) - .setSatIsLos(parcel.readBoolean()) + .setProbSatIsLos(parcel.readFloat()) .setExcessPathLengthMeters(parcel.readFloat()) .setExcessPathLengthUncertaintyMeters(parcel.readFloat()) .setReflectingPlane( @@ -239,7 +248,7 @@ public final class GnssSingleSatCorrection implements Parcelable { builder.append(String.format(format, "ConstellationType = ", mConstellationType)); builder.append(String.format(format, "SatId = ", mSatId)); builder.append(String.format(format, "CarrierFrequencyHz = ", mCarrierFrequencyHz)); - builder.append(String.format(format, "SatIsLos = ", mSatIsLos)); + builder.append(String.format(format, "ProbSatIsLos = ", mProbSatIsLos)); builder.append(String.format(format, "ExcessPathLengthMeters = ", mExcessPathLengthMeters)); builder.append( String.format( @@ -256,7 +265,7 @@ public final class GnssSingleSatCorrection implements Parcelable { parcel.writeInt(mConstellationType); parcel.writeInt(mSatId); parcel.writeFloat(mCarrierFrequencyHz); - parcel.writeBoolean(mSatIsLos); + parcel.writeFloat(mProbSatIsLos); parcel.writeFloat(mExcessPathLengthMeters); parcel.writeFloat(mExcessPathLengthUncertaintyMeters); mReflectingPlane.writeToParcel(parcel, flags); @@ -274,7 +283,7 @@ public final class GnssSingleSatCorrection implements Parcelable { private int mConstellationType; private int mSatId; private float mCarrierFrequencyHz; - private boolean mSatIsLos; + private float mProbSatIsLos; private float mExcessPathLengthMeters; private float mExcessPathLengthUncertaintyMeters; private GnssReflectingPlane mReflectingPlane; @@ -303,10 +312,16 @@ public final class GnssSingleSatCorrection implements Parcelable { return this; } - /** Sets the line=of-sight state of the satellite */ - public Builder setSatIsLos(boolean satIsLos) { - mSatIsLos = satIsLos; - mSingleSatCorrectionFlags = (byte) (mSingleSatCorrectionFlags | HAS_SAT_IS_LOS_MASK); + /** + * Sets the line-of-sight probability of the satellite at the given location in the range + * between 0 and 1. + */ + public Builder setProbSatIsLos(@FloatRange(from = 0f, to = 1f) float probSatIsLos) { + Preconditions.checkArgumentInRange(probSatIsLos, 0, 1, + "probSatIsLos should be between 0 and 1."); + mProbSatIsLos = probSatIsLos; + mSingleSatCorrectionFlags = + (byte) (mSingleSatCorrectionFlags | HAS_PROB_SAT_IS_LOS_MASK); return this; } diff --git a/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java b/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java index c18d58f9a704..d6227bbfcd0d 100644 --- a/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java +++ b/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java @@ -59,7 +59,7 @@ public class GnssMeasurementCorrectionsTest extends TestCase { assertEquals(GnssStatus.CONSTELLATION_GPS, singleSatCorrection.getConstellationType()); assertEquals(11, singleSatCorrection.getSatId()); assertEquals(1575430000f, singleSatCorrection.getCarrierFrequencyHz()); - assertEquals(false, singleSatCorrection.isSatelliteLineOfSight()); + assertEquals(0.9f, singleSatCorrection.getProbSatIsLos()); assertEquals(50.0f, singleSatCorrection.getExcessPathLengthMeters()); assertEquals(55.0f, singleSatCorrection.getExcessPathLengthUncertaintyMeters()); GnssReflectingPlane reflectingPlane = singleSatCorrection.getReflectingPlane(); @@ -88,7 +88,7 @@ public class GnssMeasurementCorrectionsTest extends TestCase { .setConstellationType(GnssStatus.CONSTELLATION_GPS) .setSatId(11) .setCarrierFrequencyHz(1575430000f) - .setSatIsLos(false) + .setProbSatIsLos(0.9f) .setExcessPathLengthMeters(50.0f) .setExcessPathLengthUncertaintyMeters(55.0f) .setReflectingPlane(generateTestReflectingPlane()); diff --git a/location/tests/locationtests/src/android/location/GnssSingleSatCorrectionsTest.java b/location/tests/locationtests/src/android/location/GnssSingleSatCorrectionsTest.java index 2e54ae463595..f358806d0b26 100644 --- a/location/tests/locationtests/src/android/location/GnssSingleSatCorrectionsTest.java +++ b/location/tests/locationtests/src/android/location/GnssSingleSatCorrectionsTest.java @@ -44,7 +44,7 @@ public class GnssSingleSatCorrectionsTest extends TestCase { assertEquals(GnssStatus.CONSTELLATION_GALILEO, singleSatCorrection.getConstellationType()); assertEquals(12, singleSatCorrection.getSatId()); assertEquals(1575420000f, singleSatCorrection.getCarrierFrequencyHz()); - assertEquals(true, singleSatCorrection.isSatelliteLineOfSight()); + assertEquals(0.1f, singleSatCorrection.getProbSatIsLos()); assertEquals(10.0f, singleSatCorrection.getExcessPathLengthMeters()); assertEquals(5.0f, singleSatCorrection.getExcessPathLengthUncertaintyMeters()); GnssReflectingPlane reflectingPlane = singleSatCorrection.getReflectingPlane(); @@ -58,7 +58,7 @@ public class GnssSingleSatCorrectionsTest extends TestCase { .setConstellationType(singleSatCorr.getConstellationType()) .setSatId(singleSatCorr.getSatId()) .setCarrierFrequencyHz(singleSatCorr.getCarrierFrequencyHz()) - .setSatIsLos(singleSatCorr.isSatelliteLineOfSight()) + .setProbSatIsLos(singleSatCorr.getProbSatIsLos()) .setExcessPathLengthMeters(singleSatCorr.getExcessPathLengthMeters()) .setExcessPathLengthUncertaintyMeters( singleSatCorr.getExcessPathLengthUncertaintyMeters()) @@ -72,7 +72,7 @@ public class GnssSingleSatCorrectionsTest extends TestCase { .setConstellationType(GnssStatus.CONSTELLATION_GALILEO) .setSatId(12) .setCarrierFrequencyHz(1575420000f) - .setSatIsLos(true) + .setProbSatIsLos(0.1f) .setExcessPathLengthMeters(10.0f) .setExcessPathLengthUncertaintyMeters(5.0f) .setReflectingPlane(GnssReflectingPlaneTest.generateTestReflectingPlane()); diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp index dcb2ff5f9df5..f3c19d099851 100644 --- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp +++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp @@ -81,7 +81,7 @@ static jmethodID method_correctionSatFlags; static jmethodID method_correctionSatConstType; static jmethodID method_correctionSatId; static jmethodID method_correctionSatCarrierFreq; -static jmethodID method_correctionSatIsLos; +static jmethodID method_correctionSatIsLosProb; static jmethodID method_correctionSatEpl; static jmethodID method_correctionSatEplUnc; static jmethodID method_correctionSatRefPlane; @@ -2277,8 +2277,8 @@ static jboolean android_location_GnssMeasurementsProvider_inject_gnss_measuremen singleSatCorrClass, "getSatId", "()I"); method_correctionSatCarrierFreq = env->GetMethodID( singleSatCorrClass, "getCarrierFrequencyHz", "()F"); - method_correctionSatIsLos = env->GetMethodID( - singleSatCorrClass,"getSatIsLos", "()Z"); + method_correctionSatIsLosProb = env->GetMethodID( + singleSatCorrClass,"getProbSatIsLos", "()F"); method_correctionSatEpl = env->GetMethodID( singleSatCorrClass, "getExcessPathLengthMeters", "()F"); method_correctionSatEplUnc = env->GetMethodID( @@ -2296,8 +2296,8 @@ static jboolean android_location_GnssMeasurementsProvider_inject_gnss_measuremen env->CallIntMethod(singleSatCorrectionObj, method_correctionSatId); jfloat carrierFreqHz = env->CallFloatMethod( singleSatCorrectionObj, method_correctionSatCarrierFreq); - jboolean satIsLos = env->CallBooleanMethod(singleSatCorrectionObj, - method_correctionSatIsLos); + jfloat probSatIsLos = env->CallFloatMethod(singleSatCorrectionObj, + method_correctionSatIsLosProb); jfloat eplMeters = env->CallFloatMethod(singleSatCorrectionObj, method_correctionSatEpl); jfloat eplUncMeters = env->CallFloatMethod(singleSatCorrectionObj, @@ -2337,7 +2337,7 @@ static jboolean android_location_GnssMeasurementsProvider_inject_gnss_measuremen .constellation = static_cast<GnssConstellationType>(constType), .svid = static_cast<uint16_t>(satId), .carrierFrequencyHz = carrierFreqHz, - .satIsLos = static_cast<bool>(satIsLos), + .probSatIsLos = probSatIsLos, .excessPathLengthMeters = eplMeters, .excessPathLengthUncertaintyMeters = eplUncMeters, .reflectingPlane = reflectingPlane, |