Merge "Removed clock type from GnssClock" into nyc-dev
am: d6492a1c76
* commit 'd6492a1c7637f9ce3c2c2be3ce6c14c605335e06':
Removed clock type from GnssClock
This commit is contained in:
@@ -19173,7 +19173,6 @@ package android.location {
|
||||
method public short getLeapSecond();
|
||||
method public long getTimeInNs();
|
||||
method public double getTimeUncertaintyInNs();
|
||||
method public byte getType();
|
||||
method public boolean hasBiasInNs();
|
||||
method public boolean hasBiasUncertaintyInNs();
|
||||
method public boolean hasDriftInNsPerSec();
|
||||
@@ -19199,17 +19198,10 @@ package android.location {
|
||||
method public void setLeapSecond(short);
|
||||
method public void setTimeInNs(long);
|
||||
method public void setTimeUncertaintyInNs(double);
|
||||
method public void setType(byte);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final byte CLOCK_TYPE_GPS_TIME = 2; // 0x2
|
||||
field public static final byte CLOCK_TYPE_LOCAL_HW_TIME = 1; // 0x1
|
||||
field public static final byte CLOCK_TYPE_UNKNOWN = 0; // 0x0
|
||||
field public static final android.os.Parcelable.Creator<android.location.GnssClock> CREATOR;
|
||||
}
|
||||
|
||||
public static abstract class GnssClock.GnssClockType implements java.lang.annotation.Annotation {
|
||||
}
|
||||
|
||||
public final class GnssMeasurement implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public double getAccumulatedDeltaRangeInMeters();
|
||||
|
||||
@@ -20362,7 +20362,6 @@ package android.location {
|
||||
method public short getLeapSecond();
|
||||
method public long getTimeInNs();
|
||||
method public double getTimeUncertaintyInNs();
|
||||
method public byte getType();
|
||||
method public boolean hasBiasInNs();
|
||||
method public boolean hasBiasUncertaintyInNs();
|
||||
method public boolean hasDriftInNsPerSec();
|
||||
@@ -20388,17 +20387,10 @@ package android.location {
|
||||
method public void setLeapSecond(short);
|
||||
method public void setTimeInNs(long);
|
||||
method public void setTimeUncertaintyInNs(double);
|
||||
method public void setType(byte);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final byte CLOCK_TYPE_GPS_TIME = 2; // 0x2
|
||||
field public static final byte CLOCK_TYPE_LOCAL_HW_TIME = 1; // 0x1
|
||||
field public static final byte CLOCK_TYPE_UNKNOWN = 0; // 0x0
|
||||
field public static final android.os.Parcelable.Creator<android.location.GnssClock> CREATOR;
|
||||
}
|
||||
|
||||
public static abstract class GnssClock.GnssClockType implements java.lang.annotation.Annotation {
|
||||
}
|
||||
|
||||
public final class GnssMeasurement implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public double getAccumulatedDeltaRangeInMeters();
|
||||
|
||||
@@ -19181,7 +19181,6 @@ package android.location {
|
||||
method public short getLeapSecond();
|
||||
method public long getTimeInNs();
|
||||
method public double getTimeUncertaintyInNs();
|
||||
method public byte getType();
|
||||
method public boolean hasBiasInNs();
|
||||
method public boolean hasBiasUncertaintyInNs();
|
||||
method public boolean hasDriftInNsPerSec();
|
||||
@@ -19207,17 +19206,10 @@ package android.location {
|
||||
method public void setLeapSecond(short);
|
||||
method public void setTimeInNs(long);
|
||||
method public void setTimeUncertaintyInNs(double);
|
||||
method public void setType(byte);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final byte CLOCK_TYPE_GPS_TIME = 2; // 0x2
|
||||
field public static final byte CLOCK_TYPE_LOCAL_HW_TIME = 1; // 0x1
|
||||
field public static final byte CLOCK_TYPE_UNKNOWN = 0; // 0x0
|
||||
field public static final android.os.Parcelable.Creator<android.location.GnssClock> CREATOR;
|
||||
}
|
||||
|
||||
public static abstract class GnssClock.GnssClockType implements java.lang.annotation.Annotation {
|
||||
}
|
||||
|
||||
public final class GnssMeasurement implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public double getAccumulatedDeltaRangeInMeters();
|
||||
|
||||
@@ -16,42 +16,16 @@
|
||||
|
||||
package android.location;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* A class containing a GPS clock timestamp.
|
||||
* It represents a measurement of the GPS receiver's clock.
|
||||
*/
|
||||
public final class GnssClock implements Parcelable {
|
||||
|
||||
// The following enumerations must be in sync with the values declared in gps.h
|
||||
|
||||
/** The type of the GPS Clock. */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({CLOCK_TYPE_UNKNOWN, CLOCK_TYPE_LOCAL_HW_TIME, CLOCK_TYPE_GPS_TIME})
|
||||
public @interface GnssClockType {}
|
||||
|
||||
/**
|
||||
* The type of the time stored is not available or it is unknown.
|
||||
*/
|
||||
public static final byte CLOCK_TYPE_UNKNOWN = 0;
|
||||
|
||||
/**
|
||||
* The source of the time value reported by this class is the 'Local Hardware Clock'.
|
||||
*/
|
||||
public static final byte CLOCK_TYPE_LOCAL_HW_TIME = 1;
|
||||
|
||||
/**
|
||||
* The source of the time value reported by this class is the 'GPS time' derived from
|
||||
* satellites (epoch = Jan 6, 1980).
|
||||
*/
|
||||
public static final byte CLOCK_TYPE_GPS_TIME = 2;
|
||||
|
||||
private static final short HAS_NO_FLAGS = 0;
|
||||
private static final short HAS_LEAP_SECOND = (1<<0);
|
||||
private static final short HAS_TIME_UNCERTAINTY = (1<<1);
|
||||
@@ -65,7 +39,6 @@ public final class GnssClock implements Parcelable {
|
||||
|
||||
private short mFlags;
|
||||
private short mLeapSecond;
|
||||
private byte mType;
|
||||
private long mTimeInNs;
|
||||
private double mTimeUncertaintyInNs;
|
||||
private long mFullBiasInNs;
|
||||
@@ -85,7 +58,6 @@ public final class GnssClock implements Parcelable {
|
||||
public void set(GnssClock clock) {
|
||||
mFlags = clock.mFlags;
|
||||
mLeapSecond = clock.mLeapSecond;
|
||||
mType = clock.mType;
|
||||
mTimeInNs = clock.mTimeInNs;
|
||||
mTimeUncertaintyInNs = clock.mTimeUncertaintyInNs;
|
||||
mFullBiasInNs = clock.mFullBiasInNs;
|
||||
@@ -103,38 +75,6 @@ public final class GnssClock implements Parcelable {
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of time reported by {@link #getTimeInNs()}.
|
||||
*/
|
||||
@GnssClockType
|
||||
public byte getType() {
|
||||
return mType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of time reported.
|
||||
*/
|
||||
public void setType(@GnssClockType byte value) {
|
||||
mType = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string representation of the 'type'.
|
||||
* For internal and logging use only.
|
||||
*/
|
||||
private String getTypeString() {
|
||||
switch (mType) {
|
||||
case CLOCK_TYPE_UNKNOWN:
|
||||
return "Unknown";
|
||||
case CLOCK_TYPE_GPS_TIME:
|
||||
return "GpsTime";
|
||||
case CLOCK_TYPE_LOCAL_HW_TIME:
|
||||
return "LocalHwClock";
|
||||
default:
|
||||
return "<Invalid:" + mType + ">";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if {@link #getLeapSecond()} is available, false otherwise.
|
||||
*/
|
||||
@@ -170,10 +110,7 @@ public final class GnssClock implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GPS receiver internal clock value in nanoseconds.
|
||||
* This can be either the 'local hardware clock' value ({@link #CLOCK_TYPE_LOCAL_HW_TIME}), or the
|
||||
* current GPS time derived inside GPS receiver ({@link #CLOCK_TYPE_GPS_TIME}).
|
||||
* {@link #getType()} defines the time reported.
|
||||
* Gets the GNSS receiver internal clock value in nanoseconds.
|
||||
*
|
||||
* For 'local hardware clock' this value is expected to be monotonically increasing during the
|
||||
* reporting session. The real GPS time can be derived by compensating
|
||||
@@ -241,15 +178,14 @@ public final class GnssClock implements Parcelable {
|
||||
* Gets the difference between hardware clock ({@link #getTimeInNs()}) inside GPS receiver and
|
||||
* the true GPS time since 0000Z, January 6, 1980, in nanoseconds.
|
||||
*
|
||||
* This value is available if {@link #CLOCK_TYPE_LOCAL_HW_TIME} is set, and GPS receiver has solved
|
||||
* the clock for GPS time.
|
||||
* {@link #getBiasUncertaintyInNs()} should be used for quality check.
|
||||
* This value is available if the receiver has estimated GPS time. If the computed time is for a
|
||||
* non-GPS constellation, the time offset of that constellation to GPS has to be applied to fill
|
||||
* this value. The value contains the 'bias uncertainty' {@link #getBiasUncertaintyInNs()} in
|
||||
* it, and it should be used for quality check. The value is only available if
|
||||
* {@link #hasFullBiasInNs()} is true.
|
||||
*
|
||||
* The sign of the value is defined by the following equation:
|
||||
* true time (GPS time) = time_ns + (full_bias_ns + bias_ns)
|
||||
*
|
||||
* The reported full bias includes {@link #getBiasUncertaintyInNs()}.
|
||||
* The value is onl available if {@link #hasFullBiasInNs()} is true.
|
||||
* local estimate of GPS time = time_ns + (full_bias_ns + bias_ns)
|
||||
*/
|
||||
public long getFullBiasInNs() {
|
||||
return mFullBiasInNs;
|
||||
@@ -423,7 +359,6 @@ public final class GnssClock implements Parcelable {
|
||||
|
||||
gpsClock.mFlags = (short) parcel.readInt();
|
||||
gpsClock.mLeapSecond = (short) parcel.readInt();
|
||||
gpsClock.mType = parcel.readByte();
|
||||
gpsClock.mTimeInNs = parcel.readLong();
|
||||
gpsClock.mTimeUncertaintyInNs = parcel.readDouble();
|
||||
gpsClock.mFullBiasInNs = parcel.readLong();
|
||||
@@ -446,7 +381,6 @@ public final class GnssClock implements Parcelable {
|
||||
public void writeToParcel(Parcel parcel, int flags) {
|
||||
parcel.writeInt(mFlags);
|
||||
parcel.writeInt(mLeapSecond);
|
||||
parcel.writeByte(mType);
|
||||
parcel.writeLong(mTimeInNs);
|
||||
parcel.writeDouble(mTimeUncertaintyInNs);
|
||||
parcel.writeLong(mFullBiasInNs);
|
||||
@@ -468,8 +402,6 @@ public final class GnssClock implements Parcelable {
|
||||
final String formatWithUncertainty = " %-15s = %-25s %-26s = %s\n";
|
||||
StringBuilder builder = new StringBuilder("GnssClock:\n");
|
||||
|
||||
builder.append(String.format(format, "Type", getTypeString()));
|
||||
|
||||
builder.append(String.format(format, "LeapSecond", hasLeapSecond() ? mLeapSecond : null));
|
||||
|
||||
builder.append(String.format(
|
||||
@@ -498,17 +430,12 @@ public final class GnssClock implements Parcelable {
|
||||
"DriftUncertaintyInNsPerSec",
|
||||
hasDriftUncertaintyInNsPerSec() ? mDriftUncertaintyInNsPerSec : null));
|
||||
|
||||
builder.append(String.format(format, "HardwareClockDiscontinuityCount",
|
||||
getType() == CLOCK_TYPE_LOCAL_HW_TIME
|
||||
? mHardwareClockDiscontinuityCount : null));
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
mFlags = HAS_NO_FLAGS;
|
||||
resetLeapSecond();
|
||||
setType(CLOCK_TYPE_UNKNOWN);
|
||||
setTimeInNs(Long.MIN_VALUE);
|
||||
resetTimeUncertaintyInNs();
|
||||
resetFullBiasInNs();
|
||||
|
||||
@@ -272,8 +272,9 @@ public final class GnssMeasurement implements Parcelable {
|
||||
|
||||
/**
|
||||
* Gets the time offset at which the measurement was taken in nanoseconds.
|
||||
* The reference receiver's time is specified by {@link GnssClock#getTimeInNs()} and should be
|
||||
* interpreted in the same way as indicated by {@link GnssClock#getType()}.
|
||||
*
|
||||
* The reference receiver's time from which this is offset is specified by
|
||||
* {@link GnssClock#getTimeInNs()}.
|
||||
*
|
||||
* The sign of this value is given by the following equation:
|
||||
* measurement time = time_ns + time_offset_ns
|
||||
|
||||
@@ -29,10 +29,11 @@
|
||||
#include "android_runtime/Log.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <limits>
|
||||
#include <linux/in.h>
|
||||
#include <linux/in6.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
|
||||
static jobject mCallbacksObj = NULL;
|
||||
|
||||
@@ -1090,11 +1091,37 @@ const char *const JavaMethodHelper<bool>::signature_ = "(Z)V";
|
||||
if (flags & (flag)) object.callSetter("set" # setter, (value))
|
||||
|
||||
static jobject translate_gps_clock(JNIEnv* env, GpsClock* clock) {
|
||||
static uint32_t discontinuity_count_to_handle_old_lock_type = 0;
|
||||
JavaObject object(env, "android/location/GnssClock");
|
||||
GpsClockFlags flags = clock->flags;
|
||||
|
||||
SET_IF(GNSS_CLOCK_HAS_LEAP_SECOND, LeapSecond, clock->leap_second);
|
||||
SET(Type, clock->type);
|
||||
|
||||
// GnssClock only supports the more effective HW_CLOCK type, so type
|
||||
// handling and documentation complexity has been removed. To convert the
|
||||
// old GPS_CLOCK types (active only in a limited number of older devices),
|
||||
// the GPS time information is handled as an always discontinuous HW clock,
|
||||
// with the GPS time information put into the full_bias_ns instead - so that
|
||||
// time_ns + full_bias_ns = local estimate of GPS time (as remains true, in
|
||||
// the new GnssClock struct.)
|
||||
switch (clock->type) {
|
||||
case GPS_CLOCK_TYPE_UNKNOWN:
|
||||
// Clock type unsupported.
|
||||
ALOGE("Unknown clock type provided.");
|
||||
break;
|
||||
case GPS_CLOCK_TYPE_LOCAL_HW_TIME:
|
||||
// Already local hardware time. No need to do anything.
|
||||
break;
|
||||
case GPS_CLOCK_TYPE_GPS_TIME:
|
||||
// GPS time, need to convert.
|
||||
flags |= GNSS_CLOCK_HAS_FULL_BIAS;
|
||||
clock->full_bias_ns = clock->time_ns;
|
||||
clock->time_ns = 0;
|
||||
SET(HardwareClockDiscontinuityCount,
|
||||
discontinuity_count_to_handle_old_lock_type++);
|
||||
break;
|
||||
}
|
||||
|
||||
SET(TimeInNs, clock->time_ns);
|
||||
SET_IF(GNSS_CLOCK_HAS_TIME_UNCERTAINTY,
|
||||
TimeUncertaintyInNs,
|
||||
|
||||
Reference in New Issue
Block a user