diff options
5 files changed, 89 insertions, 5 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 31e6c6c04386..1c6e64805ed5 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -2929,10 +2929,12 @@ package android.location { public final class GnssMeasurementCorrections implements android.os.Parcelable { method public int describeContents(); method public double getAltitudeMeters(); + method public double getHorizontalPositionUncertaintyMeters(); method public double getLatitudeDegrees(); method public double getLongitudeDegrees(); method @Nullable public java.util.List<android.location.GnssSingleSatCorrection> getSingleSatCorrectionList(); method public long getToaGpsNanosecondsOfWeek(); + method public double getVerticalPositionUncertaintyMeters(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.location.GnssMeasurementCorrections> CREATOR; } @@ -2941,10 +2943,12 @@ package android.location { ctor public GnssMeasurementCorrections.Builder(); method public android.location.GnssMeasurementCorrections build(); method public android.location.GnssMeasurementCorrections.Builder setAltitudeMeters(double); + method public android.location.GnssMeasurementCorrections.Builder setHorizontalPositionUncertaintyMeters(double); method public android.location.GnssMeasurementCorrections.Builder setLatitudeDegrees(double); method public android.location.GnssMeasurementCorrections.Builder setLongitudeDegrees(double); method public android.location.GnssMeasurementCorrections.Builder setSingleSatCorrectionList(@Nullable java.util.List<android.location.GnssSingleSatCorrection>); method public android.location.GnssMeasurementCorrections.Builder setToaGpsNanosecondsOfWeek(long); + method public android.location.GnssMeasurementCorrections.Builder setVerticalPositionUncertaintyMeters(double); } public final class GnssReflectingPlane implements android.os.Parcelable { diff --git a/location/java/android/location/GnssMeasurementCorrections.java b/location/java/android/location/GnssMeasurementCorrections.java index b81bf908053c..3ce48b4f7627 100644 --- a/location/java/android/location/GnssMeasurementCorrections.java +++ b/location/java/android/location/GnssMeasurementCorrections.java @@ -43,13 +43,27 @@ public final class GnssMeasurementCorrections implements Parcelable { * are computed. */ private double mAltitudeMeters; + /** + * Represents the horizontal uncertainty (68% confidence) in meters on the device position at + * which the corrections are provided. + * + * <p> This value is useful for example to judge how accurate the provided corrections are. + */ + private double mHorizontalPositionUncertaintyMeters; + /** + * Represents the vertical uncertainty (68% confidence) in meters on the device position at + * which the corrections are provided. + * + * <p> This value is useful for example to judge how accurate the provided corrections are. + */ + private double mVerticalPositionUncertaintyMeters; - /** Time Of Applicability, GPS time of week */ + /** Time Of Applicability, GPS time of week in nanoseconds. */ private long mToaGpsNanosecondsOfWeek; /** * A set of {@link GnssSingleSatCorrection} each containing measurement corrections for a - * satellite in view + * satellite in view. */ private @Nullable List<GnssSingleSatCorrection> mSingleSatCorrectionList; @@ -57,6 +71,8 @@ public final class GnssMeasurementCorrections implements Parcelable { mLatitudeDegrees = builder.mLatitudeDegrees; mLongitudeDegrees = builder.mLongitudeDegrees; mAltitudeMeters = builder.mAltitudeMeters; + mHorizontalPositionUncertaintyMeters = builder.mHorizontalPositionUncertaintyMeters; + mVerticalPositionUncertaintyMeters = builder.mVerticalPositionUncertaintyMeters; mToaGpsNanosecondsOfWeek = builder.mToaGpsNanosecondsOfWeek; mSingleSatCorrectionList = builder.mSingleSatCorrectionList == null @@ -83,6 +99,22 @@ public final class GnssMeasurementCorrections implements Parcelable { return mAltitudeMeters; } + /** + * Gets the horizontal uncertainty (68% confidence) in meters on the device position at + * which the corrections are provided. + */ + public double getHorizontalPositionUncertaintyMeters() { + return mHorizontalPositionUncertaintyMeters; + } + + /** + * Gets the vertical uncertainty (68% confidence) in meters on the device position at + * which the corrections are provided. + */ + public double getVerticalPositionUncertaintyMeters() { + return mVerticalPositionUncertaintyMeters; + } + /** Gets the time of applicability, GPS time of week in nanoseconds. */ public long getToaGpsNanosecondsOfWeek() { return mToaGpsNanosecondsOfWeek; @@ -110,6 +142,8 @@ public final class GnssMeasurementCorrections implements Parcelable { .setLatitudeDegrees(parcel.readDouble()) .setLongitudeDegrees(parcel.readDouble()) .setAltitudeMeters(parcel.readDouble()) + .setHorizontalPositionUncertaintyMeters(parcel.readDouble()) + .setVerticalPositionUncertaintyMeters(parcel.readDouble()) .setToaGpsNanosecondsOfWeek(parcel.readLong()); List<GnssSingleSatCorrection> singleSatCorrectionList = new ArrayList<>(); parcel.readTypedList(singleSatCorrectionList, GnssSingleSatCorrection.CREATOR); @@ -131,6 +165,10 @@ public final class GnssMeasurementCorrections implements Parcelable { builder.append(String.format(format, "LatitudeDegrees = ", mLatitudeDegrees)); builder.append(String.format(format, "LongitudeDegrees = ", mLongitudeDegrees)); builder.append(String.format(format, "AltitudeMeters = ", mAltitudeMeters)); + builder.append(String.format(format, "HorizontalPositionUncertaintyMeters = ", + mHorizontalPositionUncertaintyMeters)); + builder.append(String.format(format, "VerticalPositionUncertaintyMeters = ", + mVerticalPositionUncertaintyMeters)); builder.append( String.format(format, "ToaGpsNanosecondsOfWeek = ", mToaGpsNanosecondsOfWeek)); builder.append( @@ -143,6 +181,8 @@ public final class GnssMeasurementCorrections implements Parcelable { parcel.writeDouble(mLatitudeDegrees); parcel.writeDouble(mLongitudeDegrees); parcel.writeDouble(mAltitudeMeters); + parcel.writeDouble(mHorizontalPositionUncertaintyMeters); + parcel.writeDouble(mVerticalPositionUncertaintyMeters); parcel.writeLong(mToaGpsNanosecondsOfWeek); parcel.writeTypedList(mSingleSatCorrectionList); } @@ -154,9 +194,10 @@ public final class GnssMeasurementCorrections implements Parcelable { * GnssMeasurementCorrections}. */ private double mLatitudeDegrees; - private double mLongitudeDegrees; private double mAltitudeMeters; + private double mHorizontalPositionUncertaintyMeters; + private double mVerticalPositionUncertaintyMeters; private long mToaGpsNanosecondsOfWeek; private List<GnssSingleSatCorrection> mSingleSatCorrectionList; @@ -181,6 +222,27 @@ public final class GnssMeasurementCorrections implements Parcelable { return this; } + + /** + * Sets the horizontal uncertainty (68% confidence) in meters on the device position at + * which the corrections are provided. + */ + public Builder setHorizontalPositionUncertaintyMeters( + double horizontalPositionUncertaintyMeters) { + mHorizontalPositionUncertaintyMeters = horizontalPositionUncertaintyMeters; + return this; + } + + /** + * Sets the vertical uncertainty (68% confidence) in meters on the device position at which + * the corrections are provided. + */ + public Builder setVerticalPositionUncertaintyMeters( + double verticalPositionUncertaintyMeters) { + mVerticalPositionUncertaintyMeters = verticalPositionUncertaintyMeters; + return this; + } + /** Sets the time of applicability, GPS time of week in nanoseconds. */ public Builder setToaGpsNanosecondsOfWeek(long toaGpsNanosecondsOfWeek) { mToaGpsNanosecondsOfWeek = toaGpsNanosecondsOfWeek; diff --git a/location/java/android/location/GnssSingleSatCorrection.java b/location/java/android/location/GnssSingleSatCorrection.java index 3922d2f9f558..4d5303f18b81 100644 --- a/location/java/android/location/GnssSingleSatCorrection.java +++ b/location/java/android/location/GnssSingleSatCorrection.java @@ -317,8 +317,8 @@ public final class GnssSingleSatCorrection implements Parcelable { * 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."); + Preconditions.checkArgumentInRange( + probSatIsLos, 0, 1, "probSatIsLos should be between 0 and 1."); mProbSatIsLos = probSatIsLos; mSingleSatCorrectionFlags = (byte) (mSingleSatCorrectionFlags | HAS_PROB_SAT_IS_LOS_MASK); diff --git a/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java b/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java index d6227bbfcd0d..8f46e84195d5 100644 --- a/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java +++ b/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java @@ -48,6 +48,8 @@ public class GnssMeasurementCorrectionsTest extends TestCase { assertEquals(37.386051, measurementCorrections.getLatitudeDegrees()); assertEquals(-122.083855, measurementCorrections.getLongitudeDegrees()); assertEquals(32.0, measurementCorrections.getAltitudeMeters()); + assertEquals(9.25, measurementCorrections.getHorizontalPositionUncertaintyMeters()); + assertEquals(2.3, measurementCorrections.getVerticalPositionUncertaintyMeters()); assertEquals(604000000000000L, measurementCorrections.getToaGpsNanosecondsOfWeek()); GnssSingleSatCorrection singleSatCorrection = @@ -74,6 +76,8 @@ public class GnssMeasurementCorrectionsTest extends TestCase { .setLatitudeDegrees(37.386051) .setLongitudeDegrees(-122.083855) .setAltitudeMeters(32) + .setHorizontalPositionUncertaintyMeters(9.25) + .setVerticalPositionUncertaintyMeters(2.3) .setToaGpsNanosecondsOfWeek(604000000000000L); List<GnssSingleSatCorrection> singleSatCorrectionList = new ArrayList<>(); singleSatCorrectionList.add(GnssSingleSatCorrectionsTest.generateTestSingleSatCorrection()); diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp index f3c19d099851..cbc3791264bf 100644 --- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp +++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp @@ -73,6 +73,8 @@ static jmethodID method_reportGnssServiceDied; static jmethodID method_correctionsGetLatitudeDegrees; static jmethodID method_correctionsGetLongitudeDegrees; static jmethodID method_correctionsGetAltitudeMeters; +static jmethodID method_correctionsGetHorPosUncMeters; +static jmethodID method_correctionsGetVerPosUncMeters; static jmethodID method_correctionsGetToaGpsNanosecondsOfWeek; static jmethodID method_correctionsGetSingleSatCorrectionList; static jmethodID method_listSize; @@ -2233,6 +2235,12 @@ static jboolean android_location_GnssMeasurementsProvider_inject_gnss_measuremen method_correctionsGetAltitudeMeters = env->GetMethodID( measCorrClass, "getAltitudeMeters", "()D"); + method_correctionsGetHorPosUncMeters = env->GetMethodID( + measCorrClass, "getHorizontalPositionUncertaintyMeters", "()D"); + + method_correctionsGetVerPosUncMeters = env->GetMethodID( + measCorrClass, "getVerticalPositionUncertaintyMeters", "()D"); + method_correctionsGetToaGpsNanosecondsOfWeek = env->GetMethodID( measCorrClass, "getToaGpsNanosecondsOfWeek", "()J"); @@ -2246,6 +2254,10 @@ static jboolean android_location_GnssMeasurementsProvider_inject_gnss_measuremen correctionsObj, method_correctionsGetLongitudeDegrees); jdouble altitudeDegreesCorr = env->CallDoubleMethod( correctionsObj, method_correctionsGetAltitudeMeters); + jdouble horizontalPositionUncertaintyMeters = env->CallDoubleMethod( + correctionsObj, method_correctionsGetHorPosUncMeters); + jdouble verticalPositionUncertaintyMeters = env->CallDoubleMethod( + correctionsObj, method_correctionsGetVerPosUncMeters); jlong toaGpsNanosOfWeek = env->CallLongMethod( correctionsObj, method_correctionsGetToaGpsNanosecondsOfWeek); jobject singleSatCorrectionList = env->CallObjectMethod(correctionsObj, @@ -2348,6 +2360,8 @@ static jboolean android_location_GnssMeasurementsProvider_inject_gnss_measuremen .latitudeDegrees = latitudeDegreesCorr, .longitudeDegrees = longitudeDegreesCorr, .altitudeMeters = altitudeDegreesCorr, + .horizontalPositionUncertaintyMeters = horizontalPositionUncertaintyMeters, + .verticalPositionUncertaintyMeters = verticalPositionUncertaintyMeters, .toaGpsNanosecondsOfWeek = static_cast<uint64_t>(toaGpsNanosOfWeek), .satCorrections = list, }; |