Add elapasedRealtimeNanos and elapsedRealtimeUncertaintyNanos to GnssClock

Bug: 128713045
Test: atest GnssClockTest
Change-Id: I5950184202cfbb3b7a7a777b88045d0fb3ea98b1
This commit is contained in:
Yu-Han Yang
2019-03-20 15:09:14 -07:00
parent 3d3b861a5c
commit 5d3dcd5625
3 changed files with 129 additions and 9 deletions

View File

@@ -22663,18 +22663,22 @@ package android.location {
public final class GnssClock implements android.os.Parcelable {
method public int describeContents();
method public double getBiasNanos();
method public double getBiasUncertaintyNanos();
method @FloatRange(from=0.0f) public double getBiasUncertaintyNanos();
method public double getDriftNanosPerSecond();
method public double getDriftUncertaintyNanosPerSecond();
method @FloatRange(from=0.0f) public double getDriftUncertaintyNanosPerSecond();
method public long getElapsedRealtimeNanos();
method @IntRange(from=0) public long getElapsedRealtimeUncertaintyNanos();
method public long getFullBiasNanos();
method public int getHardwareClockDiscontinuityCount();
method public int getLeapSecond();
method public long getTimeNanos();
method public double getTimeUncertaintyNanos();
method @FloatRange(from=0.0f) public double getTimeUncertaintyNanos();
method public boolean hasBiasNanos();
method public boolean hasBiasUncertaintyNanos();
method public boolean hasDriftNanosPerSecond();
method public boolean hasDriftUncertaintyNanosPerSecond();
method public boolean hasElapsedRealtimeNanos();
method public boolean hasElapsedRealtimeUncertaintyNanos();
method public boolean hasFullBiasNanos();
method public boolean hasLeapSecond();
method public boolean hasTimeUncertaintyNanos();

View File

@@ -918,19 +918,23 @@ package android.location {
method public void resetBiasUncertaintyNanos();
method public void resetDriftNanosPerSecond();
method public void resetDriftUncertaintyNanosPerSecond();
method public void resetElapsedRealtimeNanos();
method public void resetElapsedRealtimeUncertaintyNanos();
method public void resetFullBiasNanos();
method public void resetLeapSecond();
method public void resetTimeUncertaintyNanos();
method public void set(android.location.GnssClock);
method public void setBiasNanos(double);
method public void setBiasUncertaintyNanos(double);
method public void setBiasUncertaintyNanos(@FloatRange(from=0.0f) double);
method public void setDriftNanosPerSecond(double);
method public void setDriftUncertaintyNanosPerSecond(double);
method public void setDriftUncertaintyNanosPerSecond(@FloatRange(from=0.0f) double);
method public void setElapsedRealtimeNanos(long);
method public void setElapsedRealtimeUncertaintyNanos(@IntRange(from=0) long);
method public void setFullBiasNanos(long);
method public void setHardwareClockDiscontinuityCount(int);
method public void setLeapSecond(int);
method public void setTimeNanos(long);
method public void setTimeUncertaintyNanos(double);
method public void setTimeUncertaintyNanos(@FloatRange(from=0.0f) double);
}
public final class GnssMeasurement implements android.os.Parcelable {

View File

@@ -16,6 +16,8 @@
package android.location;
import android.annotation.FloatRange;
import android.annotation.IntRange;
import android.annotation.TestApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -36,6 +38,8 @@ public final class GnssClock implements Parcelable {
private static final int HAS_BIAS_UNCERTAINTY = (1<<4);
private static final int HAS_DRIFT = (1<<5);
private static final int HAS_DRIFT_UNCERTAINTY = (1<<6);
private static final int HAS_ELAPSED_REALTIME_NANOS = (1 << 7);
private static final int HAS_ELAPSED_REALTIME_UNCERTAINTY_NANOS = (1 << 8);
// End enumerations in sync with gps.h
@@ -49,6 +53,8 @@ public final class GnssClock implements Parcelable {
private double mDriftNanosPerSecond;
private double mDriftUncertaintyNanosPerSecond;
private int mHardwareClockDiscontinuityCount;
private long mElapsedRealtimeNanos;
private long mElapsedRealtimeUncertaintyNanos;
/**
* @hide
@@ -74,6 +80,8 @@ public final class GnssClock implements Parcelable {
mDriftNanosPerSecond = clock.mDriftNanosPerSecond;
mDriftUncertaintyNanosPerSecond = clock.mDriftUncertaintyNanosPerSecond;
mHardwareClockDiscontinuityCount = clock.mHardwareClockDiscontinuityCount;
mElapsedRealtimeNanos = clock.mElapsedRealtimeNanos;
mElapsedRealtimeUncertaintyNanos = clock.mElapsedRealtimeUncertaintyNanos;
}
/**
@@ -167,6 +175,7 @@ public final class GnssClock implements Parcelable {
* <p>This value is often effectively zero (it is the reference clock by which all other times
* and time uncertainties are measured), and thus this field may often be 0, or not provided.
*/
@FloatRange(from = 0.0f)
public double getTimeUncertaintyNanos() {
return mTimeUncertaintyNanos;
}
@@ -176,7 +185,7 @@ public final class GnssClock implements Parcelable {
* @hide
*/
@TestApi
public void setTimeUncertaintyNanos(double timeUncertaintyNanos) {
public void setTimeUncertaintyNanos(@FloatRange(from = 0.0f) double timeUncertaintyNanos) {
setFlag(HAS_TIME_UNCERTAINTY);
mTimeUncertaintyNanos = timeUncertaintyNanos;
}
@@ -297,6 +306,7 @@ public final class GnssClock implements Parcelable {
*
* <p>The value is only available if {@link #hasBiasUncertaintyNanos()} is {@code true}.
*/
@FloatRange(from = 0.0f)
public double getBiasUncertaintyNanos() {
return mBiasUncertaintyNanos;
}
@@ -306,7 +316,7 @@ public final class GnssClock implements Parcelable {
* @hide
*/
@TestApi
public void setBiasUncertaintyNanos(double biasUncertaintyNanos) {
public void setBiasUncertaintyNanos(@FloatRange(from = 0.0f) double biasUncertaintyNanos) {
setFlag(HAS_BIAS_UNCERTAINTY);
mBiasUncertaintyNanos = biasUncertaintyNanos;
}
@@ -379,6 +389,7 @@ public final class GnssClock implements Parcelable {
* <p>The value is only available if {@link #hasDriftUncertaintyNanosPerSecond()} is
* {@code true}.
*/
@FloatRange(from = 0.0f)
public double getDriftUncertaintyNanosPerSecond() {
return mDriftUncertaintyNanosPerSecond;
}
@@ -388,7 +399,8 @@ public final class GnssClock implements Parcelable {
* @hide
*/
@TestApi
public void setDriftUncertaintyNanosPerSecond(double driftUncertaintyNanosPerSecond) {
public void setDriftUncertaintyNanosPerSecond(
@FloatRange(from = 0.0f) double driftUncertaintyNanosPerSecond) {
setFlag(HAS_DRIFT_UNCERTAINTY);
mDriftUncertaintyNanosPerSecond = driftUncertaintyNanosPerSecond;
}
@@ -403,6 +415,90 @@ public final class GnssClock implements Parcelable {
mDriftUncertaintyNanosPerSecond = Double.NaN;
}
/**
* Returns {@code true} if {@link #getElapsedRealtimeNanos()} is available, {@code false}
* otherwise.
*/
public boolean hasElapsedRealtimeNanos() {
return isFlagSet(HAS_ELAPSED_REALTIME_NANOS);
}
/**
* Returns the elapsed real-time of this clock since system boot, in nanoseconds.
*
* <p>The value is only available if {@link #hasElapsedRealtimeNanos()} is
* {@code true}.
*/
public long getElapsedRealtimeNanos() {
return mElapsedRealtimeNanos;
}
/**
* Sets the elapsed real-time of this clock since system boot, in nanoseconds.
* @hide
*/
@TestApi
public void setElapsedRealtimeNanos(long elapsedRealtimeNanos) {
setFlag(HAS_ELAPSED_REALTIME_NANOS);
mElapsedRealtimeNanos = elapsedRealtimeNanos;
}
/**
* Resets the elapsed real-time of this clock since system boot, in nanoseconds.
* @hide
*/
@TestApi
public void resetElapsedRealtimeNanos() {
resetFlag(HAS_ELAPSED_REALTIME_NANOS);
mElapsedRealtimeNanos = 0;
}
/**
* Returns {@code true} if {@link #getElapsedRealtimeUncertaintyNanos()} is available, {@code
* false} otherwise.
*/
public boolean hasElapsedRealtimeUncertaintyNanos() {
return isFlagSet(HAS_ELAPSED_REALTIME_UNCERTAINTY_NANOS);
}
/**
* Gets the estimate of the relative precision of the alignment of the
* {@link #getElapsedRealtimeNanos()} timestamp, with the reported measurements in
* nanoseconds (68% confidence).
*
* <p>The value is only available if {@link #hasElapsedRealtimeUncertaintyNanos()} is
* {@code true}.
*/
@IntRange(from = 0)
public long getElapsedRealtimeUncertaintyNanos() {
return mElapsedRealtimeUncertaintyNanos;
}
/**
* Sets the estimate of the relative precision of the alignment of the
* {@link #getElapsedRealtimeNanos()} timestamp, with the reported measurements in
* nanoseconds (68% confidence).
* @hide
*/
@TestApi
public void setElapsedRealtimeUncertaintyNanos(
@IntRange(from = 0) long elapsedRealtimeUncertaintyNanos) {
setFlag(HAS_ELAPSED_REALTIME_UNCERTAINTY_NANOS);
mElapsedRealtimeUncertaintyNanos = elapsedRealtimeUncertaintyNanos;
}
/**
* Resets the estimate of the relative precision of the alignment of the
* {@link #getElapsedRealtimeNanos()} timestamp, with the reported measurements in
* nanoseconds (68% confidence).
* @hide
*/
@TestApi
public void resetElapsedRealtimeUncertaintyNanos() {
resetFlag(HAS_ELAPSED_REALTIME_UNCERTAINTY_NANOS);
mElapsedRealtimeUncertaintyNanos = Long.MAX_VALUE;
}
/**
* Gets count of hardware clock discontinuities.
*
@@ -446,6 +542,8 @@ public final class GnssClock implements Parcelable {
gpsClock.mDriftNanosPerSecond = parcel.readDouble();
gpsClock.mDriftUncertaintyNanosPerSecond = parcel.readDouble();
gpsClock.mHardwareClockDiscontinuityCount = parcel.readInt();
gpsClock.mElapsedRealtimeNanos = parcel.readLong();
gpsClock.mElapsedRealtimeUncertaintyNanos = parcel.readLong();
return gpsClock;
}
@@ -468,6 +566,8 @@ public final class GnssClock implements Parcelable {
parcel.writeDouble(mDriftNanosPerSecond);
parcel.writeDouble(mDriftUncertaintyNanosPerSecond);
parcel.writeInt(mHardwareClockDiscontinuityCount);
parcel.writeLong(mElapsedRealtimeNanos);
parcel.writeLong(mElapsedRealtimeUncertaintyNanos);
}
@Override
@@ -514,6 +614,16 @@ public final class GnssClock implements Parcelable {
"HardwareClockDiscontinuityCount",
mHardwareClockDiscontinuityCount));
builder.append(String.format(
format,
"ElapsedRealtimeNanos",
hasElapsedRealtimeNanos() ? mElapsedRealtimeNanos : null));
builder.append(String.format(
format,
"ElapsedRealtimeUncertaintyNanos",
hasElapsedRealtimeUncertaintyNanos() ? mElapsedRealtimeUncertaintyNanos : null));
return builder.toString();
}
@@ -528,6 +638,8 @@ public final class GnssClock implements Parcelable {
resetDriftNanosPerSecond();
resetDriftUncertaintyNanosPerSecond();
setHardwareClockDiscontinuityCount(Integer.MIN_VALUE);
resetElapsedRealtimeNanos();
resetElapsedRealtimeUncertaintyNanos();
}
private void setFlag(int flag) {