Merge "Add GNSS capabilities and antenna broadcasts"

This commit is contained in:
TreeHugger Robot
2021-01-07 23:05:01 +00:00
committed by Android (Google) Code Review
19 changed files with 462 additions and 337 deletions

View File

@@ -18942,7 +18942,9 @@ package android.location {
}
public static class GnssAntennaInfo.Builder {
ctor public GnssAntennaInfo.Builder();
ctor @Deprecated public GnssAntennaInfo.Builder();
ctor public GnssAntennaInfo.Builder(double, @NonNull android.location.GnssAntennaInfo.PhaseCenterOffset);
ctor public GnssAntennaInfo.Builder(@NonNull android.location.GnssAntennaInfo);
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);
@@ -18950,8 +18952,8 @@ package android.location {
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>);
@Deprecated public static interface GnssAntennaInfo.Listener {
method @Deprecated public void onGnssAntennaInfoReceived(@NonNull java.util.List<android.location.GnssAntennaInfo>);
}
public static final class GnssAntennaInfo.PhaseCenterOffset implements android.os.Parcelable {
@@ -19124,11 +19126,11 @@ package android.location {
public abstract static class GnssMeasurementsEvent.Callback {
ctor public GnssMeasurementsEvent.Callback();
method public void onGnssMeasurementsReceived(android.location.GnssMeasurementsEvent);
method public void onStatusChanged(int);
field public static final int STATUS_LOCATION_DISABLED = 2; // 0x2
field public static final int STATUS_NOT_ALLOWED = 3; // 0x3
field public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
field public static final int STATUS_READY = 1; // 0x1
method @Deprecated public void onStatusChanged(int);
field @Deprecated public static final int STATUS_LOCATION_DISABLED = 2; // 0x2
field @Deprecated public static final int STATUS_NOT_ALLOWED = 3; // 0x3
field @Deprecated public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
field @Deprecated public static final int STATUS_READY = 1; // 0x1
}
public final class GnssNavigationMessage implements android.os.Parcelable {
@@ -19164,10 +19166,10 @@ package android.location {
public abstract static class GnssNavigationMessage.Callback {
ctor public GnssNavigationMessage.Callback();
method public void onGnssNavigationMessageReceived(android.location.GnssNavigationMessage);
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
method @Deprecated public void onStatusChanged(int);
field @Deprecated public static final int STATUS_LOCATION_DISABLED = 2; // 0x2
field @Deprecated public static final int STATUS_NOT_SUPPORTED = 0; // 0x0
field @Deprecated public static final int STATUS_READY = 1; // 0x1
}
public final class GnssStatus implements android.os.Parcelable {
@@ -19325,6 +19327,7 @@ package android.location {
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 @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void getCurrentLocation(@NonNull String, @NonNull android.location.LocationRequest, @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.location.Location>);
method @Nullable public java.util.List<android.location.GnssAntennaInfo> getGnssAntennaInfos();
method @NonNull public android.location.GnssCapabilities getGnssCapabilities();
method @Nullable public String getGnssHardwareModelName();
method public int getGnssYearOfHardware();
@@ -19337,7 +19340,7 @@ package android.location {
method public boolean hasProvider(@NonNull String);
method public boolean isLocationEnabled();
method public boolean isProviderEnabled(@NonNull String);
method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerAntennaInfoListener(@NonNull java.util.concurrent.Executor, @NonNull android.location.GnssAntennaInfo.Listener);
method @Deprecated 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);
@@ -19374,10 +19377,14 @@ 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 unregisterAntennaInfoListener(@NonNull android.location.GnssAntennaInfo.Listener);
method @Deprecated 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);
field public static final String ACTION_GNSS_ANTENNA_INFOS_CHANGED = "android.location.action.GNSS_ANTENNA_INFOS_CHANGED";
field public static final String ACTION_GNSS_CAPABILITIES_CHANGED = "android.location.action.GNSS_CAPABILITIES_CHANGED";
field public static final String EXTRA_GNSS_ANTENNA_INFOS = "android.location.extra.GNSS_ANTENNA_INFOS";
field public static final String EXTRA_GNSS_CAPABILITIES = "android.location.extra.GNSS_CAPABILITIES";
field public static final String EXTRA_LOCATION_ENABLED = "android.location.extra.LOCATION_ENABLED";
field public static final String EXTRA_PROVIDER_ENABLED = "android.location.extra.PROVIDER_ENABLED";
field public static final String EXTRA_PROVIDER_NAME = "android.location.extra.PROVIDER_NAME";

View File

@@ -34,17 +34,19 @@ import java.util.Objects;
public final class GnssAntennaInfo implements Parcelable {
private final double mCarrierFrequencyMHz;
private final PhaseCenterOffset mPhaseCenterOffset;
private final SphericalCorrections mPhaseCenterVariationCorrections;
private final SphericalCorrections mSignalGainCorrections;
private final @Nullable SphericalCorrections mPhaseCenterVariationCorrections;
private final @Nullable SphericalCorrections mSignalGainCorrections;
/**
* Used for receiving GNSS antenna info from the GNSS engine. You can implement this interface
* and call {@link LocationManager#registerAntennaInfoListener};
* Used for receiving GNSS antenna info from the GNSS engine.
*
* @deprecated Prefer to use a broadcast receiver for
* {@link LocationManager#ACTION_GNSS_ANTENNA_INFOS_CHANGED}.
*/
@Deprecated
public interface Listener {
/**
* 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).
* Invoked on a change to GNSS antenna info.
*/
void onGnssAntennaInfoReceived(@NonNull List<GnssAntennaInfo> gnssAntennaInfos);
}
@@ -172,6 +174,28 @@ public final class GnssAntennaInfo implements Parcelable {
+ ", OffsetZMm=" + mOffsetZMm + " +/-" + mOffsetZUncertaintyMm
+ '}';
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof PhaseCenterOffset)) {
return false;
}
PhaseCenterOffset that = (PhaseCenterOffset) o;
return Double.compare(that.mOffsetXMm, mOffsetXMm) == 0
&& Double.compare(that.mOffsetXUncertaintyMm, mOffsetXUncertaintyMm) == 0
&& Double.compare(that.mOffsetYMm, mOffsetYMm) == 0
&& Double.compare(that.mOffsetYUncertaintyMm, mOffsetYUncertaintyMm) == 0
&& Double.compare(that.mOffsetZMm, mOffsetZMm) == 0
&& Double.compare(that.mOffsetZUncertaintyMm, mOffsetZUncertaintyMm) == 0;
}
@Override
public int hashCode() {
return Objects.hash(mOffsetXMm, mOffsetYMm, mOffsetZMm);
}
}
/**
@@ -190,38 +214,34 @@ public final class GnssAntennaInfo implements Parcelable {
* i.e., deltaPhi = 180 / (number of columns - 1).
*/
public static final class SphericalCorrections implements Parcelable {
private final double[][] mCorrections;
private final double[][] mCorrectionUncertainties;
private final double mDeltaTheta;
private final double mDeltaPhi;
private final int mNumRows;
private final int mNumColumns;
private final double[][] mCorrections;
private final double[][] mCorrectionUncertainties;
public SphericalCorrections(@NonNull double[][] corrections,
@NonNull double[][] correctionUncertainties) {
if (corrections.length != correctionUncertainties.length
|| corrections[0].length != correctionUncertainties[0].length) {
throw new IllegalArgumentException("Correction and correction uncertainty arrays "
+ "must have the same dimensions.");
if (corrections.length != correctionUncertainties.length || corrections.length < 1) {
throw new IllegalArgumentException("correction and uncertainty arrays must have "
+ "the same (non-zero) dimensions");
}
mNumRows = corrections.length;
if (mNumRows < 1) {
throw new IllegalArgumentException("Arrays must have at least one row.");
}
mNumColumns = corrections[0].length;
if (mNumColumns < 2) {
throw new IllegalArgumentException("Arrays must have at least two columns.");
for (int i = 0; i < corrections.length; i++) {
if (corrections[i].length != mNumColumns
|| correctionUncertainties[i].length != mNumColumns || mNumColumns < 2) {
throw new IllegalArgumentException("correction and uncertainty arrays must all "
+ " have the same (greater than 2) number of columns");
}
}
mCorrections = corrections;
mCorrectionUncertainties = correctionUncertainties;
mDeltaTheta = 360.0d / mNumRows;
mDeltaPhi = 180.0d / (mNumColumns - 1);
}
SphericalCorrections(Parcel in) {
private SphericalCorrections(Parcel in) {
int numRows = in.readInt();
int numColumns = in.readInt();
@@ -231,19 +251,16 @@ public final class GnssAntennaInfo implements Parcelable {
new double[numRows][numColumns];
for (int row = 0; row < numRows; row++) {
in.readDoubleArray(corrections[row]);
}
for (int row = 0; row < numRows; row++) {
in.readDoubleArray(correctionUncertainties[row]);
for (int col = 0; col < numColumns; col++) {
corrections[row][col] = in.readDouble();
correctionUncertainties[row][col] = in.readDouble();
}
}
mNumRows = numRows;
mNumColumns = numColumns;
mCorrections = corrections;
mCorrectionUncertainties = correctionUncertainties;
mDeltaTheta = 360.0d / mNumRows;
mDeltaPhi = 180.0d / (mNumColumns - 1);
}
/**
@@ -286,7 +303,7 @@ public final class GnssAntennaInfo implements Parcelable {
*/
@FloatRange(from = 0.0f, to = 360.0f)
public double getDeltaTheta() {
return mDeltaTheta;
return 360.0D / mNumRows;
}
/**
@@ -294,7 +311,7 @@ public final class GnssAntennaInfo implements Parcelable {
*/
@FloatRange(from = 0.0f, to = 180.0f)
public double getDeltaPhi() {
return mDeltaPhi;
return 180.0D / (mNumColumns - 1);
}
@@ -320,11 +337,11 @@ public final class GnssAntennaInfo implements Parcelable {
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(mNumRows);
dest.writeInt(mNumColumns);
for (double[] row : mCorrections) {
dest.writeDoubleArray(row);
}
for (double[] row : mCorrectionUncertainties) {
dest.writeDoubleArray(row);
for (int row = 0; row < mNumRows; row++) {
for (int col = 0; col < mNumColumns; col++) {
dest.writeDouble(mCorrections[row][col]);
dest.writeDouble(mCorrectionUncertainties[row][col]);
}
}
}
@@ -333,22 +350,41 @@ public final class GnssAntennaInfo implements Parcelable {
return "SphericalCorrections{"
+ "Corrections=" + Arrays.toString(mCorrections)
+ ", CorrectionUncertainties=" + Arrays.toString(mCorrectionUncertainties)
+ ", DeltaTheta=" + mDeltaTheta
+ ", DeltaPhi=" + mDeltaPhi
+ ", DeltaTheta=" + getDeltaTheta()
+ ", DeltaPhi=" + getDeltaPhi()
+ '}';
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof SphericalCorrections)) {
return false;
}
SphericalCorrections that = (SphericalCorrections) o;
return mNumRows == that.mNumRows
&& mNumColumns == that.mNumColumns
&& Arrays.deepEquals(mCorrections, that.mCorrections)
&& Arrays.deepEquals(mCorrectionUncertainties, that.mCorrectionUncertainties);
}
@Override
public int hashCode() {
int result = Arrays.deepHashCode(mCorrections);
result = 31 * result + Arrays.deepHashCode(mCorrectionUncertainties);
return result;
}
}
private GnssAntennaInfo(
double carrierFrequencyMHz,
@NonNull PhaseCenterOffset phaseCenterOffset,
PhaseCenterOffset phaseCenterOffset,
@Nullable SphericalCorrections phaseCenterVariationCorrections,
@Nullable SphericalCorrections signalGainCorrectionDbi) {
if (phaseCenterOffset == null) {
throw new IllegalArgumentException("Phase Center Offset Coordinates cannot be null.");
}
mCarrierFrequencyMHz = carrierFrequencyMHz;
mPhaseCenterOffset = phaseCenterOffset;
mPhaseCenterOffset = Objects.requireNonNull(phaseCenterOffset);
mPhaseCenterVariationCorrections = phaseCenterVariationCorrections;
mSignalGainCorrections = signalGainCorrectionDbi;
}
@@ -359,8 +395,28 @@ public final class GnssAntennaInfo implements Parcelable {
public static class Builder {
private double mCarrierFrequencyMHz;
private PhaseCenterOffset mPhaseCenterOffset;
private SphericalCorrections mPhaseCenterVariationCorrections;
private SphericalCorrections mSignalGainCorrections;
private @Nullable SphericalCorrections mPhaseCenterVariationCorrections;
private @Nullable SphericalCorrections mSignalGainCorrections;
/**
* @deprecated Prefer {@link #Builder(double, PhaseCenterOffset)}.
*/
@Deprecated
public Builder() {
this(0, new PhaseCenterOffset(0, 0, 0, 0, 0, 0));
}
public Builder(double carrierFrequencyMHz, @NonNull PhaseCenterOffset phaseCenterOffset) {
mCarrierFrequencyMHz = carrierFrequencyMHz;
mPhaseCenterOffset = Objects.requireNonNull(phaseCenterOffset);
}
public Builder(@NonNull GnssAntennaInfo antennaInfo) {
mCarrierFrequencyMHz = antennaInfo.mCarrierFrequencyMHz;
mPhaseCenterOffset = antennaInfo.mPhaseCenterOffset;
mPhaseCenterVariationCorrections = antennaInfo.mPhaseCenterVariationCorrections;
mSignalGainCorrections = antennaInfo.mSignalGainCorrections;
}
/**
* Set antenna carrier frequency (MHz).
@@ -462,32 +518,29 @@ public final class GnssAntennaInfo implements Parcelable {
return mSignalGainCorrections;
}
public static final @android.annotation.NonNull Creator<GnssAntennaInfo> CREATOR =
new Creator<GnssAntennaInfo>() {
@Override
public GnssAntennaInfo createFromParcel(Parcel in) {
double carrierFrequencyMHz = in.readDouble();
public static final @NonNull Creator<GnssAntennaInfo> CREATOR = new Creator<GnssAntennaInfo>() {
@Override
public GnssAntennaInfo createFromParcel(Parcel in) {
double carrierFrequencyMHz = in.readDouble();
PhaseCenterOffset phaseCenterOffset =
in.readTypedObject(PhaseCenterOffset.CREATOR);
SphericalCorrections phaseCenterVariationCorrections =
in.readTypedObject(SphericalCorrections.CREATOR);
SphericalCorrections signalGainCorrections =
in.readTypedObject(SphericalCorrections.CREATOR);
ClassLoader classLoader = getClass().getClassLoader();
PhaseCenterOffset phaseCenterOffset =
in.readParcelable(classLoader);
SphericalCorrections phaseCenterVariationCorrections =
in.readParcelable(classLoader);
SphericalCorrections signalGainCorrections =
in.readParcelable(classLoader);
return new GnssAntennaInfo(
carrierFrequencyMHz,
phaseCenterOffset,
phaseCenterVariationCorrections,
signalGainCorrections);
}
return new GnssAntennaInfo(
carrierFrequencyMHz,
phaseCenterOffset,
phaseCenterVariationCorrections,
signalGainCorrections);
}
@Override
public GnssAntennaInfo[] newArray(int size) {
return new GnssAntennaInfo[size];
}
};
@Override
public GnssAntennaInfo[] newArray(int size) {
return new GnssAntennaInfo[size];
}
};
@Override
public int describeContents() {
@@ -497,9 +550,9 @@ public final class GnssAntennaInfo implements Parcelable {
@Override
public void writeToParcel(@NonNull Parcel parcel, int flags) {
parcel.writeDouble(mCarrierFrequencyMHz);
parcel.writeParcelable(mPhaseCenterOffset, flags);
parcel.writeParcelable(mPhaseCenterVariationCorrections, flags);
parcel.writeParcelable(mSignalGainCorrections, flags);
parcel.writeTypedObject(mPhaseCenterOffset, flags);
parcel.writeTypedObject(mPhaseCenterVariationCorrections, flags);
parcel.writeTypedObject(mSignalGainCorrections, flags);
}
@Override
@@ -511,4 +564,26 @@ public final class GnssAntennaInfo implements Parcelable {
+ ", SignalGainCorrections=" + mSignalGainCorrections
+ '}';
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof GnssAntennaInfo)) {
return false;
}
GnssAntennaInfo that = (GnssAntennaInfo) o;
return Double.compare(that.mCarrierFrequencyMHz, mCarrierFrequencyMHz) == 0
&& mPhaseCenterOffset.equals(that.mPhaseCenterOffset)
&& Objects.equals(mPhaseCenterVariationCorrections,
that.mPhaseCenterVariationCorrections)
&& Objects.equals(mSignalGainCorrections, that.mSignalGainCorrections);
}
@Override
public int hashCode() {
return Objects.hash(mCarrierFrequencyMHz, mPhaseCenterOffset,
mPhaseCenterVariationCorrections, mSignalGainCorrections);
}
}

View File

@@ -16,9 +16,9 @@
package android.location;
import android.annotation.TestApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.TestApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -46,8 +46,10 @@ public final class GnssMeasurementsEvent implements Parcelable {
public static abstract class Callback {
/**
* The status of the GNSS measurements event.
* @deprecated Do not use.
* @hide
*/
@Deprecated
@Retention(RetentionPolicy.SOURCE)
@IntDef({STATUS_NOT_SUPPORTED, STATUS_READY, STATUS_LOCATION_DISABLED, STATUS_NOT_ALLOWED})
public @interface GnssMeasurementsStatus {}
@@ -56,19 +58,28 @@ public final class GnssMeasurementsEvent implements Parcelable {
* The system does not support tracking of GNSS Measurements.
*
* <p>This status will not change in the future.
*
* @deprecated Do not use.
*/
@Deprecated
public static final int STATUS_NOT_SUPPORTED = 0;
/**
* GNSS Measurements are successfully being tracked, it will receive updates once they are
* available.
*
* @deprecated Do not use.
*/
@Deprecated
public static final int STATUS_READY = 1;
/**
* GPS provider or Location is disabled, updates will not be received until they are
* enabled.
*
* @deprecated Do not use.
*/
@Deprecated
public static final int STATUS_LOCATION_DISABLED = 2;
/**
@@ -81,7 +92,10 @@ public final class GnssMeasurementsEvent implements Parcelable {
*
* <p>If such a status is received, one would try again at a later time point where no
* other client is having a conflicting request.
*
* @deprecated Do not use.
*/
@Deprecated
public static final int STATUS_NOT_ALLOWED = 3;
/**
@@ -91,7 +105,13 @@ public final class GnssMeasurementsEvent implements Parcelable {
/**
* Reports the latest status of the GNSS Measurements sub-system.
*
* @deprecated Do not rely on this callback. From Android S onwards this callback will be
* invoked once with {@link #STATUS_READY} in all cases for backwards compatibility, and
* then never invoked again. Use LocationManager APIs if you need to determine if
* GNSS measurements are supported or if location is off, etc...
*/
@Deprecated
public void onStatusChanged(@GnssMeasurementsStatus int status) {}
}

View File

@@ -110,6 +110,7 @@ public final class GnssNavigationMessage implements Parcelable {
public static abstract class Callback {
/**
* The status of GNSS Navigation Message event.
* @deprecated Do not use.
* @hide
*/
@Retention(RetentionPolicy.SOURCE)
@@ -120,19 +121,28 @@ public final class GnssNavigationMessage implements Parcelable {
* The system does not support tracking of GNSS Navigation Messages.
*
* This status will not change in the future.
*
* @deprecated Do not use.
*/
@Deprecated
public static final int STATUS_NOT_SUPPORTED = 0;
/**
* GNSS Navigation Messages are successfully being tracked, it will receive updates once
* they are available.
*
* @deprecated Do not use.
*/
@Deprecated
public static final int STATUS_READY = 1;
/**
* GNSS provider or Location is disabled, updated will not be received until they are
* enabled.
*
* @deprecated Do not use.
*/
@Deprecated
public static final int STATUS_LOCATION_DISABLED = 2;
/**
@@ -142,7 +152,13 @@ public final class GnssNavigationMessage implements Parcelable {
/**
* Returns the latest status of the GNSS Navigation Messages sub-system.
*
* @deprecated Do not rely on this callback. From Android S onwards this callback will be
* invoked once with {@link #STATUS_READY} in all cases for backwards compatibility, and
* then never invoked again. Use LocationManager APIs if you need to determine if
* GNSS navigation messages are supported or if location is off, etc...
*/
@Deprecated
public void onStatusChanged(@GnssNavigationMessageStatus int status) {}
}

View File

@@ -391,20 +391,10 @@ public final class GnssStatus implements Parcelable {
float[] basebandCn0DbHzs = new float[svCount];
for (int i = 0; i < svCount; i++) {
svidWithFlags[i] = in.readInt();
}
for (int i = 0; i < svCount; i++) {
cn0DbHzs[i] = in.readFloat();
}
for (int i = 0; i < svCount; i++) {
elevations[i] = in.readFloat();
}
for (int i = 0; i < svCount; i++) {
azimuths[i] = in.readFloat();
}
for (int i = 0; i < svCount; i++) {
carrierFrequencies[i] = in.readFloat();
}
for (int i = 0; i < svCount; i++) {
basebandCn0DbHzs[i] = in.readFloat();
}
@@ -428,20 +418,10 @@ public final class GnssStatus implements Parcelable {
parcel.writeInt(mSvCount);
for (int i = 0; i < mSvCount; i++) {
parcel.writeInt(mSvidWithFlags[i]);
}
for (int i = 0; i < mSvCount; i++) {
parcel.writeFloat(mCn0DbHzs[i]);
}
for (int i = 0; i < mSvCount; i++) {
parcel.writeFloat(mElevations[i]);
}
for (int i = 0; i < mSvCount; i++) {
parcel.writeFloat(mAzimuths[i]);
}
for (int i = 0; i < mSvCount; i++) {
parcel.writeFloat(mCarrierFrequencies[i]);
}
for (int i = 0; i < mSvCount; i++) {
parcel.writeFloat(mBasebandCn0DbHzs[i]);
}
}

View File

@@ -1,26 +0,0 @@
/*
* Copyright (C) 2020, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.location;
import android.location.GnssAntennaInfo;
/**
* {@hide}
*/
oneway interface IGnssAntennaInfoListener {
void onGnssAntennaInfoReceived(in List<GnssAntennaInfo> gnssAntennaInfo);
}

View File

@@ -21,11 +21,11 @@ import android.location.Address;
import android.location.Criteria;
import android.location.GeocoderParams;
import android.location.Geofence;
import android.location.GnssAntennaInfo;
import android.location.GnssCapabilities;
import android.location.GnssMeasurementCorrections;
import android.location.GnssMeasurementRequest;
import android.location.IGeocodeListener;
import android.location.IGnssAntennaInfoListener;
import android.location.IGnssMeasurementsListener;
import android.location.IGnssStatusListener;
import android.location.IGnssNavigationMessageListener;
@@ -76,6 +76,8 @@ interface ILocationManager
int getGnssYearOfHardware();
String getGnssHardwareModelName();
@nullable List<GnssAntennaInfo> getGnssAntennaInfos();
void registerGnssStatusCallback(in IGnssStatusListener callback, String packageName, String attributionTag);
void unregisterGnssStatusCallback(in IGnssStatusListener callback);
@@ -86,9 +88,6 @@ interface ILocationManager
void removeGnssMeasurementsListener(in IGnssMeasurementsListener listener);
void injectGnssMeasurementCorrections(in GnssMeasurementCorrections corrections);
void addGnssAntennaInfoListener(in IGnssAntennaInfoListener listener, String packageName, String attributionTag);
void removeGnssAntennaInfoListener(in IGnssAntennaInfoListener listener);
void addGnssNavigationMessageListener(in IGnssNavigationMessageListener listener, String packageName, String attributionTag);
void removeGnssNavigationMessageListener(in IGnssNavigationMessageListener listener);

View File

@@ -44,7 +44,10 @@ import android.compat.Compatibility;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledAfter;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
@@ -64,6 +67,7 @@ import com.android.internal.listeners.ListenerTransportMultiplexer;
import com.android.internal.util.Preconditions;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -311,6 +315,48 @@ public class LocationManager {
public static final String HIGH_POWER_REQUEST_CHANGE_ACTION =
"android.location.HIGH_POWER_REQUEST_CHANGE";
/**
* Broadcast intent action when GNSS capabilities change. This is most common at boot time as
* GNSS capabilities are queried from the chipset. Includes an intent extra,
* {@link #EXTRA_GNSS_CAPABILITIES}, with the new {@link GnssCapabilities}.
*
* @see #EXTRA_GNSS_CAPABILITIES
* @see #getGnssCapabilities()
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_GNSS_CAPABILITIES_CHANGED =
"android.location.action.GNSS_CAPABILITIES_CHANGED";
/**
* Intent extra included with {@link #ACTION_GNSS_CAPABILITIES_CHANGED} broadcasts, containing
* the new {@link GnssCapabilities}.
*
* @see #ACTION_GNSS_CAPABILITIES_CHANGED
*/
public static final String EXTRA_GNSS_CAPABILITIES = "android.location.extra.GNSS_CAPABILITIES";
/**
* Broadcast intent action when GNSS antenna infos change. Includes an intent extra,
* {@link #EXTRA_GNSS_ANTENNA_INFOS}, with an ArrayList of the new {@link GnssAntennaInfo}. This
* may be read via {@link android.content.Intent#getParcelableArrayListExtra(String)}.
*
* @see #EXTRA_GNSS_ANTENNA_INFOS
* @see #getGnssAntennaInfos()
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_GNSS_ANTENNA_INFOS_CHANGED =
"android.location.action.GNSS_ANTENNA_INFOS_CHANGED";
/**
* Intent extra included with {@link #ACTION_GNSS_ANTENNA_INFOS_CHANGED} broadcasts, containing
* the new ArrayList of {@link GnssAntennaInfo}. This may be read via
* {@link android.content.Intent#getParcelableArrayListExtra(String)}.
*
* @see #ACTION_GNSS_ANTENNA_INFOS_CHANGED
*/
public static final String EXTRA_GNSS_ANTENNA_INFOS =
"android.location.extra.GNSS_ANTENNA_INFOS";
/**
* Broadcast intent action for Settings app to inject a footer at the bottom of location
* settings. This is for use only by apps that are included in the system image.
@@ -2136,6 +2182,20 @@ public class LocationManager {
}
}
/**
* Returns the current list of GNSS antenna infos, or null if unknown or unsupported.
*
* @see #getGnssCapabilities()
*/
@Nullable
public List<GnssAntennaInfo> getGnssAntennaInfos() {
try {
return mService.getGnssAntennaInfos();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Retrieves information about the current status of the GPS engine. This should only be called
* from within the {@link GpsStatus.Listener#onGpsStatusChanged} callback to ensure that the
@@ -2559,15 +2619,19 @@ public class LocationManager {
*
* <p>Not all GNSS chipsets support antenna info updates, see {@link #getGnssCapabilities()}.
*
* <p>Prior to Android S, this requires the {@link Manifest.permission#ACCESS_FINE_LOCATION}
* permission.
*
* @param executor the executor that the listener runs on
* @param listener the listener to register
* @return {@code true} always
*
* @throws IllegalArgumentException if executor is null
* @throws IllegalArgumentException if listener is null
* @throws SecurityException if the ACCESS_FINE_LOCATION permission is not present
*
* @deprecated Prefer to use a receiver for {@link #ACTION_GNSS_ANTENNA_INFOS_CHANGED}.
*/
@RequiresPermission(ACCESS_FINE_LOCATION)
@Deprecated
public boolean registerAntennaInfoListener(
@NonNull @CallbackExecutor Executor executor,
@NonNull GnssAntennaInfo.Listener listener) {
@@ -2579,7 +2643,10 @@ public class LocationManager {
* Unregisters a GNSS Antenna Info listener.
*
* @param listener a {@link GnssAntennaInfo.Listener} object to remove
*
* @deprecated Prefer to use a receiver for {@link #ACTION_GNSS_ANTENNA_INFOS_CHANGED}.
*/
@Deprecated
public void unregisterAntennaInfoListener(@NonNull GnssAntennaInfo.Listener listener) {
getGnssAntennaInfoTransportMultiplexer().removeListener(listener);
}
@@ -3153,40 +3220,41 @@ public class LocationManager {
private class GnssAntennaInfoTransportMultiplexer extends
ListenerTransportMultiplexer<Void, GnssAntennaInfo.Listener> {
private @Nullable IGnssAntennaInfoListener mListenerTransport;
private @Nullable BroadcastReceiver mListenerTransport;
GnssAntennaInfoTransportMultiplexer() {}
@Override
protected void registerWithServer(Void ignored) throws RemoteException {
IGnssAntennaInfoListener transport = mListenerTransport;
if (transport == null) {
transport = new GnssAntennaInfoListener();
protected void registerWithServer(Void ignored) {
if (mListenerTransport == null) {
// if an exception is thrown the transport should not be set
BroadcastReceiver transport = new GnssAntennaInfoReceiver();
mContext.registerReceiver(transport,
new IntentFilter(ACTION_GNSS_ANTENNA_INFOS_CHANGED));
mListenerTransport = transport;
}
// if a remote exception is thrown the transport should not be set
mListenerTransport = null;
mService.addGnssAntennaInfoListener(transport, mContext.getPackageName(),
mContext.getAttributionTag());
mListenerTransport = transport;
}
@Override
protected void unregisterWithServer() throws RemoteException {
protected void unregisterWithServer() {
if (mListenerTransport != null) {
IGnssAntennaInfoListener transport = mListenerTransport;
BroadcastReceiver transport = mListenerTransport;
mListenerTransport = null;
mService.removeGnssAntennaInfoListener(transport);
mContext.unregisterReceiver(transport);
}
}
private class GnssAntennaInfoListener extends IGnssAntennaInfoListener.Stub {
private class GnssAntennaInfoReceiver extends BroadcastReceiver {
GnssAntennaInfoListener() {}
GnssAntennaInfoReceiver() {}
@Override
public void onGnssAntennaInfoReceived(List<GnssAntennaInfo> infos) {
deliverToListeners(callback -> callback.onGnssAntennaInfoReceived(infos));
public void onReceive(Context context, Intent intent) {
ArrayList<GnssAntennaInfo> infos = intent.getParcelableArrayListExtra(
EXTRA_GNSS_ANTENNA_INFOS);
if (infos != null) {
deliverToListeners(callback -> callback.onGnssAntennaInfoReceived(infos));
}
}
}
}

View File

@@ -45,11 +45,11 @@ import android.content.Intent;
import android.location.Criteria;
import android.location.GeocoderParams;
import android.location.Geofence;
import android.location.GnssAntennaInfo;
import android.location.GnssCapabilities;
import android.location.GnssMeasurementCorrections;
import android.location.GnssMeasurementRequest;
import android.location.IGeocodeListener;
import android.location.IGnssAntennaInfoListener;
import android.location.IGnssMeasurementsListener;
import android.location.IGnssNavigationMessageListener;
import android.location.IGnssNmeaListener;
@@ -913,18 +913,8 @@ public class LocationManagerService extends ILocationManager.Stub {
}
@Override
public void addGnssAntennaInfoListener(IGnssAntennaInfoListener listener,
String packageName, String attributionTag) {
if (mGnssManagerService != null) {
mGnssManagerService.addGnssAntennaInfoListener(listener, packageName, attributionTag);
}
}
@Override
public void removeGnssAntennaInfoListener(IGnssAntennaInfoListener listener) {
if (mGnssManagerService != null) {
mGnssManagerService.removeGnssAntennaInfoListener(listener);
}
public List<GnssAntennaInfo> getGnssAntennaInfos() {
return mGnssManagerService == null ? null : mGnssManagerService.getGnssAntennaInfos();
}
@Override

View File

@@ -1,101 +0,0 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.server.location.gnss;
import static com.android.server.location.gnss.GnssManagerService.D;
import static com.android.server.location.gnss.GnssManagerService.TAG;
import android.location.GnssAntennaInfo;
import android.location.GnssCapabilities;
import android.location.IGnssAntennaInfoListener;
import android.location.util.identity.CallerIdentity;
import android.util.Log;
import com.android.server.location.gnss.hal.GnssNative;
import com.android.server.location.injector.Injector;
import java.util.Collection;
import java.util.List;
/**
* Provides GNSS antenna information to clients.
*/
public class GnssAntennaInfoProvider extends
GnssListenerMultiplexer<Void, IGnssAntennaInfoListener, Void> implements
GnssNative.BaseCallbacks, GnssNative.AntennaInfoCallbacks {
private final GnssNative mGnssNative;
public GnssAntennaInfoProvider(Injector injector, GnssNative gnssNative) {
super(injector);
mGnssNative = gnssNative;
mGnssNative.addBaseCallbacks(this);
mGnssNative.addAntennaInfoCallbacks(this);
}
@Override
protected boolean isServiceSupported() {
return mGnssNative.isAntennaInfoListeningSupported();
}
@Override
public void addListener(CallerIdentity identity, IGnssAntennaInfoListener listener) {
super.addListener(identity, listener);
}
@Override
protected boolean registerWithService(Void ignored,
Collection<GnssListenerRegistration> registrations) {
if (mGnssNative.startAntennaInfoListening()) {
if (D) {
Log.d(TAG, "starting gnss antenna info");
}
return true;
} else {
Log.e(TAG, "error starting gnss antenna info");
return false;
}
}
@Override
protected void unregisterWithService() {
if (mGnssNative.stopAntennaInfoListening()) {
if (D) {
Log.d(TAG, "stopping gnss antenna info");
}
} else {
Log.e(TAG, "error stopping gnss antenna info");
}
}
@Override
public void onHalRestarted() {
resetService();
}
@Override
public void onCapabilitiesChanged(GnssCapabilities oldCapabilities,
GnssCapabilities newCapabilities) {}
@Override
public void onReportAntennaInfo(List<GnssAntennaInfo> antennaInfos) {
deliverToListeners(listener -> {
listener.onGnssAntennaInfoReceived(antennaInfos);
});
}
}

View File

@@ -16,7 +16,6 @@
package com.android.server.location.gnss;
import android.location.GnssCapabilities;
import android.location.IGpsGeofenceHardware;
import android.util.SparseArray;
@@ -141,8 +140,4 @@ class GnssGeofenceProxy extends IGpsGeofenceHardware.Stub implements GnssNative.
}
}
}
@Override
public void onCapabilitiesChanged(GnssCapabilities oldCapabilities,
GnssCapabilities newCapabilities) {}
}

View File

@@ -96,12 +96,29 @@ public abstract class GnssListenerMultiplexer<TRequest, TListener extends IInter
}
@Override
protected void onBinderListenerRegister() {
protected final void onBinderListenerRegister() {
mPermitted = mLocationPermissionsHelper.hasLocationPermissions(PERMISSION_FINE,
getIdentity());
mForeground = mAppForegroundHelper.isAppForeground(getIdentity().getUid());
onGnssListenerRegister();
}
@Override
protected final void onBinderListenerUnregister() {
onGnssListenerUnregister();
}
/**
* May be overridden in place of {@link #onBinderListenerRegister()}.
*/
protected void onGnssListenerRegister() {}
/**
* May be overridden in place of {@link #onBinderListenerUnregister()}.
*/
protected void onGnssListenerUnregister() {}
boolean onLocationPermissionsChanged(String packageName) {
if (getIdentity().getPackageName().equals(packageName)) {
return onLocationPermissionsChanged();

View File

@@ -50,7 +50,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.location.Criteria;
import android.location.GnssCapabilities;
import android.location.GnssStatus;
import android.location.INetInitiatedListener;

View File

@@ -19,23 +19,27 @@ package com.android.server.location.gnss;
import android.Manifest;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Intent;
import android.hardware.location.GeofenceHardware;
import android.hardware.location.GeofenceHardwareImpl;
import android.location.FusedBatchOptions;
import android.location.GnssAntennaInfo;
import android.location.GnssCapabilities;
import android.location.GnssMeasurementCorrections;
import android.location.GnssMeasurementRequest;
import android.location.IGnssAntennaInfoListener;
import android.location.IGnssMeasurementsListener;
import android.location.IGnssNavigationMessageListener;
import android.location.IGnssNmeaListener;
import android.location.IGnssStatusListener;
import android.location.IGpsGeofenceHardware;
import android.location.Location;
import android.location.LocationManager;
import android.location.util.identity.CallerIdentity;
import android.os.BatteryStats;
import android.os.Binder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.util.IndentingPrintWriter;
import android.util.Log;
@@ -45,6 +49,8 @@ import com.android.server.location.gnss.hal.GnssNative;
import com.android.server.location.injector.Injector;
import java.io.FileDescriptor;
import java.util.ArrayList;
import java.util.List;
/** Manages Gnss providers and related Gnss functions for LocationManagerService. */
public class GnssManagerService {
@@ -61,10 +67,13 @@ public class GnssManagerService {
private final GnssStatusProvider mGnssStatusProvider;
private final GnssNmeaProvider mGnssNmeaProvider;
private final GnssMeasurementsProvider mGnssMeasurementsProvider;
private final GnssAntennaInfoProvider mGnssAntennaInfoProvider;
private final GnssNavigationMessageProvider mGnssNavigationMessageProvider;
private final IGpsGeofenceHardware mGnssGeofenceProxy;
private final GnssGeofenceHalModule mGeofenceHalModule;
private final GnssCapabilitiesHalModule mCapabilitiesHalModule;
private final GnssAntennaInfoHalModule mAntennaInfoHalModule;
private final GnssMetrics mGnssMetrics;
public GnssManagerService(Context context, Injector injector, GnssNative gnssNative) {
@@ -79,11 +88,12 @@ public class GnssManagerService {
mGnssStatusProvider = new GnssStatusProvider(injector, mGnssNative);
mGnssNmeaProvider = new GnssNmeaProvider(injector, mGnssNative);
mGnssMeasurementsProvider = new GnssMeasurementsProvider(injector, mGnssNative);
mGnssAntennaInfoProvider = new GnssAntennaInfoProvider(injector, mGnssNative);
mGnssNavigationMessageProvider = new GnssNavigationMessageProvider(injector, mGnssNative);
mGnssGeofenceProxy = new GnssGeofenceProxy(mGnssNative);
mGnssNative.setGeofenceCallbacks(new GnssGeofenceHalModule());
mGeofenceHalModule = new GnssGeofenceHalModule(mGnssNative);
mCapabilitiesHalModule = new GnssCapabilitiesHalModule(mGnssNative);
mAntennaInfoHalModule = new GnssAntennaInfoHalModule(mGnssNative);
// allow gnss access to begin - we must assume that callbacks can start immediately
mGnssNative.register();
@@ -120,13 +130,19 @@ public class GnssManagerService {
}
/**
* Get GNSS hardware capabilities. The capabilities returned are a bitfield as described in
* {@link android.location.GnssCapabilities}.
* Get GNSS hardware capabilities.
*/
public GnssCapabilities getGnssCapabilities() {
return mGnssNative.getCapabilities();
}
/**
* Get GNSS antenna information.
*/
public @Nullable List<GnssAntennaInfo> getGnssAntennaInfos() {
return mAntennaInfoHalModule.getAntennaInfos();
}
/**
* Get size of GNSS batch (GNSS location results are batched together for power savings).
*/
@@ -201,29 +217,6 @@ public class GnssManagerService {
mGnssMeasurementsProvider.removeListener(listener);
}
/**
* Adds a GNSS Antenna Info listener.
*
* @param listener called when GNSS antenna info is received
* @param packageName name of requesting package
*/
public void addGnssAntennaInfoListener(IGnssAntennaInfoListener listener, String packageName,
@Nullable String attributionTag) {
mContext.enforceCallingOrSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION, null);
CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, attributionTag);
mGnssAntennaInfoProvider.addListener(identity, listener);
}
/**
* Removes a GNSS Antenna Info listener.
*
* @param listener called when GNSS antenna info is received
*/
public void removeGnssAntennaInfoListener(IGnssAntennaInfoListener listener) {
mGnssAntennaInfoProvider.removeListener(listener);
}
/**
* Adds a GNSS navigation message listener.
*/
@@ -264,12 +257,12 @@ public class GnssManagerService {
ipw.println("Capabilities: " + mGnssNative.getCapabilities());
ipw.println("Antenna Info Provider:");
ipw.increaseIndent();
mGnssAntennaInfoProvider.dump(fd, ipw, args);
ipw.decreaseIndent();
List<GnssAntennaInfo> infos = mAntennaInfoHalModule.getAntennaInfos();
if (infos != null) {
ipw.println("Antenna Infos: " + infos);
}
ipw.println("Measurement Provider:");
ipw.println("Measurements Provider:");
ipw.increaseIndent();
mGnssMeasurementsProvider.dump(fd, ipw, args);
ipw.decreaseIndent();
@@ -293,10 +286,39 @@ public class GnssManagerService {
}
}
private class GnssCapabilitiesHalModule implements GnssNative.BaseCallbacks {
GnssCapabilitiesHalModule(GnssNative gnssNative) {
gnssNative.addBaseCallbacks(this);
}
@Override
public void onHalRestarted() {}
@Override
public void onCapabilitiesChanged(GnssCapabilities oldCapabilities,
GnssCapabilities newCapabilities) {
long ident = Binder.clearCallingIdentity();
try {
Intent intent = new Intent(LocationManager.ACTION_GNSS_CAPABILITIES_CHANGED)
.putExtra(LocationManager.EXTRA_GNSS_CAPABILITIES, newCapabilities)
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY)
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
}
private class GnssGeofenceHalModule implements GnssNative.GeofenceCallbacks {
private GeofenceHardwareImpl mGeofenceHardwareImpl;
GnssGeofenceHalModule(GnssNative gnssNative) {
gnssNative.setGeofenceCallbacks(this);
}
private synchronized GeofenceHardwareImpl getGeofenceHardware() {
if (mGeofenceHardwareImpl == null) {
mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
@@ -371,4 +393,53 @@ public class GnssManagerService {
}
}
}
private class GnssAntennaInfoHalModule implements GnssNative.BaseCallbacks,
GnssNative.AntennaInfoCallbacks {
private final GnssNative mGnssNative;
private volatile @Nullable List<GnssAntennaInfo> mAntennaInfos;
GnssAntennaInfoHalModule(GnssNative gnssNative) {
mGnssNative = gnssNative;
mGnssNative.addBaseCallbacks(this);
mGnssNative.addAntennaInfoCallbacks(this);
}
@Nullable List<GnssAntennaInfo> getAntennaInfos() {
return mAntennaInfos;
}
@Override
public void onHalStarted() {
mGnssNative.startAntennaInfoListening();
}
@Override
public void onHalRestarted() {
mGnssNative.startAntennaInfoListening();
}
@Override
public void onReportAntennaInfo(List<GnssAntennaInfo> antennaInfos) {
if (antennaInfos.equals(mAntennaInfos)) {
return;
}
mAntennaInfos = antennaInfos;
long ident = Binder.clearCallingIdentity();
try {
Intent intent = new Intent(LocationManager.ACTION_GNSS_ANTENNA_INFOS_CHANGED)
.putParcelableArrayListExtra(LocationManager.EXTRA_GNSS_ANTENNA_INFOS,
new ArrayList<>(antennaInfos))
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY)
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
}
}

View File

@@ -21,7 +21,6 @@ import static com.android.server.location.gnss.GnssManagerService.TAG;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.location.GnssCapabilities;
import android.location.GnssMeasurementRequest;
import android.location.GnssMeasurementsEvent;
import android.location.IGnssMeasurementsListener;
@@ -58,8 +57,14 @@ public final class GnssMeasurementsProvider extends
protected GnssMeasurementListenerRegistration(
@Nullable GnssMeasurementRequest request,
CallerIdentity callerIdentity,
IGnssMeasurementsListener iGnssMeasurementsListener) {
super(request, callerIdentity, iGnssMeasurementsListener);
IGnssMeasurementsListener listener) {
super(request, callerIdentity, listener);
}
@Override
protected void onGnssListenerRegister() {
executeOperation(listener -> listener.onStatusChanged(
GnssMeasurementsEvent.Callback.STATUS_READY));
}
@Nullable
@@ -200,10 +205,6 @@ public final class GnssMeasurementsProvider extends
resetService();
}
@Override
public void onCapabilitiesChanged(GnssCapabilities oldCapabilities,
GnssCapabilities newCapabilities) {}
@Override
public void onReportMeasurements(GnssMeasurementsEvent event) {
deliverToListeners(registration -> {

View File

@@ -20,7 +20,6 @@ import static com.android.server.location.gnss.GnssManagerService.D;
import static com.android.server.location.gnss.GnssManagerService.TAG;
import android.app.AppOpsManager;
import android.location.GnssCapabilities;
import android.location.GnssNavigationMessage;
import android.location.IGnssNavigationMessageListener;
import android.location.util.identity.CallerIdentity;
@@ -43,6 +42,21 @@ public class GnssNavigationMessageProvider extends
GnssListenerMultiplexer<Void, IGnssNavigationMessageListener, Void> implements
GnssNative.BaseCallbacks, GnssNative.NavigationMessageCallbacks {
private class GnssNavigationMessageListenerRegistration extends GnssListenerRegistration {
protected GnssNavigationMessageListenerRegistration(
CallerIdentity callerIdentity,
IGnssNavigationMessageListener listener) {
super(null, callerIdentity, listener);
}
@Override
protected void onGnssListenerRegister() {
executeOperation(listener -> listener.onStatusChanged(
GnssNavigationMessage.Callback.STATUS_READY));
}
}
private final AppOpsHelper mAppOpsHelper;
private final GnssNative mGnssNative;
@@ -65,6 +79,12 @@ public class GnssNavigationMessageProvider extends
super.addListener(identity, listener);
}
@Override
protected GnssListenerRegistration createRegistration(Void request,
CallerIdentity callerIdentity, IGnssNavigationMessageListener listener) {
return new GnssNavigationMessageListenerRegistration(callerIdentity, listener);
}
@Override
protected boolean registerWithService(Void ignored,
Collection<GnssListenerRegistration> registrations) {
@@ -95,10 +115,6 @@ public class GnssNavigationMessageProvider extends
resetService();
}
@Override
public void onCapabilitiesChanged(GnssCapabilities oldCapabilities,
GnssCapabilities newCapabilities) {}
@Override
public void onReportNavigationMessage(GnssNavigationMessage event) {
deliverToListeners(registration -> {

View File

@@ -21,7 +21,6 @@ import static com.android.server.location.gnss.GnssManagerService.TAG;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.location.GnssCapabilities;
import android.location.IGnssNmeaListener;
import android.location.util.identity.CallerIdentity;
import android.util.Log;
@@ -82,10 +81,6 @@ class GnssNmeaProvider extends GnssListenerMultiplexer<Void, IGnssNmeaListener,
resetService();
}
@Override
public void onCapabilitiesChanged(GnssCapabilities oldCapabilities,
GnssCapabilities newCapabilities) {}
@Override
public void onReportNmea(long timestamp) {
deliverToListeners(

View File

@@ -20,7 +20,6 @@ import static com.android.server.location.gnss.GnssManagerService.D;
import static com.android.server.location.gnss.GnssManagerService.TAG;
import android.app.AppOpsManager;
import android.location.GnssCapabilities;
import android.location.GnssStatus;
import android.location.IGnssStatusListener;
import android.location.util.identity.CallerIdentity;
@@ -110,10 +109,6 @@ public class GnssStatusProvider extends
resetService();
}
@Override
public void onCapabilitiesChanged(GnssCapabilities oldCapabilities,
GnssCapabilities newCapabilities) {}
@Override
public void onReportStatus(@GnssNative.StatusCallbacks.GnssStatusValue int gnssStatus) {
boolean isNavigating;

View File

@@ -141,9 +141,10 @@ public class GnssNative {
/** Callbacks relevant to the entire HAL. */
public interface BaseCallbacks {
default void onHalStarted() {}
void onHalRestarted();
void onCapabilitiesChanged(GnssCapabilities oldCapabilities,
GnssCapabilities newCapabilities);
default void onCapabilitiesChanged(GnssCapabilities oldCapabilities,
GnssCapabilities newCapabilities) {}
}
/** Callbacks for status events. */
@@ -480,6 +481,11 @@ public class GnssNative {
mRegistered = true;
initializeGnss(false);
Log.i(TAG, "gnss hal started");
for (int i = 0; i < mBaseCallbacks.length; i++) {
mBaseCallbacks[i].onHalStarted();
}
}
private void initializeGnss(boolean restart) {
@@ -1413,6 +1419,8 @@ public class GnssNative {
private static native boolean native_stop_navigation_message_collection();
// antenna info APIS
// TODO: in a next version of the HAL, consider removing the necessity for listening to antenna
// info changes, and simply report them always, same as capabilities.
private static native boolean native_is_antenna_info_supported();