FileDocCategorySizeDatePackage
GpsClock.javaAPI DocAndroid 5.1 API15972Thu Mar 12 22:22:30 GMT 2015android.location

GpsClock

public class GpsClock extends Object implements android.os.Parcelable
A class containing a GPS clock timestamp. It represents a measurement of the GPS receiver's clock.
hide

Fields Summary
private static final String
TAG
public static final byte
TYPE_UNKNOWN
The type of the time stored is not available or it is unknown.
public static final byte
TYPE_LOCAL_HW_TIME
The source of the time value reported by this class is the 'Local Hardware Clock'.
public static final byte
TYPE_GPS_TIME
The source of the time value reported by this class is the 'GPS time' derived from satellites (epoch = Jan 6, 1980).
private static final short
HAS_NO_FLAGS
private static final short
HAS_LEAP_SECOND
private static final short
HAS_TIME_UNCERTAINTY
private static final short
HAS_FULL_BIAS
private static final short
HAS_BIAS
private static final short
HAS_BIAS_UNCERTAINTY
private static final short
HAS_DRIFT
private static final short
HAS_DRIFT_UNCERTAINTY
private short
mFlags
private short
mLeapSecond
private byte
mType
private long
mTimeInNs
private double
mTimeUncertaintyInNs
private long
mFullBiasInNs
private double
mBiasInNs
private double
mBiasUncertaintyInNs
private double
mDriftInNsPerSec
private double
mDriftUncertaintyInNsPerSec
public static final Creator
CREATOR
Constructors Summary
GpsClock()


     
        initialize();
    
Methods Summary
public intdescribeContents()

        return 0;
    
public doublegetBiasInNs()
Gets the clock's sub-nanosecond bias. The reported bias includes {@link #getBiasUncertaintyInNs()}. The value is only available if {@link #hasBiasInNs()} is true.

        return mBiasInNs;
    
public doublegetBiasUncertaintyInNs()
Gets the clock's Bias Uncertainty (1-Sigma) in nanoseconds. The value is only available if {@link #hasBiasUncertaintyInNs()} is true.

        return mBiasUncertaintyInNs;
    
public doublegetDriftInNsPerSec()
Gets the clock's Drift in nanoseconds per second. A positive value indicates that the frequency is higher than the nominal frequency. The reported drift includes {@link #getDriftUncertaintyInNsPerSec()}. The value is only available if {@link #hasDriftInNsPerSec()} is true.

        return mDriftInNsPerSec;
    
public doublegetDriftUncertaintyInNsPerSec()
Gets the clock's Drift Uncertainty (1-Sigma) in nanoseconds per second. The value is only available if {@link #hasDriftUncertaintyInNsPerSec()} is true.

        return mDriftUncertaintyInNsPerSec;
    
public longgetFullBiasInNs()
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 #TYPE_LOCAL_HW_TIME} is set, and GPS receiver has solved the clock for GPS time. {@link #getBiasUncertaintyInNs()} should be used for quality check. 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.

        return mFullBiasInNs;
    
public shortgetLeapSecond()
Gets the leap second associated with the clock's time. The sign of the value is defined by the following equation: utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second * 1,000,000,000 The value is only available if {@link #hasLeapSecond()} is true.

        return mLeapSecond;
    
