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
diff --git a/api/system-current.txt b/api/system-current.txt
index 5b153f0..5306d1e 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -2899,6 +2899,7 @@
     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 @@
     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 @@
     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 6c757f9..3922d2f 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 @@
 
     /**
      * 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 @@
     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 @@
         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 @@
         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 @@
         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 @@
                                     .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 @@
         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 @@
         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 @@
         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 @@
             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 c18d58f..d6227bb 100644
--- a/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java
+++ b/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java
@@ -59,7 +59,7 @@
         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 @@
                 .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 2e54ae4..f358806 100644
--- a/location/tests/locationtests/src/android/location/GnssSingleSatCorrectionsTest.java
+++ b/location/tests/locationtests/src/android/location/GnssSingleSatCorrectionsTest.java
@@ -44,7 +44,7 @@
         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 @@
                 .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 @@
                         .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 dcb2ff5..f3c19d0 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_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 @@
                 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 @@
             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 @@
             .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,