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/current.txt b/current.txt
index 8518c5e..fcb8447 100644
--- a/current.txt
+++ b/current.txt
@@ -469,7 +469,7 @@
 4deafcdcffa2d002119e7f58810b767a84666e76475aae68e757ec2845d9756d android.hardware.gnss@2.0::IGnss
 db6bdf6dfc5edf6c85d2944976db899227abb51079c893874353c322342c50b6 android.hardware.gnss@2.0::IGnssBatching
 1f89392f1ebb693d8fa6f50324b1635fc79fab246d31900e63998e1b0e17511c android.hardware.gnss@2.0::IGnssBatchingCallback
-b11a5e4a1602d3f408716b6fe2c578a79f060d571aad8e828f9a4426d161fbcf android.hardware.gnss@2.0::IGnssCallback
+64232037109a5e5f53ab0377e755ec494ae93fcb5279e6eea71dec2e7ac6fbfc android.hardware.gnss@2.0::IGnssCallback
 ecc966c68bddbd95c8dae782b84204cf01c75734675e8769963f3b5106ec128b android.hardware.gnss@2.0::IGnssConfiguration
 b670bae2ab8517336290532e364502b4db9120340d75474ccc8442b1b15d6ab7 android.hardware.gnss@2.0::IGnssDebug
 c67759f5d6387d273b66729180d03690e827f0b6b8d4e13ce2ff42d31b224065 android.hardware.gnss@2.0::IGnssMeasurement
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);