diff --git a/api/current.txt b/api/current.txt index 6bddcfb47718b..fa94cc8bad3aa 100644 --- a/api/current.txt +++ b/api/current.txt @@ -18887,6 +18887,251 @@ package android.location { method public void onStopped(); } + public final class GpsClock 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 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.GpsClock); + 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 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 CREATOR; + } + + public static abstract class GpsClock.GpsClockType implements java.lang.annotation.Annotation { + } + + public final class GpsMeasurement 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 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.GpsMeasurement); + 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 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 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 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 { + ctor public GpsMeasurementsEvent(android.location.GpsClock, android.location.GpsMeasurement[]); + method public int describeContents(); + method public android.location.GpsClock getClock(); + method public java.util.Collection getMeasurements(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator 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); + method public void onStatusChanged(int); + } + + public static abstract class GpsMeasurementsEvent.GpsMeasurementsStatus implements java.lang.annotation.Annotation { + } + + public final class GpsNavigationMessage 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.GpsNavigationMessage); + 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 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 GpsNavigationMessage.GpsNavigationMessageType implements java.lang.annotation.Annotation { + } + + public final 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 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); + method public void onStatusChanged(int); + } + + public static abstract class GpsNavigationMessageEvent.GpsNavigationMessageStatus implements java.lang.annotation.Annotation { + } + public final class GpsSatellite { method public float getAzimuth(); method public float getElevation(); @@ -18990,6 +19235,10 @@ package android.location { method public boolean isProviderEnabled(java.lang.String); 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); @@ -19011,6 +19260,8 @@ package android.location { 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 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 8657544b8b028..acdae7abf4cf8 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -19874,7 +19874,7 @@ package android.location { method public void onStopped(); } - public class GpsClock implements android.os.Parcelable { + public final class GpsClock implements android.os.Parcelable { method public int describeContents(); method public double getBiasInNs(); method public double getBiasUncertaintyInNs(); @@ -19911,13 +19911,16 @@ package android.location { 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 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 class GpsMeasurement implements android.os.Parcelable { + public static abstract class GpsClock.GpsClockType implements java.lang.annotation.Annotation { + } + + public final class GpsMeasurement implements android.os.Parcelable { method public int describeContents(); method public double getAccumulatedDeltaRangeInMeters(); method public short getAccumulatedDeltaRangeState(); @@ -20038,7 +20041,13 @@ package android.location { field public static final short STATE_UNKNOWN = 0; // 0x0 } - public class GpsMeasurementsEvent implements android.os.Parcelable { + 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 { ctor public GpsMeasurementsEvent(android.location.GpsClock, android.location.GpsMeasurement[]); method public int describeContents(); method public android.location.GpsClock getClock(); @@ -20050,12 +20059,16 @@ package android.location { field public static final int STATUS_READY = 1; // 0x1 } - public static abstract interface GpsMeasurementsEvent.Listener { - method public abstract void onGpsMeasurementsReceived(android.location.GpsMeasurementsEvent); - method public abstract void onStatusChanged(int); + public static abstract class GpsMeasurementsEvent.Callback { + ctor public GpsMeasurementsEvent.Callback(); + method public void onGpsMeasurementsReceived(android.location.GpsMeasurementsEvent); + method public void onStatusChanged(int); } - public class GpsNavigationMessage implements android.os.Parcelable { + public static abstract class GpsMeasurementsEvent.GpsMeasurementsStatus implements java.lang.annotation.Annotation { + } + + public final class GpsNavigationMessage implements android.os.Parcelable { method public int describeContents(); method public byte[] getData(); method public short getMessageId(); @@ -20073,30 +20086,37 @@ package android.location { method public void setType(byte); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator 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 class GpsNavigationMessageEvent implements android.os.Parcelable { + public static abstract class GpsNavigationMessage.GpsNavigationMessageType implements java.lang.annotation.Annotation { + } + + public final 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 CREATOR; - field public static int STATUS_GPS_LOCATION_DISABLED; - field public static int STATUS_NOT_SUPPORTED; - field public static int STATUS_READY; + 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 interface GpsNavigationMessageEvent.Listener { - method public abstract void onGpsNavigationMessageReceived(android.location.GpsNavigationMessageEvent); - method public abstract void onStatusChanged(int); + 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 final class GpsSatellite { @@ -20203,8 +20223,6 @@ package android.location { } public class LocationManager { - method public boolean addGpsMeasurementListener(android.location.GpsMeasurementsEvent.Listener); - method public 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); @@ -20224,8 +20242,10 @@ package android.location { method public boolean isProviderEnabled(java.lang.String); method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback); method public boolean registerGnssStatusCallback(android.location.GnssStatusCallback, android.os.Handler); - method public void removeGpsMeasurementListener(android.location.GpsMeasurementsEvent.Listener); - method public void removeGpsNavigationMessageListener(android.location.GpsNavigationMessageEvent.Listener); + 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); @@ -20249,6 +20269,8 @@ package android.location { 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 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 cd1abaf74e94c..e1d6e840a02da 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -18887,6 +18887,251 @@ package android.location { method public void onStopped(); } + public final class GpsClock 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 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.GpsClock); + 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 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 CREATOR; + } + + public static abstract class GpsClock.GpsClockType implements java.lang.annotation.Annotation { + } + + public final class GpsMeasurement 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 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.GpsMeasurement); + 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 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 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 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 { + ctor public GpsMeasurementsEvent(android.location.GpsClock, android.location.GpsMeasurement[]); + method public int describeContents(); + method public android.location.GpsClock getClock(); + method public java.util.Collection getMeasurements(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator 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); + method public void onStatusChanged(int); + } + + public static abstract class GpsMeasurementsEvent.GpsMeasurementsStatus implements java.lang.annotation.Annotation { + } + + public final class GpsNavigationMessage 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.GpsNavigationMessage); + 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 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 GpsNavigationMessage.GpsNavigationMessageType implements java.lang.annotation.Annotation { + } + + public final 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 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); + method public void onStatusChanged(int); + } + + public static abstract class GpsNavigationMessageEvent.GpsNavigationMessageStatus implements java.lang.annotation.Annotation { + } + public final class GpsSatellite { method public float getAzimuth(); method public float getElevation(); @@ -18990,6 +19235,10 @@ package android.location { method public boolean isProviderEnabled(java.lang.String); 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); @@ -19011,6 +19260,8 @@ package android.location { 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 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/GpsClock.java b/location/java/android/location/GpsClock.java index 4135a1c949bb1..f8640e6d73cd0 100644 --- a/location/java/android/location/GpsClock.java +++ b/location/java/android/location/GpsClock.java @@ -16,36 +16,41 @@ package android.location; -import android.annotation.SystemApi; +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. - * - * @hide */ -@SystemApi -public class GpsClock implements Parcelable { +public final 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 TYPE_UNKNOWN = 0; + 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 TYPE_LOCAL_HW_TIME = 1; + 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 TYPE_GPS_TIME = 2; + 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); @@ -99,6 +104,7 @@ public class GpsClock implements Parcelable { /** * Gets the type of time reported by {@link #getTimeInNs()}. */ + @GpsClockType public byte getType() { return mType; } @@ -106,7 +112,7 @@ public class GpsClock implements Parcelable { /** * Sets the type of time reported. */ - public void setType(byte value) { + public void setType(@GpsClockType byte value) { mType = value; } @@ -116,11 +122,11 @@ public class GpsClock implements Parcelable { */ private String getTypeString() { switch (mType) { - case TYPE_UNKNOWN: + case CLOCK_TYPE_UNKNOWN: return "Unknown"; - case TYPE_GPS_TIME: + case CLOCK_TYPE_GPS_TIME: return "GpsTime"; - case TYPE_LOCAL_HW_TIME: + case CLOCK_TYPE_LOCAL_HW_TIME: return "LocalHwClock"; default: return ""; @@ -163,8 +169,8 @@ public class GpsClock implements Parcelable { /** * Gets the GPS receiver internal clock value in nanoseconds. - * This can be either the 'local hardware clock' value ({@link #TYPE_LOCAL_HW_TIME}), or the - * current GPS time derived inside GPS receiver ({@link #TYPE_GPS_TIME}). + * 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 @@ -223,7 +229,7 @@ public 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); @@ -233,7 +239,7 @@ public 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 #TYPE_LOCAL_HW_TIME} is set, and GPS receiver has solved + * 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. * @@ -479,7 +485,7 @@ public class GpsClock implements Parcelable { private void initialize() { mFlags = HAS_NO_FLAGS; resetLeapSecond(); - setType(TYPE_UNKNOWN); + setType(CLOCK_TYPE_UNKNOWN); setTimeInNs(Long.MIN_VALUE); resetTimeUncertaintyInNs(); resetFullBiasInNs(); diff --git a/location/java/android/location/GpsMeasurement.java b/location/java/android/location/GpsMeasurement.java index f13a440f411ae..0d91c797be270 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.SystemApi; +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. - * - * @hide */ -@SystemApi -public class GpsMeasurement implements Parcelable { +public final class GpsMeasurement implements Parcelable { private int mFlags; private byte mPrn; private double mTimeOffsetInNs; @@ -83,6 +83,11 @@ public 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. */ @@ -98,6 +103,12 @@ public 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. */ @@ -776,6 +787,7 @@ public class GpsMeasurement implements Parcelable { /** * Gets a value indicating the 'loss of lock' state of the event. */ + @LossOfLockStatus public byte getLossOfLock() { return mLossOfLock; } @@ -783,7 +795,7 @@ public class GpsMeasurement implements Parcelable { /** * Sets the 'loss of lock' status. */ - public void setLossOfLock(byte value) { + public void setLossOfLock(@LossOfLockStatus byte value) { mLossOfLock = value; } @@ -941,6 +953,7 @@ public class GpsMeasurement implements Parcelable { /** * Gets a value indicating the 'multipath' state of the event. */ + @MultipathIndicator public byte getMultipathIndicator() { return mMultipathIndicator; } @@ -948,7 +961,7 @@ public class GpsMeasurement implements Parcelable { /** * Sets the 'multi-path' indicator. */ - public void setMultipathIndicator(byte value) { + public void setMultipathIndicator(@MultipathIndicator byte value) { mMultipathIndicator = value; } diff --git a/location/java/android/location/GpsMeasurementListenerTransport.java b/location/java/android/location/GpsMeasurementCallbackTransport.java similarity index 68% rename from location/java/android/location/GpsMeasurementListenerTransport.java rename to location/java/android/location/GpsMeasurementCallbackTransport.java index 610da96e0fda8..02d9026de6ce3 100644 --- a/location/java/android/location/GpsMeasurementListenerTransport.java +++ b/location/java/android/location/GpsMeasurementCallbackTransport.java @@ -20,17 +20,17 @@ import android.content.Context; import android.os.RemoteException; /** - * A handler class to manage transport listeners for {@link GpsMeasurementsEvent.Listener}. + * A handler class to manage transport callbacks for {@link GpsMeasurementsEvent.Callback}. * * @hide */ -class GpsMeasurementListenerTransport - extends LocalListenerHelper { +class GpsMeasurementCallbackTransport + extends LocalListenerHelper { private final ILocationManager mLocationManager; private final IGpsMeasurementsListener mListenerTransport = new ListenerTransport(); - public GpsMeasurementListenerTransport(Context context, ILocationManager locationManager) { + public GpsMeasurementCallbackTransport(Context context, ILocationManager locationManager) { super(context, "GpsMeasurementListenerTransport"); mLocationManager = locationManager; } @@ -50,11 +50,11 @@ class GpsMeasurementListenerTransport private class ListenerTransport extends IGpsMeasurementsListener.Stub { @Override public void onGpsMeasurementsReceived(final GpsMeasurementsEvent event) { - ListenerOperation operation = - new ListenerOperation() { + ListenerOperation operation = + new ListenerOperation() { @Override - public void execute(GpsMeasurementsEvent.Listener listener) throws RemoteException { - listener.onGpsMeasurementsReceived(event); + public void execute(GpsMeasurementsEvent.Callback callback) throws RemoteException { + callback.onGpsMeasurementsReceived(event); } }; foreach(operation); @@ -62,11 +62,11 @@ class GpsMeasurementListenerTransport @Override public void onStatusChanged(final int status) { - ListenerOperation operation = - new ListenerOperation() { + ListenerOperation operation = + new ListenerOperation() { @Override - public void execute(GpsMeasurementsEvent.Listener listener) throws RemoteException { - listener.onStatusChanged(status); + public void execute(GpsMeasurementsEvent.Callback callback) throws RemoteException { + callback.onStatusChanged(status); } }; foreach(operation); diff --git a/location/java/android/location/GpsMeasurementsEvent.java b/location/java/android/location/GpsMeasurementsEvent.java index 1366873378617..ef9edeb7692dd 100644 --- a/location/java/android/location/GpsMeasurementsEvent.java +++ b/location/java/android/location/GpsMeasurementsEvent.java @@ -16,11 +16,13 @@ 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; @@ -28,12 +30,13 @@ import java.util.Collections; /** * A class implementing a container for data associated with a measurement event. - * Events are delivered to registered instances of {@link Listener}. - * - * @hide + * Events are delivered to registered instances of {@link Callback}. */ -@SystemApi -public class GpsMeasurementsEvent implements Parcelable { +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 {} /** * The system does not support tracking of GPS Measurements. This status will not change in the @@ -58,22 +61,20 @@ public 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#addGpsMeasurementListener}. - * - * @hide + * You can implement this interface and call + * {@link LocationManager#registerGpsMeasurementCallback}. */ - @SystemApi - public interface Listener { + public static abstract class Callback { /** * Returns the latest collected GPS Measurements. */ - void onGpsMeasurementsReceived(GpsMeasurementsEvent eventArgs); + public void onGpsMeasurementsReceived(GpsMeasurementsEvent eventArgs) {} /** * Returns the latest status of the GPS Measurements sub-system. */ - void onStatusChanged(int status); + public void onStatusChanged(@GpsMeasurementsStatus 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 5c3c71012cdd5..d799572436766 100644 --- a/location/java/android/location/GpsNavigationMessage.java +++ b/location/java/android/location/GpsNavigationMessage.java @@ -16,49 +16,54 @@ 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 */ -@SystemApi -public class GpsNavigationMessage implements Parcelable { +public final 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 TYPE_UNKNOWN = 0; + public static final byte MESSAGE_TYPE_UNKNOWN = 0; /** * The Navigation Message is of type L1 C/A. */ - public static final byte TYPE_L1CA = 1; + public static final byte MESSAGE_TYPE_L1CA = 1; /** * The Navigation Message is of type L1-CNAV. */ - public static final byte TYPE_L2CNAV = 2; + public static final byte MESSAGE_TYPE_L2CNAV = 2; /** * The Navigation Message is of type L5-CNAV. */ - public static final byte TYPE_L5CNAV = 3; + public static final byte MESSAGE_TYPE_L5CNAV = 3; /** * The Navigation Message is of type CNAV-2. */ - public static final byte TYPE_CNAV2 = 4; + public static final byte MESSAGE_TYPE_CNAV2 = 4; /** * The Navigation Message Status is 'unknown'. @@ -111,6 +116,7 @@ public class GpsNavigationMessage implements Parcelable { /** * Gets the type of the navigation message contained in the object. */ + @GpsNavigationMessageType public byte getType() { return mType; } @@ -118,7 +124,7 @@ public class GpsNavigationMessage implements Parcelable { /** * Sets the type of the navigation message. */ - public void setType(byte value) { + public void setType(@GpsNavigationMessageType byte value) { mType = value; } @@ -128,15 +134,15 @@ public class GpsNavigationMessage implements Parcelable { */ private String getTypeString() { switch (mType) { - case TYPE_UNKNOWN: + case MESSAGE_TYPE_UNKNOWN: return "Unknown"; - case TYPE_L1CA: + case MESSAGE_TYPE_L1CA: return "L1 C/A"; - case TYPE_L2CNAV: + case MESSAGE_TYPE_L2CNAV: return "L2-CNAV"; - case TYPE_L5CNAV: + case MESSAGE_TYPE_L5CNAV: return "L5-CNAV"; - case TYPE_CNAV2: + case MESSAGE_TYPE_CNAV2: return "CNAV-2"; default: return ""; @@ -314,7 +320,7 @@ public class GpsNavigationMessage implements Parcelable { } private void initialize() { - mType = TYPE_UNKNOWN; + mType = MESSAGE_TYPE_UNKNOWN; mPrn = 0; mMessageId = -1; mSubmessageId = -1; diff --git a/location/java/android/location/GpsNavigationMessageListenerTransport.java b/location/java/android/location/GpsNavigationMessageCallbackTransport.java similarity index 73% rename from location/java/android/location/GpsNavigationMessageListenerTransport.java rename to location/java/android/location/GpsNavigationMessageCallbackTransport.java index f6ba407d9c707..155d96dce35e0 100644 --- a/location/java/android/location/GpsNavigationMessageListenerTransport.java +++ b/location/java/android/location/GpsNavigationMessageCallbackTransport.java @@ -20,20 +20,20 @@ import android.content.Context; import android.os.RemoteException; /** - * A handler class to manage transport listeners for {@link GpsNavigationMessageEvent.Listener}. + * A handler class to manage transport callback for {@link GpsNavigationMessageEvent.Callback}. * * @hide */ -class GpsNavigationMessageListenerTransport - extends LocalListenerHelper { +class GpsNavigationMessageCallbackTransport + extends LocalListenerHelper { private final ILocationManager mLocationManager; private final IGpsNavigationMessageListener mListenerTransport = new ListenerTransport(); - public GpsNavigationMessageListenerTransport( + public GpsNavigationMessageCallbackTransport( Context context, ILocationManager locationManager) { - super(context, "GpsNavigationMessageListenerTransport"); + super(context, "GpsNavigationMessageCallbackTransport"); mLocationManager = locationManager; } @@ -52,12 +52,12 @@ class GpsNavigationMessageListenerTransport private class ListenerTransport extends IGpsNavigationMessageListener.Stub { @Override public void onGpsNavigationMessageReceived(final GpsNavigationMessageEvent event) { - ListenerOperation operation = - new ListenerOperation() { + ListenerOperation operation = + new ListenerOperation() { @Override - public void execute(GpsNavigationMessageEvent.Listener listener) + public void execute(GpsNavigationMessageEvent.Callback callback) throws RemoteException { - listener.onGpsNavigationMessageReceived(event); + callback.onGpsNavigationMessageReceived(event); } }; foreach(operation); @@ -65,12 +65,12 @@ class GpsNavigationMessageListenerTransport @Override public void onStatusChanged(final int status) { - ListenerOperation operation = - new ListenerOperation() { + ListenerOperation operation = + new ListenerOperation() { @Override - public void execute(GpsNavigationMessageEvent.Listener listener) + public void execute(GpsNavigationMessageEvent.Callback callback) throws RemoteException { - listener.onStatusChanged(status); + callback.onStatusChanged(status); } }; foreach(operation); diff --git a/location/java/android/location/GpsNavigationMessageEvent.java b/location/java/android/location/GpsNavigationMessageEvent.java index bd6921c741529..b16a4855f3899 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 Listener}. - * - * @hide + * Events are delivered to registered instances of {@link Callback}. */ -@SystemApi -public class GpsNavigationMessageEvent implements Parcelable { +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 {} /** * The system does not support tracking of GPS Navigation Messages. This status will not change * in the future. */ - public static int STATUS_NOT_SUPPORTED = 0; + 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 int STATUS_READY = 1; + public static final int STATUS_READY = 1; /** * GPS provider or Location is disabled, updated will not be received until they are enabled. */ - public static int STATUS_GPS_LOCATION_DISABLED = 2; + public static final 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#addGpsNavigationMessageListener}. - * - * @hide + * {@link LocationManager#registerGpsNavigationMessageCallback}. */ - @SystemApi - public interface Listener { + public static abstract class Callback { /** * Returns the latest collected GPS Navigation Message. */ - void onGpsNavigationMessageReceived(GpsNavigationMessageEvent event); + public void onGpsNavigationMessageReceived(GpsNavigationMessageEvent event) {} /** * Returns the latest status of the GPS Navigation Messages sub-system. */ - void onStatusChanged(int status); + public void onStatusChanged(@GpsNavigationMessageStatus int status) {} } public GpsNavigationMessageEvent(GpsNavigationMessage message) { diff --git a/location/java/android/location/LocalListenerHelper.java b/location/java/android/location/LocalListenerHelper.java index 458c451c61238..d7d2c5131606b 100644 --- a/location/java/android/location/LocalListenerHelper.java +++ b/location/java/android/location/LocalListenerHelper.java @@ -20,12 +20,14 @@ import com.android.internal.util.Preconditions; import android.annotation.NonNull; import android.content.Context; +import android.os.Handler; import android.os.RemoteException; import android.util.Log; import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; /** * A base handler class to manage transport and local listeners. @@ -33,7 +35,7 @@ import java.util.HashSet; * @hide */ abstract class LocalListenerHelper { - private final HashSet mListeners = new HashSet<>(); + private final HashMap mListeners = new HashMap<>(); private final String mTag; private final Context mContext; @@ -44,7 +46,7 @@ abstract class LocalListenerHelper { mTag = name; } - public boolean add(@NonNull TListener listener) { + public boolean add(@NonNull TListener listener, Handler handler) { Preconditions.checkNotNull(listener); synchronized (mListeners) { // we need to register with the service first, because we need to find out if the @@ -62,17 +64,19 @@ abstract class LocalListenerHelper { return false; } } - if (mListeners.contains(listener)) { + if (mListeners.containsKey(listener)) { return true; } - return mListeners.add(listener); + mListeners.put(listener, handler); + return true; } } public void remove(@NonNull TListener listener) { Preconditions.checkNotNull(listener); synchronized (mListeners) { - boolean removed = mListeners.remove(listener); + boolean removed = mListeners.containsKey(listener); + mListeners.remove(listener); boolean isLastRemoved = removed && mListeners.isEmpty(); if (isLastRemoved) { try { @@ -95,17 +99,30 @@ abstract class LocalListenerHelper { return mContext; } - protected void foreach(ListenerOperation operation) { - Collection listeners; - synchronized (mListeners) { - listeners = new ArrayList<>(mListeners); + private void executeOperation(ListenerOperation operation, TListener listener) { + try { + operation.execute(listener); + } catch (RemoteException e) { + Log.e(mTag, "Error in monitored listener.", e); + // don't return, give a fair chance to all listeners to receive the event } - for (TListener listener : listeners) { - try { - operation.execute(listener); - } catch (RemoteException e) { - Log.e(mTag, "Error in monitored listener.", e); - // don't return, give a fair chance to all listeners to receive the event + } + + protected void foreach(final ListenerOperation operation) { + Collection> listeners; + synchronized (mListeners) { + listeners = new ArrayList<>(mListeners.entrySet()); + } + for (final Map.Entry listener : listeners) { + if (listener.getValue() == null) { + executeOperation(operation, listener.getKey()); + } else { + listener.getValue().post(new Runnable() { + @Override + public void run() { + executeOperation(operation, listener.getKey()); + } + }); } } } diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index d35d5297d03db..02639b621606e 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -63,8 +63,8 @@ public class LocationManager { private final Context mContext; private final ILocationManager mService; - private final GpsMeasurementListenerTransport mGpsMeasurementListenerTransport; - private final GpsNavigationMessageListenerTransport mGpsNavigationMessageListenerTransport; + private final GpsMeasurementCallbackTransport mGpsMeasurementCallbackTransport; + private final GpsNavigationMessageCallbackTransport mGpsNavigationMessageCallbackTransport; private final HashMap mGpsStatusListeners = new HashMap<>(); private final HashMap mGpsNmeaListeners = @@ -320,9 +320,9 @@ public class LocationManager { public LocationManager(Context context, ILocationManager service) { mService = service; mContext = context; - mGpsMeasurementListenerTransport = new GpsMeasurementListenerTransport(mContext, mService); - mGpsNavigationMessageListenerTransport = - new GpsNavigationMessageListenerTransport(mContext, mService); + mGpsMeasurementCallbackTransport = new GpsMeasurementCallbackTransport(mContext, mService); + mGpsNavigationMessageCallbackTransport = + new GpsNavigationMessageCallbackTransport(mContext, mService); } private LocationProvider createProvider(String name, ProviderProperties properties) { @@ -1816,54 +1816,70 @@ public class LocationManager { } /** - * Adds a GPS Measurement listener. + * Registers a GPS Measurement callback. * - * @param listener a {@link GpsMeasurementsEvent.Listener} object to register. - * @return {@code true} if the listener was added successfully, {@code false} otherwise. - * - * @hide + * @param callback a {@link GpsMeasurementsEvent.Callback} object to register. + * @return {@code true} if the callback was added successfully, {@code false} otherwise. */ - @SystemApi - public boolean addGpsMeasurementListener(GpsMeasurementsEvent.Listener listener) { - return mGpsMeasurementListenerTransport.add(listener); + @RequiresPermission(ACCESS_FINE_LOCATION) + public boolean registerGpsMeasurementCallback(GpsMeasurementsEvent.Callback callback) { + return registerGpsMeasurementCallback(callback, null); } /** - * Removes a GPS Measurement listener. + * Registers a GPS Measurement callback. * - * @param listener a {@link GpsMeasurementsEvent.Listener} object to remove. - * - * @hide + * @param callback a {@link GpsMeasurementsEvent.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. */ - @SystemApi - public void removeGpsMeasurementListener(GpsMeasurementsEvent.Listener listener) { - mGpsMeasurementListenerTransport.remove(listener); + @RequiresPermission(ACCESS_FINE_LOCATION) + public boolean registerGpsMeasurementCallback(GpsMeasurementsEvent.Callback callback, + Handler handler) { + return mGpsMeasurementCallbackTransport.add(callback, handler); } /** - * Adds a GPS Navigation Message listener. + * Unregisters a GPS Measurement callback. * - * @param listener a {@link GpsNavigationMessageEvent.Listener} object to register. - * @return {@code true} if the listener was added successfully, {@code false} otherwise. - * - * @hide + * @param callback a {@link GpsMeasurementsEvent.Callback} object to remove. */ - @SystemApi - public boolean addGpsNavigationMessageListener(GpsNavigationMessageEvent.Listener listener) { - return mGpsNavigationMessageListenerTransport.add(listener); + public void unregisterGpsMeasurementCallback(GpsMeasurementsEvent.Callback callback) { + mGpsMeasurementCallbackTransport.remove(callback); } /** - * Removes a GPS Navigation Message listener. + * Registers a GPS Navigation Message callback. * - * @param listener a {@link GpsNavigationMessageEvent.Listener} object to remove. - * - * @hide + * @param callback a {@link GpsNavigationMessageEvent.Callback} object to register. + * @return {@code true} if the callback was added successfully, {@code false} otherwise. */ - @SystemApi - public void removeGpsNavigationMessageListener( - GpsNavigationMessageEvent.Listener listener) { - mGpsNavigationMessageListenerTransport.remove(listener); + public boolean registerGpsNavigationMessageCallback( + GpsNavigationMessageEvent.Callback callback) { + return registerGpsNavigationMessageCallback(callback, null); + } + + /** + * Registers a GPS Navigation Message callback. + * + * @param callback a {@link GpsNavigationMessageEvent.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); + } + + /** + * Unregisters a GPS Navigation Message callback. + * + * @param callback a {@link GpsNavigationMessageEvent.Callback} object to remove. + */ + public void unregisterGpsNavigationMessageCallback( + GpsNavigationMessageEvent.Callback callback) { + mGpsNavigationMessageCallbackTransport.remove(callback); } /** @@ -1878,6 +1894,7 @@ public class LocationManager { * @return status object containing updated GPS status. */ @Deprecated + @RequiresPermission(ACCESS_FINE_LOCATION) public GpsStatus getGpsStatus(GpsStatus status) { if (status == null) { status = new GpsStatus(); diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp index f736cd554a166..21320e04f3f01 100644 --- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp +++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp @@ -21,7 +21,7 @@ #include "JNIHelp.h" #include "jni.h" #include "hardware/hardware.h" -#include "hardware/gps.h" +#include "hardware/gps_internal.h" #include "hardware_legacy/power.h" #include "utils/Log.h" #include "utils/misc.h" @@ -68,6 +68,7 @@ static const GpsNavigationMessageInterface* sGpsNavigationMessageInterface = NUL static const GnssConfigurationInterface* sGnssConfigurationInterface = NULL; #define MAX_SATELLITE_COUNT 512 +#define MAX_GPS_SATELLITE_COUNT 512 #define PRN_SHIFT_WIDTH 3 @@ -116,7 +117,7 @@ static void sv_status_callback(GpsSvStatus* sv_status) if (status_size == 0) { status_size = sizeof(GpsSvStatus_v1); } - if (sv_status->size == sizeof(GpsSvStatus_v2)) { + if (status_size == sizeof(GpsSvStatus)) { sGnssSvListSize = sv_status->gnss_sv_list_size; // Cramp the list size if (sGnssSvListSize > MAX_SATELLITE_COUNT) { @@ -128,6 +129,10 @@ static void sv_status_callback(GpsSvStatus* sv_status) } } else if (status_size == sizeof(GpsSvStatus_v1)) { sGnssSvListSize = sv_status->num_svs; + // Cramp the list size + if (sGnssSvListSize > MAX_GPS_SATELLITE_COUNT) { + sGnssSvListSize = MAX_GPS_SATELLITE_COUNT; + } uint32_t ephemeris_mask = sv_status->ephemeris_mask; uint32_t almanac_mask = sv_status->almanac_mask; uint32_t used_in_fix_mask = sv_status->used_in_fix_mask; @@ -139,14 +144,17 @@ static void sv_status_callback(GpsSvStatus* sv_status) info.elevation = sv_status->sv_list[i].elevation; info.azimuth = sv_status->sv_list[i].azimuth; info.flags = GNSS_SV_FLAGS_NONE; - if ((ephemeris_mask & (1 << (info.prn - 1))) != 0) { + if (info.prn > 0 && info.prn <= 32) { + int32_t this_prn_mask = (1 << (info.prn - 1)); + if ((ephemeris_mask & this_prn_mask) != 0) { info.flags |= GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA; - } - if ((almanac_mask & (1 << (info.prn - 1))) != 0) { + } + if ((almanac_mask & this_prn_mask) != 0) { info.flags |= GNSS_SV_FLAGS_HAS_ALMANAC_DATA; - } - if ((used_in_fix_mask & (1 << (info.prn - 1))) != 0) { + } + if ((used_in_fix_mask & this_prn_mask) != 0) { info.flags |= GNSS_SV_FLAGS_USED_IN_FIX; + } } } } else { @@ -262,7 +270,7 @@ static void agps_status_callback(AGpsStatus* agps_status) bool isSupported = false; size_t status_size = agps_status->size; - if (status_size == sizeof(AGpsStatus_v3)) { + if (status_size == sizeof(AGpsStatus)) { ALOGV("AGpsStatus is V3: %zd", status_size); switch (agps_status->addr.ss_family) { @@ -805,7 +813,7 @@ static void android_location_GnssLocationProvider_agps_data_conn_open( const char *apnStr = env->GetStringUTFChars(apn, NULL); size_t interface_size = sAGpsInterface->size; - if (interface_size == sizeof(AGpsInterface_v2)) { + if (interface_size == sizeof(AGpsInterface)) { sAGpsInterface->data_conn_open_with_apn_ip_type(apnStr, apnIpType); } else if (interface_size == sizeof(AGpsInterface_v1)) { sAGpsInterface->data_conn_open(apnStr);