summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xapi/system-current.txt5
-rw-r--r--location/java/android/location/GnssMeasurementCorrections.java100
-rw-r--r--services/core/jni/com_android_server_location_GnssLocationProvider.cpp102
3 files changed, 182 insertions, 25 deletions
diff --git a/api/system-current.txt b/api/system-current.txt
index 59f2835b984f..b8df8f2f08f1 100755
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -3801,12 +3801,15 @@ package android.location {
public final class GnssMeasurementCorrections implements android.os.Parcelable {
method public int describeContents();
method @FloatRange(from=-1000.0F, to=10000.0f) public double getAltitudeMeters();
+ method @FloatRange(from=0.0f, to=360.0f) public float getEnvironmentBearingDegrees();
+ method @FloatRange(from=0.0f, to=180.0f) public float getEnvironmentBearingUncertaintyDegrees();
method @FloatRange(from=0.0f) public double getHorizontalPositionUncertaintyMeters();
method @FloatRange(from=-90.0F, to=90.0f) public double getLatitudeDegrees();
method @FloatRange(from=-180.0F, to=180.0f) public double getLongitudeDegrees();
method @NonNull public java.util.List<android.location.GnssSingleSatCorrection> getSingleSatelliteCorrectionList();
method @IntRange(from=0) public long getToaGpsNanosecondsOfWeek();
method @FloatRange(from=0.0f) public double getVerticalPositionUncertaintyMeters();
+ method public boolean hasEnvironmentBearing();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.location.GnssMeasurementCorrections> CREATOR;
}
@@ -3815,6 +3818,8 @@ package android.location {
ctor public GnssMeasurementCorrections.Builder();
method @NonNull public android.location.GnssMeasurementCorrections build();
method @NonNull public android.location.GnssMeasurementCorrections.Builder setAltitudeMeters(@FloatRange(from=-1000.0F, to=10000.0f) double);
+ method @NonNull public android.location.GnssMeasurementCorrections.Builder setEnvironmentBearingDegrees(@FloatRange(from=0.0f, to=360.0f) float);
+ method @NonNull public android.location.GnssMeasurementCorrections.Builder setEnvironmentBearingUncertaintyDegrees(@FloatRange(from=0.0f, to=180.0f) float);
method @NonNull public android.location.GnssMeasurementCorrections.Builder setHorizontalPositionUncertaintyMeters(@FloatRange(from=0.0f) double);
method @NonNull public android.location.GnssMeasurementCorrections.Builder setLatitudeDegrees(@FloatRange(from=-90.0F, to=90.0f) double);
method @NonNull public android.location.GnssMeasurementCorrections.Builder setLongitudeDegrees(@FloatRange(from=-180.0F, to=180.0f) double);
diff --git a/location/java/android/location/GnssMeasurementCorrections.java b/location/java/android/location/GnssMeasurementCorrections.java
index a23213ff260c..19c3992ebed3 100644
--- a/location/java/android/location/GnssMeasurementCorrections.java
+++ b/location/java/android/location/GnssMeasurementCorrections.java
@@ -79,6 +79,25 @@ public final class GnssMeasurementCorrections implements Parcelable {
@NonNull
private final List<GnssSingleSatCorrection> mSingleSatCorrectionList;
+ /**
+ * Indicates whether the environment bearing is available.
+ */
+ private final boolean mHasEnvironmentBearing;
+
+ /**
+ * Environment bearing in degrees clockwise from true north, in the direction of user motion.
+ * Environment bearing is provided when it is known with high probability that velocity is
+ * aligned with an environment feature (such as edge of a building, or road).
+ */
+ @FloatRange(from = 0.0f, to = 360.0f)
+ private final float mEnvironmentBearingDegrees;
+
+ /**
+ * Environment bearing uncertainty in degrees.
+ */
+ @FloatRange(from = 0.0f, to = 180.0f)
+ private final float mEnvironmentBearingUncertaintyDegrees;
+
private GnssMeasurementCorrections(Builder builder) {
mLatitudeDegrees = builder.mLatitudeDegrees;
mLongitudeDegrees = builder.mLongitudeDegrees;
@@ -89,6 +108,10 @@ public final class GnssMeasurementCorrections implements Parcelable {
final List<GnssSingleSatCorrection> singleSatCorrList = builder.mSingleSatCorrectionList;
Preconditions.checkArgument(singleSatCorrList != null && !singleSatCorrList.isEmpty());
mSingleSatCorrectionList = Collections.unmodifiableList(new ArrayList<>(singleSatCorrList));
+ mHasEnvironmentBearing = builder.mEnvironmentBearingIsSet
+ && builder.mEnvironmentBearingUncertaintyIsSet;
+ mEnvironmentBearingDegrees = builder.mEnvironmentBearingDegrees;
+ mEnvironmentBearingUncertaintyDegrees = builder.mEnvironmentBearingUncertaintyDegrees;
}
/** Gets the latitude in degrees at which the corrections are computed. */
@@ -145,6 +168,31 @@ public final class GnssMeasurementCorrections implements Parcelable {
return mSingleSatCorrectionList;
}
+ /**
+ * If true, environment bearing will be available.
+ */
+ public boolean hasEnvironmentBearing() {
+ return mHasEnvironmentBearing;
+ }
+
+ /**
+ * Gets the environment bearing in degrees clockwise from true north, in the direction of user
+ * motion. Environment bearing is provided when it is known with high probability that
+ * velocity is aligned with an environment feature (such as edge of a building, or road).
+ */
+ @FloatRange(from = 0.0f, to = 360.0f)
+ public float getEnvironmentBearingDegrees() {
+ return mEnvironmentBearingDegrees;
+ }
+
+ /**
+ * Gets the environment bearing uncertainty in degrees.
+ */
+ @FloatRange(from = 0.0f, to = 180.0f)
+ public float getEnvironmentBearingUncertaintyDegrees() {
+ return mEnvironmentBearingUncertaintyDegrees;
+ }
+
@Override
public int describeContents() {
return 0;
@@ -167,6 +215,12 @@ public final class GnssMeasurementCorrections implements Parcelable {
parcel.readTypedList(singleSatCorrectionList, GnssSingleSatCorrection.CREATOR);
gnssMeasurementCorrectons.setSingleSatelliteCorrectionList(
singleSatCorrectionList);
+ boolean hasEnvironmentBearing = parcel.readBoolean();
+ if (hasEnvironmentBearing) {
+ gnssMeasurementCorrectons.setEnvironmentBearingDegrees(parcel.readFloat());
+ gnssMeasurementCorrectons.setEnvironmentBearingUncertaintyDegrees(
+ parcel.readFloat());
+ }
return gnssMeasurementCorrectons.build();
}
@@ -192,6 +246,14 @@ public final class GnssMeasurementCorrections implements Parcelable {
String.format(format, "ToaGpsNanosecondsOfWeek = ", mToaGpsNanosecondsOfWeek));
builder.append(
String.format(format, "mSingleSatCorrectionList = ", mSingleSatCorrectionList));
+ builder.append(
+ String.format(format, "HasEnvironmentBearing = ", mHasEnvironmentBearing));
+ builder.append(
+ String.format(format, "EnvironmentBearingDegrees = ",
+ mEnvironmentBearingDegrees));
+ builder.append(
+ String.format(format, "EnvironmentBearingUncertaintyDegrees = ",
+ mEnvironmentBearingUncertaintyDegrees));
return builder.toString();
}
@@ -204,6 +266,11 @@ public final class GnssMeasurementCorrections implements Parcelable {
parcel.writeDouble(mVerticalPositionUncertaintyMeters);
parcel.writeLong(mToaGpsNanosecondsOfWeek);
parcel.writeTypedList(mSingleSatCorrectionList);
+ parcel.writeBoolean(mHasEnvironmentBearing);
+ if (mHasEnvironmentBearing) {
+ parcel.writeFloat(mEnvironmentBearingDegrees);
+ parcel.writeFloat(mEnvironmentBearingUncertaintyDegrees);
+ }
}
/** Builder for {@link GnssMeasurementCorrections} */
@@ -219,6 +286,10 @@ public final class GnssMeasurementCorrections implements Parcelable {
private double mVerticalPositionUncertaintyMeters;
private long mToaGpsNanosecondsOfWeek;
@Nullable private List<GnssSingleSatCorrection> mSingleSatCorrectionList;
+ private float mEnvironmentBearingDegrees;
+ private boolean mEnvironmentBearingIsSet = false;
+ private float mEnvironmentBearingUncertaintyDegrees;
+ private boolean mEnvironmentBearingUncertaintyIsSet = false;
/** Sets the latitude in degrees at which the corrections are computed. */
@NonNull public Builder setLatitudeDegrees(
@@ -282,8 +353,37 @@ public final class GnssMeasurementCorrections implements Parcelable {
return this;
}
+ /**
+ * Sets the environment bearing in degrees clockwise from true north, in the direction of
+ * user motion. Environment bearing is provided when it is known with high probability
+ * that velocity is aligned with an environment feature (such as edge of a building, or
+ * road).
+ */
+ @NonNull public Builder setEnvironmentBearingDegrees(
+ @FloatRange(from = 0.0f, to = 360.0f)
+ float environmentBearingDegrees) {
+ mEnvironmentBearingDegrees = environmentBearingDegrees;
+ mEnvironmentBearingIsSet = true;
+ return this;
+ }
+
+ /**
+ * Sets the environment bearing uncertainty in degrees.
+ */
+ @NonNull public Builder setEnvironmentBearingUncertaintyDegrees(
+ @FloatRange(from = 0.0f, to = 180.0f)
+ float environmentBearingUncertaintyDegrees) {
+ mEnvironmentBearingUncertaintyDegrees = environmentBearingUncertaintyDegrees;
+ mEnvironmentBearingUncertaintyIsSet = true;
+ return this;
+ }
+
/** Builds a {@link GnssMeasurementCorrections} instance as specified by this builder. */
@NonNull public GnssMeasurementCorrections build() {
+ if (mEnvironmentBearingIsSet ^ mEnvironmentBearingUncertaintyIsSet) {
+ throw new IllegalStateException("Both environment bearing and environment bearing "
+ + "uncertainty must be set.");
+ }
return new GnssMeasurementCorrections(this);
}
}
diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
index 08a759227526..12de20cc3d51 100644
--- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
+++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
@@ -28,6 +28,7 @@
#include <android/hardware/gnss/2.0/IGnssMeasurement.h>
#include <android/hardware/gnss/2.1/IGnssMeasurement.h>
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrections.h>
+#include <android/hardware/gnss/measurement_corrections/1.1/IMeasurementCorrections.h>
#include <android/hardware/gnss/visibility_control/1.0/IGnssVisibilityControl.h>
#include <nativehelper/JNIHelp.h>
#include "jni.h"
@@ -88,6 +89,9 @@ static jmethodID method_correctionsGetHorPosUncMeters;
static jmethodID method_correctionsGetVerPosUncMeters;
static jmethodID method_correctionsGetToaGpsNanosecondsOfWeek;
static jmethodID method_correctionsGetSingleSatCorrectionList;
+static jmethodID method_correctionsHasEnvironmentBearing;
+static jmethodID method_correctionsGetEnvironmentBearingDegrees;
+static jmethodID method_correctionsGetEnvironmentBearingUncertaintyDegrees;
static jmethodID method_listSize;
static jmethodID method_correctionListGet;
static jmethodID method_correctionSatFlags;
@@ -142,7 +146,9 @@ using android::hardware::gnss::V1_0::IGnssXtraCallback;
using android::hardware::gnss::V2_0::ElapsedRealtimeFlags;
-using android::hardware::gnss::measurement_corrections::V1_0::MeasurementCorrections;
+using MeasurementCorrections_V1_0 = android::hardware::gnss::measurement_corrections::V1_0::MeasurementCorrections;
+using MeasurementCorrections_V1_1 = android::hardware::gnss::measurement_corrections::V1_1::MeasurementCorrections;
+
using android::hardware::gnss::measurement_corrections::V1_0::SingleSatCorrection;
using android::hardware::gnss::measurement_corrections::V1_0::ReflectingPlane;
@@ -184,7 +190,8 @@ using IGnssBatching_V2_0 = android::hardware::gnss::V2_0::IGnssBatching;
using IGnssBatchingCallback_V1_0 = android::hardware::gnss::V1_0::IGnssBatchingCallback;
using IGnssBatchingCallback_V2_0 = android::hardware::gnss::V2_0::IGnssBatchingCallback;
-using android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections;
+using IMeasurementCorrections_V1_0 = android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections;
+using IMeasurementCorrections_V1_1 = android::hardware::gnss::measurement_corrections::V1_1::IMeasurementCorrections;
using android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
using android::hardware::gnss::measurement_corrections::V1_0::GnssSingleSatCorrectionFlags;
@@ -231,7 +238,8 @@ sp<IGnssMeasurement_V1_1> gnssMeasurementIface_V1_1 = nullptr;
sp<IGnssMeasurement_V2_0> gnssMeasurementIface_V2_0 = nullptr;
sp<IGnssMeasurement_V2_1> gnssMeasurementIface_V2_1 = nullptr;
sp<IGnssNavigationMessage> gnssNavigationMessageIface = nullptr;
-sp<IMeasurementCorrections> gnssCorrectionsIface = nullptr;
+sp<IMeasurementCorrections_V1_0> gnssCorrectionsIface_V1_0 = nullptr;
+sp<IMeasurementCorrections_V1_1> gnssCorrectionsIface_V1_1 = nullptr;
sp<IGnssVisibilityControl> gnssVisibilityControlIface = nullptr;
#define WAKE_LOCK_NAME "GPS"
@@ -1735,6 +1743,13 @@ static void android_location_GnssLocationProvider_class_init_native(JNIEnv* env,
method_correctionsGetSingleSatCorrectionList = env->GetMethodID(
measCorrClass, "getSingleSatelliteCorrectionList", "()Ljava/util/List;");
+ method_correctionsHasEnvironmentBearing = env->GetMethodID(
+ measCorrClass, "hasEnvironmentBearing", "()Z");
+ method_correctionsGetEnvironmentBearingDegrees = env->GetMethodID(
+ measCorrClass, "getEnvironmentBearingDegrees", "()F");
+ method_correctionsGetEnvironmentBearingUncertaintyDegrees = env->GetMethodID(
+ measCorrClass, "getEnvironmentBearingUncertaintyDegrees", "()F");
+
jclass corrListClass = env->FindClass("java/util/List");
method_listSize = env->GetMethodID(corrListClass, "size", "()I");
method_correctionListGet = env->GetMethodID(corrListClass, "get", "(I)Ljava/lang/Object;");
@@ -1917,12 +1932,20 @@ static void android_location_GnssLocationProvider_init_once(JNIEnv* env, jclass
}
}
- if (gnssHal_V2_0 != nullptr) {
+ if (gnssHal_V2_1 != nullptr) {
+ auto gnssCorrections = gnssHal_V2_1->getExtensionMeasurementCorrections_1_1();
+ if (!gnssCorrections.isOk()) {
+ ALOGD("Unable to get a handle to GnssMeasurementCorrections 1.1 interface");
+ } else {
+ gnssCorrectionsIface_V1_1 = gnssCorrections;
+ gnssCorrectionsIface_V1_0 = gnssCorrectionsIface_V1_1;
+ }
+ } else if (gnssHal_V2_0 != nullptr) {
auto gnssCorrections = gnssHal_V2_0->getExtensionMeasurementCorrections();
if (!gnssCorrections.isOk()) {
ALOGD("Unable to get a handle to GnssMeasurementCorrections interface");
} else {
- gnssCorrectionsIface = gnssCorrections;
+ gnssCorrectionsIface_V1_0 = gnssCorrections;
}
}
@@ -2153,11 +2176,18 @@ static jboolean android_location_GnssLocationProvider_init(JNIEnv* env, jobject
}
// Set IMeasurementCorrections.hal callback.
- if (gnssCorrectionsIface != nullptr) {
+ if (gnssCorrectionsIface_V1_1 != nullptr) {
+ sp<IMeasurementCorrectionsCallback> gnssCorrectionsIfaceCbIface =
+ new MeasurementCorrectionsCallback();
+ result = gnssCorrectionsIface_V1_1->setCallback(gnssCorrectionsIfaceCbIface);
+ checkHidlReturn(result, "IMeasurementCorrections 1.1 setCallback() failed.");
+ } else if (gnssCorrectionsIface_V1_0 != nullptr) {
sp<IMeasurementCorrectionsCallback> gnssCorrectionsIfaceCbIface =
new MeasurementCorrectionsCallback();
- result = gnssCorrectionsIface->setCallback(gnssCorrectionsIfaceCbIface);
- checkHidlReturn(result, "IMeasurementCorrections setCallback() failed.");
+ result = gnssCorrectionsIface_V1_0->setCallback(gnssCorrectionsIfaceCbIface);
+ checkHidlReturn(result, "IMeasurementCorrections 1.0 setCallback() failed.");
+ } else {
+ ALOGI("Unable to find IMeasurementCorrections.");
}
return JNI_TRUE;
@@ -2760,7 +2790,7 @@ static jboolean android_location_GnssMeasurementsProvider_stop_measurement_colle
static jboolean
android_location_GnssMeasurementCorrectionsProvider_is_measurement_corrections_supported(
JNIEnv* env, jclass clazz) {
- if (gnssCorrectionsIface != nullptr) {
+ if (gnssCorrectionsIface_V1_0 != nullptr || gnssCorrectionsIface_V1_1 != nullptr) {
return JNI_TRUE;
}
@@ -2773,24 +2803,12 @@ static jboolean
jobject obj /* clazz*/,
jobject correctionsObj) {
- if (gnssCorrectionsIface == nullptr) {
+ if (gnssCorrectionsIface_V1_0 == nullptr && gnssCorrectionsIface_V1_1 == nullptr) {
ALOGW("Trying to inject GNSS measurement corrections on a chipset that does not"
" support them.");
return JNI_FALSE;
}
- jdouble latitudeDegreesCorr = env->CallDoubleMethod(
- correctionsObj, method_correctionsGetLatitudeDegrees);
- jdouble longitudeDegreesCorr = env->CallDoubleMethod(
- correctionsObj, method_correctionsGetLongitudeDegrees);
- jdouble altitudeDegreesCorr = env->CallDoubleMethod(
- correctionsObj, method_correctionsGetAltitudeMeters);
- jdouble horizontalPositionUncertaintyMeters = env->CallDoubleMethod(
- correctionsObj, method_correctionsGetHorPosUncMeters);
- jdouble verticalPositionUncertaintyMeters = env->CallDoubleMethod(
- correctionsObj, method_correctionsGetVerPosUncMeters);
- jlong toaGpsNanosOfWeek = env->CallLongMethod(
- correctionsObj, method_correctionsGetToaGpsNanosecondsOfWeek);
jobject singleSatCorrectionList = env->CallObjectMethod(correctionsObj,
method_correctionsGetSingleSatCorrectionList);
@@ -2859,7 +2877,21 @@ static jboolean
};
list[i] = singleSatCorrection;
}
- MeasurementCorrections measurementCorrections = {
+
+ jdouble latitudeDegreesCorr = env->CallDoubleMethod(
+ correctionsObj, method_correctionsGetLatitudeDegrees);
+ jdouble longitudeDegreesCorr = env->CallDoubleMethod(
+ correctionsObj, method_correctionsGetLongitudeDegrees);
+ jdouble altitudeDegreesCorr = env->CallDoubleMethod(
+ correctionsObj, method_correctionsGetAltitudeMeters);
+ jdouble horizontalPositionUncertaintyMeters = env->CallDoubleMethod(
+ correctionsObj, method_correctionsGetHorPosUncMeters);
+ jdouble verticalPositionUncertaintyMeters = env->CallDoubleMethod(
+ correctionsObj, method_correctionsGetVerPosUncMeters);
+ jlong toaGpsNanosOfWeek = env->CallLongMethod(
+ correctionsObj, method_correctionsGetToaGpsNanosecondsOfWeek);
+
+ MeasurementCorrections_V1_0 measurementCorrections_1_0 = {
.latitudeDegrees = latitudeDegreesCorr,
.longitudeDegrees = longitudeDegreesCorr,
.altitudeMeters = altitudeDegreesCorr,
@@ -2869,8 +2901,28 @@ static jboolean
.satCorrections = list,
};
- auto result = gnssCorrectionsIface->setCorrections(measurementCorrections);
- return checkHidlReturn(result, "IMeasurementCorrections setCorrections() failed.");
+ if (gnssCorrectionsIface_V1_1 != nullptr) {
+
+ jboolean hasEnvironmentBearingCorr = env->CallBooleanMethod(
+ correctionsObj, method_correctionsHasEnvironmentBearing);
+ jfloat environmentBearingDegreesCorr = env->CallFloatMethod(
+ correctionsObj, method_correctionsGetEnvironmentBearingDegrees);
+ jfloat environmentBearingUncertaintyDegreesCorr = env->CallFloatMethod(
+ correctionsObj, method_correctionsGetEnvironmentBearingUncertaintyDegrees);
+
+ MeasurementCorrections_V1_1 measurementCorrections_1_1 = {
+ .v1_0 = measurementCorrections_1_0,
+ .hasEnvironmentBearing = static_cast<bool>(hasEnvironmentBearingCorr),
+ .environmentBearingDegrees = environmentBearingDegreesCorr,
+ .environmentBearingUncertaintyDegrees = environmentBearingUncertaintyDegreesCorr,
+ };
+
+ auto result = gnssCorrectionsIface_V1_1->setCorrections_1_1(measurementCorrections_1_1);
+ return checkHidlReturn(result, "IMeasurementCorrections 1.1 setCorrections() failed.");
+ }
+
+ auto result = gnssCorrectionsIface_V1_0->setCorrections(measurementCorrections_1_0);
+ return checkHidlReturn(result, "IMeasurementCorrections 1.0 setCorrections() failed.");
}
static jboolean android_location_GnssNavigationMessageProvider_is_navigation_message_supported(