diff options
27 files changed, 3402 insertions, 607 deletions
diff --git a/Android.mk b/Android.mk index d68da97451c5..c3e679b63e5c 100644 --- a/Android.mk +++ b/Android.mk @@ -336,8 +336,8 @@ LOCAL_SRC_FILES += \ location/java/android/location/IGeofenceProvider.aidl \ location/java/android/location/IGnssStatusListener.aidl \ location/java/android/location/IGnssStatusProvider.aidl \ - location/java/android/location/IGpsMeasurementsListener.aidl \ - location/java/android/location/IGpsNavigationMessageListener.aidl \ + location/java/android/location/IGnssMeasurementsListener.aidl \ + location/java/android/location/IGnssNavigationMessageListener.aidl \ location/java/android/location/ILocationListener.aidl \ location/java/android/location/ILocationManager.aidl \ location/java/android/location/IFusedGeofenceHardware.aidl \ diff --git a/api/current.txt b/api/current.txt index 18a1582167f7..0b204b289666 100644 --- a/api/current.txt +++ b/api/current.txt @@ -19115,38 +19115,7 @@ package android.location { method public static boolean isPresent(); } - public abstract interface GnssNmeaListener { - method public abstract void onNmeaReceived(long, java.lang.String); - } - - public final class GnssStatus { - method public float getAzimuth(int); - method public int getConstellationType(int); - method public float getElevation(int); - method public int getNumSatellites(); - method public int getPrn(int); - method public float getSnr(int); - method public boolean hasAlmanac(int); - method public boolean hasEphemeris(int); - method public boolean usedInFix(int); - field public static final int CONSTELLATION_BEIDOU = 5; // 0x5 - field public static final int CONSTELLATION_GALILEO = 6; // 0x6 - field public static final int CONSTELLATION_GLONASS = 3; // 0x3 - field public static final int CONSTELLATION_GPS = 1; // 0x1 - field public static final int CONSTELLATION_QZSS = 4; // 0x4 - field public static final int CONSTELLATION_SBAS = 2; // 0x2 - field public static final int CONSTELLATION_UNKNOWN = 0; // 0x0 - } - - public abstract class GnssStatusCallback { - ctor public GnssStatusCallback(); - method public void onFirstFix(int); - method public void onSatelliteStatusChanged(android.location.GnssStatus); - method public void onStarted(); - method public void onStopped(); - } - - public final class GpsClock implements android.os.Parcelable { + public final class GnssClock implements android.os.Parcelable { method public int describeContents(); method public double getBiasInNs(); method public double getBiasUncertaintyInNs(); @@ -19173,7 +19142,7 @@ package android.location { method public void resetFullBiasInNs(); method public void resetLeapSecond(); method public void resetTimeUncertaintyInNs(); - method public void set(android.location.GpsClock); + method public void set(android.location.GnssClock); method public void setBiasInNs(double); method public void setBiasUncertaintyInNs(double); method public void setDriftInNsPerSec(double); @@ -19188,13 +19157,13 @@ package android.location { 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.GpsClock> CREATOR; + field public static final android.os.Parcelable.Creator<android.location.GnssClock> CREATOR; } - public static abstract class GpsClock.GpsClockType implements java.lang.annotation.Annotation { + public static abstract class GnssClock.GnssClockType implements java.lang.annotation.Annotation { } - public final class GpsMeasurement implements android.os.Parcelable { + public final class GnssMeasurement implements android.os.Parcelable { method public int describeContents(); method public double getAccumulatedDeltaRangeInMeters(); method public short getAccumulatedDeltaRangeState(); @@ -19265,7 +19234,7 @@ package android.location { method public void resetPseudorangeUncertaintyInMeters(); method public void resetSnrInDb(); method public void resetTimeFromLastBitInMs(); - method public void set(android.location.GpsMeasurement); + method public void set(android.location.GnssMeasurement); method public void setAccumulatedDeltaRangeInMeters(double); method public void setAccumulatedDeltaRangeState(short); method public void setAccumulatedDeltaRangeUncertaintyInMeters(double); @@ -19304,7 +19273,7 @@ package android.location { field public static final short ADR_STATE_RESET = 2; // 0x2 field public static final short ADR_STATE_UNKNOWN = 0; // 0x0 field public static final short ADR_STATE_VALID = 1; // 0x1 - field public static final android.os.Parcelable.Creator<android.location.GpsMeasurement> CREATOR; + field public static final android.os.Parcelable.Creator<android.location.GnssMeasurement> CREATOR; field public static final byte LOSS_OF_LOCK_CYCLE_SLIP = 2; // 0x2 field public static final byte LOSS_OF_LOCK_OK = 1; // 0x1 field public static final byte LOSS_OF_LOCK_UNKNOWN = 0; // 0x0 @@ -19319,34 +19288,34 @@ package android.location { field public static final short STATE_UNKNOWN = 0; // 0x0 } - public static abstract class GpsMeasurement.LossOfLockStatus implements java.lang.annotation.Annotation { + public static abstract class GnssMeasurement.LossOfLockStatus implements java.lang.annotation.Annotation { } - public static abstract class GpsMeasurement.MultipathIndicator implements java.lang.annotation.Annotation { + public static abstract class GnssMeasurement.MultipathIndicator implements java.lang.annotation.Annotation { } - public final class GpsMeasurementsEvent implements android.os.Parcelable { - ctor public GpsMeasurementsEvent(android.location.GpsClock, android.location.GpsMeasurement[]); + public final class GnssMeasurementsEvent implements android.os.Parcelable { + ctor public GnssMeasurementsEvent(android.location.GnssClock, android.location.GnssMeasurement[]); method public int describeContents(); - method public android.location.GpsClock getClock(); - method public java.util.Collection<android.location.GpsMeasurement> getMeasurements(); + method public android.location.GnssClock getClock(); + method public java.util.Collection<android.location.GnssMeasurement> getMeasurements(); method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.location.GpsMeasurementsEvent> CREATOR; + field public static final android.os.Parcelable.Creator<android.location.GnssMeasurementsEvent> CREATOR; field public static final int STATUS_GPS_LOCATION_DISABLED = 2; // 0x2 field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0 field public static final int STATUS_READY = 1; // 0x1 } - public static abstract class GpsMeasurementsEvent.Callback { - ctor public GpsMeasurementsEvent.Callback(); - method public void onGpsMeasurementsReceived(android.location.GpsMeasurementsEvent); + public static abstract class GnssMeasurementsEvent.Callback { + ctor public GnssMeasurementsEvent.Callback(); + method public void onGnssMeasurementsReceived(android.location.GnssMeasurementsEvent); method public void onStatusChanged(int); } - public static abstract class GpsMeasurementsEvent.GpsMeasurementsStatus implements java.lang.annotation.Annotation { + public static abstract class GnssMeasurementsEvent.GnssMeasurementsStatus implements java.lang.annotation.Annotation { } - public final class GpsNavigationMessage implements android.os.Parcelable { + public final class GnssNavigationMessage implements android.os.Parcelable { method public int describeContents(); method public byte[] getData(); method public short getMessageId(); @@ -19355,7 +19324,7 @@ package android.location { method public short getSubmessageId(); method public byte getType(); method public void reset(); - method public void set(android.location.GpsNavigationMessage); + method public void set(android.location.GnssNavigationMessage); method public void setData(byte[]); method public void setMessageId(short); method public void setPrn(byte); @@ -19363,7 +19332,7 @@ package android.location { method public void setSubmessageId(short); method public void setType(byte); method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.location.GpsNavigationMessage> CREATOR; + field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessage> CREATOR; field public static final byte MESSAGE_TYPE_CNAV2 = 4; // 0x4 field public static final byte MESSAGE_TYPE_L1CA = 1; // 0x1 field public static final byte MESSAGE_TYPE_L2CNAV = 2; // 0x2 @@ -19374,27 +19343,58 @@ package android.location { field public static final short STATUS_UNKNOWN = 0; // 0x0 } - public static abstract class GpsNavigationMessage.GpsNavigationMessageType implements java.lang.annotation.Annotation { + public static abstract class GnssNavigationMessage.GnssNavigationMessageType implements java.lang.annotation.Annotation { } - public final class GpsNavigationMessageEvent implements android.os.Parcelable { - ctor public GpsNavigationMessageEvent(android.location.GpsNavigationMessage); + public final class GnssNavigationMessageEvent implements android.os.Parcelable { + ctor public GnssNavigationMessageEvent(android.location.GnssNavigationMessage); method public int describeContents(); - method public android.location.GpsNavigationMessage getNavigationMessage(); + method public android.location.GnssNavigationMessage getNavigationMessage(); method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.location.GpsNavigationMessageEvent> CREATOR; + field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessageEvent> CREATOR; field public static final int STATUS_GPS_LOCATION_DISABLED = 2; // 0x2 field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0 field public static final int STATUS_READY = 1; // 0x1 } - public static abstract class GpsNavigationMessageEvent.Callback { - ctor public GpsNavigationMessageEvent.Callback(); - method public void onGpsNavigationMessageReceived(android.location.GpsNavigationMessageEvent); + public static abstract class GnssNavigationMessageEvent.Callback { + ctor public GnssNavigationMessageEvent.Callback(); + method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessageEvent); method public void onStatusChanged(int); } - public static abstract class GpsNavigationMessageEvent.GpsNavigationMessageStatus implements java.lang.annotation.Annotation { + public static abstract class GnssNavigationMessageEvent.GnssNavigationMessageStatus implements java.lang.annotation.Annotation { + } + + public abstract interface GnssNmeaListener { + method public abstract void onNmeaReceived(long, java.lang.String); + } + + public final class GnssStatus { + method public float getAzimuth(int); + method public int getConstellationType(int); + method public float getElevation(int); + method public int getNumSatellites(); + method public int getPrn(int); + method public float getSnr(int); + method public boolean hasAlmanac(int); + method public boolean hasEphemeris(int); + method public boolean usedInFix(int); + field public static final int CONSTELLATION_BEIDOU = 5; // 0x5 + field public static final int CONSTELLATION_GALILEO = 6; // 0x6 + field public static final int CONSTELLATION_GLONASS = 3; // 0x3 + field public static final int CONSTELLATION_GPS = 1; // 0x1 + field public static final int CONSTELLATION_QZSS = 4; // 0x4 + field public static final int CONSTELLATION_SBAS = 2; // 0x2 + field public static final int CONSTELLATION_UNKNOWN = 0; // 0x0 + } + + public abstract class GnssStatusCallback { + ctor public GnssStatusCallback(); + method public void onFirstFix(int); + method public void onSatelliteStatusChanged(android.location.GnssStatus); + method public void onStarted(); + method public void onStopped(); } public final class GpsSatellite { @@ -19498,12 +19498,12 @@ package android.location { method public java.util.List<java.lang.String> getProviders(boolean); method public java.util.List<java.lang.String> getProviders(android.location.Criteria, boolean); method public boolean isProviderEnabled(java.lang.String); + method public boolean registerGnssMeasurementCallback(android.location.GnssMeasurementsEvent.Callback); + method public boolean registerGnssMeasurementCallback(android.location.GnssMeasurementsEvent.Callback, android.os.Handler); + method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback); + method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback, android.os.Handler); method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback); method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback, android.os.Handler); - method public boolean registerGpsMeasurementCallback(android.location.GpsMeasurementsEvent.Callback); - method public boolean registerGpsMeasurementCallback(android.location.GpsMeasurementsEvent.Callback, android.os.Handler); - method public boolean registerGpsNavigationMessageCallback(android.location.GpsNavigationMessageEvent.Callback); - method public boolean registerGpsNavigationMessageCallback(android.location.GpsNavigationMessageEvent.Callback, android.os.Handler); method public deprecated void removeGpsStatusListener(android.location.GpsStatus.Listener); method public deprecated void removeNmeaListener(android.location.GpsStatus.NmeaListener); method public void removeNmeaListener(android.location.GnssNmeaListener); @@ -19524,9 +19524,9 @@ package android.location { method public void setTestProviderEnabled(java.lang.String, boolean); method public void setTestProviderLocation(java.lang.String, android.location.Location); method public void setTestProviderStatus(java.lang.String, int, android.os.Bundle, long); + method public void unregisterGnssMeasurementCallback(android.location.GnssMeasurementsEvent.Callback); + method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback); method public void unregisterGnssStatusCallback(android.location.GnssStatusCallback); - method public void unregisterGpsMeasurementCallback(android.location.GpsMeasurementsEvent.Callback); - method public void unregisterGpsNavigationMessageCallback(android.location.GpsNavigationMessageEvent.Callback); field public static final java.lang.String GPS_PROVIDER = "gps"; field public static final java.lang.String KEY_LOCATION_CHANGED = "location"; field public static final java.lang.String KEY_PROVIDER_ENABLED = "providerEnabled"; diff --git a/api/system-current.txt b/api/system-current.txt index 7c181c80fd9e..909b296e84bc 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -20296,6 +20296,257 @@ package android.location { method public static boolean isPresent(); } + public final class GnssClock implements android.os.Parcelable { + method public int describeContents(); + method public double getBiasInNs(); + method public double getBiasUncertaintyInNs(); + method public double getDriftInNsPerSec(); + method public double getDriftUncertaintyInNsPerSec(); + method public long getFullBiasInNs(); + method public short getLeapSecond(); + method public long getTimeInNs(); + method public long getTimeOfLastHwClockDiscontinuityInNs(); + method public double getTimeUncertaintyInNs(); + method public byte getType(); + method public boolean hasBiasInNs(); + method public boolean hasBiasUncertaintyInNs(); + method public boolean hasDriftInNsPerSec(); + method public boolean hasDriftUncertaintyInNsPerSec(); + method public boolean hasFullBiasInNs(); + method public boolean hasLeapSecond(); + method public boolean hasTimeUncertaintyInNs(); + method public void reset(); + method public void resetBiasInNs(); + method public void resetBiasUncertaintyInNs(); + method public void resetDriftInNsPerSec(); + method public void resetDriftUncertaintyInNsPerSec(); + method public void resetFullBiasInNs(); + method public void resetLeapSecond(); + method public void resetTimeUncertaintyInNs(); + method public void set(android.location.GnssClock); + method public void setBiasInNs(double); + method public void setBiasUncertaintyInNs(double); + method public void setDriftInNsPerSec(double); + method public void setDriftUncertaintyInNsPerSec(double); + method public void setFullBiasInNs(long); + method public void setLeapSecond(short); + method public void setTimeInNs(long); + method public void setTimeOfLastHwClockDiscontinuityInNs(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(); + method public short getAccumulatedDeltaRangeState(); + method public double getAccumulatedDeltaRangeUncertaintyInMeters(); + method public double getAzimuthInDeg(); + method public double getAzimuthUncertaintyInDeg(); + method public int getBitNumber(); + method public long getCarrierCycles(); + method public float getCarrierFrequencyInHz(); + method public double getCarrierPhase(); + method public double getCarrierPhaseUncertainty(); + method public double getCn0InDbHz(); + method public double getCodePhaseInChips(); + method public double getCodePhaseUncertaintyInChips(); + method public double getDopplerShiftInHz(); + method public double getDopplerShiftUncertaintyInHz(); + method public double getElevationInDeg(); + method public double getElevationUncertaintyInDeg(); + method public byte getLossOfLock(); + method public byte getMultipathIndicator(); + method public byte getPrn(); + method public double getPseudorangeInMeters(); + method public double getPseudorangeRateCarrierInMetersPerSec(); + method public double getPseudorangeRateCarrierUncertaintyInMetersPerSec(); + method public double getPseudorangeRateInMetersPerSec(); + method public double getPseudorangeRateUncertaintyInMetersPerSec(); + method public double getPseudorangeUncertaintyInMeters(); + method public long getReceivedGpsTowInNs(); + method public long getReceivedGpsTowUncertaintyInNs(); + method public double getSnrInDb(); + method public short getState(); + method public short getTimeFromLastBitInMs(); + method public double getTimeOffsetInNs(); + method public boolean hasAzimuthInDeg(); + method public boolean hasAzimuthUncertaintyInDeg(); + method public boolean hasBitNumber(); + method public boolean hasCarrierCycles(); + method public boolean hasCarrierFrequencyInHz(); + method public boolean hasCarrierPhase(); + method public boolean hasCarrierPhaseUncertainty(); + method public boolean hasCodePhaseInChips(); + method public boolean hasCodePhaseUncertaintyInChips(); + method public boolean hasDopplerShiftInHz(); + method public boolean hasDopplerShiftUncertaintyInHz(); + method public boolean hasElevationInDeg(); + method public boolean hasElevationUncertaintyInDeg(); + method public boolean hasPseudorangeInMeters(); + method public boolean hasPseudorangeUncertaintyInMeters(); + method public boolean hasSnrInDb(); + method public boolean hasTimeFromLastBitInMs(); + method public boolean isPseudorangeRateCorrected(); + method public boolean isUsedInFix(); + method public void reset(); + method public void resetAzimuthInDeg(); + method public void resetAzimuthUncertaintyInDeg(); + method public void resetBitNumber(); + method public void resetCarrierCycles(); + method public void resetCarrierFrequencyInHz(); + method public void resetCarrierPhase(); + method public void resetCarrierPhaseUncertainty(); + method public void resetCodePhaseInChips(); + method public void resetCodePhaseUncertaintyInChips(); + method public void resetDopplerShiftInHz(); + method public void resetDopplerShiftUncertaintyInHz(); + method public void resetElevationInDeg(); + method public void resetElevationUncertaintyInDeg(); + method public void resetPseudorangeInMeters(); + method public void resetPseudorangeUncertaintyInMeters(); + method public void resetSnrInDb(); + method public void resetTimeFromLastBitInMs(); + method public void set(android.location.GnssMeasurement); + method public void setAccumulatedDeltaRangeInMeters(double); + method public void setAccumulatedDeltaRangeState(short); + method public void setAccumulatedDeltaRangeUncertaintyInMeters(double); + method public void setAzimuthInDeg(double); + method public void setAzimuthUncertaintyInDeg(double); + method public void setBitNumber(int); + method public void setCarrierCycles(long); + method public void setCarrierFrequencyInHz(float); + method public void setCarrierPhase(double); + method public void setCarrierPhaseUncertainty(double); + method public void setCn0InDbHz(double); + method public void setCodePhaseInChips(double); + method public void setCodePhaseUncertaintyInChips(double); + method public void setDopplerShiftInHz(double); + method public void setDopplerShiftUncertaintyInHz(double); + method public void setElevationInDeg(double); + method public void setElevationUncertaintyInDeg(double); + method public void setLossOfLock(byte); + method public void setMultipathIndicator(byte); + method public void setPrn(byte); + method public void setPseudorangeInMeters(double); + method public void setPseudorangeRateCarrierInMetersPerSec(double); + method public void setPseudorangeRateCarrierUncertaintyInMetersPerSec(double); + method public void setPseudorangeRateInMetersPerSec(double); + method public void setPseudorangeRateUncertaintyInMetersPerSec(double); + method public void setPseudorangeUncertaintyInMeters(double); + method public void setReceivedGpsTowInNs(long); + method public void setReceivedGpsTowUncertaintyInNs(long); + method public void setSnrInDb(double); + method public void setState(short); + method public void setTimeFromLastBitInMs(short); + method public void setTimeOffsetInNs(double); + method public void setUsedInFix(boolean); + method public void writeToParcel(android.os.Parcel, int); + field public static final short ADR_STATE_CYCLE_SLIP = 4; // 0x4 + field public static final short ADR_STATE_RESET = 2; // 0x2 + field public static final short ADR_STATE_UNKNOWN = 0; // 0x0 + field public static final short ADR_STATE_VALID = 1; // 0x1 + field public static final android.os.Parcelable.Creator<android.location.GnssMeasurement> CREATOR; + field public static final byte LOSS_OF_LOCK_CYCLE_SLIP = 2; // 0x2 + field public static final byte LOSS_OF_LOCK_OK = 1; // 0x1 + field public static final byte LOSS_OF_LOCK_UNKNOWN = 0; // 0x0 + field public static final byte MULTIPATH_INDICATOR_DETECTED = 1; // 0x1 + field public static final byte MULTIPATH_INDICATOR_NOT_USED = 2; // 0x2 + field public static final byte MULTIPATH_INDICATOR_UNKNOWN = 0; // 0x0 + field public static final short STATE_BIT_SYNC = 2; // 0x2 + field public static final short STATE_CODE_LOCK = 1; // 0x1 + field public static final short STATE_MSEC_AMBIGUOUS = 16; // 0x10 + field public static final short STATE_SUBFRAME_SYNC = 4; // 0x4 + field public static final short STATE_TOW_DECODED = 8; // 0x8 + field public static final short STATE_UNKNOWN = 0; // 0x0 + } + + public static abstract class GnssMeasurement.LossOfLockStatus implements java.lang.annotation.Annotation { + } + + public static abstract class GnssMeasurement.MultipathIndicator implements java.lang.annotation.Annotation { + } + + public final class GnssMeasurementsEvent implements android.os.Parcelable { + ctor public GnssMeasurementsEvent(android.location.GnssClock, android.location.GnssMeasurement[]); + method public int describeContents(); + method public android.location.GnssClock getClock(); + method public java.util.Collection<android.location.GnssMeasurement> getMeasurements(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator<android.location.GnssMeasurementsEvent> CREATOR; + field public static final int STATUS_GPS_LOCATION_DISABLED = 2; // 0x2 + field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0 + field public static final int STATUS_READY = 1; // 0x1 + } + + public static abstract class GnssMeasurementsEvent.Callback { + ctor public GnssMeasurementsEvent.Callback(); + method public void onGnssMeasurementsReceived(android.location.GnssMeasurementsEvent); + method public void onStatusChanged(int); + } + + public static abstract class GnssMeasurementsEvent.GnssMeasurementsStatus implements java.lang.annotation.Annotation { + } + + public final class GnssNavigationMessage implements android.os.Parcelable { + method public int describeContents(); + method public byte[] getData(); + method public short getMessageId(); + method public byte getPrn(); + method public short getStatus(); + method public short getSubmessageId(); + method public byte getType(); + method public void reset(); + method public void set(android.location.GnssNavigationMessage); + method public void setData(byte[]); + method public void setMessageId(short); + method public void setPrn(byte); + method public void setStatus(short); + method public void setSubmessageId(short); + method public void setType(byte); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessage> CREATOR; + field public static final byte MESSAGE_TYPE_CNAV2 = 4; // 0x4 + field public static final byte MESSAGE_TYPE_L1CA = 1; // 0x1 + field public static final byte MESSAGE_TYPE_L2CNAV = 2; // 0x2 + field public static final byte MESSAGE_TYPE_L5CNAV = 3; // 0x3 + field public static final byte MESSAGE_TYPE_UNKNOWN = 0; // 0x0 + field public static final short STATUS_PARITY_PASSED = 1; // 0x1 + field public static final short STATUS_PARITY_REBUILT = 2; // 0x2 + field public static final short STATUS_UNKNOWN = 0; // 0x0 + } + + public static abstract class GnssNavigationMessage.GnssNavigationMessageType implements java.lang.annotation.Annotation { + } + + public final class GnssNavigationMessageEvent implements android.os.Parcelable { + ctor public GnssNavigationMessageEvent(android.location.GnssNavigationMessage); + method public int describeContents(); + method public android.location.GnssNavigationMessage getNavigationMessage(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessageEvent> CREATOR; + field public static final int STATUS_GPS_LOCATION_DISABLED = 2; // 0x2 + field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0 + field public static final int STATUS_READY = 1; // 0x1 + } + + public static abstract class GnssNavigationMessageEvent.Callback { + ctor public GnssNavigationMessageEvent.Callback(); + method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessageEvent); + method public void onStatusChanged(int); + } + + public static abstract class GnssNavigationMessageEvent.GnssNavigationMessageStatus implements java.lang.annotation.Annotation { + } + public abstract interface GnssNmeaListener { method public abstract void onNmeaReceived(long, java.lang.String); } @@ -20327,7 +20578,7 @@ package android.location { method public void onStopped(); } - public final class GpsClock implements android.os.Parcelable { + public class GpsClock implements android.os.Parcelable { method public int describeContents(); method public double getBiasInNs(); method public double getBiasUncertaintyInNs(); @@ -20336,7 +20587,6 @@ package android.location { method public long getFullBiasInNs(); method public short getLeapSecond(); method public long getTimeInNs(); - method public long getTimeOfLastHwClockDiscontinuityInNs(); method public double getTimeUncertaintyInNs(); method public byte getType(); method public boolean hasBiasInNs(); @@ -20362,20 +20612,16 @@ package android.location { method public void setFullBiasInNs(long); method public void setLeapSecond(short); method public void setTimeInNs(long); - method public void setTimeOfLastHwClockDiscontinuityInNs(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.GpsClock> CREATOR; + field public static final byte TYPE_GPS_TIME = 2; // 0x2 + field public static final byte TYPE_LOCAL_HW_TIME = 1; // 0x1 + field public static final byte TYPE_UNKNOWN = 0; // 0x0 } - public static abstract class GpsClock.GpsClockType implements java.lang.annotation.Annotation { - } - - public final class GpsMeasurement implements android.os.Parcelable { + public class GpsMeasurement implements android.os.Parcelable { method public int describeContents(); method public double getAccumulatedDeltaRangeInMeters(); method public short getAccumulatedDeltaRangeState(); @@ -20398,8 +20644,6 @@ package android.location { method public byte getMultipathIndicator(); method public byte getPrn(); method public double getPseudorangeInMeters(); - method public double getPseudorangeRateCarrierInMetersPerSec(); - method public double getPseudorangeRateCarrierUncertaintyInMetersPerSec(); method public double getPseudorangeRateInMetersPerSec(); method public double getPseudorangeRateUncertaintyInMetersPerSec(); method public double getPseudorangeUncertaintyInMeters(); @@ -20468,8 +20712,6 @@ package android.location { method public void setMultipathIndicator(byte); method public void setPrn(byte); method public void setPseudorangeInMeters(double); - method public void setPseudorangeRateCarrierInMetersPerSec(double); - method public void setPseudorangeRateCarrierUncertaintyInMetersPerSec(double); method public void setPseudorangeRateInMetersPerSec(double); method public void setPseudorangeRateUncertaintyInMetersPerSec(double); method public void setPseudorangeUncertaintyInMeters(double); @@ -20500,13 +20742,7 @@ package android.location { field public static final short STATE_UNKNOWN = 0; // 0x0 } - public static abstract class GpsMeasurement.LossOfLockStatus implements java.lang.annotation.Annotation { - } - - public static abstract class GpsMeasurement.MultipathIndicator implements java.lang.annotation.Annotation { - } - - public final class GpsMeasurementsEvent implements android.os.Parcelable { + public class GpsMeasurementsEvent implements android.os.Parcelable { ctor public GpsMeasurementsEvent(android.location.GpsClock, android.location.GpsMeasurement[]); method public int describeContents(); method public android.location.GpsClock getClock(); @@ -20518,16 +20754,12 @@ package android.location { field public static final int STATUS_READY = 1; // 0x1 } - public static abstract class GpsMeasurementsEvent.Callback { - ctor public GpsMeasurementsEvent.Callback(); - method public void onGpsMeasurementsReceived(android.location.GpsMeasurementsEvent); - method public void onStatusChanged(int); - } - - public static abstract class GpsMeasurementsEvent.GpsMeasurementsStatus implements java.lang.annotation.Annotation { + public static abstract interface GpsMeasurementsEvent.Listener { + method public abstract void onGpsMeasurementsReceived(android.location.GpsMeasurementsEvent); + method public abstract void onStatusChanged(int); } - public final class GpsNavigationMessage implements android.os.Parcelable { + public class GpsNavigationMessage implements android.os.Parcelable { method public int describeContents(); method public byte[] getData(); method public short getMessageId(); @@ -20545,37 +20777,30 @@ package android.location { method public void setType(byte); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.location.GpsNavigationMessage> CREATOR; - field public static final byte MESSAGE_TYPE_CNAV2 = 4; // 0x4 - field public static final byte MESSAGE_TYPE_L1CA = 1; // 0x1 - field public static final byte MESSAGE_TYPE_L2CNAV = 2; // 0x2 - field public static final byte MESSAGE_TYPE_L5CNAV = 3; // 0x3 - field public static final byte MESSAGE_TYPE_UNKNOWN = 0; // 0x0 field public static final short STATUS_PARITY_PASSED = 1; // 0x1 field public static final short STATUS_PARITY_REBUILT = 2; // 0x2 field public static final short STATUS_UNKNOWN = 0; // 0x0 + field public static final byte TYPE_CNAV2 = 4; // 0x4 + field public static final byte TYPE_L1CA = 1; // 0x1 + field public static final byte TYPE_L2CNAV = 2; // 0x2 + field public static final byte TYPE_L5CNAV = 3; // 0x3 + field public static final byte TYPE_UNKNOWN = 0; // 0x0 } - public static abstract class GpsNavigationMessage.GpsNavigationMessageType implements java.lang.annotation.Annotation { - } - - public final class GpsNavigationMessageEvent implements android.os.Parcelable { + public class GpsNavigationMessageEvent implements android.os.Parcelable { ctor public GpsNavigationMessageEvent(android.location.GpsNavigationMessage); method public int describeContents(); method public android.location.GpsNavigationMessage getNavigationMessage(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.location.GpsNavigationMessageEvent> CREATOR; - field public static final int STATUS_GPS_LOCATION_DISABLED = 2; // 0x2 - field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0 - field public static final int STATUS_READY = 1; // 0x1 + field public static int STATUS_GPS_LOCATION_DISABLED; + field public static int STATUS_NOT_SUPPORTED; + field public static int STATUS_READY; } - public static abstract class GpsNavigationMessageEvent.Callback { - ctor public GpsNavigationMessageEvent.Callback(); - method public void onGpsNavigationMessageReceived(android.location.GpsNavigationMessageEvent); - method public void onStatusChanged(int); - } - - public static abstract class GpsNavigationMessageEvent.GpsNavigationMessageStatus implements java.lang.annotation.Annotation { + public static abstract interface GpsNavigationMessageEvent.Listener { + method public abstract void onGpsNavigationMessageReceived(android.location.GpsNavigationMessageEvent); + method public abstract void onStatusChanged(int); } public final class GpsSatellite { @@ -20682,6 +20907,8 @@ package android.location { } public class LocationManager { + method public deprecated boolean addGpsMeasurementListener(android.location.GpsMeasurementsEvent.Listener); + method public deprecated boolean addGpsNavigationMessageListener(android.location.GpsNavigationMessageEvent.Listener); method public deprecated boolean addGpsStatusListener(android.location.GpsStatus.Listener); method public deprecated boolean addNmeaListener(android.location.GpsStatus.NmeaListener); method public boolean addNmeaListener(android.location.GnssNmeaListener); @@ -20699,12 +20926,14 @@ package android.location { method public java.util.List<java.lang.String> getProviders(boolean); method public java.util.List<java.lang.String> getProviders(android.location.Criteria, boolean); method public boolean isProviderEnabled(java.lang.String); + method public boolean registerGnssMeasurementCallback(android.location.GnssMeasurementsEvent.Callback); + method public boolean registerGnssMeasurementCallback(android.location.GnssMeasurementsEvent.Callback, android.os.Handler); + method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback); + method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback, android.os.Handler); method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback); method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback, android.os.Handler); - method public boolean registerGpsMeasurementCallback(android.location.GpsMeasurementsEvent.Callback); - method public boolean registerGpsMeasurementCallback(android.location.GpsMeasurementsEvent.Callback, android.os.Handler); - method public boolean registerGpsNavigationMessageCallback(android.location.GpsNavigationMessageEvent.Callback); - method public boolean registerGpsNavigationMessageCallback(android.location.GpsNavigationMessageEvent.Callback, android.os.Handler); + method public deprecated void removeGpsMeasurementListener(android.location.GpsMeasurementsEvent.Listener); + method public deprecated void removeGpsNavigationMessageListener(android.location.GpsNavigationMessageEvent.Listener); method public deprecated void removeGpsStatusListener(android.location.GpsStatus.Listener); method public deprecated void removeNmeaListener(android.location.GpsStatus.NmeaListener); method public void removeNmeaListener(android.location.GnssNmeaListener); @@ -20727,9 +20956,9 @@ package android.location { method public void setTestProviderEnabled(java.lang.String, boolean); method public void setTestProviderLocation(java.lang.String, android.location.Location); method public void setTestProviderStatus(java.lang.String, int, android.os.Bundle, long); + method public void unregisterGnssMeasurementCallback(android.location.GnssMeasurementsEvent.Callback); + method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback); method public void unregisterGnssStatusCallback(android.location.GnssStatusCallback); - method public void unregisterGpsMeasurementCallback(android.location.GpsMeasurementsEvent.Callback); - method public void unregisterGpsNavigationMessageCallback(android.location.GpsNavigationMessageEvent.Callback); field public static final java.lang.String GPS_PROVIDER = "gps"; field public static final java.lang.String KEY_LOCATION_CHANGED = "location"; field public static final java.lang.String KEY_PROVIDER_ENABLED = "providerEnabled"; diff --git a/api/test-current.txt b/api/test-current.txt index 8551950c1c9e..86ad3e6507ed 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -19123,38 +19123,7 @@ package android.location { method public static boolean isPresent(); } - public abstract interface GnssNmeaListener { - method public abstract void onNmeaReceived(long, java.lang.String); - } - - public final class GnssStatus { - method public float getAzimuth(int); - method public int getConstellationType(int); - method public float getElevation(int); - method public int getNumSatellites(); - method public int getPrn(int); - method public float getSnr(int); - method public boolean hasAlmanac(int); - method public boolean hasEphemeris(int); - method public boolean usedInFix(int); - field public static final int CONSTELLATION_BEIDOU = 5; // 0x5 - field public static final int CONSTELLATION_GALILEO = 6; // 0x6 - field public static final int CONSTELLATION_GLONASS = 3; // 0x3 - field public static final int CONSTELLATION_GPS = 1; // 0x1 - field public static final int CONSTELLATION_QZSS = 4; // 0x4 - field public static final int CONSTELLATION_SBAS = 2; // 0x2 - field public static final int CONSTELLATION_UNKNOWN = 0; // 0x0 - } - - public abstract class GnssStatusCallback { - ctor public GnssStatusCallback(); - method public void onFirstFix(int); - method public void onSatelliteStatusChanged(android.location.GnssStatus); - method public void onStarted(); - method public void onStopped(); - } - - public final class GpsClock implements android.os.Parcelable { + public final class GnssClock implements android.os.Parcelable { method public int describeContents(); method public double getBiasInNs(); method public double getBiasUncertaintyInNs(); @@ -19181,7 +19150,7 @@ package android.location { method public void resetFullBiasInNs(); method public void resetLeapSecond(); method public void resetTimeUncertaintyInNs(); - method public void set(android.location.GpsClock); + method public void set(android.location.GnssClock); method public void setBiasInNs(double); method public void setBiasUncertaintyInNs(double); method public void setDriftInNsPerSec(double); @@ -19196,13 +19165,13 @@ package android.location { 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.GpsClock> CREATOR; + field public static final android.os.Parcelable.Creator<android.location.GnssClock> CREATOR; } - public static abstract class GpsClock.GpsClockType implements java.lang.annotation.Annotation { + public static abstract class GnssClock.GnssClockType implements java.lang.annotation.Annotation { } - public final class GpsMeasurement implements android.os.Parcelable { + public final class GnssMeasurement implements android.os.Parcelable { method public int describeContents(); method public double getAccumulatedDeltaRangeInMeters(); method public short getAccumulatedDeltaRangeState(); @@ -19273,7 +19242,7 @@ package android.location { method public void resetPseudorangeUncertaintyInMeters(); method public void resetSnrInDb(); method public void resetTimeFromLastBitInMs(); - method public void set(android.location.GpsMeasurement); + method public void set(android.location.GnssMeasurement); method public void setAccumulatedDeltaRangeInMeters(double); method public void setAccumulatedDeltaRangeState(short); method public void setAccumulatedDeltaRangeUncertaintyInMeters(double); @@ -19312,7 +19281,7 @@ package android.location { field public static final short ADR_STATE_RESET = 2; // 0x2 field public static final short ADR_STATE_UNKNOWN = 0; // 0x0 field public static final short ADR_STATE_VALID = 1; // 0x1 - field public static final android.os.Parcelable.Creator<android.location.GpsMeasurement> CREATOR; + field public static final android.os.Parcelable.Creator<android.location.GnssMeasurement> CREATOR; field public static final byte LOSS_OF_LOCK_CYCLE_SLIP = 2; // 0x2 field public static final byte LOSS_OF_LOCK_OK = 1; // 0x1 field public static final byte LOSS_OF_LOCK_UNKNOWN = 0; // 0x0 @@ -19327,34 +19296,34 @@ package android.location { field public static final short STATE_UNKNOWN = 0; // 0x0 } - public static abstract class GpsMeasurement.LossOfLockStatus implements java.lang.annotation.Annotation { + public static abstract class GnssMeasurement.LossOfLockStatus implements java.lang.annotation.Annotation { } - public static abstract class GpsMeasurement.MultipathIndicator implements java.lang.annotation.Annotation { + public static abstract class GnssMeasurement.MultipathIndicator implements java.lang.annotation.Annotation { } - public final class GpsMeasurementsEvent implements android.os.Parcelable { - ctor public GpsMeasurementsEvent(android.location.GpsClock, android.location.GpsMeasurement[]); + public final class GnssMeasurementsEvent implements android.os.Parcelable { + ctor public GnssMeasurementsEvent(android.location.GnssClock, android.location.GnssMeasurement[]); method public int describeContents(); - method public android.location.GpsClock getClock(); - method public java.util.Collection<android.location.GpsMeasurement> getMeasurements(); + method public android.location.GnssClock getClock(); + method public java.util.Collection<android.location.GnssMeasurement> getMeasurements(); method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.location.GpsMeasurementsEvent> CREATOR; + field public static final android.os.Parcelable.Creator<android.location.GnssMeasurementsEvent> CREATOR; field public static final int STATUS_GPS_LOCATION_DISABLED = 2; // 0x2 field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0 field public static final int STATUS_READY = 1; // 0x1 } - public static abstract class GpsMeasurementsEvent.Callback { - ctor public GpsMeasurementsEvent.Callback(); - method public void onGpsMeasurementsReceived(android.location.GpsMeasurementsEvent); + public static abstract class GnssMeasurementsEvent.Callback { + ctor public GnssMeasurementsEvent.Callback(); + method public void onGnssMeasurementsReceived(android.location.GnssMeasurementsEvent); method public void onStatusChanged(int); } - public static abstract class GpsMeasurementsEvent.GpsMeasurementsStatus implements java.lang.annotation.Annotation { + public static abstract class GnssMeasurementsEvent.GnssMeasurementsStatus implements java.lang.annotation.Annotation { } - public final class GpsNavigationMessage implements android.os.Parcelable { + public final class GnssNavigationMessage implements android.os.Parcelable { method public int describeContents(); method public byte[] getData(); method public short getMessageId(); @@ -19363,7 +19332,7 @@ package android.location { method public short getSubmessageId(); method public byte getType(); method public void reset(); - method public void set(android.location.GpsNavigationMessage); + method public void set(android.location.GnssNavigationMessage); method public void setData(byte[]); method public void setMessageId(short); method public void setPrn(byte); @@ -19371,7 +19340,7 @@ package android.location { method public void setSubmessageId(short); method public void setType(byte); method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.location.GpsNavigationMessage> CREATOR; + field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessage> CREATOR; field public static final byte MESSAGE_TYPE_CNAV2 = 4; // 0x4 field public static final byte MESSAGE_TYPE_L1CA = 1; // 0x1 field public static final byte MESSAGE_TYPE_L2CNAV = 2; // 0x2 @@ -19382,27 +19351,58 @@ package android.location { field public static final short STATUS_UNKNOWN = 0; // 0x0 } - public static abstract class GpsNavigationMessage.GpsNavigationMessageType implements java.lang.annotation.Annotation { + public static abstract class GnssNavigationMessage.GnssNavigationMessageType implements java.lang.annotation.Annotation { } - public final class GpsNavigationMessageEvent implements android.os.Parcelable { - ctor public GpsNavigationMessageEvent(android.location.GpsNavigationMessage); + public final class GnssNavigationMessageEvent implements android.os.Parcelable { + ctor public GnssNavigationMessageEvent(android.location.GnssNavigationMessage); method public int describeContents(); - method public android.location.GpsNavigationMessage getNavigationMessage(); + method public android.location.GnssNavigationMessage getNavigationMessage(); method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.location.GpsNavigationMessageEvent> CREATOR; + field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessageEvent> CREATOR; field public static final int STATUS_GPS_LOCATION_DISABLED = 2; // 0x2 field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0 field public static final int STATUS_READY = 1; // 0x1 } - public static abstract class GpsNavigationMessageEvent.Callback { - ctor public GpsNavigationMessageEvent.Callback(); - method public void onGpsNavigationMessageReceived(android.location.GpsNavigationMessageEvent); + public static abstract class GnssNavigationMessageEvent.Callback { + ctor public GnssNavigationMessageEvent.Callback(); + method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessageEvent); method public void onStatusChanged(int); } - public static abstract class GpsNavigationMessageEvent.GpsNavigationMessageStatus implements java.lang.annotation.Annotation { + public static abstract class GnssNavigationMessageEvent.GnssNavigationMessageStatus implements java.lang.annotation.Annotation { + } + + public abstract interface GnssNmeaListener { + method public abstract void onNmeaReceived(long, java.lang.String); + } + + public final class GnssStatus { + method public float getAzimuth(int); + method public int getConstellationType(int); + method public float getElevation(int); + method public int getNumSatellites(); + method public int getPrn(int); + method public float getSnr(int); + method public boolean hasAlmanac(int); + method public boolean hasEphemeris(int); + method public boolean usedInFix(int); + field public static final int CONSTELLATION_BEIDOU = 5; // 0x5 + field public static final int CONSTELLATION_GALILEO = 6; // 0x6 + field public static final int CONSTELLATION_GLONASS = 3; // 0x3 + field public static final int CONSTELLATION_GPS = 1; // 0x1 + field public static final int CONSTELLATION_QZSS = 4; // 0x4 + field public static final int CONSTELLATION_SBAS = 2; // 0x2 + field public static final int CONSTELLATION_UNKNOWN = 0; // 0x0 + } + + public abstract class GnssStatusCallback { + ctor public GnssStatusCallback(); + method public void onFirstFix(int); + method public void onSatelliteStatusChanged(android.location.GnssStatus); + method public void onStarted(); + method public void onStopped(); } public final class GpsSatellite { @@ -19507,12 +19507,12 @@ package android.location { method public java.util.List<java.lang.String> getProviders(boolean); method public java.util.List<java.lang.String> getProviders(android.location.Criteria, boolean); method public boolean isProviderEnabled(java.lang.String); + method public boolean registerGnssMeasurementCallback(android.location.GnssMeasurementsEvent.Callback); + method public boolean registerGnssMeasurementCallback(android.location.GnssMeasurementsEvent.Callback, android.os.Handler); + method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback); + method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback, android.os.Handler); method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback); method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback, android.os.Handler); - method public boolean registerGpsMeasurementCallback(android.location.GpsMeasurementsEvent.Callback); - method public boolean registerGpsMeasurementCallback(android.location.GpsMeasurementsEvent.Callback, android.os.Handler); - method public boolean registerGpsNavigationMessageCallback(android.location.GpsNavigationMessageEvent.Callback); - method public boolean registerGpsNavigationMessageCallback(android.location.GpsNavigationMessageEvent.Callback, android.os.Handler); method public deprecated void removeGpsStatusListener(android.location.GpsStatus.Listener); method public deprecated void removeNmeaListener(android.location.GpsStatus.NmeaListener); method public void removeNmeaListener(android.location.GnssNmeaListener); @@ -19533,9 +19533,9 @@ package android.location { method public void setTestProviderEnabled(java.lang.String, boolean); method public void setTestProviderLocation(java.lang.String, android.location.Location); method public void setTestProviderStatus(java.lang.String, int, android.os.Bundle, long); + method public void unregisterGnssMeasurementCallback(android.location.GnssMeasurementsEvent.Callback); + method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessageEvent.Callback); method public void unregisterGnssStatusCallback(android.location.GnssStatusCallback); - method public void unregisterGpsMeasurementCallback(android.location.GpsMeasurementsEvent.Callback); - method public void unregisterGpsNavigationMessageCallback(android.location.GpsNavigationMessageEvent.Callback); field public static final java.lang.String GPS_PROVIDER = "gps"; field public static final java.lang.String KEY_LOCATION_CHANGED = "location"; field public static final java.lang.String KEY_PROVIDER_ENABLED = "providerEnabled"; diff --git a/location/java/android/location/GnssClock.java b/location/java/android/location/GnssClock.java new file mode 100644 index 000000000000..37ef3df7990f --- /dev/null +++ b/location/java/android/location/GnssClock.java @@ -0,0 +1,532 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +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); + private static final short HAS_FULL_BIAS = (1<<2); + private static final short HAS_BIAS = (1<<3); + private static final short HAS_BIAS_UNCERTAINTY = (1<<4); + private static final short HAS_DRIFT = (1<<5); + private static final short HAS_DRIFT_UNCERTAINTY = (1<<6); + + // End enumerations in sync with gps.h + + 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; + private long mTimeOfLastHwClockDiscontinuityInNs; + + GnssClock() { + initialize(); + } + + /** + * Sets all contents to the values stored in the provided object. + */ + public void set(GnssClock clock) { + 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; + mTimeOfLastHwClockDiscontinuityInNs = clock.mTimeOfLastHwClockDiscontinuityInNs; + } + + /** + * Resets all the contents to its original state. + */ + public void reset() { + 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. + */ + public boolean hasLeapSecond() { + return isFlagSet(HAS_LEAP_SECOND); + } + + /** + * 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. + */ + public short getLeapSecond() { + return mLeapSecond; + } + + /** + * Sets the leap second associated with the clock's time. + */ + public void setLeapSecond(short leapSecond) { + setFlag(HAS_LEAP_SECOND); + mLeapSecond = leapSecond; + } + + /** + * Resets the leap second associated with the clock's time. + */ + public void resetLeapSecond() { + resetFlag(HAS_LEAP_SECOND); + mLeapSecond = Short.MIN_VALUE; + } + + /** + * 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. + * + * 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()}. + */ + public long getTimeInNs() { + return mTimeInNs; + } + + /** + * Sets the GPS receiver internal clock in nanoseconds. + */ + public void setTimeInNs(long timeInNs) { + mTimeInNs = timeInNs; + } + + /** + * Returns true if {@link #getTimeUncertaintyInNs()} is available, false otherwise. + */ + public boolean hasTimeUncertaintyInNs() { + return isFlagSet(HAS_TIME_UNCERTAINTY); + } + + /** + * 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. + */ + public double getTimeUncertaintyInNs() { + return mTimeUncertaintyInNs; + } + + /** + * Sets the clock's Time Uncertainty (1-Sigma) in nanoseconds. + */ + public void setTimeUncertaintyInNs(double timeUncertaintyInNs) { + setFlag(HAS_TIME_UNCERTAINTY); + mTimeUncertaintyInNs = timeUncertaintyInNs; + } + + /** + * Resets the clock's Time Uncertainty (1-Sigma) in nanoseconds. + */ + public void resetTimeUncertaintyInNs() { + resetFlag(HAS_TIME_UNCERTAINTY); + mTimeUncertaintyInNs = Double.NaN; + } + + /** + * Returns true if {@link #getFullBiasInNs()} is available, false otherwise. + */ + public boolean hasFullBiasInNs() { + return isFlagSet(HAS_FULL_BIAS); + } + + /** + * 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. + * + * 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. + */ + public long getFullBiasInNs() { + return mFullBiasInNs; + } + + /** + * Sets the full bias in nanoseconds. + */ + public void setFullBiasInNs(long value) { + setFlag(HAS_FULL_BIAS); + mFullBiasInNs = value; + } + + /** + * Resets the full bias in nanoseconds. + */ + public void resetFullBiasInNs() { + resetFlag(HAS_FULL_BIAS); + mFullBiasInNs = Long.MIN_VALUE; + } + + /** + * Returns true if {@link #getBiasInNs()} is available, false otherwise. + */ + public boolean hasBiasInNs() { + return isFlagSet(HAS_BIAS); + } + + /** + * Gets the clock's sub-nanosecond bias. + * The reported bias includes {@link #getBiasUncertaintyInNs()}. + * + * The value is only available if {@link #hasBiasInNs()} is true. + */ + public double getBiasInNs() { + return mBiasInNs; + } + + /** + * Sets the sub-nanosecond bias. + */ + public void setBiasInNs(double biasInNs) { + setFlag(HAS_BIAS); + mBiasInNs = biasInNs; + } + + /** + * Resets the clock's Bias in nanoseconds. + */ + public void resetBiasInNs() { + resetFlag(HAS_BIAS); + mBiasInNs = Double.NaN; + } + + /** + * Returns true if {@link #getBiasUncertaintyInNs()} is available, false otherwise. + */ + public boolean hasBiasUncertaintyInNs() { + return isFlagSet(HAS_BIAS_UNCERTAINTY); + } + + /** + * Gets the clock's Bias Uncertainty (1-Sigma) in nanoseconds. + * + * The value is only available if {@link #hasBiasUncertaintyInNs()} is true. + */ + public double getBiasUncertaintyInNs() { + return mBiasUncertaintyInNs; + } + + /** + * Sets the clock's Bias Uncertainty (1-Sigma) in nanoseconds. + */ + public void setBiasUncertaintyInNs(double biasUncertaintyInNs) { + setFlag(HAS_BIAS_UNCERTAINTY); + mBiasUncertaintyInNs = biasUncertaintyInNs; + } + + /** + * Resets the clock's Bias Uncertainty (1-Sigma) in nanoseconds. + */ + public void resetBiasUncertaintyInNs() { + resetFlag(HAS_BIAS_UNCERTAINTY); + mBiasUncertaintyInNs = Double.NaN; + } + + /** + * Returns true if {@link #getDriftInNsPerSec()} is available, false otherwise. + */ + public boolean hasDriftInNsPerSec() { + return isFlagSet(HAS_DRIFT); + } + + /** + * 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. + */ + public double getDriftInNsPerSec() { + return mDriftInNsPerSec; + } + + /** + * Sets the clock's Drift in nanoseconds per second. + */ + public void setDriftInNsPerSec(double driftInNsPerSec) { + setFlag(HAS_DRIFT); + mDriftInNsPerSec = driftInNsPerSec; + } + + /** + * Resets the clock's Drift in nanoseconds per second. + */ + public void resetDriftInNsPerSec() { + resetFlag(HAS_DRIFT); + mDriftInNsPerSec = Double.NaN; + } + + /** + * Returns true if {@link #getDriftUncertaintyInNsPerSec()} is available, false otherwise. + */ + public boolean hasDriftUncertaintyInNsPerSec() { + return isFlagSet(HAS_DRIFT_UNCERTAINTY); + } + + /** + * Gets the clock's Drift Uncertainty (1-Sigma) in nanoseconds per second. + * + * The value is only available if {@link #hasDriftUncertaintyInNsPerSec()} is true. + */ + public double getDriftUncertaintyInNsPerSec() { + return mDriftUncertaintyInNsPerSec; + } + + /** + * Sets the clock's Drift Uncertainty (1-Sigma) in nanoseconds per second. + */ + public void setDriftUncertaintyInNsPerSec(double driftUncertaintyInNsPerSec) { + setFlag(HAS_DRIFT_UNCERTAINTY); + mDriftUncertaintyInNsPerSec = driftUncertaintyInNsPerSec; + } + + /** + * Gets time of last hardware clock discontinuity. + */ + public long getTimeOfLastHwClockDiscontinuityInNs() { + return mTimeOfLastHwClockDiscontinuityInNs; + } + + /** + * Sets time of last hardware clock discontinuity. + */ + public void setTimeOfLastHwClockDiscontinuityInNs(long timeOfLastHwClockDiscontinuityInNs) { + mTimeOfLastHwClockDiscontinuityInNs = timeOfLastHwClockDiscontinuityInNs; + } + + /** + * Resets the clock's Drift Uncertainty (1-Sigma) in nanoseconds per second. + */ + public void resetDriftUncertaintyInNsPerSec() { + resetFlag(HAS_DRIFT_UNCERTAINTY); + mDriftUncertaintyInNsPerSec = Double.NaN; + } + + public static final Creator<GnssClock> CREATOR = new Creator<GnssClock>() { + @Override + public GnssClock createFromParcel(Parcel parcel) { + GnssClock gpsClock = new GnssClock(); + + 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(); + gpsClock.mBiasInNs = parcel.readDouble(); + gpsClock.mBiasUncertaintyInNs = parcel.readDouble(); + gpsClock.mDriftInNsPerSec = parcel.readDouble(); + gpsClock.mDriftUncertaintyInNsPerSec = parcel.readDouble(); + gpsClock.mTimeOfLastHwClockDiscontinuityInNs = parcel.readLong(); + + return gpsClock; + } + + @Override + public GnssClock[] newArray(int size) { + return new GnssClock[size]; + } + }; + + 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); + parcel.writeDouble(mBiasInNs); + parcel.writeDouble(mBiasUncertaintyInNs); + parcel.writeDouble(mDriftInNsPerSec); + parcel.writeDouble(mDriftUncertaintyInNsPerSec); + parcel.writeLong(mTimeOfLastHwClockDiscontinuityInNs); + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public String toString() { + final String format = " %-15s = %s\n"; + 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( + 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)); + + builder.append(String.format(format, "TimeOfLastHwClockDiscontinuityInNs", + getType() == CLOCK_TYPE_LOCAL_HW_TIME + ? mTimeOfLastHwClockDiscontinuityInNs : null)); + + return builder.toString(); + } + + private void initialize() { + mFlags = HAS_NO_FLAGS; + resetLeapSecond(); + setType(CLOCK_TYPE_UNKNOWN); + setTimeInNs(Long.MIN_VALUE); + resetTimeUncertaintyInNs(); + resetFullBiasInNs(); + resetBiasInNs(); + resetBiasUncertaintyInNs(); + resetDriftInNsPerSec(); + resetDriftUncertaintyInNsPerSec(); + setTimeOfLastHwClockDiscontinuityInNs(Long.MIN_VALUE); + } + + private void setFlag(short flag) { + mFlags |= flag; + } + + private void resetFlag(short flag) { + mFlags &= ~flag; + } + + private boolean isFlagSet(short flag) { + return (mFlags & flag) == flag; + } +} diff --git a/location/java/android/location/GnssMeasurement.java b/location/java/android/location/GnssMeasurement.java new file mode 100644 index 000000000000..d8f507c9b70e --- /dev/null +++ b/location/java/android/location/GnssMeasurement.java @@ -0,0 +1,1471 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +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 representing a GPS satellite measurement, containing raw and computed information. + */ +public final class GnssMeasurement implements Parcelable { + private int mFlags; + private byte mPrn; + private double mTimeOffsetInNs; + private short mState; + private long mReceivedGpsTowInNs; + private long mReceivedGpsTowUncertaintyInNs; + private double mCn0InDbHz; + private double mPseudorangeRateInMetersPerSec; + private double mPseudorangeRateUncertaintyInMetersPerSec; + private short mAccumulatedDeltaRangeState; + private double mAccumulatedDeltaRangeInMeters; + private double mAccumulatedDeltaRangeUncertaintyInMeters; + private double mPseudorangeInMeters; + private double mPseudorangeUncertaintyInMeters; + private double mCodePhaseInChips; + private double mCodePhaseUncertaintyInChips; + private float mCarrierFrequencyInHz; + private long mCarrierCycles; + private double mCarrierPhase; + private double mCarrierPhaseUncertainty; + private byte mLossOfLock; + private int mBitNumber; + private short mTimeFromLastBitInMs; + private double mDopplerShiftInHz; + private double mDopplerShiftUncertaintyInHz; + private byte mMultipathIndicator; + private double mSnrInDb; + private double mElevationInDeg; + private double mElevationUncertaintyInDeg; + private double mAzimuthInDeg; + private double mAzimuthUncertaintyInDeg; + private boolean mUsedInFix; + private double mPseudorangeRateCarrierInMetersPerSec; + private double mPseudorangeRateCarrierUncertaintyInMetersPerSec; + + // The following enumerations must be in sync with the values declared in gps.h + + private static final int HAS_NO_FLAGS = 0; + private static final int HAS_SNR = (1<<0); + private static final int HAS_ELEVATION = (1<<1); + private static final int HAS_ELEVATION_UNCERTAINTY = (1<<2); + private static final int HAS_AZIMUTH = (1<<3); + private static final int HAS_AZIMUTH_UNCERTAINTY = (1<<4); + private static final int HAS_PSEUDORANGE = (1<<5); + private static final int HAS_PSEUDORANGE_UNCERTAINTY = (1<<6); + private static final int HAS_CODE_PHASE = (1<<7); + private static final int HAS_CODE_PHASE_UNCERTAINTY = (1<<8); + private static final int HAS_CARRIER_FREQUENCY = (1<<9); + private static final int HAS_CARRIER_CYCLES = (1<<10); + private static final int HAS_CARRIER_PHASE = (1<<11); + private static final int HAS_CARRIER_PHASE_UNCERTAINTY = (1<<12); + private static final int HAS_BIT_NUMBER = (1<<13); + private static final int HAS_TIME_FROM_LAST_BIT = (1<<14); + private static final int HAS_DOPPLER_SHIFT = (1<<15); + private static final int HAS_DOPPLER_SHIFT_UNCERTAINTY = (1<<16); + private static final int HAS_USED_IN_FIX = (1<<17); + private static final int GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE = (1<<18); + + /** The status of 'loss of lock'. */ + @Retention(RetentionPolicy.SOURCE) + @IntDef({LOSS_OF_LOCK_UNKNOWN, LOSS_OF_LOCK_OK, LOSS_OF_LOCK_CYCLE_SLIP}) + public @interface LossOfLockStatus {} + + /** + * The indicator is not available or it is unknown. + */ + public static final byte LOSS_OF_LOCK_UNKNOWN = 0; + + /** + * The measurement does not present any indication of 'loss of lock'. + */ + public static final byte LOSS_OF_LOCK_OK = 1; + + /** + * 'Loss of lock' detected between the previous and current observation: cycle slip possible. + */ + public static final byte LOSS_OF_LOCK_CYCLE_SLIP = 2; + + /** The status of multipath. */ + @Retention(RetentionPolicy.SOURCE) + @IntDef({MULTIPATH_INDICATOR_UNKNOWN, MULTIPATH_INDICATOR_DETECTED, + MULTIPATH_INDICATOR_NOT_USED}) + public @interface MultipathIndicator {} + + /** + * The indicator is not available or it is unknown. + */ + public static final byte MULTIPATH_INDICATOR_UNKNOWN = 0; + + /** + * The measurement has been indicated to use multi-path. + */ + public static final byte MULTIPATH_INDICATOR_DETECTED = 1; + + /** + * The measurement has been indicated not tu use multi-path. + */ + public static final byte MULTIPATH_INDICATOR_NOT_USED = 2; + + /** + * The state of GPS receiver the measurement is invalid or unknown. + */ + public static final short STATE_UNKNOWN = 0; + + /** + * The state of the GPS receiver is ranging code lock. + */ + public static final short STATE_CODE_LOCK = (1<<0); + + /** + * The state of the GPS receiver is in bit sync. + */ + public static final short STATE_BIT_SYNC = (1<<1); + + /** + *The state of the GPS receiver is in sub-frame sync. + */ + public static final short STATE_SUBFRAME_SYNC = (1<<2); + + /** + * The state of the GPS receiver has TOW decoded. + */ + public static final short STATE_TOW_DECODED = (1<<3); + + /** + * The state of the GPS receiver contains millisecond ambiguity. + */ + public static final short STATE_MSEC_AMBIGUOUS = (1<<4); + + /** + * All the GPS receiver state flags. + */ + private static final short STATE_ALL = STATE_CODE_LOCK | STATE_BIT_SYNC | STATE_SUBFRAME_SYNC + | STATE_TOW_DECODED | STATE_MSEC_AMBIGUOUS; + + /** + * The state of the 'Accumulated Delta Range' is invalid or unknown. + */ + public static final short ADR_STATE_UNKNOWN = 0; + + /** + * The state of the 'Accumulated Delta Range' is valid. + */ + public static final short ADR_STATE_VALID = (1<<0); + + /** + * The state of the 'Accumulated Delta Range' has detected a reset. + */ + public static final short ADR_STATE_RESET = (1<<1); + + /** + * The state of the 'Accumulated Delta Range' has a cycle slip detected. + */ + public static final short ADR_STATE_CYCLE_SLIP = (1<<2); + + /** + * All the 'Accumulated Delta Range' flags. + */ + private static final short ADR_ALL = ADR_STATE_VALID | ADR_STATE_RESET | ADR_STATE_CYCLE_SLIP; + + // End enumerations in sync with gps.h + + GnssMeasurement() { + initialize(); + } + + /** + * Sets all contents to the values stored in the provided object. + */ + public void set(GnssMeasurement measurement) { + mFlags = measurement.mFlags; + mPrn = measurement.mPrn; + mTimeOffsetInNs = measurement.mTimeOffsetInNs; + mState = measurement.mState; + mReceivedGpsTowInNs = measurement.mReceivedGpsTowInNs; + mReceivedGpsTowUncertaintyInNs = measurement.mReceivedGpsTowUncertaintyInNs; + mCn0InDbHz = measurement.mCn0InDbHz; + mPseudorangeRateInMetersPerSec = measurement.mPseudorangeRateInMetersPerSec; + mPseudorangeRateUncertaintyInMetersPerSec = + measurement.mPseudorangeRateUncertaintyInMetersPerSec; + mAccumulatedDeltaRangeState = measurement.mAccumulatedDeltaRangeState; + mAccumulatedDeltaRangeInMeters = measurement.mAccumulatedDeltaRangeInMeters; + mAccumulatedDeltaRangeUncertaintyInMeters = + measurement.mAccumulatedDeltaRangeUncertaintyInMeters; + mPseudorangeInMeters = measurement.mPseudorangeInMeters; + mPseudorangeUncertaintyInMeters = measurement.mPseudorangeUncertaintyInMeters; + mCodePhaseInChips = measurement.mCodePhaseInChips; + mCodePhaseUncertaintyInChips = measurement.mCodePhaseUncertaintyInChips; + mCarrierFrequencyInHz = measurement.mCarrierFrequencyInHz; + mCarrierCycles = measurement.mCarrierCycles; + mCarrierPhase = measurement.mCarrierPhase; + mCarrierPhaseUncertainty = measurement.mCarrierPhaseUncertainty; + mLossOfLock = measurement.mLossOfLock; + mBitNumber = measurement.mBitNumber; + mTimeFromLastBitInMs = measurement.mTimeFromLastBitInMs; + mDopplerShiftInHz = measurement.mDopplerShiftInHz; + mDopplerShiftUncertaintyInHz = measurement.mDopplerShiftUncertaintyInHz; + mMultipathIndicator = measurement.mMultipathIndicator; + mSnrInDb = measurement.mSnrInDb; + mElevationInDeg = measurement.mElevationInDeg; + mElevationUncertaintyInDeg = measurement.mElevationUncertaintyInDeg; + mAzimuthInDeg = measurement.mAzimuthInDeg; + mAzimuthUncertaintyInDeg = measurement.mAzimuthUncertaintyInDeg; + mUsedInFix = measurement.mUsedInFix; + mPseudorangeRateCarrierInMetersPerSec = + measurement.mPseudorangeRateCarrierInMetersPerSec; + mPseudorangeRateCarrierUncertaintyInMetersPerSec = + measurement.mPseudorangeRateCarrierUncertaintyInMetersPerSec; + } + + /** + * Resets all the contents to its original state. + */ + public void reset() { + initialize(); + } + + /** + * Gets the Pseudo-random number (PRN). + * Range: [1, 32] + */ + public byte getPrn() { + return mPrn; + } + + /** + * Sets the Pseud-random number (PRN). + */ + public void setPrn(byte value) { + mPrn = value; + } + + /** + * 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 sign of this value is given by the following equation: + * measurement time = time_ns + time_offset_ns + * + * The value provides an individual time-stamp for the measurement, and allows sub-nanosecond + * accuracy. + */ + public double getTimeOffsetInNs() { + return mTimeOffsetInNs; + } + + /** + * Sets the time offset at which the measurement was taken in nanoseconds. + */ + public void setTimeOffsetInNs(double value) { + mTimeOffsetInNs = value; + } + + /** + * Gets per-satellite sync state. + * It represents the current sync state for the associated satellite. + * + * This value helps interpret {@link #getReceivedGpsTowInNs()}. + */ + public short getState() { + return mState; + } + + /** + * Sets the sync state. + */ + public void setState(short value) { + mState = value; + } + + /** + * Gets a string representation of the 'sync state'. + * For internal and logging use only. + */ + private String getStateString() { + if (mState == STATE_UNKNOWN) { + return "Unknown"; + } + StringBuilder builder = new StringBuilder(); + if ((mState & STATE_CODE_LOCK) == STATE_CODE_LOCK) { + builder.append("CodeLock|"); + } + if ((mState & STATE_BIT_SYNC) == STATE_BIT_SYNC) { + builder.append("BitSync|"); + } + if ((mState & STATE_SUBFRAME_SYNC) == STATE_SUBFRAME_SYNC) { + builder.append("SubframeSync|"); + } + if ((mState & STATE_TOW_DECODED) == STATE_TOW_DECODED) { + builder.append("TowDecoded|"); + } + if ((mState & STATE_MSEC_AMBIGUOUS) == STATE_MSEC_AMBIGUOUS) { + builder.append("MsecAmbiguous"); + } + int remainingStates = mState & ~STATE_ALL; + if (remainingStates > 0) { + builder.append("Other("); + builder.append(Integer.toBinaryString(remainingStates)); + builder.append(")|"); + } + builder.deleteCharAt(builder.length() - 1); + return builder.toString(); + } + + /** + * Gets the received GPS Time-of-Week at the measurement time, in nanoseconds. + * The value is relative to the beginning of the current GPS week. + * + * Given {@link #getState()} of the GPS receiver, the range of this field can be: + * Searching : [ 0 ] : {@link #STATE_UNKNOWN} is set + * Ranging code lock : [ 0 1 ms ] : {@link #STATE_CODE_LOCK} is set + * Bit sync : [ 0 20 ms ] : {@link #STATE_BIT_SYNC} is set + * Subframe sync : [ 0 6 ms ] : {@link #STATE_SUBFRAME_SYNC} is set + * TOW decoded : [ 0 1 week ] : {@link #STATE_TOW_DECODED} is set + */ + public long getReceivedGpsTowInNs() { + return mReceivedGpsTowInNs; + } + + /** + * Sets the received GPS time-of-week in nanoseconds. + */ + public void setReceivedGpsTowInNs(long value) { + 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]. + * + * The value contains the measured C/N0 for the signal at the antenna input. + */ + public double getCn0InDbHz() { + return mCn0InDbHz; + } + + /** + * Sets the carrier-to-noise density in dB-Hz. + */ + public void setCn0InDbHz(double value) { + mCn0InDbHz = value; + } + + /** + * Gets the Pseudorange rate at the timestamp in m/s. + * The reported value includes {@link #getPseudorangeRateUncertaintyInMetersPerSec()}. + * + * The correction of a given Pseudorange Rate value includes corrections from receiver and + * satellite clock frequency errors. + * {@link #isPseudorangeRateCorrected()} identifies the type of value reported. + * + * A positive 'uncorrected' value indicates that the SV is moving away from the receiver. + * The sign of the 'uncorrected' Pseudorange Rate and its relation to the sign of + * {@link #getDopplerShiftInHz()} is given by the equation: + * pseudorange rate = -k * doppler shift (where k is a constant) + */ + public double getPseudorangeRateInMetersPerSec() { + return mPseudorangeRateInMetersPerSec; + } + + /** + * Sets the pseudorange rate at the timestamp in m/s. + */ + public void setPseudorangeRateInMetersPerSec(double value) { + mPseudorangeRateInMetersPerSec = value; + } + + /** + * See {@link #getPseudorangeRateInMetersPerSec()} for more details. + * + * @return {@code true} if {@link #getPseudorangeRateInMetersPerSec()} contains a corrected + * value, {@code false} if it contains an uncorrected value. + */ + public boolean isPseudorangeRateCorrected() { + return !isFlagSet(GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE); + } + + /** + * Gets the pseudorange's rate uncertainty (1-Sigma) in m/s. + * The uncertainty is represented as an absolute (single sided) value. + */ + public double getPseudorangeRateUncertaintyInMetersPerSec() { + return mPseudorangeRateUncertaintyInMetersPerSec; + } + + /** + * Sets the pseudorange's rate uncertainty (1-Sigma) in m/s. + */ + public void setPseudorangeRateUncertaintyInMetersPerSec(double value) { + mPseudorangeRateUncertaintyInMetersPerSec = value; + } + + /** + * Gets 'Accumulated Delta Range' state. + * It indicates whether {@link #getAccumulatedDeltaRangeInMeters()} is reset or there is a + * cycle slip (indicating 'loss of lock'). + */ + public short getAccumulatedDeltaRangeState() { + return mAccumulatedDeltaRangeState; + } + + /** + * Sets the 'Accumulated Delta Range' state. + */ + public void setAccumulatedDeltaRangeState(short value) { + mAccumulatedDeltaRangeState = value; + } + + /** + * Gets a string representation of the 'Accumulated Delta Range state'. + * For internal and logging use only. + */ + private String getAccumulatedDeltaRangeStateString() { + if (mAccumulatedDeltaRangeState == ADR_STATE_UNKNOWN) { + return "Unknown"; + } + StringBuilder builder = new StringBuilder(); + if ((mAccumulatedDeltaRangeState & ADR_STATE_VALID) == ADR_STATE_VALID) { + builder.append("Valid|"); + } + if ((mAccumulatedDeltaRangeState & ADR_STATE_RESET) == ADR_STATE_RESET) { + builder.append("Reset|"); + } + if ((mAccumulatedDeltaRangeState & ADR_STATE_CYCLE_SLIP) == ADR_STATE_CYCLE_SLIP) { + builder.append("CycleSlip|"); + } + int remainingStates = mAccumulatedDeltaRangeState & ~ADR_ALL; + if (remainingStates > 0) { + builder.append("Other("); + builder.append(Integer.toBinaryString(remainingStates)); + builder.append(")|"); + } + builder.deleteCharAt(builder.length() - 1); + return builder.toString(); + } + + /** + * Gets the accumulated delta range since the last channel reset, in meters. + * The reported value includes {@link #getAccumulatedDeltaRangeUncertaintyInMeters()}. + * + * The availability of the value is represented by {@link #getAccumulatedDeltaRangeState()}. + * + * A positive value indicates that the SV is moving away from the receiver. + * The sign of {@link #getAccumulatedDeltaRangeInMeters()} and its relation to the sign of + * {@link #getCarrierPhase()} is given by the equation: + * accumulated delta range = -k * carrier phase (where k is a constant) + */ + public double getAccumulatedDeltaRangeInMeters() { + return mAccumulatedDeltaRangeInMeters; + } + + /** + * Sets the accumulated delta range in meters. + */ + public void setAccumulatedDeltaRangeInMeters(double value) { + mAccumulatedDeltaRangeInMeters = value; + } + + /** + * Gets the accumulated delta range's uncertainty (1-Sigma) in meters. + * The uncertainty is represented as an absolute (single sided) value. + * + * The status of the value is represented by {@link #getAccumulatedDeltaRangeState()}. + */ + public double getAccumulatedDeltaRangeUncertaintyInMeters() { + return mAccumulatedDeltaRangeUncertaintyInMeters; + } + + /** + * Sets the accumulated delta range's uncertainty (1-sigma) in meters. + * + * The status of the value is represented by {@link #getAccumulatedDeltaRangeState()}. + */ + public void setAccumulatedDeltaRangeUncertaintyInMeters(double value) { + mAccumulatedDeltaRangeUncertaintyInMeters = value; + } + + /** + * Returns true if {@link #getPseudorangeInMeters()} is available, false otherwise. + */ + public boolean hasPseudorangeInMeters() { + return isFlagSet(HAS_PSEUDORANGE); + } + + /** + * Gets the best derived pseudorange by the chipset, in meters. + * The reported pseudorange includes {@link #getPseudorangeUncertaintyInMeters()}. + * + * The value is only available if {@link #hasPseudorangeInMeters()} is true. + */ + public double getPseudorangeInMeters() { + return mPseudorangeInMeters; + } + + /** + * Sets the Pseudo-range in meters. + */ + public void setPseudorangeInMeters(double value) { + setFlag(HAS_PSEUDORANGE); + mPseudorangeInMeters = value; + } + + /** + * Resets the Pseudo-range in meters. + */ + public void resetPseudorangeInMeters() { + resetFlag(HAS_PSEUDORANGE); + mPseudorangeInMeters = Double.NaN; + } + + /** + * Returns true if {@link #getPseudorangeUncertaintyInMeters()} is available, false otherwise. + */ + public boolean hasPseudorangeUncertaintyInMeters() { + return isFlagSet(HAS_PSEUDORANGE_UNCERTAINTY); + } + + /** + * Gets the pseudorange's uncertainty (1-Sigma) in meters. + * The value contains the 'pseudorange' and 'clock' uncertainty in it. + * The uncertainty is represented as an absolute (single sided) value. + * + * The value is only available if {@link #hasPseudorangeUncertaintyInMeters()} is true. + */ + public double getPseudorangeUncertaintyInMeters() { + return mPseudorangeUncertaintyInMeters; + } + + /** + * Sets the pseudo-range's uncertainty (1-Sigma) in meters. + */ + public void setPseudorangeUncertaintyInMeters(double value) { + setFlag(HAS_PSEUDORANGE_UNCERTAINTY); + mPseudorangeUncertaintyInMeters = value; + } + + /** + * Resets the pseudo-range's uncertainty (1-Sigma) in meters. + */ + public void resetPseudorangeUncertaintyInMeters() { + resetFlag(HAS_PSEUDORANGE_UNCERTAINTY); + mPseudorangeUncertaintyInMeters = Double.NaN; + } + + /** + * Returns true if {@link #getCodePhaseInChips()} is available, false otherwise. + */ + public boolean hasCodePhaseInChips() { + return isFlagSet(HAS_CODE_PHASE); + } + + /** + * Gets the fraction of the current C/A code cycle. + * Range: [0, 1023] + * The reference frequency is given by the value of {@link #getCarrierFrequencyInHz()}. + * The reported code-phase includes {@link #getCodePhaseUncertaintyInChips()}. + * + * The value is only available if {@link #hasCodePhaseInChips()} is true. + */ + public double getCodePhaseInChips() { + return mCodePhaseInChips; + } + + /** + * Sets the Code-phase in chips. + */ + public void setCodePhaseInChips(double value) { + setFlag(HAS_CODE_PHASE); + mCodePhaseInChips = value; + } + + /** + * Resets the Code-phase in chips. + */ + public void resetCodePhaseInChips() { + resetFlag(HAS_CODE_PHASE); + mCodePhaseInChips = Double.NaN; + } + + /** + * Returns true if {@link #getCodePhaseUncertaintyInChips()} is available, false otherwise. + */ + public boolean hasCodePhaseUncertaintyInChips() { + return isFlagSet(HAS_CODE_PHASE_UNCERTAINTY); + } + + /** + * Gets the code-phase's uncertainty (1-Sigma) as a fraction of chips. + * The uncertainty is represented as an absolute (single sided) value. + * + * The value is only available if {@link #hasCodePhaseUncertaintyInChips()} is true. + */ + public double getCodePhaseUncertaintyInChips() { + return mCodePhaseUncertaintyInChips; + } + + /** + * Sets the Code-phase's uncertainty (1-Sigma) in fractions of chips. + */ + public void setCodePhaseUncertaintyInChips(double value) { + setFlag(HAS_CODE_PHASE_UNCERTAINTY); + mCodePhaseUncertaintyInChips = value; + } + + /** + * Resets the Code-phase's uncertainty (1-Sigma) in fractions of chips. + */ + public void resetCodePhaseUncertaintyInChips() { + resetFlag(HAS_CODE_PHASE_UNCERTAINTY); + mCodePhaseUncertaintyInChips = Double.NaN; + } + + /** + * Returns true if {@link #getCarrierFrequencyInHz()} is available, false otherwise. + */ + public boolean hasCarrierFrequencyInHz() { + return isFlagSet(HAS_CARRIER_FREQUENCY); + } + + /** + * Gets the carrier frequency at which codes and messages are modulated, it can be L1 or L2. + * If the field is not set, the carrier frequency corresponds to L1. + * + * The value is only available if {@link #hasCarrierFrequencyInHz()} is true. + */ + public float getCarrierFrequencyInHz() { + return mCarrierFrequencyInHz; + } + + /** + * Sets the Carrier frequency (L1 or L2) in Hz. + */ + public void setCarrierFrequencyInHz(float carrierFrequencyInHz) { + setFlag(HAS_CARRIER_FREQUENCY); + mCarrierFrequencyInHz = carrierFrequencyInHz; + } + + /** + * Resets the Carrier frequency (L1 or L2) in Hz. + */ + public void resetCarrierFrequencyInHz() { + resetFlag(HAS_CARRIER_FREQUENCY); + mCarrierFrequencyInHz = Float.NaN; + } + + /** + * Returns true if {@link #getCarrierCycles()} is available, false otherwise. + */ + public boolean hasCarrierCycles() { + return isFlagSet(HAS_CARRIER_CYCLES); + } + + /** + * The number of full carrier cycles between the satellite and the receiver. + * The reference frequency is given by the value of {@link #getCarrierFrequencyInHz()}. + * + * The value is only available if {@link #hasCarrierCycles()} is true. + */ + public long getCarrierCycles() { + return mCarrierCycles; + } + + /** + * Sets the number of full carrier cycles between the satellite and the receiver. + */ + public void setCarrierCycles(long value) { + setFlag(HAS_CARRIER_CYCLES); + mCarrierCycles = value; + } + + /** + * Resets the number of full carrier cycles between the satellite and the receiver. + */ + public void resetCarrierCycles() { + resetFlag(HAS_CARRIER_CYCLES); + mCarrierCycles = Long.MIN_VALUE; + } + + /** + * Returns true if {@link #getCarrierPhase()} is available, false otherwise. + */ + public boolean hasCarrierPhase() { + return isFlagSet(HAS_CARRIER_PHASE); + } + + /** + * Gets the RF phase detected by the receiver. + * Range: [0.0, 1.0]. + * This is usually the fractional part of the complete carrier phase measurement. + * + * The reference frequency is given by the value of {@link #getCarrierFrequencyInHz()}. + * The reported carrier-phase includes {@link #getCarrierPhaseUncertainty()}. + * + * The value is only available if {@link #hasCarrierPhase()} is true. + */ + public double getCarrierPhase() { + return mCarrierPhase; + } + + /** + * Sets the RF phase detected by the receiver. + */ + public void setCarrierPhase(double value) { + setFlag(HAS_CARRIER_PHASE); + mCarrierPhase = value; + } + + /** + * Resets the RF phase detected by the receiver. + */ + public void resetCarrierPhase() { + resetFlag(HAS_CARRIER_PHASE); + mCarrierPhase = Double.NaN; + } + + /** + * Returns true if {@link #getCarrierPhaseUncertainty()} is available, false otherwise. + */ + public boolean hasCarrierPhaseUncertainty() { + return isFlagSet(HAS_CARRIER_PHASE_UNCERTAINTY); + } + + /** + * Gets the carrier-phase's uncertainty (1-Sigma). + * The uncertainty is represented as an absolute (single sided) value. + * + * The value is only available if {@link #hasCarrierPhaseUncertainty()} is true. + */ + public double getCarrierPhaseUncertainty() { + return mCarrierPhaseUncertainty; + } + + /** + * Sets the Carrier-phase's uncertainty (1-Sigma) in cycles. + */ + public void setCarrierPhaseUncertainty(double value) { + setFlag(HAS_CARRIER_PHASE_UNCERTAINTY); + mCarrierPhaseUncertainty = value; + } + + /** + * Resets the Carrier-phase's uncertainty (1-Sigma) in cycles. + */ + public void resetCarrierPhaseUncertainty() { + resetFlag(HAS_CARRIER_PHASE_UNCERTAINTY); + mCarrierPhaseUncertainty = Double.NaN; + } + + /** + * Gets a value indicating the 'loss of lock' state of the event. + */ + @LossOfLockStatus + public byte getLossOfLock() { + return mLossOfLock; + } + + /** + * Sets the 'loss of lock' status. + */ + public void setLossOfLock(@LossOfLockStatus byte value) { + mLossOfLock = value; + } + + /** + * Gets a string representation of the 'loss of lock'. + * For internal and logging use only. + */ + private String getLossOfLockString() { + switch (mLossOfLock) { + case LOSS_OF_LOCK_UNKNOWN: + return "Unknown"; + case LOSS_OF_LOCK_OK: + return "Ok"; + case LOSS_OF_LOCK_CYCLE_SLIP: + return "CycleSlip"; + default: + return "<Invalid:" + mLossOfLock + ">"; + } + } + + /** + * Returns true if {@link #getBitNumber()} is available, false otherwise. + */ + public boolean hasBitNumber() { + return isFlagSet(HAS_BIT_NUMBER); + } + + /** + * Gets the number of GPS bits transmitted since Sat-Sun midnight (GPS week). + * + * The value is only available if {@link #hasBitNumber()} is true. + */ + public int getBitNumber() { + return mBitNumber; + } + + /** + * Sets the bit number within the broadcast frame. + */ + public void setBitNumber(int bitNumber) { + setFlag(HAS_BIT_NUMBER); + mBitNumber = bitNumber; + } + + /** + * Resets the bit number within the broadcast frame. + */ + public void resetBitNumber() { + resetFlag(HAS_BIT_NUMBER); + mBitNumber = Integer.MIN_VALUE; + } + + /** + * Returns true if {@link #getTimeFromLastBitInMs()} is available, false otherwise. + */ + public boolean hasTimeFromLastBitInMs() { + return isFlagSet(HAS_TIME_FROM_LAST_BIT); + } + + /** + * Gets the elapsed time since the last received bit in milliseconds. + * Range: [0, 20]. + * + * The value is only available if {@link #hasTimeFromLastBitInMs()} is true. + */ + public short getTimeFromLastBitInMs() { + return mTimeFromLastBitInMs; + } + + /** + * Sets the elapsed time since the last received bit in milliseconds. + */ + public void setTimeFromLastBitInMs(short value) { + setFlag(HAS_TIME_FROM_LAST_BIT); + mTimeFromLastBitInMs = value; + } + + /** + * Resets the elapsed time since the last received bit in milliseconds. + */ + public void resetTimeFromLastBitInMs() { + resetFlag(HAS_TIME_FROM_LAST_BIT); + mTimeFromLastBitInMs = Short.MIN_VALUE; + } + + /** + * Returns true if {@link #getDopplerShiftInHz()} is available, false otherwise. + */ + public boolean hasDopplerShiftInHz() { + return isFlagSet(HAS_DOPPLER_SHIFT); + } + + /** + * Gets the Doppler Shift in Hz. + * A positive value indicates that the SV is moving toward the receiver. + * + * The reference frequency is given by the value of {@link #getCarrierFrequencyInHz()}. + * The reported doppler shift includes {@link #getDopplerShiftUncertaintyInHz()}. + * + * The value is only available if {@link #hasDopplerShiftInHz()} is true. + */ + public double getDopplerShiftInHz() { + return mDopplerShiftInHz; + } + + /** + * Sets the Doppler shift in Hz. + */ + public void setDopplerShiftInHz(double value) { + setFlag(HAS_DOPPLER_SHIFT); + mDopplerShiftInHz = value; + } + + /** + * Resets the Doppler shift in Hz. + */ + public void resetDopplerShiftInHz() { + resetFlag(HAS_DOPPLER_SHIFT); + mDopplerShiftInHz = Double.NaN; + } + + /** + * Returns true if {@link #getDopplerShiftUncertaintyInHz()} is available, false otherwise. + */ + public boolean hasDopplerShiftUncertaintyInHz() { + return isFlagSet(HAS_DOPPLER_SHIFT_UNCERTAINTY); + } + + /** + * Gets the Doppler's Shift uncertainty (1-Sigma) in Hz. + * The uncertainty is represented as an absolute (single sided) value. + * + * The value is only available if {@link #hasDopplerShiftUncertaintyInHz()} is true. + */ + public double getDopplerShiftUncertaintyInHz() { + return mDopplerShiftUncertaintyInHz; + } + + /** + * Sets the Doppler's shift uncertainty (1-Sigma) in Hz. + */ + public void setDopplerShiftUncertaintyInHz(double value) { + setFlag(HAS_DOPPLER_SHIFT_UNCERTAINTY); + mDopplerShiftUncertaintyInHz = value; + } + + /** + * Resets the Doppler's shift uncertainty (1-Sigma) in Hz. + */ + public void resetDopplerShiftUncertaintyInHz() { + resetFlag(HAS_DOPPLER_SHIFT_UNCERTAINTY); + mDopplerShiftUncertaintyInHz = Double.NaN; + } + + /** + * Gets a value indicating the 'multipath' state of the event. + */ + @MultipathIndicator + public byte getMultipathIndicator() { + return mMultipathIndicator; + } + + /** + * Sets the 'multi-path' indicator. + */ + public void setMultipathIndicator(@MultipathIndicator byte value) { + mMultipathIndicator = value; + } + + /** + * Gets a string representation of the 'multi-path indicator'. + * For internal and logging use only. + */ + private String getMultipathIndicatorString() { + switch(mMultipathIndicator) { + case MULTIPATH_INDICATOR_UNKNOWN: + return "Unknown"; + case MULTIPATH_INDICATOR_DETECTED: + return "Detected"; + case MULTIPATH_INDICATOR_NOT_USED: + return "NotUsed"; + default: + return "<Invalid:" + mMultipathIndicator + ">"; + } + } + + /** + * Returns true if {@link #getSnrInDb()} is available, false otherwise. + */ + public boolean hasSnrInDb() { + return isFlagSet(HAS_SNR); + } + + /** + * Gets the Signal-to-Noise ratio (SNR) in dB. + * + * The value is only available if {@link #hasSnrInDb()} is true. + */ + public double getSnrInDb() { + return mSnrInDb; + } + + /** + * Sets the Signal-to-noise ratio (SNR) in dB. + */ + public void setSnrInDb(double snrInDb) { + setFlag(HAS_SNR); + mSnrInDb = snrInDb; + } + + /** + * Resets the Signal-to-noise ratio (SNR) in dB. + */ + public void resetSnrInDb() { + resetFlag(HAS_SNR); + mSnrInDb = Double.NaN; + } + + /** + * Returns true if {@link #getElevationInDeg()} is available, false otherwise. + */ + public boolean hasElevationInDeg() { + return isFlagSet(HAS_ELEVATION); + } + + /** + * Gets the Elevation in degrees. + * Range: [-90, 90] + * The reported elevation includes {@link #getElevationUncertaintyInDeg()}. + * + * The value is only available if {@link #hasElevationInDeg()} is true. + */ + public double getElevationInDeg() { + return mElevationInDeg; + } + + /** + * Sets the Elevation in degrees. + */ + public void setElevationInDeg(double elevationInDeg) { + setFlag(HAS_ELEVATION); + mElevationInDeg = elevationInDeg; + } + + /** + * Resets the Elevation in degrees. + */ + public void resetElevationInDeg() { + resetFlag(HAS_ELEVATION); + mElevationInDeg = Double.NaN; + } + + /** + * Returns true if {@link #getElevationUncertaintyInDeg()} is available, false otherwise. + */ + public boolean hasElevationUncertaintyInDeg() { + return isFlagSet(HAS_ELEVATION_UNCERTAINTY); + } + + /** + * Gets the elevation's uncertainty (1-Sigma) in degrees. + * Range: [0, 90] + * + * The uncertainty is represented as an absolute (single sided) value. + * + * The value is only available if {@link #hasElevationUncertaintyInDeg()} is true. + */ + public double getElevationUncertaintyInDeg() { + return mElevationUncertaintyInDeg; + } + + /** + * Sets the elevation's uncertainty (1-Sigma) in degrees. + */ + public void setElevationUncertaintyInDeg(double value) { + setFlag(HAS_ELEVATION_UNCERTAINTY); + mElevationUncertaintyInDeg = value; + } + + /** + * Resets the elevation's uncertainty (1-Sigma) in degrees. + */ + public void resetElevationUncertaintyInDeg() { + resetFlag(HAS_ELEVATION_UNCERTAINTY); + mElevationUncertaintyInDeg = Double.NaN; + } + + /** + * Returns true if {@link #getAzimuthInDeg()} is available, false otherwise. + */ + public boolean hasAzimuthInDeg() { + return isFlagSet(HAS_AZIMUTH); + } + + /** + * Gets the azimuth in degrees. + * Range: [0, 360). + * + * The reported azimuth includes {@link #getAzimuthUncertaintyInDeg()}. + * + * The value is only available if {@link #hasAzimuthInDeg()} is true. + */ + public double getAzimuthInDeg() { + return mAzimuthInDeg; + } + + /** + * Sets the Azimuth in degrees. + */ + public void setAzimuthInDeg(double value) { + setFlag(HAS_AZIMUTH); + mAzimuthInDeg = value; + } + + /** + * Resets the Azimuth in degrees. + */ + public void resetAzimuthInDeg() { + resetFlag(HAS_AZIMUTH); + mAzimuthInDeg = Double.NaN; + } + + /** + * Returns true if {@link #getAzimuthUncertaintyInDeg()} is available, false otherwise. + */ + public boolean hasAzimuthUncertaintyInDeg() { + return isFlagSet(HAS_AZIMUTH_UNCERTAINTY); + } + + /** + * Gets the azimuth's uncertainty (1-Sigma) in degrees. + * Range: [0, 180]. + * + * The uncertainty is represented as an absolute (single sided) value. + * + * The value is only available if {@link #hasAzimuthUncertaintyInDeg()} is true. + */ + public double getAzimuthUncertaintyInDeg() { + return mAzimuthUncertaintyInDeg; + } + + /** + * Sets the Azimuth's uncertainty (1-Sigma) in degrees. + */ + public void setAzimuthUncertaintyInDeg(double value) { + setFlag(HAS_AZIMUTH_UNCERTAINTY); + mAzimuthUncertaintyInDeg = value; + } + + /** + * Resets the Azimuth's uncertainty (1-Sigma) in degrees. + */ + public void resetAzimuthUncertaintyInDeg() { + resetFlag(HAS_AZIMUTH_UNCERTAINTY); + mAzimuthUncertaintyInDeg = Double.NaN; + } + + /** + * Gets a flag indicating whether the GPS represented by the measurement was used for computing + * the most recent fix. + * + * @return A non-null value if the data is available, null otherwise. + */ + public boolean isUsedInFix() { + return mUsedInFix; + } + + /** + * Sets the Used-in-Fix flag. + */ + public void setUsedInFix(boolean value) { + mUsedInFix = value; + } + + /** + * Gets pseudorange rate (based on carrier phase changes) at the timestamp in m/s. + */ + public double getPseudorangeRateCarrierInMetersPerSec() { + return mPseudorangeRateCarrierInMetersPerSec; + } + + /** + * Sets pseudorange rate (based on carrier phase changes) at the timestamp in m/s. + */ + public void setPseudorangeRateCarrierInMetersPerSec(double value) { + mPseudorangeRateCarrierInMetersPerSec = value; + } + + /** + * Gets 1-Sigma uncertainty of the pseudorange rate carrier. + */ + public double getPseudorangeRateCarrierUncertaintyInMetersPerSec() { + return mPseudorangeRateCarrierUncertaintyInMetersPerSec; + } + + /** + * Sets 1-Sigma uncertainty of the pseudorange rate carrier. + */ + public void setPseudorangeRateCarrierUncertaintyInMetersPerSec(double value) { + mPseudorangeRateCarrierUncertaintyInMetersPerSec = value; + } + + public static final Creator<GnssMeasurement> CREATOR = new Creator<GnssMeasurement>() { + @Override + public GnssMeasurement createFromParcel(Parcel parcel) { + GnssMeasurement gnssMeasurement = new GnssMeasurement(); + + gnssMeasurement.mFlags = parcel.readInt(); + gnssMeasurement.mPrn = parcel.readByte(); + gnssMeasurement.mTimeOffsetInNs = parcel.readDouble(); + gnssMeasurement.mState = (short) parcel.readInt(); + gnssMeasurement.mReceivedGpsTowInNs = parcel.readLong(); + gnssMeasurement.mReceivedGpsTowUncertaintyInNs = parcel.readLong(); + gnssMeasurement.mCn0InDbHz = parcel.readDouble(); + gnssMeasurement.mPseudorangeRateInMetersPerSec = parcel.readDouble(); + gnssMeasurement.mPseudorangeRateUncertaintyInMetersPerSec = parcel.readDouble(); + gnssMeasurement.mAccumulatedDeltaRangeState = (short) parcel.readInt(); + gnssMeasurement.mAccumulatedDeltaRangeInMeters = parcel.readDouble(); + gnssMeasurement.mAccumulatedDeltaRangeUncertaintyInMeters = parcel.readDouble(); + gnssMeasurement.mPseudorangeInMeters = parcel.readDouble(); + gnssMeasurement.mPseudorangeUncertaintyInMeters = parcel.readDouble(); + gnssMeasurement.mCodePhaseInChips = parcel.readDouble(); + gnssMeasurement.mCodePhaseUncertaintyInChips = parcel.readDouble(); + gnssMeasurement.mCarrierFrequencyInHz = parcel.readFloat(); + gnssMeasurement.mCarrierCycles = parcel.readLong(); + gnssMeasurement.mCarrierPhase = parcel.readDouble(); + gnssMeasurement.mCarrierPhaseUncertainty = parcel.readDouble(); + gnssMeasurement.mLossOfLock = parcel.readByte(); + gnssMeasurement.mBitNumber = parcel.readInt(); + gnssMeasurement.mTimeFromLastBitInMs = (short) parcel.readInt(); + gnssMeasurement.mDopplerShiftInHz = parcel.readDouble(); + gnssMeasurement.mDopplerShiftUncertaintyInHz = parcel.readDouble(); + gnssMeasurement.mMultipathIndicator = parcel.readByte(); + gnssMeasurement.mSnrInDb = parcel.readDouble(); + gnssMeasurement.mElevationInDeg = parcel.readDouble(); + gnssMeasurement.mElevationUncertaintyInDeg = parcel.readDouble(); + gnssMeasurement.mAzimuthInDeg = parcel.readDouble(); + gnssMeasurement.mAzimuthUncertaintyInDeg = parcel.readDouble(); + gnssMeasurement.mUsedInFix = parcel.readInt() != 0; + gnssMeasurement.mPseudorangeRateCarrierInMetersPerSec = parcel.readDouble(); + gnssMeasurement.mPseudorangeRateCarrierUncertaintyInMetersPerSec = parcel.readDouble(); + + return gnssMeasurement; + } + + @Override + public GnssMeasurement[] newArray(int i) { + return new GnssMeasurement[i]; + } + }; + + public void writeToParcel(Parcel parcel, int flags) { + parcel.writeInt(mFlags); + parcel.writeByte(mPrn); + parcel.writeDouble(mTimeOffsetInNs); + parcel.writeInt(mState); + parcel.writeLong(mReceivedGpsTowInNs); + parcel.writeLong(mReceivedGpsTowUncertaintyInNs); + parcel.writeDouble(mCn0InDbHz); + parcel.writeDouble(mPseudorangeRateInMetersPerSec); + parcel.writeDouble(mPseudorangeRateUncertaintyInMetersPerSec); + parcel.writeInt(mAccumulatedDeltaRangeState); + parcel.writeDouble(mAccumulatedDeltaRangeInMeters); + parcel.writeDouble(mAccumulatedDeltaRangeUncertaintyInMeters); + parcel.writeDouble(mPseudorangeInMeters); + parcel.writeDouble(mPseudorangeUncertaintyInMeters); + parcel.writeDouble(mCodePhaseInChips); + parcel.writeDouble(mCodePhaseUncertaintyInChips); + parcel.writeFloat(mCarrierFrequencyInHz); + parcel.writeLong(mCarrierCycles); + parcel.writeDouble(mCarrierPhase); + parcel.writeDouble(mCarrierPhaseUncertainty); + parcel.writeByte(mLossOfLock); + parcel.writeInt(mBitNumber); + parcel.writeInt(mTimeFromLastBitInMs); + parcel.writeDouble(mDopplerShiftInHz); + parcel.writeDouble(mDopplerShiftUncertaintyInHz); + parcel.writeByte(mMultipathIndicator); + parcel.writeDouble(mSnrInDb); + parcel.writeDouble(mElevationInDeg); + parcel.writeDouble(mElevationUncertaintyInDeg); + parcel.writeDouble(mAzimuthInDeg); + parcel.writeDouble(mAzimuthUncertaintyInDeg); + parcel.writeInt(mUsedInFix ? 1 : 0); + parcel.writeDouble(mPseudorangeRateCarrierInMetersPerSec); + parcel.writeDouble(mPseudorangeRateCarrierUncertaintyInMetersPerSec); + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public String toString() { + final String format = " %-29s = %s\n"; + final String formatWithUncertainty = " %-29s = %-25s %-40s = %s\n"; + StringBuilder builder = new StringBuilder("GnssMeasurement:\n"); + + builder.append(String.format(format, "Prn", mPrn)); + + builder.append(String.format(format, "TimeOffsetInNs", mTimeOffsetInNs)); + + builder.append(String.format(format, "State", getStateString())); + + builder.append(String.format( + formatWithUncertainty, + "ReceivedGpsTowInNs", + mReceivedGpsTowInNs, + "ReceivedGpsTowUncertaintyInNs", + mReceivedGpsTowUncertaintyInNs)); + + builder.append(String.format(format, "Cn0InDbHz", mCn0InDbHz)); + + builder.append(String.format( + formatWithUncertainty, + "PseudorangeRateInMetersPerSec", + mPseudorangeRateInMetersPerSec, + "PseudorangeRateUncertaintyInMetersPerSec", + mPseudorangeRateUncertaintyInMetersPerSec)); + builder.append(String.format( + format, + "PseudorangeRateIsCorrected", + isPseudorangeRateCorrected())); + + builder.append(String.format( + format, + "AccumulatedDeltaRangeState", + getAccumulatedDeltaRangeStateString())); + + builder.append(String.format( + formatWithUncertainty, + "AccumulatedDeltaRangeInMeters", + mAccumulatedDeltaRangeInMeters, + "AccumulatedDeltaRangeUncertaintyInMeters", + mAccumulatedDeltaRangeUncertaintyInMeters)); + + builder.append(String.format( + formatWithUncertainty, + "PseudorangeInMeters", + hasPseudorangeInMeters() ? mPseudorangeInMeters : null, + "PseudorangeUncertaintyInMeters", + hasPseudorangeUncertaintyInMeters() ? mPseudorangeUncertaintyInMeters : null)); + + builder.append(String.format( + formatWithUncertainty, + "CodePhaseInChips", + hasCodePhaseInChips() ? mCodePhaseInChips : null, + "CodePhaseUncertaintyInChips", + hasCodePhaseUncertaintyInChips() ? mCodePhaseUncertaintyInChips : null)); + + builder.append(String.format( + format, + "CarrierFrequencyInHz", + hasCarrierFrequencyInHz() ? mCarrierFrequencyInHz : null)); + + builder.append(String.format( + format, + "CarrierCycles", + hasCarrierCycles() ? mCarrierCycles : null)); + + builder.append(String.format( + formatWithUncertainty, + "CarrierPhase", + hasCarrierPhase() ? mCarrierPhase : null, + "CarrierPhaseUncertainty", + hasCarrierPhaseUncertainty() ? mCarrierPhaseUncertainty : null)); + + builder.append(String.format(format, "LossOfLock", getLossOfLockString())); + + builder.append(String.format( + format, + "BitNumber", + hasBitNumber() ? mBitNumber : null)); + + builder.append(String.format( + format, + "TimeFromLastBitInMs", + hasTimeFromLastBitInMs() ? mTimeFromLastBitInMs : null)); + + builder.append(String.format( + formatWithUncertainty, + "DopplerShiftInHz", + hasDopplerShiftInHz() ? mDopplerShiftInHz : null, + "DopplerShiftUncertaintyInHz", + hasDopplerShiftUncertaintyInHz() ? mDopplerShiftUncertaintyInHz : null)); + + builder.append(String.format(format, "MultipathIndicator", getMultipathIndicatorString())); + + builder.append(String.format( + format, + "SnrInDb", + hasSnrInDb() ? mSnrInDb : null)); + + builder.append(String.format( + formatWithUncertainty, + "ElevationInDeg", + hasElevationInDeg() ? mElevationInDeg : null, + "ElevationUncertaintyInDeg", + hasElevationUncertaintyInDeg() ? mElevationUncertaintyInDeg : null)); + + builder.append(String.format( + formatWithUncertainty, + "AzimuthInDeg", + hasAzimuthInDeg() ? mAzimuthInDeg : null, + "AzimuthUncertaintyInDeg", + hasAzimuthUncertaintyInDeg() ? mAzimuthUncertaintyInDeg : null)); + + builder.append(String.format(format, "UsedInFix", mUsedInFix)); + + builder.append(String.format(format, "PseudorangeRateCarrierInMetersPerSec", + mPseudorangeRateCarrierInMetersPerSec)); + builder.append(String.format(format, "PseudorangeRateCarrierUncertaintyInMetersPerSec", + mPseudorangeRateCarrierUncertaintyInMetersPerSec)); + + return builder.toString(); + } + + private void initialize() { + mFlags = HAS_NO_FLAGS; + setPrn(Byte.MIN_VALUE); + 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); + setAccumulatedDeltaRangeState(ADR_STATE_UNKNOWN); + setAccumulatedDeltaRangeInMeters(Double.MIN_VALUE); + setAccumulatedDeltaRangeUncertaintyInMeters(Double.MIN_VALUE); + resetPseudorangeInMeters(); + resetPseudorangeUncertaintyInMeters(); + resetCodePhaseInChips(); + resetCodePhaseUncertaintyInChips(); + resetCarrierFrequencyInHz(); + resetCarrierCycles(); + resetCarrierPhase(); + resetCarrierPhaseUncertainty(); + setLossOfLock(LOSS_OF_LOCK_UNKNOWN); + resetBitNumber(); + resetTimeFromLastBitInMs(); + resetDopplerShiftInHz(); + resetDopplerShiftUncertaintyInHz(); + setMultipathIndicator(MULTIPATH_INDICATOR_UNKNOWN); + resetSnrInDb(); + resetElevationInDeg(); + resetElevationUncertaintyInDeg(); + resetAzimuthInDeg(); + resetAzimuthUncertaintyInDeg(); + setUsedInFix(false); + setPseudorangeRateCarrierInMetersPerSec(Double.MIN_VALUE); + setPseudorangeRateCarrierUncertaintyInMetersPerSec(Double.MIN_VALUE); + } + + private void setFlag(int flag) { + mFlags |= flag; + } + + private void resetFlag(int flag) { + mFlags &= ~flag; + } + + private boolean isFlagSet(int flag) { + return (mFlags & flag) == flag; + } +} diff --git a/location/java/android/location/GpsMeasurementCallbackTransport.java b/location/java/android/location/GnssMeasurementCallbackTransport.java index 02d9026de6ce..21f63068084e 100644 --- a/location/java/android/location/GpsMeasurementCallbackTransport.java +++ b/location/java/android/location/GnssMeasurementCallbackTransport.java @@ -20,41 +20,42 @@ import android.content.Context; import android.os.RemoteException; /** - * A handler class to manage transport callbacks for {@link GpsMeasurementsEvent.Callback}. + * A handler class to manage transport callbacks for {@link GnssMeasurementsEvent.Callback}. * * @hide */ -class GpsMeasurementCallbackTransport - extends LocalListenerHelper<GpsMeasurementsEvent.Callback> { +class GnssMeasurementCallbackTransport + extends LocalListenerHelper<GnssMeasurementsEvent.Callback> { private final ILocationManager mLocationManager; - private final IGpsMeasurementsListener mListenerTransport = new ListenerTransport(); + private final IGnssMeasurementsListener mListenerTransport = new ListenerTransport(); - public GpsMeasurementCallbackTransport(Context context, ILocationManager locationManager) { - super(context, "GpsMeasurementListenerTransport"); + public GnssMeasurementCallbackTransport(Context context, ILocationManager locationManager) { + super(context, "GnssMeasurementListenerTransport"); mLocationManager = locationManager; } @Override protected boolean registerWithServer() throws RemoteException { - return mLocationManager.addGpsMeasurementsListener( + return mLocationManager.addGnssMeasurementsListener( mListenerTransport, getContext().getPackageName()); } @Override protected void unregisterFromServer() throws RemoteException { - mLocationManager.removeGpsMeasurementsListener(mListenerTransport); + mLocationManager.removeGnssMeasurementsListener(mListenerTransport); } - private class ListenerTransport extends IGpsMeasurementsListener.Stub { + private class ListenerTransport extends IGnssMeasurementsListener.Stub { @Override - public void onGpsMeasurementsReceived(final GpsMeasurementsEvent event) { - ListenerOperation<GpsMeasurementsEvent.Callback> operation = - new ListenerOperation<GpsMeasurementsEvent.Callback>() { + public void onGnssMeasurementsReceived(final GnssMeasurementsEvent event) { + ListenerOperation<GnssMeasurementsEvent.Callback> operation = + new ListenerOperation<GnssMeasurementsEvent.Callback>() { @Override - public void execute(GpsMeasurementsEvent.Callback callback) throws RemoteException { - callback.onGpsMeasurementsReceived(event); + public void execute(GnssMeasurementsEvent.Callback callback) + throws RemoteException { + callback.onGnssMeasurementsReceived(event); } }; foreach(operation); @@ -62,10 +63,11 @@ class GpsMeasurementCallbackTransport @Override public void onStatusChanged(final int status) { - ListenerOperation<GpsMeasurementsEvent.Callback> operation = - new ListenerOperation<GpsMeasurementsEvent.Callback>() { + ListenerOperation<GnssMeasurementsEvent.Callback> operation = + new ListenerOperation<GnssMeasurementsEvent.Callback>() { @Override - public void execute(GpsMeasurementsEvent.Callback callback) throws RemoteException { + public void execute(GnssMeasurementsEvent.Callback callback) + throws RemoteException { callback.onStatusChanged(status); } }; diff --git a/location/java/android/location/GpsMeasurementsEvent.aidl b/location/java/android/location/GnssMeasurementsEvent.aidl index 2c4626238dae..5ce594da372f 100644 --- a/location/java/android/location/GpsMeasurementsEvent.aidl +++ b/location/java/android/location/GnssMeasurementsEvent.aidl @@ -16,4 +16,4 @@ package android.location; -parcelable GpsMeasurementsEvent; +parcelable GnssMeasurementsEvent; diff --git a/location/java/android/location/GnssMeasurementsEvent.java b/location/java/android/location/GnssMeasurementsEvent.java new file mode 100644 index 000000000000..b744a0381b76 --- /dev/null +++ b/location/java/android/location/GnssMeasurementsEvent.java @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package android.location; + +import android.annotation.IntDef; +import android.annotation.NonNull; +import android.os.Parcel; +import android.os.Parcelable; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.security.InvalidParameterException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + +/** + * A class implementing a container for data associated with a measurement event. + * Events are delivered to registered instances of {@link Callback}. + */ +public final class GnssMeasurementsEvent implements Parcelable { + /** The status of GPS measurements event. */ + @Retention(RetentionPolicy.SOURCE) + @IntDef({STATUS_NOT_SUPPORTED, STATUS_READY, STATUS_GPS_LOCATION_DISABLED}) + public @interface GnssMeasurementsStatus {} + + /** + * The system does not support tracking of GPS Measurements. This status will not change in the + * future. + */ + public static final int STATUS_NOT_SUPPORTED = 0; + + /** + * GPS Measurements are successfully being tracked, it will receive updates once they are + * available. + */ + public static final int STATUS_READY = 1; + + /** + * GPS provider or Location is disabled, updates will not be received until they are enabled. + */ + public static final int STATUS_GPS_LOCATION_DISABLED = 2; + + private final GnssClock mClock; + private final Collection<GnssMeasurement> mReadOnlyMeasurements; + + /** + * Used for receiving GPS satellite measurements from the GPS engine. + * Each measurement contains raw and computed data identifying a satellite. + * You can implement this interface and call + * {@link LocationManager#registerGnssMeasurementCallback}. + */ + public static abstract class Callback { + + /** + * Returns the latest collected GPS Measurements. + */ + public void onGnssMeasurementsReceived(GnssMeasurementsEvent eventArgs) {} + + /** + * Returns the latest status of the GPS Measurements sub-system. + */ + public void onStatusChanged(@GnssMeasurementsStatus int status) {} + } + + public GnssMeasurementsEvent(GnssClock clock, GnssMeasurement[] measurements) { + if (clock == null) { + throw new InvalidParameterException("Parameter 'clock' must not be null."); + } + if (measurements == null || measurements.length == 0) { + throw new InvalidParameterException( + "Parameter 'measurements' must not be null or empty."); + } + + mClock = clock; + Collection<GnssMeasurement> measurementCollection = Arrays.asList(measurements); + mReadOnlyMeasurements = Collections.unmodifiableCollection(measurementCollection); + } + + @NonNull + public GnssClock getClock() { + return mClock; + } + + /** + * Gets a read-only collection of measurements associated with the current event. + */ + @NonNull + public Collection<GnssMeasurement> getMeasurements() { + return mReadOnlyMeasurements; + } + + public static final Creator<GnssMeasurementsEvent> CREATOR = + new Creator<GnssMeasurementsEvent>() { + @Override + public GnssMeasurementsEvent createFromParcel(Parcel in) { + ClassLoader classLoader = getClass().getClassLoader(); + + GnssClock clock = in.readParcelable(classLoader); + + int measurementsLength = in.readInt(); + GnssMeasurement[] measurementsArray = new GnssMeasurement[measurementsLength]; + in.readTypedArray(measurementsArray, GnssMeasurement.CREATOR); + + return new GnssMeasurementsEvent(clock, measurementsArray); + } + + @Override + public GnssMeasurementsEvent[] newArray(int size) { + return new GnssMeasurementsEvent[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel parcel, int flags) { + parcel.writeParcelable(mClock, flags); + + int measurementsCount = mReadOnlyMeasurements.size(); + GnssMeasurement[] measurementsArray = + mReadOnlyMeasurements.toArray(new GnssMeasurement[measurementsCount]); + parcel.writeInt(measurementsArray.length); + parcel.writeTypedArray(measurementsArray, flags); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder("[ GnssMeasurementsEvent:\n\n"); + + builder.append(mClock.toString()); + builder.append("\n"); + + for (GnssMeasurement measurement : mReadOnlyMeasurements) { + builder.append(measurement.toString()); + builder.append("\n"); + } + + builder.append("]"); + + return builder.toString(); + } +} diff --git a/location/java/android/location/GnssNavigationMessage.java b/location/java/android/location/GnssNavigationMessage.java new file mode 100644 index 000000000000..0e011d5c98a8 --- /dev/null +++ b/location/java/android/location/GnssNavigationMessage.java @@ -0,0 +1,330 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package android.location; + +import android.annotation.IntDef; +import android.annotation.NonNull; +import android.os.Parcel; +import android.os.Parcelable; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.security.InvalidParameterException; + +/** + * A class containing a GPS satellite Navigation Message. + */ +public final class GnssNavigationMessage implements Parcelable { + + private static final byte[] EMPTY_ARRAY = new byte[0]; + + /** The type of the GPS Clock. */ + @Retention(RetentionPolicy.SOURCE) + @IntDef({MESSAGE_TYPE_UNKNOWN, MESSAGE_TYPE_L1CA, MESSAGE_TYPE_L2CNAV, MESSAGE_TYPE_L5CNAV, + MESSAGE_TYPE_CNAV2}) + public @interface GnssNavigationMessageType {} + + // The following enumerations must be in sync with the values declared in gps.h + + /** + * The type of the navigation message is not available or unknown. + */ + public static final byte MESSAGE_TYPE_UNKNOWN = 0; + + /** + * The Navigation Message is of type L1 C/A. + */ + public static final byte MESSAGE_TYPE_L1CA = 1; + + /** + * The Navigation Message is of type L1-CNAV. + */ + public static final byte MESSAGE_TYPE_L2CNAV = 2; + + /** + * The Navigation Message is of type L5-CNAV. + */ + public static final byte MESSAGE_TYPE_L5CNAV = 3; + + /** + * The Navigation Message is of type CNAV-2. + */ + public static final byte MESSAGE_TYPE_CNAV2 = 4; + + /** + * The Navigation Message Status is 'unknown'. + */ + public static final short STATUS_UNKNOWN = 0; + + /** + * The Navigation Message was received without any parity error in its navigation words. + */ + public static final short STATUS_PARITY_PASSED = (1<<0); + + /** + * The Navigation Message was received with words that failed parity check, but the receiver was + * able to correct those words. + */ + public static final short STATUS_PARITY_REBUILT = (1<<1); + + // End enumerations in sync with gps.h + + private byte mType; + private byte mPrn; + private short mMessageId; + private short mSubmessageId; + private byte[] mData; + private short mStatus; + + GnssNavigationMessage() { + initialize(); + } + + /** + * Sets all contents to the values stored in the provided object. + */ + public void set(GnssNavigationMessage navigationMessage) { + mType = navigationMessage.mType; + mPrn = navigationMessage.mPrn; + mMessageId = navigationMessage.mMessageId; + mSubmessageId = navigationMessage.mSubmessageId; + mData = navigationMessage.mData; + mStatus = navigationMessage.mStatus; + } + + /** + * Resets all the contents to its original state. + */ + public void reset() { + initialize(); + } + + /** + * Gets the type of the navigation message contained in the object. + */ + @GnssNavigationMessageType + public byte getType() { + return mType; + } + + /** + * Sets the type of the navigation message. + */ + public void setType(@GnssNavigationMessageType byte value) { + mType = value; + } + + /** + * Gets a string representation of the 'type'. + * For internal and logging use only. + */ + private String getTypeString() { + switch (mType) { + case MESSAGE_TYPE_UNKNOWN: + return "Unknown"; + case MESSAGE_TYPE_L1CA: + return "L1 C/A"; + case MESSAGE_TYPE_L2CNAV: + return "L2-CNAV"; + case MESSAGE_TYPE_L5CNAV: + return "L5-CNAV"; + case MESSAGE_TYPE_CNAV2: + return "CNAV-2"; + default: + return "<Invalid:" + mType + ">"; + } + } + + /** + * Gets the Pseudo-random number. + * Range: [1, 32]. + */ + public byte getPrn() { + return mPrn; + } + + /** + * Sets the Pseud-random number. + */ + public void setPrn(byte value) { + mPrn = value; + } + + /** + * Gets the Message Identifier. + * It provides an index so the complete Navigation Message can be assembled. i.e. for L1 C/A + * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message. + * Subframe 1, 2, 3 does not contain a 'frame id' and this might be reported as -1. + */ + public short getMessageId() { + return mMessageId; + } + + /** + * Sets the Message Identifier. + */ + public void setMessageId(short value) { + mMessageId = value; + } + + /** + * Gets the Sub-message Identifier. + * If required by {@link #getType()}, this value contains a sub-index within the current message + * (or frame) that is being transmitted. i.e. for L1 C/A the sub-message identifier corresponds + * to the sub-frame Id of the navigation message. + */ + public short getSubmessageId() { + return mSubmessageId; + } + + /** + * Sets the Sub-message identifier. + */ + public void setSubmessageId(short value) { + mSubmessageId = value; + } + + /** + * Gets the data associated with the Navigation Message. + * The bytes (or words) specified using big endian format (MSB first). + */ + @NonNull + public byte[] getData() { + return mData; + } + + /** + * Sets the data associated with the Navigation Message. + */ + public void setData(byte[] value) { + if (value == null) { + throw new InvalidParameterException("Data must be a non-null array"); + } + + mData = value; + } + + /** + * Gets the Status of the navigation message contained in the object. + */ + public short getStatus() { + return mStatus; + } + + /** + * Sets the status of the navigation message. + */ + public void setStatus(short value) { + mStatus = value; + } + + /** + * Gets a string representation of the 'status'. + * For internal and logging use only. + */ + private String getStatusString() { + switch (mStatus) { + case STATUS_UNKNOWN: + return "Unknown"; + case STATUS_PARITY_PASSED: + return "ParityPassed"; + case STATUS_PARITY_REBUILT: + return "ParityRebuilt"; + default: + return "<Invalid:" + mStatus + ">"; + } + } + + public static final Creator<GnssNavigationMessage> CREATOR = + new Creator<GnssNavigationMessage>() { + @Override + public GnssNavigationMessage createFromParcel(Parcel parcel) { + GnssNavigationMessage navigationMessage = new GnssNavigationMessage(); + + navigationMessage.setType(parcel.readByte()); + navigationMessage.setPrn(parcel.readByte()); + navigationMessage.setMessageId((short) parcel.readInt()); + navigationMessage.setSubmessageId((short) parcel.readInt()); + + int dataLength = parcel.readInt(); + byte[] data = new byte[dataLength]; + parcel.readByteArray(data); + navigationMessage.setData(data); + + if (parcel.dataAvail() >= Integer.SIZE) { + int status = parcel.readInt(); + navigationMessage.setStatus((short) status); + } else { + navigationMessage.setStatus(STATUS_UNKNOWN); + } + + return navigationMessage; + } + + @Override + public GnssNavigationMessage[] newArray(int size) { + return new GnssNavigationMessage[size]; + } + }; + + public void writeToParcel(Parcel parcel, int flags) { + parcel.writeByte(mType); + parcel.writeByte(mPrn); + parcel.writeInt(mMessageId); + parcel.writeInt(mSubmessageId); + parcel.writeInt(mData.length); + parcel.writeByteArray(mData); + parcel.writeInt(mStatus); + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public String toString() { + final String format = " %-15s = %s\n"; + StringBuilder builder = new StringBuilder("GnssNavigationMessage:\n"); + + builder.append(String.format(format, "Type", getTypeString())); + builder.append(String.format(format, "Prn", mPrn)); + builder.append(String.format(format, "Status", getStatusString())); + builder.append(String.format(format, "MessageId", mMessageId)); + builder.append(String.format(format, "SubmessageId", mSubmessageId)); + + builder.append(String.format(format, "Data", "{")); + String prefix = " "; + for(byte value : mData) { + builder.append(prefix); + builder.append(value); + prefix = ", "; + } + builder.append(" }"); + + return builder.toString(); + } + + private void initialize() { + mType = MESSAGE_TYPE_UNKNOWN; + mPrn = 0; + mMessageId = -1; + mSubmessageId = -1; + mData = EMPTY_ARRAY; + mStatus = STATUS_UNKNOWN; + } +} diff --git a/location/java/android/location/GpsNavigationMessageCallbackTransport.java b/location/java/android/location/GnssNavigationMessageCallbackTransport.java index 155d96dce35e..4204b99b3ee0 100644 --- a/location/java/android/location/GpsNavigationMessageCallbackTransport.java +++ b/location/java/android/location/GnssNavigationMessageCallbackTransport.java @@ -20,44 +20,44 @@ import android.content.Context; import android.os.RemoteException; /** - * A handler class to manage transport callback for {@link GpsNavigationMessageEvent.Callback}. + * A handler class to manage transport callback for {@link GnssNavigationMessageEvent.Callback}. * * @hide */ -class GpsNavigationMessageCallbackTransport - extends LocalListenerHelper<GpsNavigationMessageEvent.Callback> { +class GnssNavigationMessageCallbackTransport + extends LocalListenerHelper<GnssNavigationMessageEvent.Callback> { private final ILocationManager mLocationManager; - private final IGpsNavigationMessageListener mListenerTransport = new ListenerTransport(); + private final IGnssNavigationMessageListener mListenerTransport = new ListenerTransport(); - public GpsNavigationMessageCallbackTransport( + public GnssNavigationMessageCallbackTransport( Context context, ILocationManager locationManager) { - super(context, "GpsNavigationMessageCallbackTransport"); + super(context, "GnssNavigationMessageCallbackTransport"); mLocationManager = locationManager; } @Override protected boolean registerWithServer() throws RemoteException { - return mLocationManager.addGpsNavigationMessageListener( + return mLocationManager.addGnssNavigationMessageListener( mListenerTransport, getContext().getPackageName()); } @Override protected void unregisterFromServer() throws RemoteException { - mLocationManager.removeGpsNavigationMessageListener(mListenerTransport); + mLocationManager.removeGnssNavigationMessageListener(mListenerTransport); } - private class ListenerTransport extends IGpsNavigationMessageListener.Stub { + private class ListenerTransport extends IGnssNavigationMessageListener.Stub { @Override - public void onGpsNavigationMessageReceived(final GpsNavigationMessageEvent event) { - ListenerOperation<GpsNavigationMessageEvent.Callback> operation = - new ListenerOperation<GpsNavigationMessageEvent.Callback>() { + public void onGnssNavigationMessageReceived(final GnssNavigationMessageEvent event) { + ListenerOperation<GnssNavigationMessageEvent.Callback> operation = + new ListenerOperation<GnssNavigationMessageEvent.Callback>() { @Override - public void execute(GpsNavigationMessageEvent.Callback callback) + public void execute(GnssNavigationMessageEvent.Callback callback) throws RemoteException { - callback.onGpsNavigationMessageReceived(event); + callback.onGnssNavigationMessageReceived(event); } }; foreach(operation); @@ -65,10 +65,10 @@ class GpsNavigationMessageCallbackTransport @Override public void onStatusChanged(final int status) { - ListenerOperation<GpsNavigationMessageEvent.Callback> operation = - new ListenerOperation<GpsNavigationMessageEvent.Callback>() { + ListenerOperation<GnssNavigationMessageEvent.Callback> operation = + new ListenerOperation<GnssNavigationMessageEvent.Callback>() { @Override - public void execute(GpsNavigationMessageEvent.Callback callback) + public void execute(GnssNavigationMessageEvent.Callback callback) throws RemoteException { callback.onStatusChanged(status); } diff --git a/location/java/android/location/GpsNavigationMessageEvent.aidl b/location/java/android/location/GnssNavigationMessageEvent.aidl index f84c2f72ca17..e765739942bf 100644 --- a/location/java/android/location/GpsNavigationMessageEvent.aidl +++ b/location/java/android/location/GnssNavigationMessageEvent.aidl @@ -16,4 +16,4 @@ package android.location; -parcelable GpsNavigationMessageEvent; +parcelable GnssNavigationMessageEvent; diff --git a/location/java/android/location/GnssNavigationMessageEvent.java b/location/java/android/location/GnssNavigationMessageEvent.java new file mode 100644 index 000000000000..19c82e9175f2 --- /dev/null +++ b/location/java/android/location/GnssNavigationMessageEvent.java @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package android.location; + +import android.annotation.IntDef; +import android.annotation.NonNull; +import android.os.Parcel; +import android.os.Parcelable; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.security.InvalidParameterException; + +/** + * A class implementing a container for data associated with a navigation message event. + * Events are delivered to registered instances of {@link Callback}. + */ +public final class GnssNavigationMessageEvent implements Parcelable { + /** The status of GPS measurements event. */ + @Retention(RetentionPolicy.SOURCE) + @IntDef({STATUS_NOT_SUPPORTED, STATUS_READY, STATUS_GPS_LOCATION_DISABLED}) + public @interface GnssNavigationMessageStatus {} + + /** + * The system does not support tracking of GPS Navigation Messages. This status will not change + * in the future. + */ + public static final int STATUS_NOT_SUPPORTED = 0; + + /** + * GPS Navigation Messages are successfully being tracked, it will receive updates once they are + * available. + */ + public static final int STATUS_READY = 1; + + /** + * GPS provider or Location is disabled, updated will not be received until they are enabled. + */ + public static final int STATUS_GPS_LOCATION_DISABLED = 2; + + private final GnssNavigationMessage mNavigationMessage; + + /** + * Used for receiving GPS satellite Navigation Messages from the GPS engine. + * You can implement this interface and call + * {@link LocationManager#registerGnssNavigationMessageCallback}. + */ + public static abstract class Callback { + + /** + * Returns the latest collected GPS Navigation Message. + */ + public void onGnssNavigationMessageReceived(GnssNavigationMessageEvent event) {} + + /** + * Returns the latest status of the GPS Navigation Messages sub-system. + */ + public void onStatusChanged(@GnssNavigationMessageStatus int status) {} + } + + public GnssNavigationMessageEvent(GnssNavigationMessage message) { + if (message == null) { + throw new InvalidParameterException("Parameter 'message' must not be null."); + } + mNavigationMessage = message; + } + + @NonNull + public GnssNavigationMessage getNavigationMessage() { + return mNavigationMessage; + } + + public static final Creator<GnssNavigationMessageEvent> CREATOR = + new Creator<GnssNavigationMessageEvent>() { + @Override + public GnssNavigationMessageEvent createFromParcel(Parcel in) { + ClassLoader classLoader = getClass().getClassLoader(); + GnssNavigationMessage navigationMessage = in.readParcelable(classLoader); + return new GnssNavigationMessageEvent(navigationMessage); + } + + @Override + public GnssNavigationMessageEvent[] newArray(int size) { + return new GnssNavigationMessageEvent[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel parcel, int flags) { + parcel.writeParcelable(mNavigationMessage, flags); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder("[ GnssNavigationMessageEvent:\n\n"); + builder.append(mNavigationMessage.toString()); + builder.append("\n]"); + return builder.toString(); + } +} diff --git a/location/java/android/location/GpsClock.java b/location/java/android/location/GpsClock.java index 719e56f9dcce..4135a1c949bb 100644 --- a/location/java/android/location/GpsClock.java +++ b/location/java/android/location/GpsClock.java @@ -16,41 +16,36 @@ package android.location; -import android.annotation.IntDef; +import android.annotation.SystemApi; 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. + * + * @hide */ -public final class GpsClock implements Parcelable { +@SystemApi +public class GpsClock 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 GpsClockType {} - /** * The type of the time stored is not available or it is unknown. */ - public static final byte CLOCK_TYPE_UNKNOWN = 0; + public static final byte 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; + public static final byte 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; + public static final byte TYPE_GPS_TIME = 2; private static final short HAS_NO_FLAGS = 0; private static final short HAS_LEAP_SECOND = (1<<0); @@ -73,7 +68,6 @@ public final class GpsClock implements Parcelable { private double mBiasUncertaintyInNs; private double mDriftInNsPerSec; private double mDriftUncertaintyInNsPerSec; - private long mTimeOfLastHwClockDiscontinuityInNs; GpsClock() { initialize(); @@ -93,7 +87,6 @@ public final class GpsClock implements Parcelable { mBiasUncertaintyInNs = clock.mBiasUncertaintyInNs; mDriftInNsPerSec = clock.mDriftInNsPerSec; mDriftUncertaintyInNsPerSec = clock.mDriftUncertaintyInNsPerSec; - mTimeOfLastHwClockDiscontinuityInNs = clock.mTimeOfLastHwClockDiscontinuityInNs; } /** @@ -106,7 +99,6 @@ public final class GpsClock implements Parcelable { /** * Gets the type of time reported by {@link #getTimeInNs()}. */ - @GpsClockType public byte getType() { return mType; } @@ -114,7 +106,7 @@ public final class GpsClock implements Parcelable { /** * Sets the type of time reported. */ - public void setType(@GpsClockType byte value) { + public void setType(byte value) { mType = value; } @@ -124,11 +116,11 @@ public final class GpsClock implements Parcelable { */ private String getTypeString() { switch (mType) { - case CLOCK_TYPE_UNKNOWN: + case TYPE_UNKNOWN: return "Unknown"; - case CLOCK_TYPE_GPS_TIME: + case TYPE_GPS_TIME: return "GpsTime"; - case CLOCK_TYPE_LOCAL_HW_TIME: + case TYPE_LOCAL_HW_TIME: return "LocalHwClock"; default: return "<Invalid:" + mType + ">"; @@ -171,8 +163,8 @@ public final class GpsClock 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}). + * 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 @@ -231,7 +223,7 @@ public final class GpsClock implements Parcelable { } /** - * Returns true if {@link #getFullBiasInNs()} is available, false otherwise. + * Returns true if {@link @getFullBiasInNs()} is available, false otherwise. */ public boolean hasFullBiasInNs() { return isFlagSet(HAS_FULL_BIAS); @@ -241,7 +233,7 @@ public final class GpsClock 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 + * 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. * @@ -395,20 +387,6 @@ public final class GpsClock implements Parcelable { } /** - * Gets time of last hardware clock discontinuity. - */ - public long getTimeOfLastHwClockDiscontinuityInNs() { - return mTimeOfLastHwClockDiscontinuityInNs; - } - - /** - * Sets time of last hardware clock discontinuity. - */ - public void setTimeOfLastHwClockDiscontinuityInNs(long timeOfLastHwClockDiscontinuityInNs) { - mTimeOfLastHwClockDiscontinuityInNs = timeOfLastHwClockDiscontinuityInNs; - } - - /** * Resets the clock's Drift Uncertainty (1-Sigma) in nanoseconds per second. */ public void resetDriftUncertaintyInNsPerSec() { @@ -431,7 +409,6 @@ public final class GpsClock implements Parcelable { gpsClock.mBiasUncertaintyInNs = parcel.readDouble(); gpsClock.mDriftInNsPerSec = parcel.readDouble(); gpsClock.mDriftUncertaintyInNsPerSec = parcel.readDouble(); - gpsClock.mTimeOfLastHwClockDiscontinuityInNs = parcel.readLong(); return gpsClock; } @@ -453,7 +430,6 @@ public final class GpsClock implements Parcelable { parcel.writeDouble(mBiasUncertaintyInNs); parcel.writeDouble(mDriftInNsPerSec); parcel.writeDouble(mDriftUncertaintyInNsPerSec); - parcel.writeLong(mTimeOfLastHwClockDiscontinuityInNs); } @Override @@ -497,17 +473,13 @@ public final class GpsClock implements Parcelable { "DriftUncertaintyInNsPerSec", hasDriftUncertaintyInNsPerSec() ? mDriftUncertaintyInNsPerSec : null)); - builder.append(String.format(format, "TimeOfLastHwClockDiscontinuityInNs", - getType() == CLOCK_TYPE_LOCAL_HW_TIME - ? mTimeOfLastHwClockDiscontinuityInNs : null)); - return builder.toString(); } private void initialize() { mFlags = HAS_NO_FLAGS; resetLeapSecond(); - setType(CLOCK_TYPE_UNKNOWN); + setType(TYPE_UNKNOWN); setTimeInNs(Long.MIN_VALUE); resetTimeUncertaintyInNs(); resetFullBiasInNs(); @@ -515,7 +487,6 @@ public final class GpsClock implements Parcelable { resetBiasUncertaintyInNs(); resetDriftInNsPerSec(); resetDriftUncertaintyInNsPerSec(); - setTimeOfLastHwClockDiscontinuityInNs(Long.MIN_VALUE); } private void setFlag(short flag) { diff --git a/location/java/android/location/GpsMeasurement.java b/location/java/android/location/GpsMeasurement.java index 366ad61f4188..f13a440f411a 100644 --- a/location/java/android/location/GpsMeasurement.java +++ b/location/java/android/location/GpsMeasurement.java @@ -16,17 +16,17 @@ package android.location; -import android.annotation.IntDef; +import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - /** * A class representing a GPS satellite measurement, containing raw and computed information. + * + * @hide */ -public final class GpsMeasurement implements Parcelable { +@SystemApi +public class GpsMeasurement implements Parcelable { private int mFlags; private byte mPrn; private double mTimeOffsetInNs; @@ -59,8 +59,6 @@ public final class GpsMeasurement implements Parcelable { private double mAzimuthInDeg; private double mAzimuthUncertaintyInDeg; private boolean mUsedInFix; - private double mPseudorangeRateCarrierInMetersPerSec; - private double mPseudorangeRateCarrierUncertaintyInMetersPerSec; // The following enumerations must be in sync with the values declared in gps.h @@ -85,11 +83,6 @@ public final class GpsMeasurement implements Parcelable { private static final int HAS_USED_IN_FIX = (1<<17); private static final int GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE = (1<<18); - /** The status of 'loss of lock'. */ - @Retention(RetentionPolicy.SOURCE) - @IntDef({LOSS_OF_LOCK_UNKNOWN, LOSS_OF_LOCK_OK, LOSS_OF_LOCK_CYCLE_SLIP}) - public @interface LossOfLockStatus {} - /** * The indicator is not available or it is unknown. */ @@ -105,12 +98,6 @@ public final class GpsMeasurement implements Parcelable { */ public static final byte LOSS_OF_LOCK_CYCLE_SLIP = 2; - /** The status of multipath. */ - @Retention(RetentionPolicy.SOURCE) - @IntDef({MULTIPATH_INDICATOR_UNKNOWN, MULTIPATH_INDICATOR_DETECTED, - MULTIPATH_INDICATOR_NOT_USED}) - public @interface MultipathIndicator {} - /** * The indicator is not available or it is unknown. */ @@ -231,10 +218,6 @@ public final class GpsMeasurement implements Parcelable { mAzimuthInDeg = measurement.mAzimuthInDeg; mAzimuthUncertaintyInDeg = measurement.mAzimuthUncertaintyInDeg; mUsedInFix = measurement.mUsedInFix; - mPseudorangeRateCarrierInMetersPerSec = - measurement.mPseudorangeRateCarrierInMetersPerSec; - mPseudorangeRateCarrierUncertaintyInMetersPerSec = - measurement.mPseudorangeRateCarrierUncertaintyInMetersPerSec; } /** @@ -793,7 +776,6 @@ public final class GpsMeasurement implements Parcelable { /** * Gets a value indicating the 'loss of lock' state of the event. */ - @LossOfLockStatus public byte getLossOfLock() { return mLossOfLock; } @@ -801,7 +783,7 @@ public final class GpsMeasurement implements Parcelable { /** * Sets the 'loss of lock' status. */ - public void setLossOfLock(@LossOfLockStatus byte value) { + public void setLossOfLock(byte value) { mLossOfLock = value; } @@ -959,7 +941,6 @@ public final class GpsMeasurement implements Parcelable { /** * Gets a value indicating the 'multipath' state of the event. */ - @MultipathIndicator public byte getMultipathIndicator() { return mMultipathIndicator; } @@ -967,7 +948,7 @@ public final class GpsMeasurement implements Parcelable { /** * Sets the 'multi-path' indicator. */ - public void setMultipathIndicator(@MultipathIndicator byte value) { + public void setMultipathIndicator(byte value) { mMultipathIndicator = value; } @@ -1176,34 +1157,6 @@ public final class GpsMeasurement implements Parcelable { mUsedInFix = value; } - /** - * Gets pseudorange rate (based on carrier phase changes) at the timestamp in m/s. - */ - public double getPseudorangeRateCarrierInMetersPerSec() { - return mPseudorangeRateCarrierInMetersPerSec; - } - - /** - * Sets pseudorange rate (based on carrier phase changes) at the timestamp in m/s. - */ - public void setPseudorangeRateCarrierInMetersPerSec(double value) { - mPseudorangeRateCarrierInMetersPerSec = value; - } - - /** - * Gets 1-Sigma uncertainty of the pseudorange rate carrier. - */ - public double getPseudorangeRateCarrierUncertaintyInMetersPerSec() { - return mPseudorangeRateCarrierUncertaintyInMetersPerSec; - } - - /** - * Sets 1-Sigma uncertainty of the pseudorange rate carrier. - */ - public void setPseudorangeRateCarrierUncertaintyInMetersPerSec(double value) { - mPseudorangeRateCarrierUncertaintyInMetersPerSec = value; - } - public static final Creator<GpsMeasurement> CREATOR = new Creator<GpsMeasurement>() { @Override public GpsMeasurement createFromParcel(Parcel parcel) { @@ -1241,8 +1194,6 @@ public final class GpsMeasurement implements Parcelable { gpsMeasurement.mAzimuthInDeg = parcel.readDouble(); gpsMeasurement.mAzimuthUncertaintyInDeg = parcel.readDouble(); gpsMeasurement.mUsedInFix = parcel.readInt() != 0; - gpsMeasurement.mPseudorangeRateCarrierInMetersPerSec = parcel.readDouble(); - gpsMeasurement.mPseudorangeRateCarrierUncertaintyInMetersPerSec = parcel.readDouble(); return gpsMeasurement; } @@ -1286,8 +1237,6 @@ public final class GpsMeasurement implements Parcelable { parcel.writeDouble(mAzimuthInDeg); parcel.writeDouble(mAzimuthUncertaintyInDeg); parcel.writeInt(mUsedInFix ? 1 : 0); - parcel.writeDouble(mPseudorangeRateCarrierInMetersPerSec); - parcel.writeDouble(mPseudorangeRateCarrierUncertaintyInMetersPerSec); } @Override @@ -1412,11 +1361,6 @@ public final class GpsMeasurement implements Parcelable { builder.append(String.format(format, "UsedInFix", mUsedInFix)); - builder.append(String.format(format, "PseudorangeRateCarrierInMetersPerSec", - mPseudorangeRateCarrierInMetersPerSec)); - builder.append(String.format(format, "PseudorangeRateCarrierUncertaintyInMetersPerSec", - mPseudorangeRateCarrierUncertaintyInMetersPerSec)); - return builder.toString(); } @@ -1453,8 +1397,6 @@ public final class GpsMeasurement implements Parcelable { resetAzimuthInDeg(); resetAzimuthUncertaintyInDeg(); setUsedInFix(false); - setPseudorangeRateCarrierInMetersPerSec(Double.MIN_VALUE); - setPseudorangeRateCarrierUncertaintyInMetersPerSec(Double.MIN_VALUE); } private void setFlag(int flag) { diff --git a/location/java/android/location/GpsMeasurementsEvent.java b/location/java/android/location/GpsMeasurementsEvent.java index ef9edeb7692d..136687337861 100644 --- a/location/java/android/location/GpsMeasurementsEvent.java +++ b/location/java/android/location/GpsMeasurementsEvent.java @@ -16,13 +16,11 @@ package android.location; -import android.annotation.IntDef; import android.annotation.NonNull; +import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; import java.security.InvalidParameterException; import java.util.Arrays; import java.util.Collection; @@ -30,13 +28,12 @@ import java.util.Collections; /** * A class implementing a container for data associated with a measurement event. - * Events are delivered to registered instances of {@link Callback}. + * Events are delivered to registered instances of {@link Listener}. + * + * @hide */ -public final class GpsMeasurementsEvent implements Parcelable { - /** The status of GPS measurements event. */ - @Retention(RetentionPolicy.SOURCE) - @IntDef({STATUS_NOT_SUPPORTED, STATUS_READY, STATUS_GPS_LOCATION_DISABLED}) - public @interface GpsMeasurementsStatus {} +@SystemApi +public class GpsMeasurementsEvent implements Parcelable { /** * The system does not support tracking of GPS Measurements. This status will not change in the @@ -61,20 +58,22 @@ public final class GpsMeasurementsEvent implements Parcelable { /** * Used for receiving GPS satellite measurements from the GPS engine. * Each measurement contains raw and computed data identifying a satellite. - * You can implement this interface and call - * {@link LocationManager#registerGpsMeasurementCallback}. + * You can implement this interface and call {@link LocationManager#addGpsMeasurementListener}. + * + * @hide */ - public static abstract class Callback { + @SystemApi + public interface Listener { /** * Returns the latest collected GPS Measurements. */ - public void onGpsMeasurementsReceived(GpsMeasurementsEvent eventArgs) {} + void onGpsMeasurementsReceived(GpsMeasurementsEvent eventArgs); /** * Returns the latest status of the GPS Measurements sub-system. */ - public void onStatusChanged(@GpsMeasurementsStatus int status) {} + void onStatusChanged(int status); } public GpsMeasurementsEvent(GpsClock clock, GpsMeasurement[] measurements) { diff --git a/location/java/android/location/GpsNavigationMessage.java b/location/java/android/location/GpsNavigationMessage.java index d79957243676..5c3c71012cdd 100644 --- a/location/java/android/location/GpsNavigationMessage.java +++ b/location/java/android/location/GpsNavigationMessage.java @@ -16,54 +16,49 @@ package android.location; -import android.annotation.IntDef; import android.annotation.NonNull; +import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; import java.security.InvalidParameterException; /** * A class containing a GPS satellite Navigation Message. + * + * @hide */ -public final class GpsNavigationMessage implements Parcelable { +@SystemApi +public class GpsNavigationMessage implements Parcelable { private static final byte[] EMPTY_ARRAY = new byte[0]; - /** The type of the GPS Clock. */ - @Retention(RetentionPolicy.SOURCE) - @IntDef({MESSAGE_TYPE_UNKNOWN, MESSAGE_TYPE_L1CA, MESSAGE_TYPE_L2CNAV, MESSAGE_TYPE_L5CNAV, - MESSAGE_TYPE_CNAV2}) - public @interface GpsNavigationMessageType {} - // The following enumerations must be in sync with the values declared in gps.h /** * The type of the navigation message is not available or unknown. */ - public static final byte MESSAGE_TYPE_UNKNOWN = 0; + public static final byte TYPE_UNKNOWN = 0; /** * The Navigation Message is of type L1 C/A. */ - public static final byte MESSAGE_TYPE_L1CA = 1; + public static final byte TYPE_L1CA = 1; /** * The Navigation Message is of type L1-CNAV. */ - public static final byte MESSAGE_TYPE_L2CNAV = 2; + public static final byte TYPE_L2CNAV = 2; /** * The Navigation Message is of type L5-CNAV. */ - public static final byte MESSAGE_TYPE_L5CNAV = 3; + public static final byte TYPE_L5CNAV = 3; /** * The Navigation Message is of type CNAV-2. */ - public static final byte MESSAGE_TYPE_CNAV2 = 4; + public static final byte TYPE_CNAV2 = 4; /** * The Navigation Message Status is 'unknown'. @@ -116,7 +111,6 @@ public final class GpsNavigationMessage implements Parcelable { /** * Gets the type of the navigation message contained in the object. */ - @GpsNavigationMessageType public byte getType() { return mType; } @@ -124,7 +118,7 @@ public final class GpsNavigationMessage implements Parcelable { /** * Sets the type of the navigation message. */ - public void setType(@GpsNavigationMessageType byte value) { + public void setType(byte value) { mType = value; } @@ -134,15 +128,15 @@ public final class GpsNavigationMessage implements Parcelable { */ private String getTypeString() { switch (mType) { - case MESSAGE_TYPE_UNKNOWN: + case TYPE_UNKNOWN: return "Unknown"; - case MESSAGE_TYPE_L1CA: + case TYPE_L1CA: return "L1 C/A"; - case MESSAGE_TYPE_L2CNAV: + case TYPE_L2CNAV: return "L2-CNAV"; - case MESSAGE_TYPE_L5CNAV: + case TYPE_L5CNAV: return "L5-CNAV"; - case MESSAGE_TYPE_CNAV2: + case TYPE_CNAV2: return "CNAV-2"; default: return "<Invalid:" + mType + ">"; @@ -320,7 +314,7 @@ public final class GpsNavigationMessage implements Parcelable { } private void initialize() { - mType = MESSAGE_TYPE_UNKNOWN; + mType = TYPE_UNKNOWN; mPrn = 0; mMessageId = -1; mSubmessageId = -1; diff --git a/location/java/android/location/GpsNavigationMessageEvent.java b/location/java/android/location/GpsNavigationMessageEvent.java index b16a4855f389..bd6921c74152 100644 --- a/location/java/android/location/GpsNavigationMessageEvent.java +++ b/location/java/android/location/GpsNavigationMessageEvent.java @@ -16,60 +16,60 @@ package android.location; -import android.annotation.IntDef; import android.annotation.NonNull; +import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; import java.security.InvalidParameterException; /** * A class implementing a container for data associated with a navigation message event. - * Events are delivered to registered instances of {@link Callback}. + * Events are delivered to registered instances of {@link Listener}. + * + * @hide */ -public final class GpsNavigationMessageEvent implements Parcelable { - /** The status of GPS measurements event. */ - @Retention(RetentionPolicy.SOURCE) - @IntDef({STATUS_NOT_SUPPORTED, STATUS_READY, STATUS_GPS_LOCATION_DISABLED}) - public @interface GpsNavigationMessageStatus {} +@SystemApi +public class GpsNavigationMessageEvent implements Parcelable { /** * The system does not support tracking of GPS Navigation Messages. This status will not change * in the future. */ - public static final int STATUS_NOT_SUPPORTED = 0; + public static int STATUS_NOT_SUPPORTED = 0; /** * GPS Navigation Messages are successfully being tracked, it will receive updates once they are * available. */ - public static final int STATUS_READY = 1; + public static int STATUS_READY = 1; /** * GPS provider or Location is disabled, updated will not be received until they are enabled. */ - public static final int STATUS_GPS_LOCATION_DISABLED = 2; + public static int STATUS_GPS_LOCATION_DISABLED = 2; private final GpsNavigationMessage mNavigationMessage; /** * Used for receiving GPS satellite Navigation Messages from the GPS engine. * You can implement this interface and call - * {@link LocationManager#registerGpsNavigationMessageCallback}. + * {@link LocationManager#addGpsNavigationMessageListener}. + * + * @hide */ - public static abstract class Callback { + @SystemApi + public interface Listener { /** * Returns the latest collected GPS Navigation Message. */ - public void onGpsNavigationMessageReceived(GpsNavigationMessageEvent event) {} + void onGpsNavigationMessageReceived(GpsNavigationMessageEvent event); /** * Returns the latest status of the GPS Navigation Messages sub-system. */ - public void onStatusChanged(@GpsNavigationMessageStatus int status) {} + void onStatusChanged(int status); } public GpsNavigationMessageEvent(GpsNavigationMessage message) { diff --git a/location/java/android/location/IGpsMeasurementsListener.aidl b/location/java/android/location/IGnssMeasurementsListener.aidl index cbd31000094d..69fa48a0fb63 100644 --- a/location/java/android/location/IGpsMeasurementsListener.aidl +++ b/location/java/android/location/IGnssMeasurementsListener.aidl @@ -16,12 +16,12 @@ package android.location; -import android.location.GpsMeasurementsEvent; +import android.location.GnssMeasurementsEvent; /** * {@hide} */ -oneway interface IGpsMeasurementsListener { - void onGpsMeasurementsReceived(in GpsMeasurementsEvent event); +oneway interface IGnssMeasurementsListener { + void onGnssMeasurementsReceived(in GnssMeasurementsEvent event); void onStatusChanged(in int status); } diff --git a/location/java/android/location/IGpsNavigationMessageListener.aidl b/location/java/android/location/IGnssNavigationMessageListener.aidl index a708ea6a78d6..de6129c96e56 100644 --- a/location/java/android/location/IGpsNavigationMessageListener.aidl +++ b/location/java/android/location/IGnssNavigationMessageListener.aidl @@ -16,12 +16,12 @@ package android.location; -import android.location.GpsNavigationMessageEvent; +import android.location.GnssNavigationMessageEvent; /** * {@hide} */ -oneway interface IGpsNavigationMessageListener { - void onGpsNavigationMessageReceived(in GpsNavigationMessageEvent event); +oneway interface IGnssNavigationMessageListener { + void onGnssNavigationMessageReceived(in GnssNavigationMessageEvent event); void onStatusChanged(in int status); } diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl index 49d841fb1116..4f1e0397abd0 100644 --- a/location/java/android/location/ILocationManager.aidl +++ b/location/java/android/location/ILocationManager.aidl @@ -21,9 +21,9 @@ import android.location.Address; import android.location.Criteria; import android.location.GeocoderParams; import android.location.Geofence; +import android.location.IGnssMeasurementsListener; import android.location.IGnssStatusListener; -import android.location.IGpsMeasurementsListener; -import android.location.IGpsNavigationMessageListener; +import android.location.IGnssNavigationMessageListener; import android.location.ILocationListener; import android.location.Location; import android.location.LocationRequest; @@ -61,13 +61,13 @@ interface ILocationManager boolean sendNiResponse(int notifId, int userResponse); - boolean addGpsMeasurementsListener(in IGpsMeasurementsListener listener, in String packageName); - void removeGpsMeasurementsListener(in IGpsMeasurementsListener listener); + boolean addGnssMeasurementsListener(in IGnssMeasurementsListener listener, in String packageName); + void removeGnssMeasurementsListener(in IGnssMeasurementsListener listener); - boolean addGpsNavigationMessageListener( - in IGpsNavigationMessageListener listener, + boolean addGnssNavigationMessageListener( + in IGnssNavigationMessageListener listener, in String packageName); - void removeGpsNavigationMessageListener(in IGpsNavigationMessageListener listener); + void removeGnssNavigationMessageListener(in IGnssNavigationMessageListener listener); int getGpsYearOfHardware(); diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index 5447bb13707f..30cf101397db 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -64,8 +64,8 @@ public class LocationManager { private final Context mContext; private final ILocationManager mService; - private final GpsMeasurementCallbackTransport mGpsMeasurementCallbackTransport; - private final GpsNavigationMessageCallbackTransport mGpsNavigationMessageCallbackTransport; + private final GnssMeasurementCallbackTransport mGnssMeasurementCallbackTransport; + private final GnssNavigationMessageCallbackTransport mGnssNavigationMessageCallbackTransport; private final HashMap<GpsStatus.Listener, GnssStatusListenerTransport> mGpsStatusListeners = new HashMap<>(); private final HashMap<GpsStatus.NmeaListener, GnssStatusListenerTransport> mGpsNmeaListeners = @@ -321,9 +321,9 @@ public class LocationManager { public LocationManager(Context context, ILocationManager service) { mService = service; mContext = context; - mGpsMeasurementCallbackTransport = new GpsMeasurementCallbackTransport(mContext, mService); - mGpsNavigationMessageCallbackTransport = - new GpsNavigationMessageCallbackTransport(mContext, mService); + mGnssMeasurementCallbackTransport = new GnssMeasurementCallbackTransport(mContext, mService); + mGnssNavigationMessageCallbackTransport = + new GnssNavigationMessageCallbackTransport(mContext, mService); } private LocationProvider createProvider(String name, ProviderProperties properties) { @@ -1817,73 +1817,119 @@ public class LocationManager { } /** + * No-op method to keep backward-compatibility. + * Don't use it. Use {@link #registerGnssMeasurementCallback} instead. + * @hide + * @deprecated + */ + @Deprecated + @SystemApi + public boolean addGpsMeasurementListener(GpsMeasurementsEvent.Listener listener) { + return false; + } + + /** * Registers a GPS Measurement callback. * - * @param callback a {@link GpsMeasurementsEvent.Callback} object to register. + * @param callback a {@link GnssMeasurementsEvent.Callback} object to register. * @return {@code true} if the callback was added successfully, {@code false} otherwise. */ @RequiresPermission(ACCESS_FINE_LOCATION) - public boolean registerGpsMeasurementCallback(GpsMeasurementsEvent.Callback callback) { - return registerGpsMeasurementCallback(callback, null); + public boolean registerGnssMeasurementCallback(GnssMeasurementsEvent.Callback callback) { + return registerGnssMeasurementCallback(callback, null); } /** * Registers a GPS Measurement callback. * - * @param callback a {@link GpsMeasurementsEvent.Callback} object to register. + * @param callback a {@link GnssMeasurementsEvent.Callback} object to register. * @param handler the handler that the callback runs on. * @return {@code true} if the callback was added successfully, {@code false} otherwise. */ @RequiresPermission(ACCESS_FINE_LOCATION) - public boolean registerGpsMeasurementCallback(GpsMeasurementsEvent.Callback callback, + public boolean registerGnssMeasurementCallback(GnssMeasurementsEvent.Callback callback, Handler handler) { - return mGpsMeasurementCallbackTransport.add(callback, handler); + return mGnssMeasurementCallbackTransport.add(callback, handler); + } + + /** + * No-op method to keep backward-compatibility. + * Don't use it. Use {@link #unregisterGnssMeasurementCallback} instead. + * @hide + * @deprecated + */ + @Deprecated + @SystemApi + public void removeGpsMeasurementListener(GpsMeasurementsEvent.Listener listener) { } /** * Unregisters a GPS Measurement callback. * - * @param callback a {@link GpsMeasurementsEvent.Callback} object to remove. + * @param callback a {@link GnssMeasurementsEvent.Callback} object to remove. */ - public void unregisterGpsMeasurementCallback(GpsMeasurementsEvent.Callback callback) { - mGpsMeasurementCallbackTransport.remove(callback); + public void unregisterGnssMeasurementCallback(GnssMeasurementsEvent.Callback callback) { + mGnssMeasurementCallbackTransport.remove(callback); + } + + /** + * No-op method to keep backward-compatibility. + * Don't use it. Use {@link #registerGnssNavigationMessageCallback} instead. + * @hide + * @deprecated + */ + @Deprecated + @SystemApi + public boolean addGpsNavigationMessageListener(GpsNavigationMessageEvent.Listener listener) { + return false; } /** * Registers a GPS Navigation Message callback. * - * @param callback a {@link GpsNavigationMessageEvent.Callback} object to register. + * @param callback a {@link GnssNavigationMessageEvent.Callback} object to register. * @return {@code true} if the callback was added successfully, {@code false} otherwise. */ - public boolean registerGpsNavigationMessageCallback( - GpsNavigationMessageEvent.Callback callback) { - return registerGpsNavigationMessageCallback(callback, null); + public boolean registerGnssNavigationMessageCallback( + GnssNavigationMessageEvent.Callback callback) { + return registerGnssNavigationMessageCallback(callback, null); } /** * Registers a GPS Navigation Message callback. * - * @param callback a {@link GpsNavigationMessageEvent.Callback} object to register. + * @param callback a {@link GnssNavigationMessageEvent.Callback} object to register. * @param handler the handler that the callback runs on. * @return {@code true} if the callback was added successfully, {@code false} otherwise. */ @RequiresPermission(ACCESS_FINE_LOCATION) - public boolean registerGpsNavigationMessageCallback( - GpsNavigationMessageEvent.Callback callback, Handler handler) { - return mGpsNavigationMessageCallbackTransport.add(callback, handler); + public boolean registerGnssNavigationMessageCallback( + GnssNavigationMessageEvent.Callback callback, Handler handler) { + return mGnssNavigationMessageCallbackTransport.add(callback, handler); } /** * Unregisters a GPS Navigation Message callback. * - * @param callback a {@link GpsNavigationMessageEvent.Callback} object to remove. + * @param callback a {@link GnssNavigationMessageEvent.Callback} object to remove. + */ + public void unregisterGnssNavigationMessageCallback( + GnssNavigationMessageEvent.Callback callback) { + mGnssNavigationMessageCallbackTransport.remove(callback); + } + + /** + * No-op method to keep backward-compatibility. + * Don't use it. Use {@link #unregisterGnssNavigationMessageCallback} instead. + * @hide + * @deprecated */ - public void unregisterGpsNavigationMessageCallback( - GpsNavigationMessageEvent.Callback callback) { - mGpsNavigationMessageCallbackTransport.remove(callback); + @Deprecated + @SystemApi + public void removeGpsNavigationMessageListener(GpsNavigationMessageEvent.Listener listener) { } - /** + /** * Retrieves information about the current status of the GPS engine. * This should only be called from the {@link GpsStatus.Listener#onGpsStatusChanged} * callback to ensure that the data is copied atomically. diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java index c55c5b61c999..14ddc363f392 100644 --- a/services/core/java/com/android/server/LocationManagerService.java +++ b/services/core/java/com/android/server/LocationManagerService.java @@ -24,12 +24,12 @@ import com.android.internal.os.BackgroundThread; import com.android.server.location.ActivityRecognitionProxy; import com.android.server.location.FlpHardwareProvider; import com.android.server.location.FusedProxy; -import com.android.server.location.GnssLocationProvider; import com.android.server.location.GeocoderProxy; import com.android.server.location.GeofenceManager; import com.android.server.location.GeofenceProxy; -import com.android.server.location.GpsMeasurementsProvider; -import com.android.server.location.GpsNavigationMessageProvider; +import com.android.server.location.GnssLocationProvider; +import com.android.server.location.GnssMeasurementsProvider; +import com.android.server.location.GnssNavigationMessageProvider; import com.android.server.location.LocationBlacklist; import com.android.server.location.LocationFudger; import com.android.server.location.LocationProviderInterface; @@ -61,11 +61,11 @@ import android.location.Address; import android.location.Criteria; import android.location.GeocoderParams; import android.location.Geofence; +import android.location.IGnssMeasurementsListener; import android.location.IGnssStatusListener; import android.location.IGnssStatusProvider; import android.location.IGpsGeofenceHardware; -import android.location.IGpsMeasurementsListener; -import android.location.IGpsNavigationMessageListener; +import android.location.IGnssNavigationMessageListener; import android.location.ILocationListener; import android.location.ILocationManager; import android.location.INetInitiatedListener; @@ -162,8 +162,8 @@ public class LocationManagerService extends ILocationManager.Stub { private LocationWorkerHandler mLocationHandler; private PassiveProvider mPassiveProvider; // track passive provider for special cases private LocationBlacklist mBlacklist; - private GpsMeasurementsProvider mGpsMeasurementsProvider; - private GpsNavigationMessageProvider mGpsNavigationMessageProvider; + private GnssMeasurementsProvider mGnssMeasurementsProvider; + private GnssNavigationMessageProvider mGnssNavigationMessageProvider; private IGpsGeofenceHardware mGpsGeofenceProxy; // --- fields below are protected by mLock --- @@ -467,8 +467,8 @@ public class LocationManagerService extends ILocationManager.Stub { mNetInitiatedListener = gnssProvider.getNetInitiatedListener(); addProviderLocked(gnssProvider); mRealProviders.put(LocationManager.GPS_PROVIDER, gnssProvider); - mGpsMeasurementsProvider = gnssProvider.getGpsMeasurementsProvider(); - mGpsNavigationMessageProvider = gnssProvider.getGpsNavigationMessageProvider(); + mGnssMeasurementsProvider = gnssProvider.getGnssMeasurementsProvider(); + mGnssNavigationMessageProvider = gnssProvider.getGnssNavigationMessageProvider(); mGpsGeofenceProxy = gnssProvider.getGpsGeofenceProxy(); } @@ -994,7 +994,7 @@ public class LocationManagerService extends ILocationManager.Stub { */ @Override public int getGpsYearOfHardware() { - if (mGpsNavigationMessageProvider != null) { + if (mGnssNavigationMessageProvider != null) { return mGpsSystemInfoProvider.getGpsYearOfHardware(); } else { return 0; @@ -1923,8 +1923,8 @@ public class LocationManagerService extends ILocationManager.Stub { } @Override - public boolean addGpsMeasurementsListener( - IGpsMeasurementsListener listener, + public boolean addGnssMeasurementsListener( + IGnssMeasurementsListener listener, String packageName) { int allowedResolutionLevel = getCallerAllowedResolutionLevel(); checkResolutionLevelIsSufficientForProviderUse( @@ -1941,22 +1941,22 @@ public class LocationManagerService extends ILocationManager.Stub { Binder.restoreCallingIdentity(identity); } - if (!hasLocationAccess || mGpsMeasurementsProvider == null) { + if (!hasLocationAccess || mGnssMeasurementsProvider == null) { return false; } - return mGpsMeasurementsProvider.addListener(listener); + return mGnssMeasurementsProvider.addListener(listener); } @Override - public void removeGpsMeasurementsListener(IGpsMeasurementsListener listener) { - if (mGpsMeasurementsProvider != null) { - mGpsMeasurementsProvider.removeListener(listener); + public void removeGnssMeasurementsListener(IGnssMeasurementsListener listener) { + if (mGnssMeasurementsProvider != null) { + mGnssMeasurementsProvider.removeListener(listener); } } @Override - public boolean addGpsNavigationMessageListener( - IGpsNavigationMessageListener listener, + public boolean addGnssNavigationMessageListener( + IGnssNavigationMessageListener listener, String packageName) { int allowedResolutionLevel = getCallerAllowedResolutionLevel(); checkResolutionLevelIsSufficientForProviderUse( @@ -1973,16 +1973,16 @@ public class LocationManagerService extends ILocationManager.Stub { Binder.restoreCallingIdentity(identity); } - if (!hasLocationAccess || mGpsNavigationMessageProvider == null) { + if (!hasLocationAccess || mGnssNavigationMessageProvider == null) { return false; } - return mGpsNavigationMessageProvider.addListener(listener); + return mGnssNavigationMessageProvider.addListener(listener); } @Override - public void removeGpsNavigationMessageListener(IGpsNavigationMessageListener listener) { - if (mGpsNavigationMessageProvider != null) { - mGpsNavigationMessageProvider.removeListener(listener); + public void removeGnssNavigationMessageListener(IGnssNavigationMessageListener listener) { + if (mGnssNavigationMessageProvider != null) { + mGnssNavigationMessageProvider.removeListener(listener); } } diff --git a/services/core/java/com/android/server/location/GnssLocationProvider.java b/services/core/java/com/android/server/location/GnssLocationProvider.java index 9798e56237e5..ffc52b31a7d5 100644 --- a/services/core/java/com/android/server/location/GnssLocationProvider.java +++ b/services/core/java/com/android/server/location/GnssLocationProvider.java @@ -38,8 +38,8 @@ import android.location.FusedBatchOptions; import android.location.GnssStatus; import android.location.IGnssStatusListener; import android.location.IGnssStatusProvider; -import android.location.GpsMeasurementsEvent; -import android.location.GpsNavigationMessageEvent; +import android.location.GnssMeasurementsEvent; +import android.location.GnssNavigationMessageEvent; import android.location.IGpsGeofenceHardware; import android.location.ILocationManager; import android.location.INetInitiatedListener; @@ -368,8 +368,8 @@ public class GnssLocationProvider implements LocationProviderInterface { private Location mLocation = new Location(LocationManager.GPS_PROVIDER); private Bundle mLocationExtras = new Bundle(); private final GnssStatusListenerHelper mListenerHelper; - private final GpsMeasurementsProvider mGpsMeasurementsProvider; - private final GpsNavigationMessageProvider mGpsNavigationMessageProvider; + private final GnssMeasurementsProvider mGnssMeasurementsProvider; + private final GnssNavigationMessageProvider mGnssNavigationMessageProvider; // Handler for processing events private Handler mHandler; @@ -428,12 +428,12 @@ public class GnssLocationProvider implements LocationProviderInterface { return mGpsGeofenceBinder; } - public GpsMeasurementsProvider getGpsMeasurementsProvider() { - return mGpsMeasurementsProvider; + public GnssMeasurementsProvider getGnssMeasurementsProvider() { + return mGnssMeasurementsProvider; } - public GpsNavigationMessageProvider getGpsNavigationMessageProvider() { - return mGpsNavigationMessageProvider; + public GnssNavigationMessageProvider getGnssNavigationMessageProvider() { + return mGnssNavigationMessageProvider; } /** @@ -713,7 +713,7 @@ public class GnssLocationProvider implements LocationProviderInterface { } }; - mGpsMeasurementsProvider = new GpsMeasurementsProvider(mHandler) { + mGnssMeasurementsProvider = new GnssMeasurementsProvider(mHandler) { @Override public boolean isAvailableInPlatform() { return native_is_measurement_supported(); @@ -735,7 +735,7 @@ public class GnssLocationProvider implements LocationProviderInterface { } }; - mGpsNavigationMessageProvider = new GpsNavigationMessageProvider(mHandler) { + mGnssNavigationMessageProvider = new GnssNavigationMessageProvider(mHandler) { @Override protected boolean isAvailableInPlatform() { return native_is_navigation_message_supported(); @@ -1087,8 +1087,8 @@ public class GnssLocationProvider implements LocationProviderInterface { native_set_agps_server(AGPS_TYPE_C2K, mC2KServerHost, mC2KServerPort); } - mGpsMeasurementsProvider.onGpsEnabledChanged(); - mGpsNavigationMessageProvider.onGpsEnabledChanged(); + mGnssMeasurementsProvider.onGpsEnabledChanged(); + mGnssNavigationMessageProvider.onGpsEnabledChanged(); } else { synchronized (mLock) { mEnabled = false; @@ -1123,8 +1123,8 @@ public class GnssLocationProvider implements LocationProviderInterface { // do this before releasing wakelock native_cleanup(); - mGpsMeasurementsProvider.onGpsEnabledChanged(); - mGpsNavigationMessageProvider.onGpsEnabledChanged(); + mGnssMeasurementsProvider.onGpsEnabledChanged(); + mGnssNavigationMessageProvider.onGpsEnabledChanged(); } @Override @@ -1655,15 +1655,15 @@ public class GnssLocationProvider implements LocationProviderInterface { /** * called from native code - Gps measurements callback */ - private void reportMeasurementData(GpsMeasurementsEvent event) { - mGpsMeasurementsProvider.onMeasurementsAvailable(event); + private void reportMeasurementData(GnssMeasurementsEvent event) { + mGnssMeasurementsProvider.onMeasurementsAvailable(event); } /** * called from native code - GPS navigation message callback */ - private void reportNavigationMessage(GpsNavigationMessageEvent event) { - mGpsNavigationMessageProvider.onNavigationMessageAvailable(event); + private void reportNavigationMessage(GnssNavigationMessageEvent event) { + mGnssNavigationMessageProvider.onNavigationMessageAvailable(event); } /** @@ -1677,9 +1677,9 @@ public class GnssLocationProvider implements LocationProviderInterface { requestUtcTime(); } - mGpsMeasurementsProvider.onCapabilitiesUpdated( + mGnssMeasurementsProvider.onCapabilitiesUpdated( (capabilities & GPS_CAPABILITY_MEASUREMENTS) == GPS_CAPABILITY_MEASUREMENTS); - mGpsNavigationMessageProvider.onCapabilitiesUpdated( + mGnssNavigationMessageProvider.onCapabilitiesUpdated( (capabilities & GPS_CAPABILITY_NAV_MESSAGES) == GPS_CAPABILITY_NAV_MESSAGES); } diff --git a/services/core/java/com/android/server/location/GpsMeasurementsProvider.java b/services/core/java/com/android/server/location/GnssMeasurementsProvider.java index b327ca260668..d9e8e91989bb 100644 --- a/services/core/java/com/android/server/location/GpsMeasurementsProvider.java +++ b/services/core/java/com/android/server/location/GnssMeasurementsProvider.java @@ -16,8 +16,8 @@ package com.android.server.location; -import android.location.GpsMeasurementsEvent; -import android.location.IGpsMeasurementsListener; +import android.location.GnssMeasurementsEvent; +import android.location.IGnssMeasurementsListener; import android.os.Handler; import android.os.RemoteException; import android.util.Log; @@ -29,27 +29,27 @@ import android.util.Log; * * @hide */ -public abstract class GpsMeasurementsProvider - extends RemoteListenerHelper<IGpsMeasurementsListener> { - private static final String TAG = "GpsMeasurementsProvider"; +public abstract class GnssMeasurementsProvider + extends RemoteListenerHelper<IGnssMeasurementsListener> { + private static final String TAG = "GnssMeasurementsProvider"; - protected GpsMeasurementsProvider(Handler handler) { + protected GnssMeasurementsProvider(Handler handler) { super(handler, TAG); } - public void onMeasurementsAvailable(final GpsMeasurementsEvent event) { - ListenerOperation<IGpsMeasurementsListener> operation = - new ListenerOperation<IGpsMeasurementsListener>() { + public void onMeasurementsAvailable(final GnssMeasurementsEvent event) { + ListenerOperation<IGnssMeasurementsListener> operation = + new ListenerOperation<IGnssMeasurementsListener>() { @Override - public void execute(IGpsMeasurementsListener listener) throws RemoteException { - listener.onGpsMeasurementsReceived(event); + public void execute(IGnssMeasurementsListener listener) throws RemoteException { + listener.onGnssMeasurementsReceived(event); } }; foreach(operation); } - public void onCapabilitiesUpdated(boolean isGpsMeasurementsSupported) { - setSupported(isGpsMeasurementsSupported); + public void onCapabilitiesUpdated(boolean isGnssMeasurementsSupported) { + setSupported(isGnssMeasurementsSupported); updateResult(); } @@ -60,19 +60,19 @@ public abstract class GpsMeasurementsProvider } @Override - protected ListenerOperation<IGpsMeasurementsListener> getHandlerOperation(int result) { + protected ListenerOperation<IGnssMeasurementsListener> getHandlerOperation(int result) { int status; switch (result) { case RESULT_SUCCESS: - status = GpsMeasurementsEvent.STATUS_READY; + status = GnssMeasurementsEvent.STATUS_READY; break; case RESULT_NOT_AVAILABLE: case RESULT_NOT_SUPPORTED: case RESULT_INTERNAL_ERROR: - status = GpsMeasurementsEvent.STATUS_NOT_SUPPORTED; + status = GnssMeasurementsEvent.STATUS_NOT_SUPPORTED; break; case RESULT_GPS_LOCATION_DISABLED: - status = GpsMeasurementsEvent.STATUS_GPS_LOCATION_DISABLED; + status = GnssMeasurementsEvent.STATUS_GPS_LOCATION_DISABLED; break; case RESULT_UNKNOWN: return null; @@ -84,7 +84,7 @@ public abstract class GpsMeasurementsProvider } private static class StatusChangedOperation - implements ListenerOperation<IGpsMeasurementsListener> { + implements ListenerOperation<IGnssMeasurementsListener> { private final int mStatus; public StatusChangedOperation(int status) { @@ -92,7 +92,7 @@ public abstract class GpsMeasurementsProvider } @Override - public void execute(IGpsMeasurementsListener listener) throws RemoteException { + public void execute(IGnssMeasurementsListener listener) throws RemoteException { listener.onStatusChanged(mStatus); } } diff --git a/services/core/java/com/android/server/location/GpsNavigationMessageProvider.java b/services/core/java/com/android/server/location/GnssNavigationMessageProvider.java index e6bbe56187d5..57bce4b0fbd7 100644 --- a/services/core/java/com/android/server/location/GpsNavigationMessageProvider.java +++ b/services/core/java/com/android/server/location/GnssNavigationMessageProvider.java @@ -16,8 +16,8 @@ package com.android.server.location; -import android.location.GpsNavigationMessageEvent; -import android.location.IGpsNavigationMessageListener; +import android.location.GnssNavigationMessageEvent; +import android.location.IGnssNavigationMessageListener; import android.os.Handler; import android.os.RemoteException; import android.util.Log; @@ -29,28 +29,28 @@ import android.util.Log; * * @hide */ -public abstract class GpsNavigationMessageProvider - extends RemoteListenerHelper<IGpsNavigationMessageListener> { - private static final String TAG = "GpsNavigationMessageProvider"; +public abstract class GnssNavigationMessageProvider + extends RemoteListenerHelper<IGnssNavigationMessageListener> { + private static final String TAG = "GnssNavigationMessageProvider"; - protected GpsNavigationMessageProvider(Handler handler) { + protected GnssNavigationMessageProvider(Handler handler) { super(handler, TAG); } - public void onNavigationMessageAvailable(final GpsNavigationMessageEvent event) { - ListenerOperation<IGpsNavigationMessageListener> operation = - new ListenerOperation<IGpsNavigationMessageListener>() { + public void onNavigationMessageAvailable(final GnssNavigationMessageEvent event) { + ListenerOperation<IGnssNavigationMessageListener> operation = + new ListenerOperation<IGnssNavigationMessageListener>() { @Override - public void execute(IGpsNavigationMessageListener listener) + public void execute(IGnssNavigationMessageListener listener) throws RemoteException { - listener.onGpsNavigationMessageReceived(event); + listener.onGnssNavigationMessageReceived(event); } }; foreach(operation); } - public void onCapabilitiesUpdated(boolean isGpsNavigationMessageSupported) { - setSupported(isGpsNavigationMessageSupported); + public void onCapabilitiesUpdated(boolean isGnssNavigationMessageSupported) { + setSupported(isGnssNavigationMessageSupported); updateResult(); } @@ -61,19 +61,19 @@ public abstract class GpsNavigationMessageProvider } @Override - protected ListenerOperation<IGpsNavigationMessageListener> getHandlerOperation(int result) { + protected ListenerOperation<IGnssNavigationMessageListener> getHandlerOperation(int result) { int status; switch (result) { case RESULT_SUCCESS: - status = GpsNavigationMessageEvent.STATUS_READY; + status = GnssNavigationMessageEvent.STATUS_READY; break; case RESULT_NOT_AVAILABLE: case RESULT_NOT_SUPPORTED: case RESULT_INTERNAL_ERROR: - status = GpsNavigationMessageEvent.STATUS_NOT_SUPPORTED; + status = GnssNavigationMessageEvent.STATUS_NOT_SUPPORTED; break; case RESULT_GPS_LOCATION_DISABLED: - status = GpsNavigationMessageEvent.STATUS_GPS_LOCATION_DISABLED; + status = GnssNavigationMessageEvent.STATUS_GPS_LOCATION_DISABLED; break; case RESULT_UNKNOWN: return null; @@ -85,7 +85,7 @@ public abstract class GpsNavigationMessageProvider } private static class StatusChangedOperation - implements ListenerOperation<IGpsNavigationMessageListener> { + implements ListenerOperation<IGnssNavigationMessageListener> { private final int mStatus; public StatusChangedOperation(int status) { @@ -93,7 +93,7 @@ public abstract class GpsNavigationMessageProvider } @Override - public void execute(IGpsNavigationMessageListener listener) throws RemoteException { + public void execute(IGnssNavigationMessageListener listener) throws RemoteException { listener.onStatusChanged(mStatus); } } diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp index 0c85a1578065..e75775fa9237 100644 --- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp +++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp @@ -537,11 +537,11 @@ static void android_location_GnssLocationProvider_class_init_native(JNIEnv* env, method_reportMeasurementData = env->GetMethodID( clazz, "reportMeasurementData", - "(Landroid/location/GpsMeasurementsEvent;)V"); + "(Landroid/location/GnssMeasurementsEvent;)V"); method_reportNavigationMessages = env->GetMethodID( clazz, "reportNavigationMessage", - "(Landroid/location/GpsNavigationMessageEvent;)V"); + "(Landroid/location/GnssNavigationMessageEvent;)V"); err = hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); if (err == 0) { @@ -974,7 +974,7 @@ static jobject translate_gps_clock(JNIEnv* env, void* data, size_t size) { GpsClock* clock = reinterpret_cast<GpsClock*>(data); - jclass gpsClockClass = env->FindClass("android/location/GpsClock"); + jclass gpsClockClass = env->FindClass("android/location/GnssClock"); jmethodID gpsClockCtor = env->GetMethodID(gpsClockClass, "<init>", "()V"); jobject gpsClockObject = env->NewObject(gpsClockClass, gpsClockCtor); @@ -1049,264 +1049,264 @@ static jobject translate_gps_measurement(JNIEnv* env, void* data, size_t size) { const char* floatSignature = "(F)V"; const char* doubleSignature = "(D)V"; - jclass gpsMeasurementClass = env->FindClass("android/location/GpsMeasurement"); - jmethodID gpsMeasurementCtor = env->GetMethodID(gpsMeasurementClass, "<init>", "()V"); + jclass gnssMeasurementClass = env->FindClass("android/location/GnssMeasurement"); + jmethodID gnssMeasurementCtor = env->GetMethodID(gnssMeasurementClass, "<init>", "()V"); GpsMeasurement* measurement = reinterpret_cast<GpsMeasurement*>(data); - jobject gpsMeasurementObject = env->NewObject(gpsMeasurementClass, gpsMeasurementCtor); + jobject gnssMeasurementObject = env->NewObject(gnssMeasurementClass, gnssMeasurementCtor); GpsMeasurementFlags flags = measurement->flags; - jmethodID prnSetterMethod = env->GetMethodID(gpsMeasurementClass, "setPrn", byteSignature); - env->CallVoidMethod(gpsMeasurementObject, prnSetterMethod, measurement->prn); + jmethodID prnSetterMethod = env->GetMethodID(gnssMeasurementClass, "setPrn", byteSignature); + env->CallVoidMethod(gnssMeasurementObject, prnSetterMethod, measurement->prn); jmethodID timeOffsetSetterMethod = - env->GetMethodID(gpsMeasurementClass, "setTimeOffsetInNs", doubleSignature); + env->GetMethodID(gnssMeasurementClass, "setTimeOffsetInNs", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, timeOffsetSetterMethod, measurement->time_offset_ns); - jmethodID stateSetterMethod = env->GetMethodID(gpsMeasurementClass, "setState", shortSignature); - env->CallVoidMethod(gpsMeasurementObject, stateSetterMethod, measurement->state); + jmethodID stateSetterMethod = env->GetMethodID(gnssMeasurementClass, "setState", shortSignature); + env->CallVoidMethod(gnssMeasurementObject, stateSetterMethod, measurement->state); jmethodID receivedGpsTowSetterMethod = - env->GetMethodID(gpsMeasurementClass, "setReceivedGpsTowInNs", longSignature); + env->GetMethodID(gnssMeasurementClass, "setReceivedGpsTowInNs", longSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, receivedGpsTowSetterMethod, measurement->received_gps_tow_ns); jmethodID receivedGpsTowUncertaintySetterMethod = env->GetMethodID( - gpsMeasurementClass, + gnssMeasurementClass, "setReceivedGpsTowUncertaintyInNs", longSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, receivedGpsTowUncertaintySetterMethod, measurement->received_gps_tow_uncertainty_ns); jmethodID cn0SetterMethod = - env->GetMethodID(gpsMeasurementClass, "setCn0InDbHz", doubleSignature); - env->CallVoidMethod(gpsMeasurementObject, cn0SetterMethod, measurement->c_n0_dbhz); + env->GetMethodID(gnssMeasurementClass, "setCn0InDbHz", doubleSignature); + env->CallVoidMethod(gnssMeasurementObject, cn0SetterMethod, measurement->c_n0_dbhz); jmethodID pseudorangeRateSetterMethod = env->GetMethodID( - gpsMeasurementClass, + gnssMeasurementClass, "setPseudorangeRateInMetersPerSec", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, pseudorangeRateSetterMethod, measurement->pseudorange_rate_mps); jmethodID pseudorangeRateUncertaintySetterMethod = env->GetMethodID( - gpsMeasurementClass, + gnssMeasurementClass, "setPseudorangeRateUncertaintyInMetersPerSec", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, pseudorangeRateUncertaintySetterMethod, measurement->pseudorange_rate_uncertainty_mps); jmethodID accumulatedDeltaRangeStateSetterMethod = - env->GetMethodID(gpsMeasurementClass, "setAccumulatedDeltaRangeState", shortSignature); + env->GetMethodID(gnssMeasurementClass, "setAccumulatedDeltaRangeState", shortSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, accumulatedDeltaRangeStateSetterMethod, measurement->accumulated_delta_range_state); jmethodID accumulatedDeltaRangeSetterMethod = env->GetMethodID( - gpsMeasurementClass, + gnssMeasurementClass, "setAccumulatedDeltaRangeInMeters", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, accumulatedDeltaRangeSetterMethod, measurement->accumulated_delta_range_m); jmethodID accumulatedDeltaRangeUncertaintySetterMethod = env->GetMethodID( - gpsMeasurementClass, + gnssMeasurementClass, "setAccumulatedDeltaRangeUncertaintyInMeters", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, accumulatedDeltaRangeUncertaintySetterMethod, measurement->accumulated_delta_range_uncertainty_m); if (flags & GPS_MEASUREMENT_HAS_PSEUDORANGE) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setPseudorangeInMeters", doubleSignature); - env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->pseudorange_m); + env->GetMethodID(gnssMeasurementClass, "setPseudorangeInMeters", doubleSignature); + env->CallVoidMethod(gnssMeasurementObject, setterMethod, measurement->pseudorange_m); } if (flags & GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY) { jmethodID setterMethod = env->GetMethodID( - gpsMeasurementClass, + gnssMeasurementClass, "setPseudorangeUncertaintyInMeters", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, setterMethod, measurement->pseudorange_uncertainty_m); } if (flags & GPS_MEASUREMENT_HAS_CODE_PHASE) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setCodePhaseInChips", doubleSignature); - env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->code_phase_chips); + env->GetMethodID(gnssMeasurementClass, "setCodePhaseInChips", doubleSignature); + env->CallVoidMethod(gnssMeasurementObject, setterMethod, measurement->code_phase_chips); } if (flags & GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY) { jmethodID setterMethod = env->GetMethodID( - gpsMeasurementClass, + gnssMeasurementClass, "setCodePhaseUncertaintyInChips", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, setterMethod, measurement->code_phase_uncertainty_chips); } if (flags & GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setCarrierFrequencyInHz", floatSignature); + env->GetMethodID(gnssMeasurementClass, "setCarrierFrequencyInHz", floatSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, setterMethod, measurement->carrier_frequency_hz); } if (flags & GPS_MEASUREMENT_HAS_CARRIER_CYCLES) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setCarrierCycles", longSignature); - env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->carrier_cycles); + env->GetMethodID(gnssMeasurementClass, "setCarrierCycles", longSignature); + env->CallVoidMethod(gnssMeasurementObject, setterMethod, measurement->carrier_cycles); } if (flags & GPS_MEASUREMENT_HAS_CARRIER_PHASE) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setCarrierPhase", doubleSignature); - env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->carrier_phase); + env->GetMethodID(gnssMeasurementClass, "setCarrierPhase", doubleSignature); + env->CallVoidMethod(gnssMeasurementObject, setterMethod, measurement->carrier_phase); } if (flags & GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY) { jmethodID setterMethod = env->GetMethodID( - gpsMeasurementClass, + gnssMeasurementClass, "setCarrierPhaseUncertainty", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, setterMethod, measurement->carrier_phase_uncertainty); } jmethodID lossOfLockSetterMethod = - env->GetMethodID(gpsMeasurementClass, "setLossOfLock", byteSignature); - env->CallVoidMethod(gpsMeasurementObject, lossOfLockSetterMethod, measurement->loss_of_lock); + env->GetMethodID(gnssMeasurementClass, "setLossOfLock", byteSignature); + env->CallVoidMethod(gnssMeasurementObject, lossOfLockSetterMethod, measurement->loss_of_lock); if (flags & GPS_MEASUREMENT_HAS_BIT_NUMBER) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setBitNumber", intSignature); - env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->bit_number); + env->GetMethodID(gnssMeasurementClass, "setBitNumber", intSignature); + env->CallVoidMethod(gnssMeasurementObject, setterMethod, measurement->bit_number); } if (flags & GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setTimeFromLastBitInMs", shortSignature); + env->GetMethodID(gnssMeasurementClass, "setTimeFromLastBitInMs", shortSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, setterMethod, measurement->time_from_last_bit_ms); } if (flags & GPS_MEASUREMENT_HAS_DOPPLER_SHIFT) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setDopplerShiftInHz", doubleSignature); - env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->doppler_shift_hz); + env->GetMethodID(gnssMeasurementClass, "setDopplerShiftInHz", doubleSignature); + env->CallVoidMethod(gnssMeasurementObject, setterMethod, measurement->doppler_shift_hz); } if (flags & GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY) { jmethodID setterMethod = env->GetMethodID( - gpsMeasurementClass, + gnssMeasurementClass, "setDopplerShiftUncertaintyInHz", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, setterMethod, measurement->doppler_shift_uncertainty_hz); } jmethodID multipathIndicatorSetterMethod = - env->GetMethodID(gpsMeasurementClass, "setMultipathIndicator", byteSignature); + env->GetMethodID(gnssMeasurementClass, "setMultipathIndicator", byteSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, multipathIndicatorSetterMethod, measurement->multipath_indicator); if (flags & GPS_MEASUREMENT_HAS_SNR) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setSnrInDb", doubleSignature); - env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->snr_db); + env->GetMethodID(gnssMeasurementClass, "setSnrInDb", doubleSignature); + env->CallVoidMethod(gnssMeasurementObject, setterMethod, measurement->snr_db); } if (flags & GPS_MEASUREMENT_HAS_ELEVATION) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setElevationInDeg", doubleSignature); - env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->elevation_deg); + env->GetMethodID(gnssMeasurementClass, "setElevationInDeg", doubleSignature); + env->CallVoidMethod(gnssMeasurementObject, setterMethod, measurement->elevation_deg); } if (flags & GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setElevationUncertaintyInDeg", doubleSignature); + env->GetMethodID(gnssMeasurementClass, "setElevationUncertaintyInDeg", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, setterMethod, measurement->elevation_uncertainty_deg); } if (flags & GPS_MEASUREMENT_HAS_AZIMUTH) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, "setAzimuthInDeg", doubleSignature); - env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->azimuth_deg); + env->GetMethodID(gnssMeasurementClass, "setAzimuthInDeg", doubleSignature); + env->CallVoidMethod(gnssMeasurementObject, setterMethod, measurement->azimuth_deg); } if (flags & GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY) { jmethodID setterMethod = env->GetMethodID( - gpsMeasurementClass, + gnssMeasurementClass, "setAzimuthUncertaintyInDeg", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, setterMethod, measurement->azimuth_uncertainty_deg); } - jmethodID usedInFixSetterMethod = env->GetMethodID(gpsMeasurementClass, "setUsedInFix", "(Z)V"); + jmethodID usedInFixSetterMethod = env->GetMethodID(gnssMeasurementClass, "setUsedInFix", "(Z)V"); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, usedInFixSetterMethod, (flags & GPS_MEASUREMENT_HAS_USED_IN_FIX) && measurement->used_in_fix); if (size == sizeof(GpsMeasurement)) { jmethodID setterMethod = - env->GetMethodID(gpsMeasurementClass, + env->GetMethodID(gnssMeasurementClass, "setPseudorangeRateCarrierInMetersPerSec", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, setterMethod, measurement->pseudorange_rate_carrier_mps); setterMethod = - env->GetMethodID(gpsMeasurementClass, + env->GetMethodID(gnssMeasurementClass, "setPseudorangeRateCarrierUncertaintyInMetersPerSec", doubleSignature); env->CallVoidMethod( - gpsMeasurementObject, + gnssMeasurementObject, setterMethod, measurement->pseudorange_rate_carrier_uncertainty_mps); } - env->DeleteLocalRef(gpsMeasurementClass); - return gpsMeasurementObject; + env->DeleteLocalRef(gnssMeasurementClass); + return gnssMeasurementObject; } /** @@ -1321,23 +1321,23 @@ static jobjectArray translate_gps_measurements(JNIEnv* env, void* data) { return NULL; } - jclass gpsMeasurementClass = env->FindClass("android/location/GpsMeasurement"); - jobjectArray gpsMeasurementArray = env->NewObjectArray( + jclass gnssMeasurementClass = env->FindClass("android/location/GnssMeasurement"); + jobjectArray gnssMeasurementArray = env->NewObjectArray( measurementCount, - gpsMeasurementClass, + gnssMeasurementClass, NULL /* initialElement */); for (uint16_t i = 0; i < measurementCount; ++i) { - jobject gpsMeasurement = translate_gps_measurement( + jobject gnssMeasurement = translate_gps_measurement( env, &(gps_data->measurements[i]), sizeof(gps_data->measurements[0])); - env->SetObjectArrayElement(gpsMeasurementArray, i, gpsMeasurement); - env->DeleteLocalRef(gpsMeasurement); + env->SetObjectArrayElement(gnssMeasurementArray, i, gnssMeasurement); + env->DeleteLocalRef(gnssMeasurement); } - env->DeleteLocalRef(gpsMeasurementClass); - return gpsMeasurementArray; + env->DeleteLocalRef(gnssMeasurementClass); + return gnssMeasurementArray; } static void measurement_callback(GpsData* data) { @@ -1360,25 +1360,25 @@ static void measurement_callback(GpsData* data) { gpsClock = translate_gps_clock(env, &data->clock, sizeof(GpsClock_v1)); measurementArray = translate_gps_measurements<GpsData_v1>(env, data); } - jclass gpsMeasurementsEventClass = env->FindClass("android/location/GpsMeasurementsEvent"); - jmethodID gpsMeasurementsEventCtor = env->GetMethodID( - gpsMeasurementsEventClass, + jclass gnssMeasurementsEventClass = env->FindClass("android/location/GnssMeasurementsEvent"); + jmethodID gnssMeasurementsEventCtor = env->GetMethodID( + gnssMeasurementsEventClass, "<init>", - "(Landroid/location/GpsClock;[Landroid/location/GpsMeasurement;)V"); + "(Landroid/location/GnssClock;[Landroid/location/GnssMeasurement;)V"); - jobject gpsMeasurementsEvent = env->NewObject( - gpsMeasurementsEventClass, - gpsMeasurementsEventCtor, + jobject gnssMeasurementsEvent = env->NewObject( + gnssMeasurementsEventClass, + gnssMeasurementsEventCtor, gpsClock, measurementArray); - env->CallVoidMethod(mCallbacksObj, method_reportMeasurementData, gpsMeasurementsEvent); + env->CallVoidMethod(mCallbacksObj, method_reportMeasurementData, gnssMeasurementsEvent); checkAndClearExceptionFromCallback(env, __FUNCTION__); env->DeleteLocalRef(gpsClock); env->DeleteLocalRef(measurementArray); - env->DeleteLocalRef(gpsMeasurementsEventClass); - env->DeleteLocalRef(gpsMeasurementsEvent); + env->DeleteLocalRef(gnssMeasurementsEventClass); + env->DeleteLocalRef(gnssMeasurementsEvent); } GpsMeasurementCallbacks sGpsMeasurementCallbacks = { @@ -1432,7 +1432,7 @@ static jobject translate_gps_navigation_message(JNIEnv* env, GpsNavigationMessag return NULL; } - jclass navigationMessageClass = env->FindClass("android/location/GpsNavigationMessage"); + jclass navigationMessageClass = env->FindClass("android/location/GnssNavigationMessage"); jmethodID navigationMessageCtor = env->GetMethodID(navigationMessageClass, "<init>", "()V"); jobject navigationMessageObject = env->NewObject(navigationMessageClass, navigationMessageCtor); @@ -1470,11 +1470,11 @@ static void navigation_message_callback(GpsNavigationMessage* message) { jobject navigationMessage = translate_gps_navigation_message(env, message); jclass navigationMessageEventClass = - env->FindClass("android/location/GpsNavigationMessageEvent"); + env->FindClass("android/location/GnssNavigationMessageEvent"); jmethodID navigationMessageEventCtor = env->GetMethodID( navigationMessageEventClass, "<init>", - "(Landroid/location/GpsNavigationMessage;)V"); + "(Landroid/location/GnssNavigationMessage;)V"); jobject navigationMessageEvent = env->NewObject( navigationMessageEventClass, navigationMessageEventCtor, |