Merge "Optimized the memory consumption and renamed PRN" into nyc-dev

This commit is contained in:
Lifu Tang
2016-02-11 20:10:10 +00:00
committed by Android (Google) Code Review
12 changed files with 603 additions and 535 deletions

View File

@@ -19221,7 +19221,6 @@ package android.location {
method public double getElevationUncertaintyInDeg(); method public double getElevationUncertaintyInDeg();
method public byte getLossOfLock(); method public byte getLossOfLock();
method public byte getMultipathIndicator(); method public byte getMultipathIndicator();
method public byte getPrn();
method public double getPseudorangeInMeters(); method public double getPseudorangeInMeters();
method public double getPseudorangeRateCarrierInMetersPerSec(); method public double getPseudorangeRateCarrierInMetersPerSec();
method public double getPseudorangeRateCarrierUncertaintyInMetersPerSec(); method public double getPseudorangeRateCarrierUncertaintyInMetersPerSec();
@@ -19232,6 +19231,7 @@ package android.location {
method public long getReceivedGpsTowUncertaintyInNs(); method public long getReceivedGpsTowUncertaintyInNs();
method public double getSnrInDb(); method public double getSnrInDb();
method public short getState(); method public short getState();
method public short getSvid();
method public short getTimeFromLastBitInMs(); method public short getTimeFromLastBitInMs();
method public double getTimeOffsetInNs(); method public double getTimeOffsetInNs();
method public boolean hasAzimuthInDeg(); method public boolean hasAzimuthInDeg();
@@ -19291,7 +19291,6 @@ package android.location {
method public void setElevationUncertaintyInDeg(double); method public void setElevationUncertaintyInDeg(double);
method public void setLossOfLock(byte); method public void setLossOfLock(byte);
method public void setMultipathIndicator(byte); method public void setMultipathIndicator(byte);
method public void setPrn(byte);
method public void setPseudorangeInMeters(double); method public void setPseudorangeInMeters(double);
method public void setPseudorangeRateCarrierInMetersPerSec(double); method public void setPseudorangeRateCarrierInMetersPerSec(double);
method public void setPseudorangeRateCarrierUncertaintyInMetersPerSec(double); method public void setPseudorangeRateCarrierUncertaintyInMetersPerSec(double);
@@ -19302,6 +19301,7 @@ package android.location {
method public void setReceivedGpsTowUncertaintyInNs(long); method public void setReceivedGpsTowUncertaintyInNs(long);
method public void setSnrInDb(double); method public void setSnrInDb(double);
method public void setState(short); method public void setState(short);
method public void setSvid(short);
method public void setTimeFromLastBitInMs(short); method public void setTimeFromLastBitInMs(short);
method public void setTimeOffsetInNs(double); method public void setTimeOffsetInNs(double);
method public void setUsedInFix(boolean); method public void setUsedInFix(boolean);
@@ -19356,17 +19356,17 @@ package android.location {
method public int describeContents(); method public int describeContents();
method public byte[] getData(); method public byte[] getData();
method public short getMessageId(); method public short getMessageId();
method public byte getPrn();
method public short getStatus(); method public short getStatus();
method public short getSubmessageId(); method public short getSubmessageId();
method public short getSvid();
method public byte getType(); method public byte getType();
method public void reset(); method public void reset();
method public void set(android.location.GnssNavigationMessage); method public void set(android.location.GnssNavigationMessage);
method public void setData(byte[]); method public void setData(byte[]);
method public void setMessageId(short); method public void setMessageId(short);
method public void setPrn(byte);
method public void setStatus(short); method public void setStatus(short);
method public void setSubmessageId(short); method public void setSubmessageId(short);
method public void setSvid(short);
method public void setType(byte); method public void setType(byte);
method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessage> CREATOR; field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessage> CREATOR;
@@ -19412,8 +19412,8 @@ package android.location {
method public int getConstellationType(int); method public int getConstellationType(int);
method public float getElevation(int); method public float getElevation(int);
method public int getNumSatellites(); method public int getNumSatellites();
method public int getPrn(int);
method public float getSnr(int); method public float getSnr(int);
method public int getSvid(int);
method public boolean hasAlmanac(int); method public boolean hasAlmanac(int);
method public boolean hasEphemeris(int); method public boolean hasEphemeris(int);
method public boolean usedInFix(int); method public boolean usedInFix(int);

View File

@@ -20401,7 +20401,6 @@ package android.location {
method public double getElevationUncertaintyInDeg(); method public double getElevationUncertaintyInDeg();
method public byte getLossOfLock(); method public byte getLossOfLock();
method public byte getMultipathIndicator(); method public byte getMultipathIndicator();
method public byte getPrn();
method public double getPseudorangeInMeters(); method public double getPseudorangeInMeters();
method public double getPseudorangeRateCarrierInMetersPerSec(); method public double getPseudorangeRateCarrierInMetersPerSec();
method public double getPseudorangeRateCarrierUncertaintyInMetersPerSec(); method public double getPseudorangeRateCarrierUncertaintyInMetersPerSec();
@@ -20412,6 +20411,7 @@ package android.location {
method public long getReceivedGpsTowUncertaintyInNs(); method public long getReceivedGpsTowUncertaintyInNs();
method public double getSnrInDb(); method public double getSnrInDb();
method public short getState(); method public short getState();
method public short getSvid();
method public short getTimeFromLastBitInMs(); method public short getTimeFromLastBitInMs();
method public double getTimeOffsetInNs(); method public double getTimeOffsetInNs();
method public boolean hasAzimuthInDeg(); method public boolean hasAzimuthInDeg();
@@ -20471,7 +20471,6 @@ package android.location {
method public void setElevationUncertaintyInDeg(double); method public void setElevationUncertaintyInDeg(double);
method public void setLossOfLock(byte); method public void setLossOfLock(byte);
method public void setMultipathIndicator(byte); method public void setMultipathIndicator(byte);
method public void setPrn(byte);
method public void setPseudorangeInMeters(double); method public void setPseudorangeInMeters(double);
method public void setPseudorangeRateCarrierInMetersPerSec(double); method public void setPseudorangeRateCarrierInMetersPerSec(double);
method public void setPseudorangeRateCarrierUncertaintyInMetersPerSec(double); method public void setPseudorangeRateCarrierUncertaintyInMetersPerSec(double);
@@ -20482,6 +20481,7 @@ package android.location {
method public void setReceivedGpsTowUncertaintyInNs(long); method public void setReceivedGpsTowUncertaintyInNs(long);
method public void setSnrInDb(double); method public void setSnrInDb(double);
method public void setState(short); method public void setState(short);
method public void setSvid(short);
method public void setTimeFromLastBitInMs(short); method public void setTimeFromLastBitInMs(short);
method public void setTimeOffsetInNs(double); method public void setTimeOffsetInNs(double);
method public void setUsedInFix(boolean); method public void setUsedInFix(boolean);
@@ -20536,17 +20536,17 @@ package android.location {
method public int describeContents(); method public int describeContents();
method public byte[] getData(); method public byte[] getData();
method public short getMessageId(); method public short getMessageId();
method public byte getPrn();
method public short getStatus(); method public short getStatus();
method public short getSubmessageId(); method public short getSubmessageId();
method public short getSvid();
method public byte getType(); method public byte getType();
method public void reset(); method public void reset();
method public void set(android.location.GnssNavigationMessage); method public void set(android.location.GnssNavigationMessage);
method public void setData(byte[]); method public void setData(byte[]);
method public void setMessageId(short); method public void setMessageId(short);
method public void setPrn(byte);
method public void setStatus(short); method public void setStatus(short);
method public void setSubmessageId(short); method public void setSubmessageId(short);
method public void setSvid(short);
method public void setType(byte); method public void setType(byte);
method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessage> CREATOR; field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessage> CREATOR;
@@ -20592,8 +20592,8 @@ package android.location {
method public int getConstellationType(int); method public int getConstellationType(int);
method public float getElevation(int); method public float getElevation(int);
method public int getNumSatellites(); method public int getNumSatellites();
method public int getPrn(int);
method public float getSnr(int); method public float getSnr(int);
method public int getSvid(int);
method public boolean hasAlmanac(int); method public boolean hasAlmanac(int);
method public boolean hasEphemeris(int); method public boolean hasEphemeris(int);
method public boolean usedInFix(int); method public boolean usedInFix(int);

View File

@@ -19229,7 +19229,6 @@ package android.location {
method public double getElevationUncertaintyInDeg(); method public double getElevationUncertaintyInDeg();
method public byte getLossOfLock(); method public byte getLossOfLock();
method public byte getMultipathIndicator(); method public byte getMultipathIndicator();
method public byte getPrn();
method public double getPseudorangeInMeters(); method public double getPseudorangeInMeters();
method public double getPseudorangeRateCarrierInMetersPerSec(); method public double getPseudorangeRateCarrierInMetersPerSec();
method public double getPseudorangeRateCarrierUncertaintyInMetersPerSec(); method public double getPseudorangeRateCarrierUncertaintyInMetersPerSec();
@@ -19240,6 +19239,7 @@ package android.location {
method public long getReceivedGpsTowUncertaintyInNs(); method public long getReceivedGpsTowUncertaintyInNs();
method public double getSnrInDb(); method public double getSnrInDb();
method public short getState(); method public short getState();
method public short getSvid();
method public short getTimeFromLastBitInMs(); method public short getTimeFromLastBitInMs();
method public double getTimeOffsetInNs(); method public double getTimeOffsetInNs();
method public boolean hasAzimuthInDeg(); method public boolean hasAzimuthInDeg();
@@ -19299,7 +19299,6 @@ package android.location {
method public void setElevationUncertaintyInDeg(double); method public void setElevationUncertaintyInDeg(double);
method public void setLossOfLock(byte); method public void setLossOfLock(byte);
method public void setMultipathIndicator(byte); method public void setMultipathIndicator(byte);
method public void setPrn(byte);
method public void setPseudorangeInMeters(double); method public void setPseudorangeInMeters(double);
method public void setPseudorangeRateCarrierInMetersPerSec(double); method public void setPseudorangeRateCarrierInMetersPerSec(double);
method public void setPseudorangeRateCarrierUncertaintyInMetersPerSec(double); method public void setPseudorangeRateCarrierUncertaintyInMetersPerSec(double);
@@ -19310,6 +19309,7 @@ package android.location {
method public void setReceivedGpsTowUncertaintyInNs(long); method public void setReceivedGpsTowUncertaintyInNs(long);
method public void setSnrInDb(double); method public void setSnrInDb(double);
method public void setState(short); method public void setState(short);
method public void setSvid(short);
method public void setTimeFromLastBitInMs(short); method public void setTimeFromLastBitInMs(short);
method public void setTimeOffsetInNs(double); method public void setTimeOffsetInNs(double);
method public void setUsedInFix(boolean); method public void setUsedInFix(boolean);
@@ -19364,17 +19364,17 @@ package android.location {
method public int describeContents(); method public int describeContents();
method public byte[] getData(); method public byte[] getData();
method public short getMessageId(); method public short getMessageId();
method public byte getPrn();
method public short getStatus(); method public short getStatus();
method public short getSubmessageId(); method public short getSubmessageId();
method public short getSvid();
method public byte getType(); method public byte getType();
method public void reset(); method public void reset();
method public void set(android.location.GnssNavigationMessage); method public void set(android.location.GnssNavigationMessage);
method public void setData(byte[]); method public void setData(byte[]);
method public void setMessageId(short); method public void setMessageId(short);
method public void setPrn(byte);
method public void setStatus(short); method public void setStatus(short);
method public void setSubmessageId(short); method public void setSubmessageId(short);
method public void setSvid(short);
method public void setType(byte); method public void setType(byte);
method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessage> CREATOR; field public static final android.os.Parcelable.Creator<android.location.GnssNavigationMessage> CREATOR;
@@ -19420,8 +19420,8 @@ package android.location {
method public int getConstellationType(int); method public int getConstellationType(int);
method public float getElevation(int); method public float getElevation(int);
method public int getNumSatellites(); method public int getNumSatellites();
method public int getPrn(int);
method public float getSnr(int); method public float getSnr(int);
method public int getSvid(int);
method public boolean hasAlmanac(int); method public boolean hasAlmanac(int);
method public boolean hasEphemeris(int); method public boolean hasEphemeris(int);
method public boolean usedInFix(int); method public boolean usedInFix(int);

View File

@@ -28,7 +28,7 @@ import java.lang.annotation.RetentionPolicy;
*/ */
public final class GnssMeasurement implements Parcelable { public final class GnssMeasurement implements Parcelable {
private int mFlags; private int mFlags;
private byte mPrn; private short mSvid;
private double mTimeOffsetInNs; private double mTimeOffsetInNs;
private short mState; private short mState;
private long mReceivedGpsTowInNs; private long mReceivedGpsTowInNs;
@@ -198,7 +198,7 @@ public final class GnssMeasurement implements Parcelable {
*/ */
public void set(GnssMeasurement measurement) { public void set(GnssMeasurement measurement) {
mFlags = measurement.mFlags; mFlags = measurement.mFlags;
mPrn = measurement.mPrn; mSvid = measurement.mSvid;
mTimeOffsetInNs = measurement.mTimeOffsetInNs; mTimeOffsetInNs = measurement.mTimeOffsetInNs;
mState = measurement.mState; mState = measurement.mState;
mReceivedGpsTowInNs = measurement.mReceivedGpsTowInNs; mReceivedGpsTowInNs = measurement.mReceivedGpsTowInNs;
@@ -248,15 +248,15 @@ public final class GnssMeasurement implements Parcelable {
* Gets the Pseudo-random number (PRN). * Gets the Pseudo-random number (PRN).
* Range: [1, 32] * Range: [1, 32]
*/ */
public byte getPrn() { public short getSvid() {
return mPrn; return mSvid;
} }
/** /**
* Sets the Pseud-random number (PRN). * Sets the Pseud-random number (PRN).
*/ */
public void setPrn(byte value) { public void setSvid(short value) {
mPrn = value; mSvid = value;
} }
/** /**
@@ -1210,7 +1210,7 @@ public final class GnssMeasurement implements Parcelable {
GnssMeasurement gnssMeasurement = new GnssMeasurement(); GnssMeasurement gnssMeasurement = new GnssMeasurement();
gnssMeasurement.mFlags = parcel.readInt(); gnssMeasurement.mFlags = parcel.readInt();
gnssMeasurement.mPrn = parcel.readByte(); gnssMeasurement.mSvid = (short) parcel.readInt();
gnssMeasurement.mTimeOffsetInNs = parcel.readDouble(); gnssMeasurement.mTimeOffsetInNs = parcel.readDouble();
gnssMeasurement.mState = (short) parcel.readInt(); gnssMeasurement.mState = (short) parcel.readInt();
gnssMeasurement.mReceivedGpsTowInNs = parcel.readLong(); gnssMeasurement.mReceivedGpsTowInNs = parcel.readLong();
@@ -1253,9 +1253,10 @@ public final class GnssMeasurement implements Parcelable {
} }
}; };
@Override
public void writeToParcel(Parcel parcel, int flags) { public void writeToParcel(Parcel parcel, int flags) {
parcel.writeInt(mFlags); parcel.writeInt(mFlags);
parcel.writeByte(mPrn); parcel.writeInt(mSvid);
parcel.writeDouble(mTimeOffsetInNs); parcel.writeDouble(mTimeOffsetInNs);
parcel.writeInt(mState); parcel.writeInt(mState);
parcel.writeLong(mReceivedGpsTowInNs); parcel.writeLong(mReceivedGpsTowInNs);
@@ -1301,7 +1302,7 @@ public final class GnssMeasurement implements Parcelable {
final String formatWithUncertainty = " %-29s = %-25s %-40s = %s\n"; final String formatWithUncertainty = " %-29s = %-25s %-40s = %s\n";
StringBuilder builder = new StringBuilder("GnssMeasurement:\n"); StringBuilder builder = new StringBuilder("GnssMeasurement:\n");
builder.append(String.format(format, "Prn", mPrn)); builder.append(String.format(format, "Svid", mSvid));
builder.append(String.format(format, "TimeOffsetInNs", mTimeOffsetInNs)); builder.append(String.format(format, "TimeOffsetInNs", mTimeOffsetInNs));
@@ -1422,7 +1423,7 @@ public final class GnssMeasurement implements Parcelable {
private void initialize() { private void initialize() {
mFlags = HAS_NO_FLAGS; mFlags = HAS_NO_FLAGS;
setPrn(Byte.MIN_VALUE); setSvid((short) 0);
setTimeOffsetInNs(Long.MIN_VALUE); setTimeOffsetInNs(Long.MIN_VALUE);
setState(STATE_UNKNOWN); setState(STATE_UNKNOWN);
setReceivedGpsTowInNs(Long.MIN_VALUE); setReceivedGpsTowInNs(Long.MIN_VALUE);

View File

@@ -26,7 +26,7 @@ import java.lang.annotation.RetentionPolicy;
import java.security.InvalidParameterException; import java.security.InvalidParameterException;
/** /**
* A class containing a GPS satellite Navigation Message. * A class containing a GNSS satellite Navigation Message.
*/ */
public final class GnssNavigationMessage implements Parcelable { public final class GnssNavigationMessage implements Parcelable {
@@ -84,7 +84,7 @@ public final class GnssNavigationMessage implements Parcelable {
// End enumerations in sync with gps.h // End enumerations in sync with gps.h
private byte mType; private byte mType;
private byte mPrn; private short mSvid;
private short mMessageId; private short mMessageId;
private short mSubmessageId; private short mSubmessageId;
private byte[] mData; private byte[] mData;
@@ -99,7 +99,7 @@ public final class GnssNavigationMessage implements Parcelable {
*/ */
public void set(GnssNavigationMessage navigationMessage) { public void set(GnssNavigationMessage navigationMessage) {
mType = navigationMessage.mType; mType = navigationMessage.mType;
mPrn = navigationMessage.mPrn; mSvid = navigationMessage.mSvid;
mMessageId = navigationMessage.mMessageId; mMessageId = navigationMessage.mMessageId;
mSubmessageId = navigationMessage.mSubmessageId; mSubmessageId = navigationMessage.mSubmessageId;
mData = navigationMessage.mData; mData = navigationMessage.mData;
@@ -153,15 +153,15 @@ public final class GnssNavigationMessage implements Parcelable {
* Gets the Pseudo-random number. * Gets the Pseudo-random number.
* Range: [1, 32]. * Range: [1, 32].
*/ */
public byte getPrn() { public short getSvid() {
return mPrn; return mSvid;
} }
/** /**
* Sets the Pseud-random number. * Sets the Pseud-random number.
*/ */
public void setPrn(byte value) { public void setSvid(short value) {
mPrn = value; mSvid = value;
} }
/** /**
@@ -256,7 +256,7 @@ public final class GnssNavigationMessage implements Parcelable {
GnssNavigationMessage navigationMessage = new GnssNavigationMessage(); GnssNavigationMessage navigationMessage = new GnssNavigationMessage();
navigationMessage.setType(parcel.readByte()); navigationMessage.setType(parcel.readByte());
navigationMessage.setPrn(parcel.readByte()); navigationMessage.setSvid((short) parcel.readInt());
navigationMessage.setMessageId((short) parcel.readInt()); navigationMessage.setMessageId((short) parcel.readInt());
navigationMessage.setSubmessageId((short) parcel.readInt()); navigationMessage.setSubmessageId((short) parcel.readInt());
@@ -281,9 +281,10 @@ public final class GnssNavigationMessage implements Parcelable {
} }
}; };
@Override
public void writeToParcel(Parcel parcel, int flags) { public void writeToParcel(Parcel parcel, int flags) {
parcel.writeByte(mType); parcel.writeByte(mType);
parcel.writeByte(mPrn); parcel.writeInt(mSvid);
parcel.writeInt(mMessageId); parcel.writeInt(mMessageId);
parcel.writeInt(mSubmessageId); parcel.writeInt(mSubmessageId);
parcel.writeInt(mData.length); parcel.writeInt(mData.length);
@@ -302,7 +303,7 @@ public final class GnssNavigationMessage implements Parcelable {
StringBuilder builder = new StringBuilder("GnssNavigationMessage:\n"); StringBuilder builder = new StringBuilder("GnssNavigationMessage:\n");
builder.append(String.format(format, "Type", getTypeString())); builder.append(String.format(format, "Type", getTypeString()));
builder.append(String.format(format, "Prn", mPrn)); builder.append(String.format(format, "Svid", mSvid));
builder.append(String.format(format, "Status", getStatusString())); builder.append(String.format(format, "Status", getStatusString()));
builder.append(String.format(format, "MessageId", mMessageId)); builder.append(String.format(format, "MessageId", mMessageId));
builder.append(String.format(format, "SubmessageId", mSubmessageId)); builder.append(String.format(format, "SubmessageId", mSubmessageId));
@@ -321,7 +322,7 @@ public final class GnssNavigationMessage implements Parcelable {
private void initialize() { private void initialize() {
mType = MESSAGE_TYPE_UNKNOWN; mType = MESSAGE_TYPE_UNKNOWN;
mPrn = 0; mSvid = 0;
mMessageId = -1; mMessageId = -1;
mSubmessageId = -1; mSubmessageId = -1;
mData = EMPTY_ARRAY; mData = EMPTY_ARRAY;

View File

@@ -47,24 +47,26 @@ public final class GnssStatus {
public static final int GNSS_SV_FLAGS_USED_IN_FIX = (1 << 2); public static final int GNSS_SV_FLAGS_USED_IN_FIX = (1 << 2);
/** @hide */ /** @hide */
public static final int PRN_SHIFT_WIDTH = 3; public static final int SVID_SHIFT_WIDTH = 7;
/** @hide */
public static final int CONSTELLATION_TYPE_SHIFT_WIDTH = 3;
/** @hide */
public static final int CONSTELLATION_TYPE_MASK = 0xf;
/* These package private values are modified by the LocationManager class */ /* These package private values are modified by the LocationManager class */
/* package */ int[] mPrnWithFlags; /* package */ int[] mSvidWithFlags;
/* package */ float[] mSnrs; /* package */ float[] mSnrs;
/* package */ float[] mElevations; /* package */ float[] mElevations;
/* package */ float[] mAzimuths; /* package */ float[] mAzimuths;
/* package */ int[] mConstellationTypes;
/* package */ int mSvCount; /* package */ int mSvCount;
GnssStatus(int svCount, int[] prnWithFlags, float[] snrs, float[] elevations, float[] azimuths, GnssStatus(int svCount, int[] svidWithFlags, float[] snrs, float[] elevations,
int[] constellationTypes) { float[] azimuths) {
mSvCount = svCount; mSvCount = svCount;
mPrnWithFlags = prnWithFlags; mSvidWithFlags = svidWithFlags;
mSnrs = snrs; mSnrs = snrs;
mElevations = elevations; mElevations = elevations;
mAzimuths = azimuths; mAzimuths = azimuths;
mConstellationTypes = constellationTypes;
} }
/** /**
@@ -79,15 +81,16 @@ public final class GnssStatus {
* @param satIndex the index of the satellite in the list. * @param satIndex the index of the satellite in the list.
*/ */
public int getConstellationType(int satIndex) { public int getConstellationType(int satIndex) {
return mConstellationTypes[satIndex]; return (mSvidWithFlags[satIndex] >> CONSTELLATION_TYPE_SHIFT_WIDTH)
& CONSTELLATION_TYPE_MASK;
} }
/** /**
* Retrieves the pseudo-random number of the satellite at the specified position. * Retrieves the pseudo-random number of the satellite at the specified position.
* @param satIndex the index of the satellite in the list. * @param satIndex the index of the satellite in the list.
*/ */
public int getPrn(int satIndex) { public int getSvid(int satIndex) {
return mPrnWithFlags[satIndex] >> PRN_SHIFT_WIDTH; return mSvidWithFlags[satIndex] >> SVID_SHIFT_WIDTH;
} }
/** /**
@@ -119,7 +122,7 @@ public final class GnssStatus {
* @param satIndex the index of the satellite in the list. * @param satIndex the index of the satellite in the list.
*/ */
public boolean hasEphemeris(int satIndex) { public boolean hasEphemeris(int satIndex) {
return (mPrnWithFlags[satIndex] & GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA) != 0; return (mSvidWithFlags[satIndex] & GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA) != 0;
} }
/** /**
@@ -127,7 +130,7 @@ public final class GnssStatus {
* @param satIndex the index of the satellite in the list. * @param satIndex the index of the satellite in the list.
*/ */
public boolean hasAlmanac(int satIndex) { public boolean hasAlmanac(int satIndex) {
return (mPrnWithFlags[satIndex] & GNSS_SV_FLAGS_HAS_ALMANAC_DATA) != 0; return (mSvidWithFlags[satIndex] & GNSS_SV_FLAGS_HAS_ALMANAC_DATA) != 0;
} }
/** /**
@@ -135,6 +138,6 @@ public final class GnssStatus {
* @param satIndex the index of the satellite in the list. * @param satIndex the index of the satellite in the list.
*/ */
public boolean usedInFix(int satIndex) { public boolean usedInFix(int satIndex) {
return (mPrnWithFlags[satIndex] & GNSS_SV_FLAGS_USED_IN_FIX) != 0; return (mSvidWithFlags[satIndex] & GNSS_SV_FLAGS_USED_IN_FIX) != 0;
} }
} }

View File

@@ -138,15 +138,19 @@ public final class GpsStatus {
// For API-compat a public ctor() is not available // For API-compat a public ctor() is not available
GpsStatus() {} GpsStatus() {}
private void setStatus(int svCount, int[] prnWithFlags, float[] snrs, float[] elevations, private void setStatus(int svCount, int[] svidWithFlags, float[] snrs, float[] elevations,
float[] azimuths, int[] constellationTypes) { float[] azimuths) {
clearSatellites(); clearSatellites();
for (int i = 0; i < svCount; i++) { for (int i = 0; i < svCount; i++) {
final int constellationType =
(svidWithFlags[i] >> GnssStatus.CONSTELLATION_TYPE_SHIFT_WIDTH)
& GnssStatus.CONSTELLATION_TYPE_MASK;
// Skip all non-GPS satellites. // Skip all non-GPS satellites.
if (constellationTypes[i] != GnssStatus.CONSTELLATION_GPS) { if (constellationType != GnssStatus.CONSTELLATION_GPS) {
// TODO: translate the defacto pre-N use of prn's >32 to new struct
continue; continue;
} }
int prn = prnWithFlags[i] >> GnssStatus.PRN_SHIFT_WIDTH; int prn = svidWithFlags[i] >> GnssStatus.SVID_SHIFT_WIDTH;
if (prn > 0 && prn <= NUM_SATELLITES) { if (prn > 0 && prn <= NUM_SATELLITES) {
GpsSatellite satellite = mSatellites.get(prn); GpsSatellite satellite = mSatellites.get(prn);
if (satellite == null) { if (satellite == null) {
@@ -159,11 +163,11 @@ public final class GpsStatus {
satellite.mElevation = elevations[i]; satellite.mElevation = elevations[i];
satellite.mAzimuth = azimuths[i]; satellite.mAzimuth = azimuths[i];
satellite.mHasEphemeris = satellite.mHasEphemeris =
(prnWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA) != 0; (svidWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA) != 0;
satellite.mHasAlmanac = satellite.mHasAlmanac =
(prnWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_HAS_ALMANAC_DATA) != 0; (svidWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_HAS_ALMANAC_DATA) != 0;
satellite.mUsedInFix = satellite.mUsedInFix =
(prnWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_USED_IN_FIX) != 0; (svidWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_USED_IN_FIX) != 0;
} }
} }
} }
@@ -176,8 +180,8 @@ public final class GpsStatus {
*/ */
void setStatus(GnssStatus status, int timeToFirstFix) { void setStatus(GnssStatus status, int timeToFirstFix) {
mTimeToFirstFix = timeToFirstFix; mTimeToFirstFix = timeToFirstFix;
setStatus(status.mSvCount, status.mPrnWithFlags, status.mSnrs, status.mElevations, setStatus(status.mSvCount, status.mSvidWithFlags, status.mSnrs, status.mElevations,
status.mAzimuths, status.mConstellationTypes); status.mAzimuths);
} }
void setTimeToFirstFix(int ttff) { void setTimeToFirstFix(int ttff) {

View File

@@ -26,7 +26,7 @@ oneway interface IGnssStatusListener
void onGnssStarted(); void onGnssStarted();
void onGnssStopped(); void onGnssStopped();
void onFirstFix(int ttff); void onFirstFix(int ttff);
void onSvStatusChanged(int svCount, in int[] prnWithFlags, in float[] snrs, void onSvStatusChanged(int svCount, in int[] svidWithFlags, in float[] snrs,
in float[] elevations, in float[] azimuths, in int[] constellationTypes); in float[] elevations, in float[] azimuths);
void onNmeaReceived(long timestamp, String nmea); void onNmeaReceived(long timestamp, String nmea);
} }

View File

@@ -1562,10 +1562,9 @@ public class LocationManager {
@Override @Override
public void onSvStatusChanged(int svCount, int[] prnWithFlags, public void onSvStatusChanged(int svCount, int[] prnWithFlags,
float[] snrs, float[] elevations, float[] azimuths, int[] constellationTypes) { float[] snrs, float[] elevations, float[] azimuths) {
if (mGnssCallback != null) { if (mGnssCallback != null) {
mGnssStatus = new GnssStatus(svCount, prnWithFlags, snrs, elevations, azimuths, mGnssStatus = new GnssStatus(svCount, prnWithFlags, snrs, elevations, azimuths);
constellationTypes);
Message msg = Message.obtain(); Message msg = Message.obtain();
msg.what = GpsStatus.GPS_EVENT_SATELLITE_STATUS; msg.what = GpsStatus.GPS_EVENT_SATELLITE_STATUS;

View File

@@ -1557,15 +1557,13 @@ public class GnssLocationProvider implements LocationProviderInterface {
* called from native code to update SV info * called from native code to update SV info
*/ */
private void reportSvStatus() { private void reportSvStatus() {
int svCount = native_read_sv_status(mPrnWithFlags, mSnrs, mSvElevations, mSvAzimuths, int svCount = native_read_sv_status(mSvidWithFlags, mSnrs, mSvElevations, mSvAzimuths);
mConstellationTypes);
mListenerHelper.onSvStatusChanged( mListenerHelper.onSvStatusChanged(
svCount, svCount,
mPrnWithFlags, mSvidWithFlags,
mSnrs, mSnrs,
mSvElevations, mSvElevations,
mSvAzimuths, mSvAzimuths);
mConstellationTypes);
if (VERBOSE) { if (VERBOSE) {
Log.v(TAG, "SV count: " + svCount); Log.v(TAG, "SV count: " + svCount);
@@ -1573,19 +1571,19 @@ public class GnssLocationProvider implements LocationProviderInterface {
// Calculate number of sets used in fix. // Calculate number of sets used in fix.
int usedInFixCount = 0; int usedInFixCount = 0;
for (int i = 0; i < svCount; i++) { for (int i = 0; i < svCount; i++) {
if ((mPrnWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_USED_IN_FIX) != 0) { if ((mSvidWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_USED_IN_FIX) != 0) {
++usedInFixCount; ++usedInFixCount;
} }
if (VERBOSE) { if (VERBOSE) {
Log.v(TAG, "prn: " + (mPrnWithFlags[i] >> GnssStatus.PRN_SHIFT_WIDTH) + Log.v(TAG, "svid: " + (mSvidWithFlags[i] >> GnssStatus.SVID_SHIFT_WIDTH) +
" snr: " + mSnrs[i]/10 + " snr: " + mSnrs[i]/10 +
" elev: " + mSvElevations[i] + " elev: " + mSvElevations[i] +
" azimuth: " + mSvAzimuths[i] + " azimuth: " + mSvAzimuths[i] +
((mPrnWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA) == 0 ((mSvidWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA) == 0
? " " : " E") + ? " " : " E") +
((mPrnWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_HAS_ALMANAC_DATA) == 0 ((mSvidWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_HAS_ALMANAC_DATA) == 0
? " " : " A") + ? " " : " A") +
((mPrnWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_USED_IN_FIX) == 0 ((mSvidWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_USED_IN_FIX) == 0
? "" : "U")); ? "" : "U"));
} }
} }
@@ -2398,14 +2396,13 @@ public class GnssLocationProvider implements LocationProviderInterface {
} }
// for GPS SV statistics // for GPS SV statistics
private static final int MAX_SVS = 512; private static final int MAX_SVS = 64;
// preallocated arrays, to avoid memory allocation in reportStatus() // preallocated arrays, to avoid memory allocation in reportStatus()
private int mPrnWithFlags[] = new int[MAX_SVS]; private int mSvidWithFlags[] = new int[MAX_SVS];
private float mSnrs[] = new float[MAX_SVS]; private float mSnrs[] = new float[MAX_SVS];
private float mSvElevations[] = new float[MAX_SVS]; private float mSvElevations[] = new float[MAX_SVS];
private float mSvAzimuths[] = new float[MAX_SVS]; private float mSvAzimuths[] = new float[MAX_SVS];
private int mConstellationTypes[] = new int[MAX_SVS];
private int mSvCount; private int mSvCount;
// preallocated to avoid memory allocation in reportNmea() // preallocated to avoid memory allocation in reportNmea()
private byte[] mNmeaBuffer = new byte[120]; private byte[] mNmeaBuffer = new byte[120];
@@ -2426,7 +2423,7 @@ public class GnssLocationProvider implements LocationProviderInterface {
// returns number of SVs // returns number of SVs
// mask[0] is ephemeris mask and mask[1] is almanac mask // mask[0] is ephemeris mask and mask[1] is almanac mask
private native int native_read_sv_status(int[] prnWithFlags, float[] snrs, float[] elevations, private native int native_read_sv_status(int[] prnWithFlags, float[] snrs, float[] elevations,
float[] azimuths, int[] constellationTypes); float[] azimuths);
private native int native_read_nmea(byte[] buffer, int bufferSize); private native int native_read_nmea(byte[] buffer, int bufferSize);
private native void native_inject_location(double latitude, double longitude, float accuracy); private native void native_inject_location(double latitude, double longitude, float accuracy);

View File

@@ -77,8 +77,7 @@ abstract class GnssStatusListenerHelper extends RemoteListenerHelper<IGnssStatus
final int[] prnWithFlags, final int[] prnWithFlags,
final float[] snrs, final float[] snrs,
final float[] elevations, final float[] elevations,
final float[] azimuths, final float[] azimuths) {
final int[] constellationTypes) {
Operation operation = new Operation() { Operation operation = new Operation() {
@Override @Override
public void execute(IGnssStatusListener listener) throws RemoteException { public void execute(IGnssStatusListener listener) throws RemoteException {
@@ -87,8 +86,7 @@ abstract class GnssStatusListenerHelper extends RemoteListenerHelper<IGnssStatus
prnWithFlags, prnWithFlags,
snrs, snrs,
elevations, elevations,
azimuths, azimuths);
constellationTypes);
} }
}; };
foreach(operation); foreach(operation);