summaryrefslogtreecommitdiff
path: root/location
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-02-19 20:34:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-02-19 20:34:29 +0000
commitfe446f7f241ca2a5d031a80b9e531755ad2e1db6 (patch)
treea7dce1ecd89b005adf4252b3d71e0b153fe66dbe /location
parentda4585593fa357905133553d1b42c924b63124b4 (diff)
parent213bb7097acab534962b0459d51c3aec29b38f12 (diff)
Merge "Fixes to GnssAntennaInfo API"
Diffstat (limited to 'location')
-rw-r--r--location/java/android/location/GnssAntennaInfo.java627
-rw-r--r--location/java/android/location/GnssCapabilities.java53
-rw-r--r--location/java/android/location/IGnssAntennaInfoListener.aidl1
-rw-r--r--location/java/android/location/LocationManager.java38
4 files changed, 261 insertions, 458 deletions
diff --git a/location/java/android/location/GnssAntennaInfo.java b/location/java/android/location/GnssAntennaInfo.java
index dfcaf814f9c9..b2f9a0f41b7e 100644
--- a/location/java/android/location/GnssAntennaInfo.java
+++ b/location/java/android/location/GnssAntennaInfo.java
@@ -16,72 +16,37 @@
package android.location;
-import android.annotation.IntDef;
+import android.annotation.FloatRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
-import com.android.internal.annotations.VisibleForTesting;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
+import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
/**
* A class that contains information about a GNSS antenna. GNSS antenna characteristics can change
* with device configuration, such as when a device is folded open or closed. Antenna information is
- * delivered to registered instances of {@link Callback}.
+ * delivered to registered instances of {@link Listener}.
*/
public final class GnssAntennaInfo implements Parcelable {
private final double mCarrierFrequencyMHz;
- private final PhaseCenterOffsetCoordinates mPhaseCenterOffsetCoordinates;
- private final PhaseCenterVariationCorrections mPhaseCenterVariationCorrections;
- private final SignalGainCorrections mSignalGainCorrections;
+ private final PhaseCenterOffset mPhaseCenterOffset;
+ private final SphericalCorrections mPhaseCenterVariationCorrections;
+ private final SphericalCorrections mSignalGainCorrections;
/**
* Used for receiving GNSS antenna info from the GNSS engine. You can implement this interface
- * and call {@link LocationManager#registerAntennaInfoCallback};
+ * and call {@link LocationManager#registerAntennaInfoListener};
*/
- public abstract static class Callback {
- /**
- * The status of GNSS antenna info.
- *
- * @hide
- */
- @Retention(RetentionPolicy.SOURCE)
- @IntDef({STATUS_NOT_SUPPORTED, STATUS_READY, STATUS_LOCATION_DISABLED})
- public @interface GnssAntennaInfoStatus {
- }
-
- /**
- * The system does not support GNSS antenna info.
- *
- * This status will not change in the future.
- */
- public static final int STATUS_NOT_SUPPORTED = 0;
-
- /**
- * GNSS antenna info updates are being successfully tracked.
- */
- public static final int STATUS_READY = 1;
-
- /**
- * GNSS provider or Location is disabled, updated will not be received until they are
- * enabled.
- */
- public static final int STATUS_LOCATION_DISABLED = 2;
-
+ public interface Listener {
/**
- * Returns the latest GNSS antenna info. This event is triggered when a callback is
+ * Returns the latest GNSS antenna info. This event is triggered when a listener is
* registered, and whenever the antenna info changes (due to a device configuration change).
*/
- public void onGnssAntennaInfoReceived(@NonNull List<GnssAntennaInfo> gnssAntennaInfos) {}
-
- /**
- * Returns the latest status of the GNSS antenna info sub-system.
- */
- public void onStatusChanged(@GnssAntennaInfoStatus int status) {}
+ void onGnssAntennaInfoReceived(@NonNull List<GnssAntennaInfo> gnssAntennaInfos);
}
/**
@@ -90,37 +55,31 @@ public final class GnssAntennaInfo implements Parcelable {
* for mobiles - see sensor or form factor documents for details. Uncertainties are reported
* to 1-sigma.
*/
- public static final class PhaseCenterOffsetCoordinates implements Parcelable {
- private final double mPhaseCenterOffsetCoordinateXMillimeters;
- private final double mPhaseCenterOffsetCoordinateXUncertaintyMillimeters;
- private final double mPhaseCenterOffsetCoordinateYMillimeters;
- private final double mPhaseCenterOffsetCoordinateYUncertaintyMillimeters;
- private final double mPhaseCenterOffsetCoordinateZMillimeters;
- private final double mPhaseCenterOffsetCoordinateZUncertaintyMillimeters;
-
- @VisibleForTesting
- public PhaseCenterOffsetCoordinates(double phaseCenterOffsetCoordinateXMillimeters,
- double phaseCenterOffsetCoordinateXUncertaintyMillimeters,
- double phaseCenterOffsetCoordinateYMillimeters,
- double phaseCenterOffsetCoordinateYUncertaintyMillimeters,
- double phaseCenterOffsetCoordinateZMillimeters,
- double phaseCenterOffsetCoordinateZUncertaintyMillimeters) {
- mPhaseCenterOffsetCoordinateXMillimeters = phaseCenterOffsetCoordinateXMillimeters;
- mPhaseCenterOffsetCoordinateYMillimeters = phaseCenterOffsetCoordinateYMillimeters;
- mPhaseCenterOffsetCoordinateZMillimeters = phaseCenterOffsetCoordinateZMillimeters;
- mPhaseCenterOffsetCoordinateXUncertaintyMillimeters =
- phaseCenterOffsetCoordinateXUncertaintyMillimeters;
- mPhaseCenterOffsetCoordinateYUncertaintyMillimeters =
- phaseCenterOffsetCoordinateYUncertaintyMillimeters;
- mPhaseCenterOffsetCoordinateZUncertaintyMillimeters =
- phaseCenterOffsetCoordinateZUncertaintyMillimeters;
- }
-
- public static final @NonNull Creator<PhaseCenterOffsetCoordinates> CREATOR =
- new Creator<PhaseCenterOffsetCoordinates>() {
+ public static final class PhaseCenterOffset implements Parcelable {
+ private final double mOffsetXMm;
+ private final double mOffsetXUncertaintyMm;
+ private final double mOffsetYMm;
+ private final double mOffsetYUncertaintyMm;
+ private final double mOffsetZMm;
+ private final double mOffsetZUncertaintyMm;
+
+ public PhaseCenterOffset(
+ double offsetXMm, double offsetXUncertaintyMm,
+ double offsetYMm, double offsetYUncertaintyMm,
+ double offsetZMm, double offsetZUncertaintyMm) {
+ mOffsetXMm = offsetXMm;
+ mOffsetYMm = offsetYMm;
+ mOffsetZMm = offsetZMm;
+ mOffsetXUncertaintyMm = offsetXUncertaintyMm;
+ mOffsetYUncertaintyMm = offsetYUncertaintyMm;
+ mOffsetZUncertaintyMm = offsetZUncertaintyMm;
+ }
+
+ public static final @NonNull Creator<PhaseCenterOffset> CREATOR =
+ new Creator<PhaseCenterOffset>() {
@Override
- public PhaseCenterOffsetCoordinates createFromParcel(Parcel in) {
- return new PhaseCenterOffsetCoordinates(
+ public PhaseCenterOffset createFromParcel(Parcel in) {
+ return new PhaseCenterOffset(
in.readDouble(),
in.readDouble(),
in.readDouble(),
@@ -131,158 +90,41 @@ public final class GnssAntennaInfo implements Parcelable {
}
@Override
- public PhaseCenterOffsetCoordinates[] newArray(int size) {
- return new PhaseCenterOffsetCoordinates[size];
+ public PhaseCenterOffset[] newArray(int size) {
+ return new PhaseCenterOffset[size];
}
};
- public double getXCoordMillimeters() {
- return mPhaseCenterOffsetCoordinateXMillimeters;
- }
-
- public double getXCoordUncertaintyMillimeters() {
- return mPhaseCenterOffsetCoordinateXUncertaintyMillimeters;
- }
-
- public double getYCoordMillimeters() {
- return mPhaseCenterOffsetCoordinateYMillimeters;
- }
-
- public double getYCoordUncertaintyMillimeters() {
- return mPhaseCenterOffsetCoordinateYUncertaintyMillimeters;
- }
-
- public double getZCoordMillimeters() {
- return mPhaseCenterOffsetCoordinateZMillimeters;
- }
-
- public double getZCoordUncertaintyMillimeters() {
- return mPhaseCenterOffsetCoordinateZUncertaintyMillimeters;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(@NonNull Parcel dest, int flags) {
- dest.writeDouble(mPhaseCenterOffsetCoordinateXMillimeters);
- dest.writeDouble(mPhaseCenterOffsetCoordinateXUncertaintyMillimeters);
- dest.writeDouble(mPhaseCenterOffsetCoordinateYMillimeters);
- dest.writeDouble(mPhaseCenterOffsetCoordinateYUncertaintyMillimeters);
- dest.writeDouble(mPhaseCenterOffsetCoordinateZMillimeters);
- dest.writeDouble(mPhaseCenterOffsetCoordinateZUncertaintyMillimeters);
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder("PhaseCenteroffset:\n");
- builder.append("X: " + mPhaseCenterOffsetCoordinateXMillimeters + " +/- "
- + mPhaseCenterOffsetCoordinateXUncertaintyMillimeters + "\n");
- builder.append("Y: " + mPhaseCenterOffsetCoordinateYMillimeters + " +/- "
- + mPhaseCenterOffsetCoordinateYUncertaintyMillimeters + "\n");
- builder.append("Z: " + mPhaseCenterOffsetCoordinateZMillimeters + " +/- "
- + mPhaseCenterOffsetCoordinateZUncertaintyMillimeters + "\n");
- return builder.toString();
- }
- }
-
- /**
- * Class containing information about the phase center variation (PCV) corrections. The PCV
- * correction is added to the phase measurement to obtain the corrected value.
- *
- * The corrections and associated (1-sigma) uncertainties are represented by respect 2D arrays.
- *
- * Each row (major indices) represents a fixed theta. The first row corresponds to a
- * theta angle of 0 degrees. The last row corresponds to a theta angle of (360 - deltaTheta)
- * degrees, where deltaTheta is the regular spacing between azimuthal angles, i.e., deltaTheta
- * = 360 / (number of rows).
- *
- * The columns (minor indices) represent fixed zenith angles, beginning at 0 degrees and ending
- * at 180 degrees. They are separated by deltaPhi, the regular spacing between zenith angles,
- * i.e., deltaPhi = 180 / (number of columns - 1).
- */
- public static final class PhaseCenterVariationCorrections extends SphericalCorrections {
-
- @VisibleForTesting
- public PhaseCenterVariationCorrections(
- @NonNull double[][] phaseCenterVariationCorrectionsMillimeters,
- @NonNull double[][] phaseCenterVariationCorrectionUncertaintiesMillimeters) {
- super(phaseCenterVariationCorrectionsMillimeters,
- phaseCenterVariationCorrectionUncertaintiesMillimeters);
- }
-
- private PhaseCenterVariationCorrections(@NonNull Parcel in) {
- super(in);
- }
-
- /**
- * Get the phase center variation correction in millimeters at the specified row and column
- * in the underlying 2D array.
- * @param row zero-based major index in the array
- * @param column zero-based minor index in the array
- * @return phase center correction in millimeters
- */
- public double getPhaseCenterVariationCorrectionMillimetersAt(int row, int column) {
- return super.getCorrectionAt(row, column);
- }
-
- /**
- * Get the phase center variation correction uncertainty in millimeters at the specified row
- * and column in the underlying 2D array.
- * @param row zero-based major index in the array
- * @param column zero-based minor index in the array
- * @return 1-sigma phase center correction uncertainty in millimeters
- */
- public double getPhaseCenterVariationCorrectionUncertaintyMillimetersAt(
- int row, int column) {
- return super.getCorrectionUncertaintyAt(row, column);
- }
-
- public @NonNull double[][] getRawCorrectionsArray() {
- return super.getRawCorrectionsArray().clone();
+ @FloatRange()
+ public double getXOffsetMm() {
+ return mOffsetXMm;
}
- public @NonNull double[][] getRawCorrectionUncertaintiesArray() {
- return super.getRawCorrectionUncertaintiesArray().clone();
+ @FloatRange()
+ public double getXOffsetUncertaintyMm() {
+ return mOffsetXUncertaintyMm;
}
- public int getNumRows() {
- return super.getNumRows();
+ @FloatRange()
+ public double getYOffsetMm() {
+ return mOffsetYMm;
}
- public int getNumColumns() {
- return super.getNumColumns();
+ @FloatRange()
+ public double getYOffsetUncertaintyMm() {
+ return mOffsetYUncertaintyMm;
}
- /**
- * The fixed theta angle separation between successive rows.
- */
- public double getDeltaTheta() {
- return super.getDeltaTheta();
+ @FloatRange()
+ public double getZOffsetMm() {
+ return mOffsetZMm;
}
- /**
- * The fixed phi angle separation between successive columns.
- */
- public double getDeltaPhi() {
- return super.getDeltaPhi();
+ @FloatRange()
+ public double getZOffsetUncertaintyMm() {
+ return mOffsetZUncertaintyMm;
}
- public static final @NonNull Creator<PhaseCenterVariationCorrections> CREATOR =
- new Creator<PhaseCenterVariationCorrections>() {
- @Override
- public PhaseCenterVariationCorrections createFromParcel(Parcel in) {
- return new PhaseCenterVariationCorrections(in);
- }
-
- @Override
- public PhaseCenterVariationCorrections[] newArray(int size) {
- return new PhaseCenterVariationCorrections[size];
- }
- };
-
@Override
public int describeContents() {
return 0;
@@ -290,20 +132,27 @@ public final class GnssAntennaInfo implements Parcelable {
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
+ dest.writeDouble(mOffsetXMm);
+ dest.writeDouble(mOffsetXUncertaintyMm);
+ dest.writeDouble(mOffsetYMm);
+ dest.writeDouble(mOffsetYUncertaintyMm);
+ dest.writeDouble(mOffsetZMm);
+ dest.writeDouble(mOffsetZUncertaintyMm);
}
@Override
public String toString() {
- StringBuilder builder = new StringBuilder("PhaseCenterVariationCorrections:\n");
- builder.append(super.toString());
- return builder.toString();
+ return "PhaseCenterOffset{"
+ + "OffsetXMm=" + mOffsetXMm + " +/-" + mOffsetXUncertaintyMm
+ + ", OffsetYMm=" + mOffsetYMm + " +/-" + mOffsetYUncertaintyMm
+ + ", OffsetZMm=" + mOffsetZMm + " +/-" + mOffsetZUncertaintyMm
+ + '}';
}
}
/**
- * Class containing information about the signal gain (SG) corrections. The SG
- * correction is added to the signal gain to obtain the corrected value.
+ * Represents corrections on a spherical mapping. Corrections are added to measurements to
+ * obtain the corrected values.
*
* The corrections and associated (1-sigma) uncertainties are represented by respect 2D arrays.
*
@@ -316,116 +165,7 @@ public final class GnssAntennaInfo implements Parcelable {
* at 180 degrees. They are separated by deltaPhi, the regular spacing between zenith angles,
* i.e., deltaPhi = 180 / (number of columns - 1).
*/
- public static final class SignalGainCorrections extends SphericalCorrections {
-
- @VisibleForTesting
- public SignalGainCorrections(
- @NonNull double[][] signalGainCorrectionsDbi,
- @NonNull double[][] signalGainCorrectionUncertaintiesDbi) {
- super(signalGainCorrectionsDbi,
- signalGainCorrectionUncertaintiesDbi);
- }
-
- private SignalGainCorrections(@NonNull Parcel in) {
- super(in);
- }
-
- /**
- * Get the signal gain correction in dbi at the specified row and column
- * in the underlying 2D array.
- * @param row zero-based major index in the array
- * @param column zero-based minor index in the array
- * @return signal gain correction in dbi
- */
- public double getSignalGainCorrectionDbiAt(int row, int column) {
- return super.getCorrectionAt(row, column);
- }
-
- /**
- * Get the signal gain correction correction uncertainty in dbi at the specified row
- * and column in the underlying 2D array.
- * @param row zero-based major index in the array
- * @param column zero-based minor index in the array
- * @return 1-sigma signal gain correction uncertainty in dbi
- */
- public double getSignalGainCorrectionUncertaintyDbiAt(int row, int column) {
- return super.getCorrectionUncertaintyAt(row, column);
- }
-
- public @NonNull double[][] getRawCorrectionsArray() {
- return super.getRawCorrectionsArray().clone();
- }
-
- public @NonNull double[][] getRawCorrectionUncertaintiesArray() {
- return super.getRawCorrectionUncertaintiesArray().clone();
- }
-
- public int getNumRows() {
- return super.getNumRows();
- }
-
- public int getNumColumns() {
- return super.getNumColumns();
- }
-
- /**
- * The fixed theta angle separation between successive rows.
- */
- public double getDeltaTheta() {
- return super.getDeltaTheta();
- }
-
- /**
- * The fixed phi angle separation between successive columns.
- */
- public double getDeltaPhi() {
- return super.getDeltaPhi();
- }
-
- public static final @NonNull Creator<SignalGainCorrections> CREATOR =
- new Creator<SignalGainCorrections>() {
- @Override
- public SignalGainCorrections createFromParcel(Parcel in) {
- return new SignalGainCorrections(in);
- }
-
- @Override
- public SignalGainCorrections[] newArray(int size) {
- return new SignalGainCorrections[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(@NonNull Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder("SignalGainCorrections:\n");
- builder.append(super.toString());
- return builder.toString();
- }
- }
-
- /**
- * Represents corrections on a spherical mapping.
- *
- * Each row (major indices) represents a fixed theta. The first row corresponds to a
- * theta angle of 0 degrees. The last row corresponds to a theta angle of (360 - deltaTheta)
- * degrees, where deltaTheta is the regular spacing between azimuthal angles, i.e., deltaTheta
- * = 360 / (number of rows).
- *
- * The columns (minor indices) represent fixed zenith angles, beginning at 0 degrees and ending
- * at 180 degrees. They are separated by deltaPhi, the regular spacing between zenith angles,
- * i.e., deltaPhi = 180 / (number of columns - 1).
- */
- private abstract static class SphericalCorrections implements Parcelable {
+ public static final class SphericalCorrections implements Parcelable{
private final double[][] mCorrections;
private final double[][] mCorrectionUncertainties;
private final double mDeltaTheta;
@@ -433,7 +173,7 @@ public final class GnssAntennaInfo implements Parcelable {
private final int mNumRows;
private final int mNumColumns;
- SphericalCorrections(@NonNull double[][] corrections,
+ public SphericalCorrections(@NonNull double[][] corrections,
@NonNull double[][] correctionUncertainties) {
if (corrections.length != correctionUncertainties.length
|| corrections[0].length != correctionUncertainties[0].length) {
@@ -474,54 +214,84 @@ public final class GnssAntennaInfo implements Parcelable {
in.readDoubleArray(correctionUncertainties[row]);
}
- mNumRows = corrections.length;
- mNumColumns = corrections[0].length;
+ mNumRows = numRows;
+ mNumColumns = numColumns;
mCorrections = corrections;
mCorrectionUncertainties = correctionUncertainties;
mDeltaTheta = 360.0d / mNumRows;
mDeltaPhi = 180.0d / (mNumColumns - 1);
}
- private double getCorrectionAt(int row, int column) {
- return mCorrections[row][column];
- }
-
- private double getCorrectionUncertaintyAt(int row, int column) {
- return mCorrectionUncertainties[row][column];
- }
-
+ /**
+ * Array representing corrections on a spherical mapping. Corrections are added to
+ * measurements to obtain the corrected values.
+ *
+ * Each row (major indices) represents a fixed theta. The first row corresponds to a
+ * theta angle of 0 degrees. The last row corresponds to a theta angle of (360 - deltaTheta)
+ * degrees, where deltaTheta is the regular spacing between azimuthal angles, i.e.,
+ * deltaTheta = 360 / (number of rows).
+ *
+ * The columns (minor indices) represent fixed zenith angles, beginning at 0 degrees and
+ * ending at 180 degrees. They are separated by deltaPhi, the regular spacing between zenith
+ * angles, i.e., deltaPhi = 180 / (number of columns - 1).
+ */
@NonNull
- private double[][] getRawCorrectionsArray() {
+ public double[][] getCorrectionsArray() {
return mCorrections;
}
+ /**
+ * Array representing uncertainty on corrections on a spherical mapping.
+ *
+ * Each row (major indices) represents a fixed theta. The first row corresponds to a
+ * theta angle of 0 degrees. The last row corresponds to a theta angle of (360 - deltaTheta)
+ * degrees, where deltaTheta is the regular spacing between azimuthal angles, i.e.,
+ * deltaTheta = 360 / (number of rows).
+ *
+ * The columns (minor indices) represent fixed zenith angles, beginning at 0 degrees and
+ * ending at 180 degrees. They are separated by deltaPhi, the regular spacing between zenith
+ * angles, i.e., deltaPhi = 180 / (number of columns - 1).
+ */
@NonNull
- private double[][] getRawCorrectionUncertaintiesArray() {
+ public double[][] getCorrectionUncertaintiesArray() {
return mCorrectionUncertainties;
}
- private int getNumRows() {
- return mNumRows;
- }
-
- private int getNumColumns() {
- return mNumColumns;
- }
-
/**
* The fixed theta angle separation between successive rows.
*/
- private double getDeltaTheta() {
+ @FloatRange(from = 0.0f, to = 360.0f)
+ public double getDeltaTheta() {
return mDeltaTheta;
}
/**
* The fixed phi angle separation between successive columns.
*/
- private double getDeltaPhi() {
+ @FloatRange(from = 0.0f, to = 180.0f)
+ public double getDeltaPhi() {
return mDeltaPhi;
}
+
+ public static final @NonNull Creator<SphericalCorrections> CREATOR =
+ new Creator<SphericalCorrections>() {
+ @Override
+ public SphericalCorrections createFromParcel(Parcel in) {
+ return new SphericalCorrections(in);
+ }
+
+ @Override
+ public SphericalCorrections[] newArray(int size) {
+ return new SphericalCorrections[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(mNumRows);
@@ -534,62 +304,114 @@ public final class GnssAntennaInfo implements Parcelable {
}
}
- private String arrayToString(double[][] array) {
- StringBuilder builder = new StringBuilder();
- for (int row = 0; row < mNumRows; row++) {
- builder.append("[ ");
- for (int column = 0; column < mNumColumns - 1; column++) {
- builder.append(array[row][column] + ", ");
- }
- builder.append(array[row][mNumColumns - 1] + " ]\n");
- }
- return builder.toString();
- }
-
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("DeltaTheta: " + mDeltaTheta + "\n");
- builder.append("DeltaPhi: " + mDeltaPhi + "\n");
- builder.append("CorrectionsArray:\n");
- builder.append(arrayToString(mCorrections));
- builder.append("CorrectionUncertaintiesArray:\n");
- builder.append(arrayToString(mCorrectionUncertainties));
- return builder.toString();
+ return "SphericalCorrections{"
+ + "Corrections=" + Arrays.toString(mCorrections)
+ + ", CorrectionUncertainties=" + Arrays.toString(mCorrectionUncertainties)
+ + ", DeltaTheta=" + mDeltaTheta
+ + ", DeltaPhi=" + mDeltaPhi
+ + '}';
}
}
- @VisibleForTesting
- public GnssAntennaInfo(
+ private GnssAntennaInfo(
double carrierFrequencyMHz,
- @NonNull PhaseCenterOffsetCoordinates phaseCenterOffsetCoordinates,
- @Nullable PhaseCenterVariationCorrections phaseCenterVariationCorrections,
- @Nullable SignalGainCorrections signalGainCorrectionDbi) {
- if (phaseCenterOffsetCoordinates == null) {
+ @NonNull PhaseCenterOffset phaseCenterOffset,
+ @Nullable SphericalCorrections phaseCenterVariationCorrections,
+ @Nullable SphericalCorrections signalGainCorrectionDbi) {
+ if (phaseCenterOffset == null) {
throw new IllegalArgumentException("Phase Center Offset Coordinates cannot be null.");
}
mCarrierFrequencyMHz = carrierFrequencyMHz;
- mPhaseCenterOffsetCoordinates = phaseCenterOffsetCoordinates;
+ mPhaseCenterOffset = phaseCenterOffset;
mPhaseCenterVariationCorrections = phaseCenterVariationCorrections;
mSignalGainCorrections = signalGainCorrectionDbi;
}
+ /**
+ * Builder class for GnssAntennaInfo.
+ */
+ public static class Builder {
+ private double mCarrierFrequencyMHz;
+ private PhaseCenterOffset mPhaseCenterOffset;
+ private SphericalCorrections mPhaseCenterVariationCorrections;
+ private SphericalCorrections mSignalGainCorrections;
+
+ /**
+ * Set antenna carrier frequency (MHz).
+ * @param carrierFrequencyMHz antenna carrier frequency (MHz)
+ * @return Builder builder object
+ */
+ @NonNull
+ public Builder setCarrierFrequencyMHz(@FloatRange(from = 0.0f) double carrierFrequencyMHz) {
+ mCarrierFrequencyMHz = carrierFrequencyMHz;
+ return this;
+ }
+
+ /**
+ * Set antenna phase center offset.
+ * @param phaseCenterOffset phase center offset object
+ * @return Builder builder object
+ */
+ @NonNull
+ public Builder setPhaseCenterOffset(@NonNull PhaseCenterOffset phaseCenterOffset) {
+ mPhaseCenterOffset = Objects.requireNonNull(phaseCenterOffset);
+ return this;
+ }
+
+ /**
+ * Set phase center variation corrections.
+ * @param phaseCenterVariationCorrections phase center variation corrections object
+ * @return Builder builder object
+ */
+ @NonNull
+ public Builder setPhaseCenterVariationCorrections(
+ @Nullable SphericalCorrections phaseCenterVariationCorrections) {
+ mPhaseCenterVariationCorrections = phaseCenterVariationCorrections;
+ return this;
+ }
+
+ /**
+ * Set signal gain corrections.
+ * @param signalGainCorrections signal gain corrections object
+ * @return Builder builder object
+ */
+ @NonNull
+ public Builder setSignalGainCorrections(
+ @Nullable SphericalCorrections signalGainCorrections) {
+ mSignalGainCorrections = signalGainCorrections;
+ return this;
+ }
+
+ /**
+ * Build GnssAntennaInfo object.
+ * @return instance of GnssAntennaInfo
+ */
+ @NonNull
+ public GnssAntennaInfo build() {
+ return new GnssAntennaInfo(mCarrierFrequencyMHz, mPhaseCenterOffset,
+ mPhaseCenterVariationCorrections, mSignalGainCorrections);
+ }
+ }
+
+ @FloatRange(from = 0.0f)
public double getCarrierFrequencyMHz() {
return mCarrierFrequencyMHz;
}
@NonNull
- public PhaseCenterOffsetCoordinates getPhaseCenterOffsetCoordinates() {
- return mPhaseCenterOffsetCoordinates;
+ public PhaseCenterOffset getPhaseCenterOffset() {
+ return mPhaseCenterOffset;
}
@Nullable
- public PhaseCenterVariationCorrections getPhaseCenterVariationCorrections() {
+ public SphericalCorrections getPhaseCenterVariationCorrections() {
return mPhaseCenterVariationCorrections;
}
@Nullable
- public SignalGainCorrections getSignalGainCorrections() {
+ public SphericalCorrections getSignalGainCorrections() {
return mSignalGainCorrections;
}
@@ -600,16 +422,18 @@ public final class GnssAntennaInfo implements Parcelable {
double carrierFrequencyMHz = in.readDouble();
ClassLoader classLoader = getClass().getClassLoader();
- PhaseCenterOffsetCoordinates phaseCenterOffsetCoordinates =
+ PhaseCenterOffset phaseCenterOffset =
in.readParcelable(classLoader);
- PhaseCenterVariationCorrections phaseCenterVariationCorrections =
+ SphericalCorrections phaseCenterVariationCorrections =
in.readParcelable(classLoader);
- SignalGainCorrections signalGainCorrections =
+ SphericalCorrections signalGainCorrections =
in.readParcelable(classLoader);
- return new GnssAntennaInfo(carrierFrequencyMHz,
- phaseCenterOffsetCoordinates,
- phaseCenterVariationCorrections, signalGainCorrections);
+ return new GnssAntennaInfo(
+ carrierFrequencyMHz,
+ phaseCenterOffset,
+ phaseCenterVariationCorrections,
+ signalGainCorrections);
}
@Override
@@ -626,29 +450,18 @@ public final class GnssAntennaInfo implements Parcelable {
@Override
public void writeToParcel(@NonNull Parcel parcel, int flags) {
parcel.writeDouble(mCarrierFrequencyMHz);
-
- // Write Phase Center Offset
- parcel.writeParcelable(mPhaseCenterOffsetCoordinates, flags);
-
- // Write Phase Center Variation Corrections
+ parcel.writeParcelable(mPhaseCenterOffset, flags);
parcel.writeParcelable(mPhaseCenterVariationCorrections, flags);
-
- // Write Signal Gain Corrections
parcel.writeParcelable(mSignalGainCorrections, flags);
}
@Override
public String toString() {
- StringBuilder builder = new StringBuilder("[ GnssAntennaInfo:\n");
- builder.append("CarrierFrequencyMHz: " + mCarrierFrequencyMHz + "\n");
- builder.append(mPhaseCenterOffsetCoordinates.toString());
- builder.append(mPhaseCenterVariationCorrections == null
- ? "PhaseCenterVariationCorrections: null\n"
- : mPhaseCenterVariationCorrections.toString());
- builder.append(mSignalGainCorrections == null
- ? "SignalGainCorrections: null\n"
- : mSignalGainCorrections.toString());
- builder.append("]");
- return builder.toString();
+ return "GnssAntennaInfo{"
+ + "CarrierFrequencyMHz=" + mCarrierFrequencyMHz
+ + ", PhaseCenterOffset=" + mPhaseCenterOffset
+ + ", PhaseCenterVariationCorrections=" + mPhaseCenterVariationCorrections
+ + ", SignalGainCorrections=" + mSignalGainCorrections
+ + '}';
}
}
diff --git a/location/java/android/location/GnssCapabilities.java b/location/java/android/location/GnssCapabilities.java
index 930180c6870f..5734bf2e9af6 100644
--- a/location/java/android/location/GnssCapabilities.java
+++ b/location/java/android/location/GnssCapabilities.java
@@ -16,15 +16,11 @@
package android.location;
-import android.annotation.NonNull;
import android.annotation.SystemApi;
/**
* A container of supported GNSS chipset capabilities.
- *
- * @hide
*/
-@SystemApi
public final class GnssCapabilities {
/**
* Bit mask indicating GNSS chipset supports low power mode.
@@ -105,7 +101,10 @@ public final class GnssCapabilities {
/**
* Returns {@code true} if GNSS chipset supports low power mode, {@code false} otherwise.
+ *
+ * @hide
*/
+ @SystemApi
public boolean hasLowPowerMode() {
return hasCapability(LOW_POWER_MODE);
}
@@ -113,28 +112,40 @@ public final class GnssCapabilities {
/**
* Returns {@code true} if GNSS chipset supports blacklisting satellites, {@code false}
* otherwise.
+ *
+ * @hide
*/
+ @SystemApi
public boolean hasSatelliteBlacklist() {
return hasCapability(SATELLITE_BLACKLIST);
}
/**
* Returns {@code true} if GNSS chipset supports geofencing, {@code false} otherwise.
+ *
+ * @hide
*/
+ @SystemApi
public boolean hasGeofencing() {
return hasCapability(GEOFENCING);
}
/**
* Returns {@code true} if GNSS chipset supports measurements, {@code false} otherwise.
+ *
+ * @hide
*/
+ @SystemApi
public boolean hasMeasurements() {
return hasCapability(MEASUREMENTS);
}
/**
* Returns {@code true} if GNSS chipset supports navigation messages, {@code false} otherwise.
+ *
+ * @hide
*/
+ @SystemApi
public boolean hasNavMessages() {
return hasCapability(NAV_MESSAGES);
}
@@ -142,7 +153,10 @@ public final class GnssCapabilities {
/**
* Returns {@code true} if GNSS chipset supports measurement corrections, {@code false}
* otherwise.
+ *
+ * @hide
*/
+ @SystemApi
public boolean hasMeasurementCorrections() {
return hasCapability(MEASUREMENT_CORRECTIONS);
}
@@ -150,7 +164,10 @@ public final class GnssCapabilities {
/**
* Returns {@code true} if GNSS chipset supports line-of-sight satellite identification
* measurement corrections, {@code false} otherwise.
+ *
+ * @hide
*/
+ @SystemApi
public boolean hasMeasurementCorrectionsLosSats() {
return hasCapability(MEASUREMENT_CORRECTIONS_LOS_SATS);
}
@@ -158,7 +175,10 @@ public final class GnssCapabilities {
/**
* Returns {@code true} if GNSS chipset supports per satellite excess-path-length measurement
* corrections, {@code false} otherwise.
+ *
+ * @hide
*/
+ @SystemApi
public boolean hasMeasurementCorrectionsExcessPathLength() {
return hasCapability(MEASUREMENT_CORRECTIONS_EXCESS_PATH_LENGTH);
}
@@ -166,7 +186,10 @@ public final class GnssCapabilities {
/**
* Returns {@code true} if GNSS chipset supports reflecting planes measurement corrections,
* {@code false} otherwise.
+ *
+ * @hide
*/
+ @SystemApi
public boolean hasMeasurementCorrectionsReflectingPane() {
return hasCapability(MEASUREMENT_CORRECTIONS_REFLECTING_PLANE);
}
@@ -178,28 +201,6 @@ public final class GnssCapabilities {
return hasCapability(ANTENNA_INFO);
}
- @NonNull
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("GnssCapabilities: ( ");
- if (hasLowPowerMode()) sb.append("LOW_POWER_MODE ");
- if (hasSatelliteBlacklist()) sb.append("SATELLITE_BLACKLIST ");
- if (hasGeofencing()) sb.append("GEOFENCING ");
- if (hasGnssAntennaInfo()) sb.append("ANTENNA_INFO ");
- if (hasMeasurements()) sb.append("MEASUREMENTS ");
- if (hasNavMessages()) sb.append("NAV_MESSAGES ");
- if (hasMeasurementCorrections()) sb.append("MEASUREMENT_CORRECTIONS ");
- if (hasMeasurementCorrectionsLosSats()) sb.append("MEASUREMENT_CORRECTIONS_LOS_SATS ");
- if (hasMeasurementCorrectionsExcessPathLength()) {
- sb.append("MEASUREMENT_CORRECTIONS_EXCESS_PATH_LENGTH ");
- }
- if (hasMeasurementCorrectionsReflectingPane()) {
- sb.append("MEASUREMENT_CORRECTIONS_REFLECTING_PLANE ");
- }
- sb.append(")");
- return sb.toString();
- }
-
private boolean hasCapability(long capability) {
return (mGnssCapabilities & capability) == capability;
}
diff --git a/location/java/android/location/IGnssAntennaInfoListener.aidl b/location/java/android/location/IGnssAntennaInfoListener.aidl
index 30bf546759f1..603ed6a2614e 100644
--- a/location/java/android/location/IGnssAntennaInfoListener.aidl
+++ b/location/java/android/location/IGnssAntennaInfoListener.aidl
@@ -23,5 +23,4 @@ import android.location.GnssAntennaInfo;
*/
oneway interface IGnssAntennaInfoListener {
void onGnssAntennaInfoReceived(in List<GnssAntennaInfo> gnssAntennaInfo);
- void onStatusChanged(in int status);
} \ No newline at end of file
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index 03e1c758feb3..19085bff0033 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -1813,13 +1813,7 @@ public class LocationManager {
/**
* Returns the supported capabilities of the GNSS chipset.
- *
- * @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present.
- *
- * @hide
*/
- @SystemApi
- @RequiresPermission(ACCESS_FINE_LOCATION)
public @NonNull GnssCapabilities getGnssCapabilities() {
try {
long gnssCapabilities = mService.getGnssCapabilities(mContext.getPackageName());
@@ -2264,35 +2258,36 @@ public class LocationManager {
}
/**
- * Registers a Gnss Antenna Info callback.
+ * Registers a Gnss Antenna Info listener. Only expect results if
+ * {@link GnssCapabilities#hasGnssAntennaInfo()} shows that antenna info is supported.
*
- * @param executor the executor that the callback runs on.
- * @param callback a {@link GnssAntennaInfo.Callback} object to register.
- * @return {@code true} if the callback was added successfully, {@code false} otherwise.
+ * @param executor the executor that the listener runs on.
+ * @param listener a {@link GnssAntennaInfo.Listener} object to register.
+ * @return {@code true} if the listener was added successfully, {@code false} otherwise.
*
* @throws IllegalArgumentException if executor is null
- * @throws IllegalArgumentException if callback is null
+ * @throws IllegalArgumentException if listener is null
* @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
*/
@RequiresPermission(ACCESS_FINE_LOCATION)
- public boolean registerAntennaInfoCallback(
+ public boolean registerAntennaInfoListener(
@NonNull @CallbackExecutor Executor executor,
- @NonNull GnssAntennaInfo.Callback callback) {
+ @NonNull GnssAntennaInfo.Listener listener) {
try {
- return mGnssAntennaInfoListenerManager.addListener(callback, executor);
+ return mGnssAntennaInfoListenerManager.addListener(listener, executor);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
- * Unregisters a GNSS Antenna Info callback.
+ * Unregisters a GNSS Antenna Info listener.
*
- * @param callback a {@link GnssAntennaInfo.Callback} object to remove.
+ * @param listener a {@link GnssAntennaInfo.Listener} object to remove.
*/
- public void unregisterAntennaInfoCallback(@NonNull GnssAntennaInfo.Callback callback) {
+ public void unregisterAntennaInfoListener(@NonNull GnssAntennaInfo.Listener listener) {
try {
- mGnssAntennaInfoListenerManager.removeListener(callback);
+ mGnssAntennaInfoListenerManager.removeListener(listener);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -3043,7 +3038,7 @@ public class LocationManager {
}
private class GnssAntennaInfoListenerManager extends
- AbstractListenerManager<Void, GnssAntennaInfo.Callback> {
+ AbstractListenerManager<Void, GnssAntennaInfo.Listener> {
@Nullable
private IGnssAntennaInfoListener mListenerTransport;
@@ -3075,11 +3070,6 @@ public class LocationManager {
public void onGnssAntennaInfoReceived(final List<GnssAntennaInfo> gnssAntennaInfos) {
execute((callback) -> callback.onGnssAntennaInfoReceived(gnssAntennaInfos));
}
-
- @Override
- public void onStatusChanged(int status) {
- execute((listener) -> listener.onStatusChanged(status));
- }
}
}