diff --git a/location/java/android/location/GpsMeasurement.java b/location/java/android/location/GpsMeasurement.java index 2272ac3d20b5d..591a6ca23c500 100644 --- a/location/java/android/location/GpsMeasurement.java +++ b/location/java/android/location/GpsMeasurement.java @@ -33,6 +33,7 @@ public class GpsMeasurement implements Parcelable { private double mTimeOffsetInNs; private short mState; private long mReceivedGpsTowInNs; + private long mReceivedGpsTowUncertaintyInNs; private double mCn0InDbHz; private double mPseudorangeRateInMetersPerSec; private double mPseudorangeRateUncertaintyInMetersPerSec; @@ -171,6 +172,7 @@ public class GpsMeasurement implements Parcelable { mTimeOffsetInNs = measurement.mTimeOffsetInNs; mState = measurement.mState; mReceivedGpsTowInNs = measurement.mReceivedGpsTowInNs; + mReceivedGpsTowUncertaintyInNs = measurement.mReceivedGpsTowUncertaintyInNs; mCn0InDbHz = measurement.mCn0InDbHz; mPseudorangeRateInMetersPerSec = measurement.mPseudorangeRateInMetersPerSec; mPseudorangeRateUncertaintyInMetersPerSec = @@ -317,6 +319,20 @@ public class GpsMeasurement implements Parcelable { mReceivedGpsTowInNs = value; } + /** + * Gets the received GPS time-of-week's uncertainty (1-Sigma) in nanoseconds. + */ + public long getReceivedGpsTowUncertaintyInNs() { + return mReceivedGpsTowUncertaintyInNs; + } + + /** + * Sets the received GPS time-of-week's uncertainty (1-Sigma) in nanoseconds. + */ + public void setReceivedGpsTowUncertaintyInNs(long value) { + mReceivedGpsTowUncertaintyInNs = value; + } + /** * Gets the Carrier-to-noise density in dB-Hz. * Range: [0, 63]. @@ -1129,6 +1145,7 @@ public class GpsMeasurement implements Parcelable { gpsMeasurement.mTimeOffsetInNs = parcel.readDouble(); gpsMeasurement.mState = (short) parcel.readInt(); gpsMeasurement.mReceivedGpsTowInNs = parcel.readLong(); + gpsMeasurement.mReceivedGpsTowUncertaintyInNs = parcel.readLong(); gpsMeasurement.mCn0InDbHz = parcel.readDouble(); gpsMeasurement.mPseudorangeRateInMetersPerSec = parcel.readDouble(); gpsMeasurement.mPseudorangeRateUncertaintyInMetersPerSec = parcel.readDouble(); @@ -1171,6 +1188,7 @@ public class GpsMeasurement implements Parcelable { parcel.writeDouble(mTimeOffsetInNs); parcel.writeInt(mState); parcel.writeLong(mReceivedGpsTowInNs); + parcel.writeLong(mReceivedGpsTowUncertaintyInNs); parcel.writeDouble(mCn0InDbHz); parcel.writeDouble(mPseudorangeRateInMetersPerSec); parcel.writeDouble(mPseudorangeRateUncertaintyInMetersPerSec); @@ -1216,7 +1234,12 @@ public class GpsMeasurement implements Parcelable { builder.append(String.format(format, "State", getStateString())); - builder.append(String.format(format, "ReceivedGpsTowInNs", mReceivedGpsTowInNs)); + builder.append(String.format( + formatWithUncertainty, + "ReceivedGpsTowInNs", + mReceivedGpsTowInNs, + "ReceivedGpsTowUncertaintyInNs", + mReceivedGpsTowUncertaintyInNs)); builder.append(String.format(format, "Cn0InDbHz", mCn0InDbHz)); @@ -1321,6 +1344,7 @@ public class GpsMeasurement implements Parcelable { setTimeOffsetInNs(Long.MIN_VALUE); setState(STATE_UNKNOWN); setReceivedGpsTowInNs(Long.MIN_VALUE); + setReceivedGpsTowUncertaintyInNs(Long.MAX_VALUE); setCn0InDbHz(Double.MIN_VALUE); setPseudorangeRateInMetersPerSec(Double.MIN_VALUE); setPseudorangeRateUncertaintyInMetersPerSec(Double.MIN_VALUE); diff --git a/services/core/jni/com_android_server_location_GpsLocationProvider.cpp b/services/core/jni/com_android_server_location_GpsLocationProvider.cpp index 46af471613d19..8bb6e8a6cc9e0 100644 --- a/services/core/jni/com_android_server_location_GpsLocationProvider.cpp +++ b/services/core/jni/com_android_server_location_GpsLocationProvider.cpp @@ -950,6 +950,15 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen receivedGpsTowSetterMethod, measurement->received_gps_tow_ns); + jmethodID receivedGpsTowUncertaintySetterMethod = env->GetMethodID( + gpsMeasurementClass, + "setReceivedGpsTowUncertaintyInNs", + longSignature); + env->CallVoidMethod( + gpsMeasurementObject, + receivedGpsTowUncertaintySetterMethod, + measurement->received_gps_tow_uncertainty_ns); + jmethodID cn0SetterMethod = env->GetMethodID(gpsMeasurementClass, "setCn0InDbHz", doubleSignature); env->CallObjectMethod(gpsMeasurementObject, cn0SetterMethod, measurement->c_n0_dbhz);