Restore gnss@1.1 HAL capability bits removed in gnss@2.0 (hal)
In the IGnssCallback.hal@2.0 introduced in Android Q, the
capability bits in IGnssCallback.hal@1.1 that represent sub-HAL
interfaces have been removed as they are derivable from the
existing getExtensionXXX() family of methods in the IGnss.hal
interface.
These need to be restored back as the synchronous nature of the
getExtensionXXX() methods called by the framework has an impact on
partner implementations that need to communicate with the modem to
get the capabilities.
Additionally, the capability bit MEASUREMENT_CORRECTIONS needs to be
added for the new optional measurement_corrections@1.0 sub-HAL
introduced in gnss@2.0.
Fixes: 129870126
Test: Verified through cuttlefish default implementation and VTS tests.
Change-Id: Ib4164c9501b8db9f09eb5429a077d477d0a4a7f9
diff --git a/gnss/2.0/IGnssCallback.hal b/gnss/2.0/IGnssCallback.hal
index a96fd6c..d6db9cc 100644
--- a/gnss/2.0/IGnssCallback.hal
+++ b/gnss/2.0/IGnssCallback.hal
@@ -30,32 +30,13 @@
/** Flags for the gnssSetCapabilities callback. */
@export(name="", value_prefix="GPS_CAPABILITY_")
- enum Capabilities : uint32_t {
- /**
- * GNSS HAL schedules fixes for RECURRENCE_PERIODIC mode.
- * If this is not set, then the framework will use 1000ms for
- * minInterval and must call start() and stop() to schedule the GNSS.
- */
- SCHEDULING = 1 << 0,
- /** GNSS supports MS-Based AGNSS mode */
- MSB = 1 << 1,
- /** GNSS supports MS-Assisted AGNSS mode */
- MSA = 1 << 2,
- /** GNSS supports single-shot fixes */
- SINGLE_SHOT = 1 << 3,
- /** GNSS supports on demand time injection */
- ON_DEMAND_TIME = 1 << 4,
- /**
- * Values for the flags removed from IGnssCallback.hal@1.0 Capabilities
- * enum are marked as reserved and not reused here to avoid confusion.
- */
- RESERVED_1 = 1 << 5,
- RESERVED_2 = 1 << 6,
- RESERVED_3 = 1 << 7,
+ enum Capabilities : @1.0::IGnssCallback.Capabilities {
/** GNSS supports low power mode */
- LOW_POWER_MODE = 1 << 8,
+ LOW_POWER_MODE = 1 << 8,
/** GNSS supports blacklisting satellites */
- SATELLITE_BLACKLIST = 1 << 9
+ SATELLITE_BLACKLIST = 1 << 9,
+ /** GNSS supports measurement corrections */
+ MEASUREMENT_CORRECTIONS = 1 << 10
};
/**
diff --git a/gnss/2.0/default/Gnss.cpp b/gnss/2.0/default/Gnss.cpp
index 75c2385..3d64fc3 100644
--- a/gnss/2.0/default/Gnss.cpp
+++ b/gnss/2.0/default/Gnss.cpp
@@ -280,7 +280,8 @@
sGnssCallback_2_0 = callback;
using Capabilities = V2_0::IGnssCallback::Capabilities;
- const auto capabilities = Capabilities::LOW_POWER_MODE | Capabilities::SATELLITE_BLACKLIST;
+ const auto capabilities = Capabilities::MEASUREMENTS | Capabilities::MEASUREMENT_CORRECTIONS |
+ Capabilities::LOW_POWER_MODE | Capabilities::SATELLITE_BLACKLIST;
auto ret = sGnssCallback_2_0->gnssSetCapabilitiesCb_2_0(capabilities);
if (!ret.isOk()) {
ALOGE("%s: Unable to invoke callback", __func__);
diff --git a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
index 0682f84..be182a9 100644
--- a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
+++ b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
@@ -289,19 +289,21 @@
/*
* TestGnssMeasurementCorrectionsCapabilities:
- * If the GnssMeasurementCorrectionsExtension is not null, verifies that the measurement corrections
+ * If measurement corrections capability is supported, verifies that the measurement corrections
* capabilities are reported and the mandatory LOS_SATS or the EXCESS_PATH_LENGTH
* capability flag is set.
*/
TEST_F(GnssHalTest, TestGnssMeasurementCorrectionsCapabilities) {
- // Setup measurement corrections callback.
- auto measurementCorrections = gnss_hal_->getExtensionMeasurementCorrections();
- ASSERT_TRUE(measurementCorrections.isOk());
- sp<IMeasurementCorrections> iMeasurementCorrections = measurementCorrections;
- if (iMeasurementCorrections == nullptr) {
+ if (!(last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENT_CORRECTIONS)) {
return;
}
+ auto measurementCorrections = gnss_hal_->getExtensionMeasurementCorrections();
+ ASSERT_TRUE(measurementCorrections.isOk());
+ sp<IMeasurementCorrections> iMeasurementCorrections = measurementCorrections;
+ ASSERT_NE(iMeasurementCorrections, nullptr);
+
+ // Setup measurement corrections callback.
sp<IMeasurementCorrectionsCallback> iMeasurementCorrectionsCallback =
new GnssMeasurementCorrectionsCallback(*this);
iMeasurementCorrections->setCallback(iMeasurementCorrectionsCallback);
@@ -316,17 +318,19 @@
/*
* TestGnssMeasurementCorrections:
- * If the GnssMeasurementCorrectionsExtension is not null, verifies that it supports the
+ * If measurement corrections capability is supported, verifies that it supports the
* gnss.measurement_corrections@1.0::IMeasurementCorrections interface by invoking a method.
*/
TEST_F(GnssHalTest, TestGnssMeasurementCorrections) {
+ if (!(last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENT_CORRECTIONS)) {
+ return;
+ }
+
// Verify IMeasurementCorrections is supported.
auto measurementCorrections = gnss_hal_->getExtensionMeasurementCorrections();
ASSERT_TRUE(measurementCorrections.isOk());
sp<IMeasurementCorrections> iMeasurementCorrections = measurementCorrections;
- if (iMeasurementCorrections == nullptr) {
- return;
- }
+ ASSERT_NE(iMeasurementCorrections, nullptr);
sp<IMeasurementCorrectionsCallback> iMeasurementCorrectionsCallback =
new GnssMeasurementCorrectionsCallback(*this);