Merge "Add valid satellite PVT fields in JNI & framework" into sc-dev
This commit is contained in:
@@ -4997,11 +4997,15 @@ package android.location {
|
|||||||
|
|
||||||
public final class SatellitePvt implements android.os.Parcelable {
|
public final class SatellitePvt implements android.os.Parcelable {
|
||||||
method public int describeContents();
|
method public int describeContents();
|
||||||
method @NonNull public android.location.SatellitePvt.ClockInfo getClockInfo();
|
method @Nullable public android.location.SatellitePvt.ClockInfo getClockInfo();
|
||||||
|
method public int getFlags();
|
||||||
method @FloatRange public double getIonoDelayMeters();
|
method @FloatRange public double getIonoDelayMeters();
|
||||||
method @NonNull public android.location.SatellitePvt.PositionEcef getPositionEcef();
|
method @Nullable public android.location.SatellitePvt.PositionEcef getPositionEcef();
|
||||||
method @FloatRange public double getTropoDelayMeters();
|
method @FloatRange public double getTropoDelayMeters();
|
||||||
method @NonNull public android.location.SatellitePvt.VelocityEcef getVelocityEcef();
|
method @Nullable public android.location.SatellitePvt.VelocityEcef getVelocityEcef();
|
||||||
|
method public boolean hasIono();
|
||||||
|
method public boolean hasPositionVelocityClockInfo();
|
||||||
|
method public boolean hasTropo();
|
||||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||||
field @NonNull public static final android.os.Parcelable.Creator<android.location.SatellitePvt> CREATOR;
|
field @NonNull public static final android.os.Parcelable.Creator<android.location.SatellitePvt> CREATOR;
|
||||||
}
|
}
|
||||||
@@ -5010,6 +5014,7 @@ package android.location {
|
|||||||
ctor public SatellitePvt.Builder();
|
ctor public SatellitePvt.Builder();
|
||||||
method @NonNull public android.location.SatellitePvt build();
|
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 setClockInfo(@NonNull android.location.SatellitePvt.ClockInfo);
|
||||||
|
method @NonNull public android.location.SatellitePvt.Builder setFlags(int);
|
||||||
method @NonNull public android.location.SatellitePvt.Builder setIonoDelayMeters(@FloatRange double);
|
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 setPositionEcef(@NonNull android.location.SatellitePvt.PositionEcef);
|
||||||
method @NonNull public android.location.SatellitePvt.Builder setTropoDelayMeters(@FloatRange double);
|
method @NonNull public android.location.SatellitePvt.Builder setTropoDelayMeters(@FloatRange double);
|
||||||
|
|||||||
@@ -45,8 +45,41 @@ import android.os.Parcelable;
|
|||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
public final class SatellitePvt implements Parcelable {
|
public final class SatellitePvt implements Parcelable {
|
||||||
|
/**
|
||||||
|
* Bit mask for {@link #mFlags} indicating valid satellite position, velocity and clock info
|
||||||
|
* fields are stored in the SatellitePvt.
|
||||||
|
*/
|
||||||
|
private static final int HAS_POSITION_VELOCITY_CLOCK_INFO = 1 << 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bit mask for {@link #mFlags} indicating a valid iono delay field is stored in the
|
||||||
|
* SatellitePvt.
|
||||||
|
*/
|
||||||
|
private static final int HAS_IONO = 1 << 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bit mask for {@link #mFlags} indicating a valid tropo delay field is stored in the
|
||||||
|
* SatellitePvt.
|
||||||
|
*/
|
||||||
|
private static final int HAS_TROPO = 1 << 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A bitfield of flags indicating the validity of the fields in this SatellitePvt.
|
||||||
|
* The bit masks are defined in the constants with prefix HAS_*
|
||||||
|
*
|
||||||
|
* <p>Fields for which there is no corresponding flag must be filled in with a valid value.
|
||||||
|
* For convenience, these are marked as mandatory.
|
||||||
|
*
|
||||||
|
* <p>Others fields may have invalid information in them, if not marked as valid by the
|
||||||
|
* corresponding bit in flags.
|
||||||
|
*/
|
||||||
|
private final int mFlags;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private final PositionEcef mPositionEcef;
|
private final PositionEcef mPositionEcef;
|
||||||
|
@Nullable
|
||||||
private final VelocityEcef mVelocityEcef;
|
private final VelocityEcef mVelocityEcef;
|
||||||
|
@Nullable
|
||||||
private final ClockInfo mClockInfo;
|
private final ClockInfo mClockInfo;
|
||||||
private final double mIonoDelayMeters;
|
private final double mIonoDelayMeters;
|
||||||
private final double mTropoDelayMeters;
|
private final double mTropoDelayMeters;
|
||||||
@@ -351,20 +384,13 @@ public final class SatellitePvt implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SatellitePvt(
|
private SatellitePvt(
|
||||||
@NonNull PositionEcef positionEcef,
|
int flags,
|
||||||
@NonNull VelocityEcef velocityEcef,
|
@Nullable PositionEcef positionEcef,
|
||||||
@NonNull ClockInfo clockInfo,
|
@Nullable VelocityEcef velocityEcef,
|
||||||
|
@Nullable ClockInfo clockInfo,
|
||||||
double ionoDelayMeters,
|
double ionoDelayMeters,
|
||||||
double tropoDelayMeters) {
|
double tropoDelayMeters) {
|
||||||
if (positionEcef == null) {
|
mFlags = flags;
|
||||||
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;
|
mPositionEcef = positionEcef;
|
||||||
mVelocityEcef = velocityEcef;
|
mVelocityEcef = velocityEcef;
|
||||||
mClockInfo = clockInfo;
|
mClockInfo = clockInfo;
|
||||||
@@ -372,11 +398,18 @@ public final class SatellitePvt implements Parcelable {
|
|||||||
mTropoDelayMeters = tropoDelayMeters;
|
mTropoDelayMeters = tropoDelayMeters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a bitmask of fields present in this object
|
||||||
|
*/
|
||||||
|
public int getFlags() {
|
||||||
|
return mFlags;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link PositionEcef} object that contains estimates of the satellite
|
* Returns a {@link PositionEcef} object that contains estimates of the satellite
|
||||||
* position fields in ECEF coordinate frame.
|
* position fields in ECEF coordinate frame.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@Nullable
|
||||||
public PositionEcef getPositionEcef() {
|
public PositionEcef getPositionEcef() {
|
||||||
return mPositionEcef;
|
return mPositionEcef;
|
||||||
}
|
}
|
||||||
@@ -385,7 +418,7 @@ public final class SatellitePvt implements Parcelable {
|
|||||||
* Returns a {@link VelocityEcef} object that contains estimates of the satellite
|
* Returns a {@link VelocityEcef} object that contains estimates of the satellite
|
||||||
* velocity fields in the ECEF coordinate frame.
|
* velocity fields in the ECEF coordinate frame.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@Nullable
|
||||||
public VelocityEcef getVelocityEcef() {
|
public VelocityEcef getVelocityEcef() {
|
||||||
return mVelocityEcef;
|
return mVelocityEcef;
|
||||||
}
|
}
|
||||||
@@ -394,7 +427,7 @@ public final class SatellitePvt implements Parcelable {
|
|||||||
* Returns a {@link ClockInfo} object that contains estimates of the satellite
|
* Returns a {@link ClockInfo} object that contains estimates of the satellite
|
||||||
* clock info.
|
* clock info.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@Nullable
|
||||||
public ClockInfo getClockInfo() {
|
public ClockInfo getClockInfo() {
|
||||||
return mClockInfo;
|
return mClockInfo;
|
||||||
}
|
}
|
||||||
@@ -415,11 +448,29 @@ public final class SatellitePvt implements Parcelable {
|
|||||||
return mTropoDelayMeters;
|
return mTropoDelayMeters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns {@code true} if {@link #getPositionEcef()}, {@link #getVelocityEcef()},
|
||||||
|
* and {@link #getClockInfo()} are valid.
|
||||||
|
*/
|
||||||
|
public boolean hasPositionVelocityClockInfo() {
|
||||||
|
return (mFlags & HAS_POSITION_VELOCITY_CLOCK_INFO) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns {@code true} if {@link #getIonoDelayMeters()} is valid. */
|
||||||
|
public boolean hasIono() {
|
||||||
|
return (mFlags & HAS_IONO) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns {@code true} if {@link #getTropoDelayMeters()} is valid. */
|
||||||
|
public boolean hasTropo() {
|
||||||
|
return (mFlags & HAS_TROPO) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static final @android.annotation.NonNull Creator<SatellitePvt> CREATOR =
|
public static final @android.annotation.NonNull Creator<SatellitePvt> CREATOR =
|
||||||
new Creator<SatellitePvt>() {
|
new Creator<SatellitePvt>() {
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public SatellitePvt createFromParcel(Parcel in) {
|
public SatellitePvt createFromParcel(Parcel in) {
|
||||||
|
int flags = in.readInt();
|
||||||
ClassLoader classLoader = getClass().getClassLoader();
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
PositionEcef positionEcef = in.readParcelable(classLoader);
|
PositionEcef positionEcef = in.readParcelable(classLoader);
|
||||||
VelocityEcef velocityEcef = in.readParcelable(classLoader);
|
VelocityEcef velocityEcef = in.readParcelable(classLoader);
|
||||||
@@ -428,6 +479,7 @@ public final class SatellitePvt implements Parcelable {
|
|||||||
double tropoDelayMeters = in.readDouble();
|
double tropoDelayMeters = in.readDouble();
|
||||||
|
|
||||||
return new SatellitePvt(
|
return new SatellitePvt(
|
||||||
|
flags,
|
||||||
positionEcef,
|
positionEcef,
|
||||||
velocityEcef,
|
velocityEcef,
|
||||||
clockInfo,
|
clockInfo,
|
||||||
@@ -448,6 +500,7 @@ public final class SatellitePvt implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(@NonNull Parcel parcel, int flags) {
|
public void writeToParcel(@NonNull Parcel parcel, int flags) {
|
||||||
|
parcel.writeInt(mFlags);
|
||||||
parcel.writeParcelable(mPositionEcef, flags);
|
parcel.writeParcelable(mPositionEcef, flags);
|
||||||
parcel.writeParcelable(mVelocityEcef, flags);
|
parcel.writeParcelable(mVelocityEcef, flags);
|
||||||
parcel.writeParcelable(mClockInfo, flags);
|
parcel.writeParcelable(mClockInfo, flags);
|
||||||
@@ -458,7 +511,8 @@ public final class SatellitePvt implements Parcelable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SatellitePvt{"
|
return "SatellitePvt{"
|
||||||
+ "PositionEcef=" + mPositionEcef
|
+ "Flags=" + mFlags
|
||||||
|
+ ", PositionEcef=" + mPositionEcef
|
||||||
+ ", VelocityEcef=" + mVelocityEcef
|
+ ", VelocityEcef=" + mVelocityEcef
|
||||||
+ ", ClockInfo=" + mClockInfo
|
+ ", ClockInfo=" + mClockInfo
|
||||||
+ ", IonoDelayMeters=" + mIonoDelayMeters
|
+ ", IonoDelayMeters=" + mIonoDelayMeters
|
||||||
@@ -470,12 +524,29 @@ public final class SatellitePvt implements Parcelable {
|
|||||||
* Builder class for SatellitePvt.
|
* Builder class for SatellitePvt.
|
||||||
*/
|
*/
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
private PositionEcef mPositionEcef;
|
/**
|
||||||
private VelocityEcef mVelocityEcef;
|
* For documentation of below fields, see corresponding fields in {@link
|
||||||
private ClockInfo mClockInfo;
|
* SatellitePvt}.
|
||||||
|
*/
|
||||||
|
private int mFlags;
|
||||||
|
@Nullable private PositionEcef mPositionEcef;
|
||||||
|
@Nullable private VelocityEcef mVelocityEcef;
|
||||||
|
@Nullable private ClockInfo mClockInfo;
|
||||||
private double mIonoDelayMeters;
|
private double mIonoDelayMeters;
|
||||||
private double mTropoDelayMeters;
|
private double mTropoDelayMeters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a bitmask of fields present in this object
|
||||||
|
*
|
||||||
|
* @param flags int flags
|
||||||
|
* @return Builder builder object
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public Builder setFlags(int flags) {
|
||||||
|
mFlags = flags;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set position ECEF.
|
* Set position ECEF.
|
||||||
*
|
*
|
||||||
@@ -546,7 +617,7 @@ public final class SatellitePvt implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public SatellitePvt build() {
|
public SatellitePvt build() {
|
||||||
return new SatellitePvt(mPositionEcef, mVelocityEcef, mClockInfo,
|
return new SatellitePvt(mFlags, mPositionEcef, mVelocityEcef, mClockInfo,
|
||||||
mIonoDelayMeters, mTropoDelayMeters);
|
mIonoDelayMeters, mTropoDelayMeters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ jmethodID method_gnssMeasurementCtor;
|
|||||||
jmethodID method_reportMeasurementData;
|
jmethodID method_reportMeasurementData;
|
||||||
jmethodID method_satellitePvtBuilderBuild;
|
jmethodID method_satellitePvtBuilderBuild;
|
||||||
jmethodID method_satellitePvtBuilderCtor;
|
jmethodID method_satellitePvtBuilderCtor;
|
||||||
|
jmethodID method_satellitePvtBuilderSetFlags;
|
||||||
jmethodID method_satellitePvtBuilderSetPositionEcef;
|
jmethodID method_satellitePvtBuilderSetPositionEcef;
|
||||||
jmethodID method_satellitePvtBuilderSetVelocityEcef;
|
jmethodID method_satellitePvtBuilderSetVelocityEcef;
|
||||||
jmethodID method_satellitePvtBuilderSetClockInfo;
|
jmethodID method_satellitePvtBuilderSetClockInfo;
|
||||||
@@ -89,6 +90,9 @@ void GnssMeasurement_class_init_once(JNIEnv* env, jclass& clazz) {
|
|||||||
jclass satellitePvtBuilder = env->FindClass("android/location/SatellitePvt$Builder");
|
jclass satellitePvtBuilder = env->FindClass("android/location/SatellitePvt$Builder");
|
||||||
class_satellitePvtBuilder = (jclass)env->NewGlobalRef(satellitePvtBuilder);
|
class_satellitePvtBuilder = (jclass)env->NewGlobalRef(satellitePvtBuilder);
|
||||||
method_satellitePvtBuilderCtor = env->GetMethodID(class_satellitePvtBuilder, "<init>", "()V");
|
method_satellitePvtBuilderCtor = env->GetMethodID(class_satellitePvtBuilder, "<init>", "()V");
|
||||||
|
method_satellitePvtBuilderSetFlags =
|
||||||
|
env->GetMethodID(class_satellitePvtBuilder, "setFlags",
|
||||||
|
"(I)Landroid/location/SatellitePvt$Builder;");
|
||||||
method_satellitePvtBuilderSetPositionEcef =
|
method_satellitePvtBuilderSetPositionEcef =
|
||||||
env->GetMethodID(class_satellitePvtBuilder, "setPositionEcef",
|
env->GetMethodID(class_satellitePvtBuilder, "setPositionEcef",
|
||||||
"(Landroid/location/SatellitePvt$PositionEcef;)"
|
"(Landroid/location/SatellitePvt$PositionEcef;)"
|
||||||
@@ -313,22 +317,33 @@ void GnssMeasurementCallbackAidl::translateSingleGnssMeasurement(JNIEnv* env,
|
|||||||
|
|
||||||
if (measurement.flags & static_cast<uint32_t>(GnssMeasurement::HAS_SATELLITE_PVT)) {
|
if (measurement.flags & static_cast<uint32_t>(GnssMeasurement::HAS_SATELLITE_PVT)) {
|
||||||
const SatellitePvt& satellitePvt = measurement.satellitePvt;
|
const SatellitePvt& satellitePvt = measurement.satellitePvt;
|
||||||
jobject positionEcef = env->NewObject(class_positionEcef, method_positionEcef,
|
uint16_t satFlags = static_cast<uint16_t>(satellitePvt.flags);
|
||||||
satellitePvt.satPosEcef.posXMeters,
|
jobject positionEcef = nullptr;
|
||||||
satellitePvt.satPosEcef.posYMeters,
|
jobject velocityEcef = nullptr;
|
||||||
satellitePvt.satPosEcef.posZMeters,
|
jobject clockInfo = nullptr;
|
||||||
satellitePvt.satPosEcef.ureMeters);
|
|
||||||
jobject velocityEcef =
|
if (satFlags & SatellitePvt::HAS_POSITION_VELOCITY_CLOCK_INFO) {
|
||||||
env->NewObject(class_velocityEcef, method_velocityEcef,
|
positionEcef = env->NewObject(class_positionEcef, method_positionEcef,
|
||||||
satellitePvt.satVelEcef.velXMps, satellitePvt.satVelEcef.velYMps,
|
satellitePvt.satPosEcef.posXMeters,
|
||||||
satellitePvt.satVelEcef.velZMps, satellitePvt.satVelEcef.ureRateMps);
|
satellitePvt.satPosEcef.posYMeters,
|
||||||
jobject clockInfo = env->NewObject(class_clockInfo, method_clockInfo,
|
satellitePvt.satPosEcef.posZMeters,
|
||||||
satellitePvt.satClockInfo.satHardwareCodeBiasMeters,
|
satellitePvt.satPosEcef.ureMeters);
|
||||||
satellitePvt.satClockInfo.satTimeCorrectionMeters,
|
velocityEcef =
|
||||||
satellitePvt.satClockInfo.satClkDriftMps);
|
env->NewObject(class_velocityEcef, method_velocityEcef,
|
||||||
|
satellitePvt.satVelEcef.velXMps, satellitePvt.satVelEcef.velYMps,
|
||||||
|
satellitePvt.satVelEcef.velZMps,
|
||||||
|
satellitePvt.satVelEcef.ureRateMps);
|
||||||
|
clockInfo = env->NewObject(class_clockInfo, method_clockInfo,
|
||||||
|
satellitePvt.satClockInfo.satHardwareCodeBiasMeters,
|
||||||
|
satellitePvt.satClockInfo.satTimeCorrectionMeters,
|
||||||
|
satellitePvt.satClockInfo.satClkDriftMps);
|
||||||
|
}
|
||||||
|
|
||||||
jobject satellitePvtBuilderObject =
|
jobject satellitePvtBuilderObject =
|
||||||
env->NewObject(class_satellitePvtBuilder, method_satellitePvtBuilderCtor);
|
env->NewObject(class_satellitePvtBuilder, method_satellitePvtBuilderCtor);
|
||||||
|
|
||||||
|
env->CallObjectMethod(satellitePvtBuilderObject, method_satellitePvtBuilderSetFlags,
|
||||||
|
satellitePvt.flags);
|
||||||
env->CallObjectMethod(satellitePvtBuilderObject, method_satellitePvtBuilderSetPositionEcef,
|
env->CallObjectMethod(satellitePvtBuilderObject, method_satellitePvtBuilderSetPositionEcef,
|
||||||
positionEcef);
|
positionEcef);
|
||||||
env->CallObjectMethod(satellitePvtBuilderObject, method_satellitePvtBuilderSetVelocityEcef,
|
env->CallObjectMethod(satellitePvtBuilderObject, method_satellitePvtBuilderSetVelocityEcef,
|
||||||
|
|||||||
Reference in New Issue
Block a user