Merge "Fixes to GnssAntennaInfo API"

This commit is contained in:
TreeHugger Robot
2020-02-19 20:34:29 +00:00
committed by Android (Google) Code Review
11 changed files with 380 additions and 608 deletions

View File

@@ -23490,66 +23490,54 @@ package android.location {
}
public final class GnssAntennaInfo implements android.os.Parcelable {
ctor public GnssAntennaInfo(double, @NonNull android.location.GnssAntennaInfo.PhaseCenterOffsetCoordinates, @Nullable android.location.GnssAntennaInfo.PhaseCenterVariationCorrections, @Nullable android.location.GnssAntennaInfo.SignalGainCorrections);
method public int describeContents();
method public double getCarrierFrequencyMHz();
method @NonNull public android.location.GnssAntennaInfo.PhaseCenterOffsetCoordinates getPhaseCenterOffsetCoordinates();
method @Nullable public android.location.GnssAntennaInfo.PhaseCenterVariationCorrections getPhaseCenterVariationCorrections();
method @Nullable public android.location.GnssAntennaInfo.SignalGainCorrections getSignalGainCorrections();
method @FloatRange(from=0.0f) public double getCarrierFrequencyMHz();
method @NonNull public android.location.GnssAntennaInfo.PhaseCenterOffset getPhaseCenterOffset();
method @Nullable public android.location.GnssAntennaInfo.SphericalCorrections getPhaseCenterVariationCorrections();
method @Nullable public android.location.GnssAntennaInfo.SphericalCorrections getSignalGainCorrections();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.location.GnssAntennaInfo> CREATOR;
}
public abstract static class GnssAntennaInfo.Callback {
ctor public GnssAntennaInfo.Callback();
public static class GnssAntennaInfo.Builder {
ctor public GnssAntennaInfo.Builder();
method @NonNull public android.location.GnssAntennaInfo build();
method @NonNull public android.location.GnssAntennaInfo.Builder setCarrierFrequencyMHz(@FloatRange(from=0.0f) double);
method @NonNull public android.location.GnssAntennaInfo.Builder setPhaseCenterOffset(@NonNull android.location.GnssAntennaInfo.PhaseCenterOffset);
method @NonNull public android.location.GnssAntennaInfo.Builder setPhaseCenterVariationCorrections(@Nullable android.location.GnssAntennaInfo.SphericalCorrections);
method @NonNull public android.location.GnssAntennaInfo.Builder setSignalGainCorrections(@Nullable android.location.GnssAntennaInfo.SphericalCorrections);
}
public static interface GnssAntennaInfo.Listener {
method public void onGnssAntennaInfoReceived(@NonNull java.util.List<android.location.GnssAntennaInfo>);
method public void onStatusChanged(int);
field public static final int STATUS_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 final class GnssAntennaInfo.PhaseCenterOffsetCoordinates implements android.os.Parcelable {
ctor public GnssAntennaInfo.PhaseCenterOffsetCoordinates(double, double, double, double, double, double);
public static final class GnssAntennaInfo.PhaseCenterOffset implements android.os.Parcelable {
ctor public GnssAntennaInfo.PhaseCenterOffset(double, double, double, double, double, double);
method public int describeContents();
method public double getXCoordMillimeters();
method public double getXCoordUncertaintyMillimeters();
method public double getYCoordMillimeters();
method public double getYCoordUncertaintyMillimeters();
method public double getZCoordMillimeters();
method public double getZCoordUncertaintyMillimeters();
method @FloatRange public double getXOffsetMm();
method @FloatRange public double getXOffsetUncertaintyMm();
method @FloatRange public double getYOffsetMm();
method @FloatRange public double getYOffsetUncertaintyMm();
method @FloatRange public double getZOffsetMm();
method @FloatRange public double getZOffsetUncertaintyMm();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.location.GnssAntennaInfo.PhaseCenterOffsetCoordinates> CREATOR;
field @NonNull public static final android.os.Parcelable.Creator<android.location.GnssAntennaInfo.PhaseCenterOffset> CREATOR;
}
public static final class GnssAntennaInfo.PhaseCenterVariationCorrections implements android.os.Parcelable {
ctor public GnssAntennaInfo.PhaseCenterVariationCorrections(@NonNull double[][], @NonNull double[][]);
public static final class GnssAntennaInfo.SphericalCorrections implements android.os.Parcelable {
ctor public GnssAntennaInfo.SphericalCorrections(@NonNull double[][], @NonNull double[][]);
method public int describeContents();
method public double getDeltaPhi();
method public double getDeltaTheta();
method public int getNumColumns();
method public int getNumRows();
method public double getPhaseCenterVariationCorrectionMillimetersAt(int, int);
method public double getPhaseCenterVariationCorrectionUncertaintyMillimetersAt(int, int);
method @NonNull public double[][] getRawCorrectionUncertaintiesArray();
method @NonNull public double[][] getRawCorrectionsArray();
method @NonNull public double[][] getCorrectionUncertaintiesArray();
method @NonNull public double[][] getCorrectionsArray();
method @FloatRange(from=0.0f, to=180.0f) public double getDeltaPhi();
method @FloatRange(from=0.0f, to=360.0f) public double getDeltaTheta();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.location.GnssAntennaInfo.PhaseCenterVariationCorrections> CREATOR;
field @NonNull public static final android.os.Parcelable.Creator<android.location.GnssAntennaInfo.SphericalCorrections> CREATOR;
}
public static final class GnssAntennaInfo.SignalGainCorrections implements android.os.Parcelable {
ctor public GnssAntennaInfo.SignalGainCorrections(@NonNull double[][], @NonNull double[][]);
method public int describeContents();
method public double getDeltaPhi();
method public double getDeltaTheta();
method public int getNumColumns();
method public int getNumRows();
method @NonNull public double[][] getRawCorrectionUncertaintiesArray();
method @NonNull public double[][] getRawCorrectionsArray();
method public double getSignalGainCorrectionDbiAt(int, int);
method public double getSignalGainCorrectionUncertaintyDbiAt(int, int);
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.location.GnssAntennaInfo.SignalGainCorrections> CREATOR;
public final class GnssCapabilities {
method public boolean hasGnssAntennaInfo();
}
public final class GnssClock implements android.os.Parcelable {
@@ -23860,6 +23848,7 @@ package android.location {
method @NonNull public java.util.List<java.lang.String> getAllProviders();
method @Nullable public String getBestProvider(@NonNull android.location.Criteria, boolean);
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void getCurrentLocation(@NonNull String, @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.location.Location>);
method @NonNull public android.location.GnssCapabilities getGnssCapabilities();
method @Nullable public String getGnssHardwareModelName();
method public int getGnssYearOfHardware();
method @Deprecated @Nullable @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public android.location.GpsStatus getGpsStatus(@Nullable android.location.GpsStatus);
@@ -23869,7 +23858,7 @@ package android.location {
method @NonNull public java.util.List<java.lang.String> getProviders(@NonNull android.location.Criteria, boolean);
method public boolean isLocationEnabled();
method public boolean isProviderEnabled(@NonNull String);
method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerAntennaInfoCallback(@NonNull java.util.concurrent.Executor, @NonNull android.location.GnssAntennaInfo.Callback);
method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerAntennaInfoListener(@NonNull java.util.concurrent.Executor, @NonNull android.location.GnssAntennaInfo.Listener);
method @Deprecated @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback(@NonNull android.location.GnssMeasurementsEvent.Callback);
method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback(@NonNull android.location.GnssMeasurementsEvent.Callback, @Nullable android.os.Handler);
method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback(@NonNull java.util.concurrent.Executor, @NonNull android.location.GnssMeasurementsEvent.Callback);
@@ -23901,7 +23890,7 @@ package android.location {
method public void setTestProviderEnabled(@NonNull String, boolean);
method public void setTestProviderLocation(@NonNull String, @NonNull android.location.Location);
method @Deprecated public void setTestProviderStatus(@NonNull String, int, @Nullable android.os.Bundle, long);
method public void unregisterAntennaInfoCallback(@NonNull android.location.GnssAntennaInfo.Callback);
method public void unregisterAntennaInfoListener(@NonNull android.location.GnssAntennaInfo.Listener);
method public void unregisterGnssMeasurementsCallback(@NonNull android.location.GnssMeasurementsEvent.Callback);
method public void unregisterGnssNavigationMessageCallback(@NonNull android.location.GnssNavigationMessage.Callback);
method public void unregisterGnssStatusCallback(@NonNull android.location.GnssStatus.Callback);

View File

@@ -3824,7 +3824,6 @@ package android.location {
public final class GnssCapabilities {
method public boolean hasGeofencing();
method public boolean hasGnssAntennaInfo();
method public boolean hasLowPowerMode();
method public boolean hasMeasurementCorrections();
method public boolean hasMeasurementCorrectionsExcessPathLength();
@@ -4164,7 +4163,6 @@ package android.location {
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void getCurrentLocation(@NonNull android.location.LocationRequest, @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.location.Location>);
method @Nullable public String getExtraLocationControllerPackage();
method @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE) public int getGnssBatchSize();
method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public android.location.GnssCapabilities getGnssCapabilities();
method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public void injectGnssMeasurementCorrections(@NonNull android.location.GnssMeasurementCorrections);
method public boolean isExtraLocationControllerPackageEnabled();
method public boolean isLocationEnabledForUser(@NonNull android.os.UserHandle);

View File

@@ -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 {
public interface Listener {
/**
* 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;
/**
* 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;
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;
@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 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<PhaseCenterOffsetCoordinates> CREATOR =
new Creator<PhaseCenterOffsetCoordinates>() {
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,33 +90,39 @@ 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;
@FloatRange()
public double getXOffsetMm() {
return mOffsetXMm;
}
public double getXCoordUncertaintyMillimeters() {
return mPhaseCenterOffsetCoordinateXUncertaintyMillimeters;
@FloatRange()
public double getXOffsetUncertaintyMm() {
return mOffsetXUncertaintyMm;
}
public double getYCoordMillimeters() {
return mPhaseCenterOffsetCoordinateYMillimeters;
@FloatRange()
public double getYOffsetMm() {
return mOffsetYMm;
}
public double getYCoordUncertaintyMillimeters() {
return mPhaseCenterOffsetCoordinateYUncertaintyMillimeters;
@FloatRange()
public double getYOffsetUncertaintyMm() {
return mOffsetYUncertaintyMm;
}
public double getZCoordMillimeters() {
return mPhaseCenterOffsetCoordinateZMillimeters;
@FloatRange()
public double getZOffsetMm() {
return mOffsetZMm;
}
public double getZCoordUncertaintyMillimeters() {
return mPhaseCenterOffsetCoordinateZUncertaintyMillimeters;
@FloatRange()
public double getZOffsetUncertaintyMm() {
return mOffsetZUncertaintyMm;
}
@Override
@@ -167,30 +132,27 @@ public final class GnssAntennaInfo implements Parcelable {
@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);
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("PhaseCenteroffset:\n");
builder.append("X: " + mPhaseCenterOffsetCoordinateXMillimeters + " +/- "
+ mPhaseCenterOffsetCoordinateXUncertaintyMillimeters + "\n");
builder.append("Y: " + mPhaseCenterOffsetCoordinateYMillimeters + " +/- "
+ mPhaseCenterOffsetCoordinateYUncertaintyMillimeters + "\n");
builder.append("Z: " + mPhaseCenterOffsetCoordinateZMillimeters + " +/- "
+ mPhaseCenterOffsetCoordinateZUncertaintyMillimeters + "\n");
return builder.toString();
return "PhaseCenterOffset{"
+ "OffsetXMm=" + mOffsetXMm + " +/-" + mOffsetXUncertaintyMm
+ ", OffsetYMm=" + mOffsetYMm + " +/-" + mOffsetYUncertaintyMm
+ ", OffsetZMm=" + mOffsetZMm + " +/-" + mOffsetZUncertaintyMm
+ '}';
}
}
/**
* Class containing information about the phase center variation (PCV) corrections. The PCV
* correction is added to the phase measurement 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.
*
@@ -203,229 +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 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();
}
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<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;
}
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
super.writeToParcel(dest, flags);
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder("PhaseCenterVariationCorrections:\n");
builder.append(super.toString());
return builder.toString();
}
}
/**
* Class containing information about the signal gain (SG) corrections. The SG
* correction is added to the signal gain 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 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
+ '}';
}
}

View File

@@ -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;
}

View File

@@ -23,5 +23,4 @@ import android.location.GnssAntennaInfo;
*/
oneway interface IGnssAntennaInfoListener {
void onGnssAntennaInfoReceived(in List<GnssAntennaInfo> gnssAntennaInfo);
void onStatusChanged(in int status);
}

View File

@@ -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));
}
}
}

View File

@@ -20,7 +20,6 @@ import android.content.Context;
import android.location.GnssAntennaInfo;
import android.location.IGnssAntennaInfoListener;
import android.os.Handler;
import android.os.RemoteException;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
@@ -100,41 +99,10 @@ public abstract class GnssAntennaInfoProvider
@Override
protected ListenerOperation<IGnssAntennaInfoListener> getHandlerOperation(int result) {
int status;
switch (result) {
case RESULT_SUCCESS:
status = GnssAntennaInfo.Callback.STATUS_READY;
break;
case RESULT_NOT_AVAILABLE:
case RESULT_NOT_SUPPORTED:
case RESULT_INTERNAL_ERROR:
status = GnssAntennaInfo.Callback.STATUS_NOT_SUPPORTED;
break;
case RESULT_GPS_LOCATION_DISABLED:
status = GnssAntennaInfo.Callback.STATUS_LOCATION_DISABLED;
break;
case RESULT_UNKNOWN:
return null;
default:
Log.v(TAG, "Unhandled addListener result: " + result);
return null;
}
return new StatusChangedOperation(status);
}
private static class StatusChangedOperation
implements ListenerOperation<IGnssAntennaInfoListener> {
private final int mStatus;
StatusChangedOperation(int status) {
mStatus = status;
}
@Override
public void execute(IGnssAntennaInfoListener listener,
CallerIdentity callerIdentity) throws RemoteException {
listener.onStatusChanged(mStatus);
}
return (IGnssAntennaInfoListener listener,
CallerIdentity callerIdentity) -> {
// Do nothing, as GnssAntennaInfo.Callback does not have an onStatusChanged method.
};
}
/** Handle Gnss Antenna Info report. */

View File

@@ -2244,6 +2244,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
if (hasCapability(GPS_CAPABILITY_MEASUREMENT_CORRECTIONS)) {
s.append("MEASUREMENT_CORRECTIONS ");
}
if (hasCapability(GPS_CAPABILITY_ANTENNA_INFO)) s.append("ANTENNA_INFO ");
s.append(")\n");
if (hasCapability(GPS_CAPABILITY_MEASUREMENT_CORRECTIONS)) {
s.append("SubHal=MEASUREMENT_CORRECTIONS[");

View File

@@ -216,9 +216,6 @@ public class GnssManagerService {
* {@link android.location.GnssCapabilities}.
*/
public long getGnssCapabilities(String packageName) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, null);
mContext.enforceCallingPermission(Manifest.permission.ACCESS_FINE_LOCATION, null);
if (!checkLocationAppOp(packageName)) {
return GnssCapabilities.INVALID_CAPABILITIES;
}

View File

@@ -55,10 +55,9 @@ static jclass class_location;
static jclass class_gnssNavigationMessage;
static jclass class_gnssClock;
static jclass class_gnssConfiguration_halInterfaceVersion;
static jclass class_gnssAntennaInfo;
static jclass class_phaseCenterOffsetCoordinates;
static jclass class_phaseCenterVariationCorrections;
static jclass class_signalGainCorrections;
static jclass class_gnssAntennaInfoBuilder;
static jclass class_phaseCenterOffset;
static jclass class_sphericalCorrections;
static jclass class_arrayList;
static jclass class_doubleArray;
@@ -122,12 +121,16 @@ static jmethodID method_gnssNavigationMessageCtor;
static jmethodID method_gnssClockCtor;
static jmethodID method_gnssMeasurementCtor;
static jmethodID method_halInterfaceVersionCtor;
static jmethodID method_gnssAntennaInfoCtor;
static jmethodID method_phaseCenterOffsetCoordinatesCtor;
static jmethodID method_phaseCenterVariationCorrectionsCtor;
static jmethodID method_signalGainCorrectionsCtor;
static jmethodID method_gnssAntennaInfoBuilderCtor;
static jmethodID method_phaseCenterOffsetCtor;
static jmethodID method_sphericalCorrectionsCtor;
static jmethodID method_arrayListCtor;
static jmethodID method_arrayListAdd;
static jmethodID method_gnssAntennaInfoBuilderSetCarrierFrequencyMHz;
static jmethodID method_gnssAntennaInfoBuilderSetPhaseCenterOffset;
static jmethodID method_gnssAntennaInfoBuilderSetPhaseCenterVariationCorrections;
static jmethodID method_gnssAntennaInfoBuilderSetSignalGainCorrections;
static jmethodID method_gnssAntennaInfoBuilderBuild;
/*
* Save a pointer to JavaVm to attach/detach threads executing
@@ -1088,7 +1091,7 @@ private:
const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos);
jobject translateSingleGnssAntennaInfo(
JNIEnv* env, const IGnssAntennaInfoCallback::GnssAntennaInfo& gnssAntennaInfo);
jobject translatePhaseCenterOffsetCoordinates(
jobject translatePhaseCenterOffset(
JNIEnv* env, const IGnssAntennaInfoCallback::GnssAntennaInfo& gnssAntennaInfo);
jobject translatePhaseCenterVariationCorrections(
JNIEnv* env, const IGnssAntennaInfoCallback::GnssAntennaInfo& gnssAntennaInfo);
@@ -1150,11 +1153,10 @@ jobject GnssAntennaInfoCallback::translateAllGnssAntennaInfos(
return arrayList;
}
jobject GnssAntennaInfoCallback::translatePhaseCenterOffsetCoordinates(
jobject GnssAntennaInfoCallback::translatePhaseCenterOffset(
JNIEnv* env, const IGnssAntennaInfoCallback::GnssAntennaInfo& gnssAntennaInfo) {
jobject phaseCenterOffsetCoordinates =
env->NewObject(class_phaseCenterOffsetCoordinates,
method_phaseCenterOffsetCoordinatesCtor,
jobject phaseCenterOffset =
env->NewObject(class_phaseCenterOffset, method_phaseCenterOffsetCtor,
gnssAntennaInfo.phaseCenterOffsetCoordinateMillimeters.x,
gnssAntennaInfo.phaseCenterOffsetCoordinateMillimeters.xUncertainty,
gnssAntennaInfo.phaseCenterOffsetCoordinateMillimeters.y,
@@ -1162,7 +1164,7 @@ jobject GnssAntennaInfoCallback::translatePhaseCenterOffsetCoordinates(
gnssAntennaInfo.phaseCenterOffsetCoordinateMillimeters.z,
gnssAntennaInfo.phaseCenterOffsetCoordinateMillimeters.zUncertainty);
return phaseCenterOffsetCoordinates;
return phaseCenterOffset;
}
jobject GnssAntennaInfoCallback::translatePhaseCenterVariationCorrections(
@@ -1185,8 +1187,7 @@ jobject GnssAntennaInfoCallback::translatePhaseCenterVariationCorrections(
}
jobject phaseCenterVariationCorrections =
env->NewObject(class_phaseCenterVariationCorrections,
method_phaseCenterVariationCorrectionsCtor,
env->NewObject(class_sphericalCorrections, method_sphericalCorrectionsCtor,
phaseCenterVariationCorrectionsArray,
phaseCenterVariationCorrectionsUncertaintiesArray);
@@ -1212,7 +1213,7 @@ jobject GnssAntennaInfoCallback::translateSignalGainCorrections(
}
jobject signalGainCorrections =
env->NewObject(class_signalGainCorrections, method_signalGainCorrectionsCtor,
env->NewObject(class_sphericalCorrections, method_sphericalCorrectionsCtor,
signalGainCorrectionsArray, signalGainCorrectionsUncertaintiesArray);
env->DeleteLocalRef(signalGainCorrectionsArray);
@@ -1223,8 +1224,7 @@ jobject GnssAntennaInfoCallback::translateSignalGainCorrections(
jobject GnssAntennaInfoCallback::translateSingleGnssAntennaInfo(
JNIEnv* env, const IGnssAntennaInfoCallback::GnssAntennaInfo& gnssAntennaInfo) {
jobject phaseCenterOffsetCoordinates =
translatePhaseCenterOffsetCoordinates(env, gnssAntennaInfo);
jobject phaseCenterOffset = translatePhaseCenterOffset(env, gnssAntennaInfo);
// Nullable
jobject phaseCenterVariationCorrections =
@@ -1233,13 +1233,29 @@ jobject GnssAntennaInfoCallback::translateSingleGnssAntennaInfo(
// Nullable
jobject signalGainCorrections = translateSignalGainCorrections(env, gnssAntennaInfo);
// Get builder
jobject gnssAntennaInfoBuilderObject =
env->NewObject(class_gnssAntennaInfoBuilder, method_gnssAntennaInfoBuilderCtor);
// Set fields
env->CallObjectMethod(gnssAntennaInfoBuilderObject,
method_gnssAntennaInfoBuilderSetCarrierFrequencyMHz,
gnssAntennaInfo.carrierFrequencyMHz);
env->CallObjectMethod(gnssAntennaInfoBuilderObject,
method_gnssAntennaInfoBuilderSetPhaseCenterOffset, phaseCenterOffset);
env->CallObjectMethod(gnssAntennaInfoBuilderObject,
method_gnssAntennaInfoBuilderSetPhaseCenterVariationCorrections,
phaseCenterVariationCorrections);
env->CallObjectMethod(gnssAntennaInfoBuilderObject,
method_gnssAntennaInfoBuilderSetSignalGainCorrections,
signalGainCorrections);
// build
jobject gnssAntennaInfoObject =
env->NewObject(class_gnssAntennaInfo, method_gnssAntennaInfoCtor,
gnssAntennaInfo.carrierFrequencyMHz, phaseCenterOffsetCoordinates,
phaseCenterVariationCorrections, signalGainCorrections);
env->CallObjectMethod(gnssAntennaInfoBuilderObject, method_gnssAntennaInfoBuilderBuild);
// Delete Local Refs
env->DeleteLocalRef(phaseCenterOffsetCoordinates);
env->DeleteLocalRef(phaseCenterOffset);
env->DeleteLocalRef(phaseCenterVariationCorrections);
env->DeleteLocalRef(signalGainCorrections);
@@ -2004,35 +2020,38 @@ static void android_location_GnssLocationProvider_class_init_native(JNIEnv* env,
class_gnssMeasurement = (jclass) env->NewGlobalRef(gnssMeasurementClass);
method_gnssMeasurementCtor = env->GetMethodID(class_gnssMeasurement, "<init>", "()V");
jclass gnssAntennaInfoClass = env->FindClass("android/location/GnssAntennaInfo");
class_gnssAntennaInfo = (jclass)env->NewGlobalRef(gnssAntennaInfoClass);
method_gnssAntennaInfoCtor =
env->GetMethodID(class_gnssAntennaInfo, "<init>",
"(D"
"Landroid/location/GnssAntennaInfo$PhaseCenterOffsetCoordinates;"
"Landroid/location/GnssAntennaInfo$PhaseCenterVariationCorrections;"
"Landroid/location/GnssAntennaInfo$SignalGainCorrections;"
")V");
jclass gnssAntennaInfoBuilder = env->FindClass("android/location/GnssAntennaInfo$Builder");
class_gnssAntennaInfoBuilder = (jclass)env->NewGlobalRef(gnssAntennaInfoBuilder);
method_gnssAntennaInfoBuilderCtor =
env->GetMethodID(class_gnssAntennaInfoBuilder, "<init>", "()V");
method_gnssAntennaInfoBuilderSetCarrierFrequencyMHz =
env->GetMethodID(class_gnssAntennaInfoBuilder, "setCarrierFrequencyMHz",
"(D)Landroid/location/GnssAntennaInfo$Builder;");
method_gnssAntennaInfoBuilderSetPhaseCenterOffset =
env->GetMethodID(class_gnssAntennaInfoBuilder, "setPhaseCenterOffset",
"(Landroid/location/GnssAntennaInfo$PhaseCenterOffset;)"
"Landroid/location/GnssAntennaInfo$Builder;");
method_gnssAntennaInfoBuilderSetPhaseCenterVariationCorrections =
env->GetMethodID(class_gnssAntennaInfoBuilder, "setPhaseCenterVariationCorrections",
"(Landroid/location/GnssAntennaInfo$SphericalCorrections;)"
"Landroid/location/GnssAntennaInfo$Builder;");
method_gnssAntennaInfoBuilderSetSignalGainCorrections =
env->GetMethodID(class_gnssAntennaInfoBuilder, "setSignalGainCorrections",
"(Landroid/location/GnssAntennaInfo$SphericalCorrections;)"
"Landroid/location/GnssAntennaInfo$Builder;");
method_gnssAntennaInfoBuilderBuild = env->GetMethodID(class_gnssAntennaInfoBuilder, "build",
"()Landroid/location/GnssAntennaInfo;");
jclass phaseCenterOffsetCoordinatesClass =
env->FindClass("android/location/GnssAntennaInfo$PhaseCenterOffsetCoordinates");
class_phaseCenterOffsetCoordinates =
(jclass)env->NewGlobalRef(phaseCenterOffsetCoordinatesClass);
method_phaseCenterOffsetCoordinatesCtor =
env->GetMethodID(class_phaseCenterOffsetCoordinates, "<init>", "(DDDDDD)V");
jclass phaseCenterOffsetClass =
env->FindClass("android/location/GnssAntennaInfo$PhaseCenterOffset");
class_phaseCenterOffset = (jclass)env->NewGlobalRef(phaseCenterOffsetClass);
method_phaseCenterOffsetCtor = env->GetMethodID(class_phaseCenterOffset, "<init>", "(DDDDDD)V");
jclass phaseCenterVariationCorrectionsClass =
env->FindClass("android/location/GnssAntennaInfo$PhaseCenterVariationCorrections");
class_phaseCenterVariationCorrections =
(jclass)env->NewGlobalRef(phaseCenterVariationCorrectionsClass);
method_phaseCenterVariationCorrectionsCtor =
env->GetMethodID(class_phaseCenterVariationCorrections, "<init>", "([[D[[D)V");
jclass signalGainCorrectionsClass =
env->FindClass("android/location/GnssAntennaInfo$SignalGainCorrections");
class_signalGainCorrections = (jclass)env->NewGlobalRef(signalGainCorrectionsClass);
method_signalGainCorrectionsCtor =
env->GetMethodID(class_signalGainCorrections, "<init>", "([[D[[D)V");
jclass sphericalCorrectionsClass =
env->FindClass("android/location/GnssAntennaInfo$SphericalCorrections");
class_sphericalCorrections = (jclass)env->NewGlobalRef(sphericalCorrectionsClass);
method_sphericalCorrectionsCtor =
env->GetMethodID(class_sphericalCorrections, "<init>", "([[D[[D)V");
jclass locationClass = env->FindClass("android/location/Location");
class_location = (jclass) env->NewGlobalRef(locationClass);

View File

@@ -38,6 +38,7 @@ import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.GnssAntennaInfo;
import android.location.GnssAntennaInfo.SphericalCorrections;
import android.location.GnssClock;
import android.location.GnssMeasurementCorrections;
import android.location.GnssMeasurementsEvent;
@@ -245,8 +246,8 @@ public class GnssManagerServiceTest {
private static List<GnssAntennaInfo> createDummyGnssAntennaInfos() {
double carrierFrequencyMHz = 13758.0;
GnssAntennaInfo.PhaseCenterOffsetCoordinates phaseCenterOffsetCoordinates = new
GnssAntennaInfo.PhaseCenterOffsetCoordinates(
GnssAntennaInfo.PhaseCenterOffset phaseCenterOffset = new
GnssAntennaInfo.PhaseCenterOffset(
4.3d,
1.4d,
2.10d,
@@ -256,22 +257,26 @@ public class GnssManagerServiceTest {
double[][] phaseCenterVariationCorrectionsMillimeters = new double[10][10];
double[][] phaseCenterVariationCorrectionsUncertaintyMillimeters = new double[10][10];
GnssAntennaInfo.PhaseCenterVariationCorrections
SphericalCorrections
phaseCenterVariationCorrections =
new GnssAntennaInfo.PhaseCenterVariationCorrections(
new SphericalCorrections(
phaseCenterVariationCorrectionsMillimeters,
phaseCenterVariationCorrectionsUncertaintyMillimeters);
double[][] signalGainCorrectionsDbi = new double[10][10];
double[][] signalGainCorrectionsUncertaintyDbi = new double[10][10];
GnssAntennaInfo.SignalGainCorrections signalGainCorrections = new
GnssAntennaInfo.SignalGainCorrections(
SphericalCorrections signalGainCorrections = new
SphericalCorrections(
signalGainCorrectionsDbi,
signalGainCorrectionsUncertaintyDbi);
List<GnssAntennaInfo> gnssAntennaInfos = new ArrayList();
gnssAntennaInfos.add(new GnssAntennaInfo(carrierFrequencyMHz, phaseCenterOffsetCoordinates,
phaseCenterVariationCorrections, signalGainCorrections));
gnssAntennaInfos.add(new GnssAntennaInfo.Builder()
.setCarrierFrequencyMHz(carrierFrequencyMHz)
.setPhaseCenterOffset(phaseCenterOffset)
.setPhaseCenterVariationCorrections(phaseCenterVariationCorrections)
.setSignalGainCorrections(signalGainCorrections)
.build());
return gnssAntennaInfos;
}
@@ -387,14 +392,6 @@ public class GnssManagerServiceTest {
gnssHardwareModelName);
}
@Test
public void getGnssCapabilitiesWithoutPermissionsTest() {
disableLocationPermissions();
assertThrows(SecurityException.class,
() -> mGnssManagerService.getGnssCapabilities("com.android.server"));
}
@Test
public void getGnssCapabilitiesWithPermissionsTest() {
final long mGnssCapabilities = 23132L;