summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/system-current.txt60
-rw-r--r--core/api/test-current.txt2
-rw-r--r--core/api/test-lint-baseline.txt2
-rw-r--r--location/java/android/location/GnssCapabilities.java29
-rw-r--r--location/java/android/location/GnssMeasurement.java67
-rw-r--r--location/java/android/location/SatellitePvt.java514
-rw-r--r--services/core/jni/gnss/GnssMeasurementCallback.cpp98
7 files changed, 770 insertions, 2 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 9451d69c59f8..075be966cce3 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -3957,6 +3957,7 @@ package android.location {
method @Deprecated public boolean hasNavMessages();
method @Deprecated public boolean hasSatelliteBlacklist();
method public boolean hasSatelliteBlocklist();
+ method public boolean hasSatellitePvt();
}
public static final class GnssCapabilities.Builder {
@@ -3967,6 +3968,12 @@ package android.location {
method @NonNull public android.location.GnssCapabilities.Builder setHasMeasurementCorrectionsLosSats(boolean);
method @NonNull public android.location.GnssCapabilities.Builder setHasMeasurementCorrectionsReflectingPlane(boolean);
method @NonNull public android.location.GnssCapabilities.Builder setHasSatelliteBlocklist(boolean);
+ method @NonNull public android.location.GnssCapabilities.Builder setHasSatellitePvt(boolean);
+ }
+
+ public final class GnssMeasurement implements android.os.Parcelable {
+ method @Nullable public android.location.SatellitePvt getSatellitePvt();
+ method public boolean hasSatellitePvt();
}
public final class GnssMeasurementCorrections implements android.os.Parcelable {
@@ -4381,6 +4388,59 @@ package android.location {
method @NonNull public static android.location.LocationResult wrap(@NonNull android.location.Location);
}
+ public final class SatellitePvt implements android.os.Parcelable {
+ method public int describeContents();
+ method @NonNull public android.location.SatellitePvt.ClockInfo getClockInfo();
+ method @FloatRange public double getIonoDelayMeters();
+ method @NonNull public android.location.SatellitePvt.PositionEcef getPositionEcef();
+ method @FloatRange public double getTropoDelayMeters();
+ method @NonNull public android.location.SatellitePvt.VelocityEcef getVelocityEcef();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.location.SatellitePvt> CREATOR;
+ }
+
+ public static final class SatellitePvt.Builder {
+ ctor public SatellitePvt.Builder();
+ method @NonNull public android.location.SatellitePvt build();
+ method @NonNull public android.location.SatellitePvt.Builder setClockInfo(@NonNull android.location.SatellitePvt.ClockInfo);
+ method @NonNull public android.location.SatellitePvt.Builder setIonoDelayMeters(@FloatRange double);
+ method @NonNull public android.location.SatellitePvt.Builder setPositionEcef(@NonNull android.location.SatellitePvt.PositionEcef);
+ method @NonNull public android.location.SatellitePvt.Builder setTropoDelayMeters(@FloatRange double);
+ method @NonNull public android.location.SatellitePvt.Builder setVelocityEcef(@NonNull android.location.SatellitePvt.VelocityEcef);
+ }
+
+ public static final class SatellitePvt.ClockInfo implements android.os.Parcelable {
+ ctor public SatellitePvt.ClockInfo(double, double, double);
+ method public int describeContents();
+ method @FloatRange public double getClockDriftMetersPerSecond();
+ method @FloatRange public double getHardwareCodeBiasMeters();
+ method @FloatRange public double getTimeCorrectionMeters();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.location.SatellitePvt.ClockInfo> CREATOR;
+ }
+
+ public static final class SatellitePvt.PositionEcef implements android.os.Parcelable {
+ ctor public SatellitePvt.PositionEcef(double, double, double, double);
+ method public int describeContents();
+ method @FloatRange(from=0.0f, fromInclusive=false) public double getUreMeters();
+ method @FloatRange public double getXMeters();
+ method @FloatRange public double getYMeters();
+ method @FloatRange public double getZMeters();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.location.SatellitePvt.PositionEcef> CREATOR;
+ }
+
+ public static final class SatellitePvt.VelocityEcef implements android.os.Parcelable {
+ ctor public SatellitePvt.VelocityEcef(double, double, double, double);
+ method public int describeContents();
+ method @FloatRange(from=0.0f, fromInclusive=false) public double getUreRateMetersPerSecond();
+ method @FloatRange public double getXMetersPerSecond();
+ method @FloatRange public double getYMetersPerSecond();
+ method @FloatRange public double getZMetersPerSecond();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.location.SatellitePvt.VelocityEcef> CREATOR;
+ }
+
}
package android.location.provider {
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 1422561e3347..bbb7c39f15c2 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -933,6 +933,7 @@ package android.location {
method public void resetFullInterSignalBiasUncertaintyNanos();
method public void resetSatelliteInterSignalBiasNanos();
method public void resetSatelliteInterSignalBiasUncertaintyNanos();
+ method public void resetSatellitePvt();
method public void resetSnrInDb();
method public void set(android.location.GnssMeasurement);
method public void setAccumulatedDeltaRangeMeters(double);
@@ -956,6 +957,7 @@ package android.location {
method public void setReceivedSvTimeUncertaintyNanos(long);
method public void setSatelliteInterSignalBiasNanos(double);
method public void setSatelliteInterSignalBiasUncertaintyNanos(@FloatRange(from=0.0) double);
+ method public void setSatellitePvt(@Nullable android.location.SatellitePvt);
method public void setSnrInDb(double);
method public void setState(int);
method public void setSvid(int);
diff --git a/core/api/test-lint-baseline.txt b/core/api/test-lint-baseline.txt
index c0b40931f1e6..3bd88a47f30d 100644
--- a/core/api/test-lint-baseline.txt
+++ b/core/api/test-lint-baseline.txt
@@ -477,6 +477,8 @@ GetterSetterNames: android.location.GnssMeasurement#setSatelliteInterSignalBiasN
GetterSetterNames: android.location.GnssMeasurement#setSatelliteInterSignalBiasUncertaintyNanos(double):
+GetterSetterNames: android.location.GnssMeasurement#setSatellitePvt(android.location.SatellitePvt):
+
GetterSetterNames: android.location.GnssMeasurement#setSnrInDb(double):
GetterSetterNames: android.location.LocationRequest#isLocationSettingsIgnored():
diff --git a/location/java/android/location/GnssCapabilities.java b/location/java/android/location/GnssCapabilities.java
index 89a3bd57519e..b650a9fd0416 100644
--- a/location/java/android/location/GnssCapabilities.java
+++ b/location/java/android/location/GnssCapabilities.java
@@ -57,6 +57,8 @@ public final class GnssCapabilities implements Parcelable {
public static final int TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS = 1024;
/** @hide */
public static final int TOP_HAL_CAPABILITY_ANTENNA_INFO = 2048;
+ /** @hide */
+ public static final int TOP_HAL_CAPABILITY_SATELLITE_PVT = 8192;
/** @hide */
@IntDef(flag = true, prefix = {"TOP_HAL_CAPABILITY_"}, value = {TOP_HAL_CAPABILITY_SCHEDULING,
@@ -64,7 +66,8 @@ public final class GnssCapabilities implements Parcelable {
TOP_HAL_CAPABILITY_ON_DEMAND_TIME, TOP_HAL_CAPABILITY_GEOFENCING,
TOP_HAL_CAPABILITY_MEASUREMENTS, TOP_HAL_CAPABILITY_NAV_MESSAGES,
TOP_HAL_CAPABILITY_LOW_POWER_MODE, TOP_HAL_CAPABILITY_SATELLITE_BLOCKLIST,
- TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS, TOP_HAL_CAPABILITY_ANTENNA_INFO})
+ TOP_HAL_CAPABILITY_MEASUREMENT_CORRECTIONS, TOP_HAL_CAPABILITY_ANTENNA_INFO,
+ TOP_HAL_CAPABILITY_SATELLITE_PVT})
@Retention(RetentionPolicy.SOURCE)
public @interface TopHalCapabilityFlags {}
@@ -294,6 +297,16 @@ public final class GnssCapabilities implements Parcelable {
}
/**
+ * Returns {@code true} if GNSS chipset supports satellite PVT, {@code false} otherwise.
+ *
+ * @hide
+ */
+ @SystemApi
+ public boolean hasSatellitePvt() {
+ return (mTopFlags & TOP_HAL_CAPABILITY_SATELLITE_PVT) != 0;
+ }
+
+ /**
* Returns {@code true} if GNSS chipset supports measurement corrections, {@code false}
* otherwise.
*
@@ -511,6 +524,9 @@ public final class GnssCapabilities implements Parcelable {
if (hasSatelliteBlocklist()) {
builder.append("SATELLITE_BLOCKLIST ");
}
+ if (hasSatellitePvt()) {
+ builder.append("SATELLITE_PVT ");
+ }
if (hasMeasurementCorrections()) {
builder.append("MEASUREMENT_CORRECTIONS ");
}
@@ -674,6 +690,17 @@ public final class GnssCapabilities implements Parcelable {
}
/**
+ * Sets satellite PVT capability.
+ *
+ * @hide
+ */
+ @SystemApi
+ public @NonNull Builder setHasSatellitePvt(boolean capable) {
+ mTopFlags = setFlag(mTopFlags, TOP_HAL_CAPABILITY_SATELLITE_PVT, capable);
+ return this;
+ }
+
+ /**
* Sets measurement corrections capability.
*
* @hide
diff --git a/location/java/android/location/GnssMeasurement.java b/location/java/android/location/GnssMeasurement.java
index bd46ffdf7e57..5509a6c65614 100644
--- a/location/java/android/location/GnssMeasurement.java
+++ b/location/java/android/location/GnssMeasurement.java
@@ -30,6 +30,8 @@ import static android.hardware.gnss.V2_1.IGnssMeasurementCallback.GnssMeasuremen
import android.annotation.FloatRange;
import android.annotation.IntDef;
import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -67,12 +69,14 @@ public final class GnssMeasurement implements Parcelable {
private double mFullInterSignalBiasUncertaintyNanos;
private double mSatelliteInterSignalBiasNanos;
private double mSatelliteInterSignalBiasUncertaintyNanos;
+ @Nullable private SatellitePvt mSatellitePvt;
// The following enumerations must be in sync with the values declared in GNSS HAL.
private static final int HAS_NO_FLAGS = 0;
private static final int HAS_CODE_TYPE = (1 << 14);
private static final int HAS_BASEBAND_CN0 = (1 << 15);
+ private static final int HAS_SATELLITE_PVT = (1 << 20);
/**
* The status of the multipath indicator.
@@ -274,6 +278,7 @@ public final class GnssMeasurement implements Parcelable {
mSatelliteInterSignalBiasNanos = measurement.mSatelliteInterSignalBiasNanos;
mSatelliteInterSignalBiasUncertaintyNanos =
measurement.mSatelliteInterSignalBiasUncertaintyNanos;
+ mSatellitePvt = measurement.mSatellitePvt;
}
/**
@@ -1691,6 +1696,55 @@ public final class GnssMeasurement implements Parcelable {
resetFlag(HAS_SATELLITE_ISB_UNCERTAINTY);
}
+ /**
+ * Returns {@code true} if {@link #getSatellitePvt()} is available,
+ * {@code false} otherwise.
+ *
+ * @hide
+ */
+ @SystemApi
+ public boolean hasSatellitePvt() {
+ return isFlagSet(HAS_SATELLITE_PVT);
+ }
+
+ /**
+ * Gets the Satellite PVT data.
+ *
+ * <p>The value is only available if {@link #hasSatellitePvt()} is
+ * {@code true}.
+ * @hide
+ */
+ @Nullable
+ @SystemApi
+ public SatellitePvt getSatellitePvt() {
+ return mSatellitePvt;
+ }
+
+ /**
+ * Sets the Satellite PVT.
+ *
+ * @hide
+ */
+ @TestApi
+ public void setSatellitePvt(@Nullable SatellitePvt satellitePvt) {
+ if (satellitePvt == null) {
+ resetSatellitePvt();
+ } else {
+ setFlag(HAS_SATELLITE_PVT);
+ mSatellitePvt = satellitePvt;
+ }
+ }
+
+ /**
+ * Resets the Satellite PVT.
+ *
+ * @hide
+ */
+ @TestApi
+ public void resetSatellitePvt() {
+ resetFlag(HAS_SATELLITE_PVT);
+ }
+
public static final @NonNull Creator<GnssMeasurement> CREATOR = new Creator<GnssMeasurement>() {
@Override
@@ -1723,7 +1777,10 @@ public final class GnssMeasurement implements Parcelable {
gnssMeasurement.mFullInterSignalBiasUncertaintyNanos = parcel.readDouble();
gnssMeasurement.mSatelliteInterSignalBiasNanos = parcel.readDouble();
gnssMeasurement.mSatelliteInterSignalBiasUncertaintyNanos = parcel.readDouble();
-
+ if (gnssMeasurement.hasSatellitePvt()) {
+ ClassLoader classLoader = getClass().getClassLoader();
+ gnssMeasurement.mSatellitePvt = parcel.readParcelable(classLoader);
+ }
return gnssMeasurement;
}
@@ -1761,6 +1818,9 @@ public final class GnssMeasurement implements Parcelable {
parcel.writeDouble(mFullInterSignalBiasUncertaintyNanos);
parcel.writeDouble(mSatelliteInterSignalBiasNanos);
parcel.writeDouble(mSatelliteInterSignalBiasUncertaintyNanos);
+ if (hasSatellitePvt()) {
+ parcel.writeParcelable(mSatellitePvt, flags);
+ }
}
@Override
@@ -1864,6 +1924,10 @@ public final class GnssMeasurement implements Parcelable {
: null));
}
+ if (hasSatellitePvt()) {
+ builder.append(mSatellitePvt.toString());
+ }
+
return builder.toString();
}
@@ -1893,6 +1957,7 @@ public final class GnssMeasurement implements Parcelable {
resetFullInterSignalBiasUncertaintyNanos();
resetSatelliteInterSignalBiasNanos();
resetSatelliteInterSignalBiasUncertaintyNanos();
+ resetSatellitePvt();
}
private void setFlag(int flag) {
diff --git a/location/java/android/location/SatellitePvt.java b/location/java/android/location/SatellitePvt.java
new file mode 100644
index 000000000000..144fa1341bd6
--- /dev/null
+++ b/location/java/android/location/SatellitePvt.java
@@ -0,0 +1,514 @@
+/*
+ * 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.annotation.FloatRange;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * A class that contains GNSS satellite position, velocity and time information at the
+ * signal transmission time {@link GnssMeasurement#getReceivedSvTimeNanos()}.
+ *
+ * @hide
+ */
+@SystemApi
+public final class SatellitePvt implements Parcelable {
+ private final PositionEcef mPositionEcef;
+ private final VelocityEcef mVelocityEcef;
+ private final ClockInfo mClockInfo;
+ private final double mIonoDelayMeters;
+ private final double mTropoDelayMeters;
+
+ /**
+ * Class containing estimates of the satellite position fields in ECEF coordinate frame.
+ */
+ public static final class PositionEcef implements Parcelable {
+ private final double mXMeters;
+ private final double mYMeters;
+ private final double mZMeters;
+ private final double mUreMeters;
+
+ public PositionEcef(
+ double xMeters,
+ double yMeters,
+ double zMeters,
+ double ureMeters) {
+ mXMeters = xMeters;
+ mYMeters = yMeters;
+ mZMeters = zMeters;
+ mUreMeters = ureMeters;
+ }
+
+ public static final @NonNull Creator<PositionEcef> CREATOR =
+ new Creator<PositionEcef>() {
+ @Override
+ public PositionEcef createFromParcel(Parcel in) {
+ return new PositionEcef(
+ in.readDouble(),
+ in.readDouble(),
+ in.readDouble(),
+ in.readDouble()
+ );
+ }
+
+ @Override
+ public PositionEcef[] newArray(int size) {
+ return new PositionEcef[size];
+ }
+ };
+
+ /**
+ * Returns the satellite position X in WGS84 ECEF (meters).
+ */
+ @FloatRange()
+ public double getXMeters() {
+ return mXMeters;
+ }
+
+ /**
+ * Returns the satellite position Y in WGS84 ECEF (meters).
+ */
+ @FloatRange()
+ public double getYMeters() {
+ return mYMeters;
+ }
+
+ /**
+ * Returns the satellite position Z in WGS84 ECEF (meters).
+ */
+ @FloatRange()
+ public double getZMeters() {
+ return mZMeters;
+ }
+
+ /**
+ * Returns the signal in Space User Range Error (URE) (meters).
+ */
+ @FloatRange(from = 0.0f, fromInclusive = false)
+ public double getUreMeters() {
+ return mUreMeters;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeDouble(mXMeters);
+ dest.writeDouble(mYMeters);
+ dest.writeDouble(mZMeters);
+ dest.writeDouble(mUreMeters);
+ }
+
+ @Override
+ public String toString() {
+ return "PositionEcef{"
+ + "xMeters=" + mXMeters
+ + ", yMeters=" + mYMeters
+ + ", zMeters=" + mZMeters
+ + ", ureMeters=" + mUreMeters
+ + "}";
+ }
+ }
+
+ /**
+ * Class containing estimates of the satellite velocity fields in the ECEF coordinate frame.
+ */
+ public static final class VelocityEcef implements Parcelable {
+ private final double mXMetersPerSecond;
+ private final double mYMetersPerSecond;
+ private final double mZMetersPerSecond;
+ private final double mUreRateMetersPerSecond;
+
+ public VelocityEcef(
+ double xMetersPerSecond,
+ double yMetersPerSecond,
+ double zMetersPerSecond,
+ double ureRateMetersPerSecond) {
+ mXMetersPerSecond = xMetersPerSecond;
+ mYMetersPerSecond = yMetersPerSecond;
+ mZMetersPerSecond = zMetersPerSecond;
+ mUreRateMetersPerSecond = ureRateMetersPerSecond;
+ }
+
+ public static final @NonNull Creator<VelocityEcef> CREATOR =
+ new Creator<VelocityEcef>() {
+ @Override
+ public VelocityEcef createFromParcel(Parcel in) {
+ return new VelocityEcef(
+ in.readDouble(),
+ in.readDouble(),
+ in.readDouble(),
+ in.readDouble()
+ );
+ }
+
+ @Override
+ public VelocityEcef[] newArray(int size) {
+ return new VelocityEcef[size];
+ }
+ };
+
+ /**
+ * Returns the satellite velocity X in WGS84 ECEF (meters per second).
+ */
+ @FloatRange()
+ public double getXMetersPerSecond() {
+ return mXMetersPerSecond;
+ }
+
+ /**
+ * Returns the satellite velocity Y in WGS84 ECEF (meters per second).
+ */
+ @FloatRange()
+ public double getYMetersPerSecond() {
+ return mYMetersPerSecond;
+ }
+
+ /**
+ *Returns the satellite velocity Z in WGS84 ECEF (meters per second).
+ */
+ @FloatRange()
+ public double getZMetersPerSecond() {
+ return mZMetersPerSecond;
+ }
+
+ /**
+ * Returns the signal in Space User Range Error Rate (URE Rate) (meters per second).
+ *
+ * It covers satellite velocity error and Satellite clock drift
+ * projected to the pseudorange rate measurements.
+ */
+ @FloatRange(from = 0.0f, fromInclusive = false)
+ public double getUreRateMetersPerSecond() {
+ return mUreRateMetersPerSecond;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeDouble(mXMetersPerSecond);
+ dest.writeDouble(mYMetersPerSecond);
+ dest.writeDouble(mZMetersPerSecond);
+ dest.writeDouble(mUreRateMetersPerSecond);
+ }
+
+ @Override
+ public String toString() {
+ return "VelocityEcef{"
+ + "xMetersPerSecond=" + mXMetersPerSecond
+ + ", yMetersPerSecond=" + mYMetersPerSecond
+ + ", zMetersPerSecond=" + mZMetersPerSecond
+ + ", ureRateMetersPerSecond=" + mUreRateMetersPerSecond
+ + "}";
+ }
+ }
+
+ /**
+ * Class containing estimates of the satellite clock info.
+ */
+ public static final class ClockInfo implements Parcelable {
+ private final double mHardwareCodeBiasMeters;
+ private final double mTimeCorrectionMeters;
+ private final double mClockDriftMetersPerSecond;
+
+ public ClockInfo(
+ double hardwareCodeBiasMeters,
+ double timeCorrectionMeters,
+ double clockDriftMetersPerSecond) {
+ mHardwareCodeBiasMeters = hardwareCodeBiasMeters;
+ mTimeCorrectionMeters = timeCorrectionMeters;
+ mClockDriftMetersPerSecond = clockDriftMetersPerSecond;
+ }
+
+ public static final @NonNull Creator<ClockInfo> CREATOR =
+ new Creator<ClockInfo>() {
+ @Override
+ public ClockInfo createFromParcel(Parcel in) {
+ return new ClockInfo(
+ in.readDouble(),
+ in.readDouble(),
+ in.readDouble()
+ );
+ }
+
+ @Override
+ public ClockInfo[] newArray(int size) {
+ return new ClockInfo[size];
+ }
+ };
+
+ /**
+ * Returns the satellite hardware code bias of the reported code type w.r.t
+ * ionosphere-free measurement in meters.
+ */
+ @FloatRange()
+ public double getHardwareCodeBiasMeters() {
+ return mHardwareCodeBiasMeters;
+ }
+
+ /**
+ * Returns the satellite time correction for ionospheric-free signal measurement
+ * (meters). The satellite clock correction for the given signal type
+ * = satTimeCorrectionMeters - satHardwareCodeBiasMeters.
+ */
+ @FloatRange()
+ public double getTimeCorrectionMeters() {
+ return mTimeCorrectionMeters;
+ }
+
+ /**
+ * Returns the satellite clock drift (meters per second).
+ */
+ @FloatRange()
+ public double getClockDriftMetersPerSecond() {
+ return mClockDriftMetersPerSecond;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeDouble(mHardwareCodeBiasMeters);
+ dest.writeDouble(mTimeCorrectionMeters);
+ dest.writeDouble(mClockDriftMetersPerSecond);
+ }
+
+ @Override
+ public String toString() {
+ return "ClockInfo{"
+ + "hardwareCodeBiasMeters=" + mHardwareCodeBiasMeters
+ + ", timeCorrectionMeters=" + mTimeCorrectionMeters
+ + ", clockDriftMetersPerSecond=" + mClockDriftMetersPerSecond
+ + "}";
+ }
+ }
+
+ private SatellitePvt(
+ @NonNull PositionEcef positionEcef,
+ @NonNull VelocityEcef velocityEcef,
+ @NonNull ClockInfo clockInfo,
+ double ionoDelayMeters,
+ double tropoDelayMeters) {
+ if (positionEcef == null) {
+ throw new IllegalArgumentException("Position Ecef cannot be null.");
+ }
+ if (velocityEcef == null) {
+ throw new IllegalArgumentException("Velocity Ecef cannot be null.");
+ }
+ if (clockInfo == null) {
+ throw new IllegalArgumentException("Clock Info cannot be null.");
+ }
+ mPositionEcef = positionEcef;
+ mVelocityEcef = velocityEcef;
+ mClockInfo = clockInfo;
+ mIonoDelayMeters = ionoDelayMeters;
+ mTropoDelayMeters = tropoDelayMeters;
+ }
+
+ /**
+ * Returns a {@link PositionEcef} object that contains estimates of the satellite
+ * position fields in ECEF coordinate frame.
+ */
+ @NonNull
+ public PositionEcef getPositionEcef() {
+ return mPositionEcef;
+ }
+
+ /**
+ * Returns a {@link VelocityEcef} object that contains estimates of the satellite
+ * velocity fields in the ECEF coordinate frame.
+ */
+ @NonNull
+ public VelocityEcef getVelocityEcef() {
+ return mVelocityEcef;
+ }
+
+ /**
+ * Returns a {@link ClockInfo} object that contains estimates of the satellite
+ * clock info.
+ */
+ @NonNull
+ public ClockInfo getClockInfo() {
+ return mClockInfo;
+ }
+
+ /**
+ * Returns the ionospheric delay in meters.
+ */
+ @FloatRange()
+ public double getIonoDelayMeters() {
+ return mIonoDelayMeters;
+ }
+
+ /**
+ * Returns the tropospheric delay in meters.
+ */
+ @FloatRange()
+ public double getTropoDelayMeters() {
+ return mTropoDelayMeters;
+ }
+
+ public static final @android.annotation.NonNull Creator<SatellitePvt> CREATOR =
+ new Creator<SatellitePvt>() {
+ @Override
+ @Nullable
+ public SatellitePvt createFromParcel(Parcel in) {
+ ClassLoader classLoader = getClass().getClassLoader();
+ PositionEcef positionEcef = in.readParcelable(classLoader);
+ VelocityEcef velocityEcef = in.readParcelable(classLoader);
+ ClockInfo clockInfo = in.readParcelable(classLoader);
+ double ionoDelayMeters = in.readDouble();
+ double tropoDelayMeters = in.readDouble();
+
+ return new SatellitePvt(
+ positionEcef,
+ velocityEcef,
+ clockInfo,
+ ionoDelayMeters,
+ tropoDelayMeters);
+ }
+
+ @Override
+ public SatellitePvt[] newArray(int size) {
+ return new SatellitePvt[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel parcel, int flags) {
+ parcel.writeParcelable(mPositionEcef, flags);
+ parcel.writeParcelable(mVelocityEcef, flags);
+ parcel.writeParcelable(mClockInfo, flags);
+ parcel.writeDouble(mIonoDelayMeters);
+ parcel.writeDouble(mTropoDelayMeters);
+ }
+
+ @Override
+ public String toString() {
+ return "SatellitePvt{"
+ + "PositionEcef=" + mPositionEcef
+ + ", VelocityEcef=" + mVelocityEcef
+ + ", ClockInfo=" + mClockInfo
+ + ", IonoDelayMeters=" + mIonoDelayMeters
+ + ", TropoDelayMeters=" + mTropoDelayMeters
+ + "}";
+ }
+
+ /**
+ * Builder class for SatellitePvt.
+ */
+ public static final class Builder {
+ private PositionEcef mPositionEcef;
+ private VelocityEcef mVelocityEcef;
+ private ClockInfo mClockInfo;
+ private double mIonoDelayMeters;
+ private double mTropoDelayMeters;
+
+ /**
+ * Set position ECEF.
+ *
+ * @param positionEcef position ECEF object
+ * @return Builder builder object
+ */
+ @NonNull
+ public Builder setPositionEcef(
+ @NonNull PositionEcef positionEcef) {
+ mPositionEcef = positionEcef;
+ return this;
+ }
+
+ /**
+ * Set velocity ECEF.
+ *
+ * @param velocityEcef velocity ECEF object
+ * @return Builder builder object
+ */
+ @NonNull
+ public Builder setVelocityEcef(
+ @NonNull VelocityEcef velocityEcef) {
+ mVelocityEcef = velocityEcef;
+ return this;
+ }
+
+ /**
+ * Set clock info.
+ *
+ * @param clockInfo clock info object
+ * @return Builder builder object
+ */
+ @NonNull
+ public Builder setClockInfo(
+ @NonNull ClockInfo clockInfo) {
+ mClockInfo = clockInfo;
+ return this;
+ }
+
+ /**
+ * Set ionospheric delay in meters.
+ *
+ * @param ionoDelayMeters ionospheric delay (meters)
+ * @return Builder builder object
+ */
+ @NonNull
+ public Builder setIonoDelayMeters(@FloatRange() double ionoDelayMeters) {
+ mIonoDelayMeters = ionoDelayMeters;
+ return this;
+ }
+
+ /**
+ * Set tropospheric delay in meters.
+ *
+ * @param tropoDelayMeters tropospheric delay (meters)
+ * @return Builder builder object
+ */
+ @NonNull
+ public Builder setTropoDelayMeters(@FloatRange() double tropoDelayMeters) {
+ mTropoDelayMeters = tropoDelayMeters;
+ return this;
+ }
+
+ /**
+ * Build SatellitePvt object.
+ *
+ * @return instance of SatellitePvt
+ */
+ @NonNull
+ public SatellitePvt build() {
+ return new SatellitePvt(mPositionEcef, mVelocityEcef, mClockInfo,
+ mIonoDelayMeters, mTropoDelayMeters);
+ }
+ }
+}
diff --git a/services/core/jni/gnss/GnssMeasurementCallback.cpp b/services/core/jni/gnss/GnssMeasurementCallback.cpp
index bb020f30f27a..8cba77328248 100644
--- a/services/core/jni/gnss/GnssMeasurementCallback.cpp
+++ b/services/core/jni/gnss/GnssMeasurementCallback.cpp
@@ -25,15 +25,31 @@ using hardware::gnss::ElapsedRealtime;
using hardware::gnss::GnssClock;
using hardware::gnss::GnssData;
using hardware::gnss::GnssMeasurement;
+using hardware::gnss::SatellitePvt;
jclass class_gnssMeasurementsEvent;
jclass class_gnssMeasurement;
jclass class_gnssClock;
+jclass class_satellitePvtBuilder;
+jclass class_positionEcef;
+jclass class_velocityEcef;
+jclass class_clockInfo;
jmethodID method_gnssMeasurementsEventCtor;
+jmethodID method_gnssMeasurementsSetSatellitePvt;
jmethodID method_gnssClockCtor;
jmethodID method_gnssMeasurementCtor;
jmethodID method_reportMeasurementData;
+jmethodID method_satellitePvtBuilderBuild;
+jmethodID method_satellitePvtBuilderCtor;
+jmethodID method_satellitePvtBuilderSetPositionEcef;
+jmethodID method_satellitePvtBuilderSetVelocityEcef;
+jmethodID method_satellitePvtBuilderSetClockInfo;
+jmethodID method_satellitePvtBuilderSetIonoDelayMeters;
+jmethodID method_satellitePvtBuilderSetTropoDelayMeters;
+jmethodID method_positionEcef;
+jmethodID method_velocityEcef;
+jmethodID method_clockInfo;
void GnssMeasurement_class_init_once(JNIEnv* env, jclass& clazz) {
method_reportMeasurementData = env->GetMethodID(clazz, "reportMeasurementData",
@@ -47,10 +63,49 @@ void GnssMeasurement_class_init_once(JNIEnv* env, jclass& clazz) {
jclass gnssMeasurementClass = env->FindClass("android/location/GnssMeasurement");
class_gnssMeasurement = (jclass)env->NewGlobalRef(gnssMeasurementClass);
method_gnssMeasurementCtor = env->GetMethodID(class_gnssMeasurement, "<init>", "()V");
+ method_gnssMeasurementsSetSatellitePvt =
+ env->GetMethodID(class_gnssMeasurement, "setSatellitePvt",
+ "(Landroid/location/SatellitePvt;)V");
jclass gnssClockClass = env->FindClass("android/location/GnssClock");
class_gnssClock = (jclass)env->NewGlobalRef(gnssClockClass);
method_gnssClockCtor = env->GetMethodID(class_gnssClock, "<init>", "()V");
+
+ jclass satellitePvtBuilder = env->FindClass("android/location/SatellitePvt$Builder");
+ class_satellitePvtBuilder = (jclass)env->NewGlobalRef(satellitePvtBuilder);
+ method_satellitePvtBuilderCtor = env->GetMethodID(class_satellitePvtBuilder, "<init>", "()V");
+ method_satellitePvtBuilderSetPositionEcef =
+ env->GetMethodID(class_satellitePvtBuilder, "setPositionEcef",
+ "(Landroid/location/SatellitePvt$PositionEcef;)"
+ "Landroid/location/SatellitePvt$Builder;");
+ method_satellitePvtBuilderSetVelocityEcef =
+ env->GetMethodID(class_satellitePvtBuilder, "setVelocityEcef",
+ "(Landroid/location/SatellitePvt$VelocityEcef;)"
+ "Landroid/location/SatellitePvt$Builder;");
+ method_satellitePvtBuilderSetClockInfo =
+ env->GetMethodID(class_satellitePvtBuilder, "setClockInfo",
+ "(Landroid/location/SatellitePvt$ClockInfo;)"
+ "Landroid/location/SatellitePvt$Builder;");
+ method_satellitePvtBuilderSetIonoDelayMeters =
+ env->GetMethodID(class_satellitePvtBuilder, "setIonoDelayMeters",
+ "(D)Landroid/location/SatellitePvt$Builder;");
+ method_satellitePvtBuilderSetTropoDelayMeters =
+ env->GetMethodID(class_satellitePvtBuilder, "setTropoDelayMeters",
+ "(D)Landroid/location/SatellitePvt$Builder;");
+ method_satellitePvtBuilderBuild = env->GetMethodID(class_satellitePvtBuilder, "build",
+ "()Landroid/location/SatellitePvt;");
+
+ jclass positionEcefClass = env->FindClass("android/location/SatellitePvt$PositionEcef");
+ class_positionEcef = (jclass)env->NewGlobalRef(positionEcefClass);
+ method_positionEcef = env->GetMethodID(class_positionEcef, "<init>", "(DDDD)V");
+
+ jclass velocityEcefClass = env->FindClass("android/location/SatellitePvt$VelocityEcef");
+ class_velocityEcef = (jclass)env->NewGlobalRef(velocityEcefClass);
+ method_velocityEcef = env->GetMethodID(class_velocityEcef, "<init>", "(DDDD)V");
+
+ jclass clockInfoClass = env->FindClass("android/location/SatellitePvt$ClockInfo");
+ class_clockInfo = (jclass)env->NewGlobalRef(clockInfoClass);
+ method_clockInfo = env->GetMethodID(class_clockInfo, "<init>", "(DDD)V");
}
void setMeasurementData(JNIEnv* env, jobject& callbacksObj, jobject clock,
@@ -212,6 +267,49 @@ void GnssMeasurementCallbackAidl::translateSingleGnssMeasurement(JNIEnv* env,
SET(CarrierFrequencyHz, static_cast<float>(measurement.signalType.carrierFrequencyHz));
}
+ if (measurement.flags & static_cast<uint32_t>(GnssMeasurement::HAS_SATELLITE_PVT)) {
+ const SatellitePvt& satellitePvt = measurement.satellitePvt;
+ jobject positionEcef = env->NewObject(class_positionEcef, method_positionEcef,
+ satellitePvt.satPosEcef.posXMeters,
+ satellitePvt.satPosEcef.posYMeters,
+ satellitePvt.satPosEcef.posZMeters,
+ satellitePvt.satPosEcef.ureMeters);
+ jobject velocityEcef =
+ env->NewObject(class_velocityEcef, method_velocityEcef,
+ satellitePvt.satVelEcef.velXMps, satellitePvt.satVelEcef.velYMps,
+ satellitePvt.satVelEcef.velZMps, satellitePvt.satVelEcef.ureRateMps);
+ jobject clockInfo = env->NewObject(class_clockInfo, method_clockInfo,
+ satellitePvt.satClockInfo.satHardwareCodeBiasMeters,
+ satellitePvt.satClockInfo.satTimeCorrectionMeters,
+ satellitePvt.satClockInfo.satClkDriftMps);
+ jobject satellitePvtBuilderObject =
+ env->NewObject(class_satellitePvtBuilder, method_satellitePvtBuilderCtor);
+
+ env->CallObjectMethod(satellitePvtBuilderObject, method_satellitePvtBuilderSetPositionEcef,
+ positionEcef);
+ env->CallObjectMethod(satellitePvtBuilderObject, method_satellitePvtBuilderSetVelocityEcef,
+ velocityEcef);
+ env->CallObjectMethod(satellitePvtBuilderObject, method_satellitePvtBuilderSetClockInfo,
+ clockInfo);
+ env->CallObjectMethod(satellitePvtBuilderObject,
+ method_satellitePvtBuilderSetIonoDelayMeters,
+ satellitePvt.ionoDelayMeters);
+ env->CallObjectMethod(satellitePvtBuilderObject,
+ method_satellitePvtBuilderSetTropoDelayMeters,
+ satellitePvt.tropoDelayMeters);
+ jobject satellitePvtObject =
+ env->CallObjectMethod(satellitePvtBuilderObject, method_satellitePvtBuilderBuild);
+
+ env->CallVoidMethod(object.get(), method_gnssMeasurementsSetSatellitePvt,
+ satellitePvtObject);
+
+ env->DeleteLocalRef(positionEcef);
+ env->DeleteLocalRef(velocityEcef);
+ env->DeleteLocalRef(clockInfo);
+ env->DeleteLocalRef(satellitePvtBuilderObject);
+ env->DeleteLocalRef(satellitePvtObject);
+ }
+
jstring codeType = env->NewStringUTF(measurement.signalType.codeType.c_str());
SET(CodeType, codeType);
env->DeleteLocalRef(codeType);