public longgetTimeInNs()
Gets the GPS receiver internal clock value in nanoseconds. This can be either the 'local hardware clock' value ({@link #TYPE_LOCAL_HW_TIME}), or the current GPS time derived inside GPS receiver ({@link #TYPE_GPS_TIME}). {@link #getType()} defines the time reported. 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 {@link #getFullBiasInNs()} (when it is available) from this value. For 'GPS time' this value is expected to be the best estimation of current GPS time that GPS receiver can achieve. {@link #getTimeUncertaintyInNs()} should be available when GPS time is specified. Sub-nanosecond accuracy can be provided by means of {@link #getBiasInNs()}. The reported time includes {@link #getTimeUncertaintyInNs()}.

        return mTimeInNs;
    
public doublegetTimeUncertaintyInNs()
Gets the clock's time Uncertainty (1-Sigma) in nanoseconds. The uncertainty is represented as an absolute (single sided) value. The value is only available if {@link #hasTimeUncertaintyInNs()} is true.

        return mTimeUncertaintyInNs;
    
public bytegetType()
Gets the type of time reported by {@link #getTimeInNs()}.

        return mType;
    
private java.lang.StringgetTypeString()
Gets a string representation of the 'type'. For internal and logging use only.

        switch (mType) {
            case TYPE_UNKNOWN:
                return "Unknown";
            case TYPE_GPS_TIME:
                return "GpsTime";
            case TYPE_LOCAL_HW_TIME:
                return "LocalHwClock";
            default:
                return "<Invalid>";
        }
    
public booleanhasBiasInNs()
Returns true if {@link #getBiasInNs()} is available, false otherwise.

        return isFlagSet(HAS_BIAS);
    
public booleanhasBiasUncertaintyInNs()
Returns true if {@link #getBiasUncertaintyInNs()} is available, false otherwise.

        return isFlagSet(HAS_BIAS_UNCERTAINTY);
    
public booleanhasDriftInNsPerSec()
Returns true if {@link #getDriftInNsPerSec()} is available, false otherwise.

        return isFlagSet(HAS_DRIFT);
    
public booleanhasDriftUncertaintyInNsPerSec()
Returns true if {@link #getDriftUncertaintyInNsPerSec()} is available, false otherwise.

        return isFlagSet(HAS_DRIFT_UNCERTAINTY);
    
public booleanhasFullBiasInNs()
Returns true if {@link @getFullBiasInNs()} is available, false otherwise.

        return isFlagSet(HAS_FULL_BIAS);
    
public booleanhasLeapSecond()
Returns true if {@link #getLeapSecond()} is available, false otherwise.

        return isFlagSet(HAS_LEAP_SECOND);
    
public booleanhasTimeUncertaintyInNs()
Returns true if {@link #getTimeUncertaintyInNs()} is available, false otherwise.

        return isFlagSet(HAS_TIME_UNCERTAINTY);
    
private voidinitialize()

        mFlags = HAS_NO_FLAGS;
        resetLeapSecond();
        setType(TYPE_UNKNOWN);
        setTimeInNs(Long.MIN_VALUE);
        resetTimeUncertaintyInNs();
        resetFullBiasInNs();
        resetBiasInNs();
        resetBiasUncertaintyInNs();
        resetDriftInNsPerSec();
        resetDriftUncertaintyInNsPerSec();
    
private booleanisFlagSet(short flag)

        return (mFlags & flag) == flag;
    
public voidreset()
Resets all the contents to its original state.

        initialize();
    
public voidresetBiasInNs()
Resets the clock's Bias in nanoseconds.

        resetFlag(HAS_BIAS);
        mBiasInNs = Double.NaN;
    
public voidresetBiasUncertaintyInNs()
Resets the clock's Bias Uncertainty (1-Sigma) in nanoseconds.

        resetFlag(HAS_BIAS_UNCERTAINTY);
        mBiasUncertaintyInNs = Double.NaN;
    
public voidresetDriftInNsPerSec()
Resets the clock's Drift in nanoseconds per second.

        resetFlag(HAS_DRIFT);
        mDriftInNsPerSec = Double.NaN;
    
public voidresetDriftUncertaintyInNsPerSec()
Resets the clock's Drift Uncertainty (1-Sigma) in nanoseconds per second.

        resetFlag(HAS_DRIFT_UNCERTAINTY);
        mDriftUncertaintyInNsPerSec = Double.NaN;
    
private voidresetFlag(short flag)

        mFlags &= ~flag;
    
public voidresetFullBiasInNs()
Resets the full bias in nanoseconds.

        resetFlag(HAS_FULL_BIAS);
        mFullBiasInNs = Long.MIN_VALUE;
    
public voidresetLeapSecond()
Resets the leap second associated with the clock's time.

        resetFlag(HAS_LEAP_SECOND);
        mLeapSecond = Short.MIN_VALUE;
    
public voidresetTimeUncertaintyInNs()
Resets the clock's Time Uncertainty (1-Sigma) in nanoseconds.

        resetFlag(HAS_TIME_UNCERTAINTY);
        mTimeUncertaintyInNs = Double.NaN;
    
public voidset(android.location.GpsClock clock)
Sets all contents to the values stored in the provided object.

        mFlags = clock.mFlags;
        mLeapSecond = clock.mLeapSecond;
        mType = clock.mType;
        mTimeInNs = clock.mTimeInNs;
        mTimeUncertaintyInNs = clock.mTimeUncertaintyInNs;
        mFullBiasInNs = clock.mFullBiasInNs;
        mBiasInNs = clock.mBiasInNs;
        mBiasUncertaintyInNs = clock.mBiasUncertaintyInNs;
        mDriftInNsPerSec = clock.mDriftInNsPerSec;
        mDriftUncertaintyInNsPerSec = clock.mDriftUncertaintyInNsPerSec;
    
public voidsetBiasInNs(double biasInNs)
Sets the sub-nanosecond bias.

        setFlag(HAS_BIAS);
        mBiasInNs = biasInNs;
    
public voidsetBiasUncertaintyInNs(double biasUncertaintyInNs)
Sets the clock's Bias Uncertainty (1-Sigma) in nanoseconds.

        setFlag(HAS_BIAS_UNCERTAINTY);
        mBiasUncertaintyInNs = biasUncertaintyInNs;
    
public voidsetDriftInNsPerSec(double driftInNsPerSec)
Sets the clock's Drift in nanoseconds per second.

        setFlag(HAS_DRIFT);
        mDriftInNsPerSec = driftInNsPerSec;
    
public voidsetDriftUncertaintyInNsPerSec(double driftUncertaintyInNsPerSec)
Sets the clock's Drift Uncertainty (1-Sigma) in nanoseconds per second.

        setFlag(HAS_DRIFT_UNCERTAINTY);
        mDriftUncertaintyInNsPerSec = driftUncertaintyInNsPerSec;
    
private voidsetFlag(short flag)

        mFlags |= flag;
    
public voidsetFullBiasInNs(long value)
Sets the full bias in nanoseconds.

        setFlag(HAS_FULL_BIAS);
        mFullBiasInNs = value;
    
public voidsetLeapSecond(short leapSecond)
Sets the leap second associated with the clock's time.

        setFlag(HAS_LEAP_SECOND);
        mLeapSecond = leapSecond;
    
public voidsetTimeInNs(long timeInNs)
Sets the GPS receiver internal clock in nanoseconds.

        mTimeInNs = timeInNs;
    
public voidsetTimeUncertaintyInNs(double timeUncertaintyInNs)
Sets the clock's Time Uncertainty (1-Sigma) in nanoseconds.

        setFlag(HAS_TIME_UNCERTAINTY);
        mTimeUncertaintyInNs = timeUncertaintyInNs;
    
public voidsetType(byte value)
Sets the type of time reported.

        switch (value) {
            case TYPE_UNKNOWN:
            case TYPE_GPS_TIME:
            case TYPE_LOCAL_HW_TIME:
                mType = value;
                break;
            default:
                Log.d(TAG, "Sanitizing invalid 'type': " + value);
                mType = TYPE_UNKNOWN;
                break;
        }
    
public java.lang.StringtoString()

        final String format = "   %-15s = %s\n";
        final String formatWithUncertainty = "   %-15s = %-25s   %-26s = %s\n";
        StringBuilder builder = new StringBuilder("GpsClock:\n");

        builder.append(String.format(format, "Type", getTypeString()));

        builder.append(String.format(format, "LeapSecond", hasLeapSecond() ? mLeapSecond : null));

        builder.append(String.format(
                formatWithUncertainty,
                "TimeInNs",
                mTimeInNs,
                "TimeUncertaintyInNs",
                hasTimeUncertaintyInNs() ? mTimeUncertaintyInNs : null));

        builder.append(String.format(
                format,
                "FullBiasInNs",
                hasFullBiasInNs() ? mFullBiasInNs : null));

        builder.append(String.format(
                formatWithUncertainty,
                "BiasInNs",
                hasBiasInNs() ? mBiasInNs : null,
                "BiasUncertaintyInNs",
                hasBiasUncertaintyInNs() ? mBiasUncertaintyInNs : null));

        builder.append(String.format(
                formatWithUncertainty,
                "DriftInNsPerSec",
                hasDriftInNsPerSec() ? mDriftInNsPerSec : null,
                "DriftUncertaintyInNsPerSec",
                hasDriftUncertaintyInNsPerSec() ? mDriftUncertaintyInNsPerSec : null));

        return builder.toString();
    
public voidwriteToParcel(android.os.Parcel parcel, int flags)


          
        parcel.writeInt(mFlags);
        parcel.writeInt(mLeapSecond);
        parcel.writeByte(mType);
        parcel.writeLong(mTimeInNs);
        parcel.writeDouble(mTimeUncertaintyInNs);
        parcel.writeLong(mFullBiasInNs);
        parcel.writeDouble(mBiasInNs);
        parcel.writeDouble(mBiasUncertaintyInNs);
        parcel.writeDouble(mDriftInNsPerSec);
        parcel.writeDouble(mDriftUncertaintyInNsPerSec);