Skip GnssConfiguration v2.1 tests for AIDL HAL

- the same tests for AIDL HAL have been added in aidl/vts.

Bug: 172989709
Test: atest VtsHalGnssV2_1TargetTest
Change-Id: Ib1ace156d9b012a1b751a1f2f31a8b1765f964a4
diff --git a/gnss/2.1/vts/functional/Android.bp b/gnss/2.1/vts/functional/Android.bp
index 175bc75..aae3571 100644
--- a/gnss/2.1/vts/functional/Android.bp
+++ b/gnss/2.1/vts/functional/Android.bp
@@ -18,6 +18,7 @@
     name: "VtsHalGnssV2_1TargetTest",
     defaults: ["VtsHalTargetTestDefaults"],
     srcs: [
+        "gnss_hal_test.cpp",
         "gnss_hal_test_cases.cpp",
         "VtsHalGnssV2_1TargetTest.cpp",
     ],
@@ -31,6 +32,9 @@
         "android.hardware.gnss@2.1",
         "android.hardware.gnss@common-vts-lib",
     ],
+    shared_libs: [
+        "libvintf",
+    ],
     test_suites: [
         "general-tests",
         "vts",
diff --git a/gnss/2.1/vts/functional/gnss_hal_test.cpp b/gnss/2.1/vts/functional/gnss_hal_test.cpp
new file mode 100644
index 0000000..1154260
--- /dev/null
+++ b/gnss/2.1/vts/functional/gnss_hal_test.cpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "GnssHalTest"
+
+#include <android/hidl/manager/1.2/IServiceManager.h>
+#include <hidl/ServiceManagement.h>
+#include <log/log.h>
+#include <vintf/VintfObject.h>
+
+#include "gnss_hal_test.h"
+
+using ::android::hardware::hidl_string;
+using ::android::hidl::manager::V1_2::IServiceManager;
+
+bool GnssHalTest::IsGnssHalVersion_2_1() const {
+    sp<IServiceManager> manager = ::android::hardware::defaultServiceManager1_2();
+    bool hasGnssHalVersion_2_1 = false;
+    manager->listManifestByInterface(
+            "android.hardware.gnss@2.1::IGnss",
+            [&hasGnssHalVersion_2_1](const hidl_vec<hidl_string>& registered) {
+                hasGnssHalVersion_2_1 = registered.size() > 0;
+            });
+
+    auto deviceManifest = ::android::vintf::VintfObject::GetDeviceHalManifest();
+    bool hasGnssAidl =
+            deviceManifest->getAidlInstances("android.hardware.gnss", "IGnss").size() > 0;
+
+    return hasGnssHalVersion_2_1 && !hasGnssAidl;
+}
\ No newline at end of file
diff --git a/gnss/2.1/vts/functional/gnss_hal_test.h b/gnss/2.1/vts/functional/gnss_hal_test.h
index c28e248..7950670 100644
--- a/gnss/2.1/vts/functional/gnss_hal_test.h
+++ b/gnss/2.1/vts/functional/gnss_hal_test.h
@@ -22,4 +22,11 @@
 using android::hardware::gnss::V2_1::IGnss;
 
 // The main test class for GNSS HAL.
-class GnssHalTest : public GnssHalTestTemplate<IGnss> {};
+class GnssHalTest : public GnssHalTestTemplate<IGnss> {
+  public:
+    /**
+     * IsGnssHalVersion_2_1:
+     * returns  true if the GNSS HAL version is exactly 2.1.
+     */
+    bool IsGnssHalVersion_2_1() const;
+};
diff --git a/gnss/2.1/vts/functional/gnss_hal_test_cases.cpp b/gnss/2.1/vts/functional/gnss_hal_test_cases.cpp
index 2902809..7afd49c 100644
--- a/gnss/2.1/vts/functional/gnss_hal_test_cases.cpp
+++ b/gnss/2.1/vts/functional/gnss_hal_test_cases.cpp
@@ -87,6 +87,10 @@
  * Gets the GnssConfigurationExtension and verifies that it returns an actual extension.
  */
 TEST_P(GnssHalTest, TestGnssConfigurationExtension) {
+    if (!IsGnssHalVersion_2_1()) {
+        ALOGI("Test TestGnssConfigurationExtension skipped. GNSS HAL version is greater than 2.1.");
+        return;
+    }
     auto gnssConfiguration_2_1 = gnss_hal_->getExtensionGnssConfiguration_2_1();
     auto gnssConfiguration_2_0 = gnss_hal_->getExtensionGnssConfiguration_2_0();
     auto gnssConfiguration_1_1 = gnss_hal_->getExtensionGnssConfiguration_1_1();
@@ -358,20 +362,24 @@
 }
 
 /*
- * BlacklistIndividualSatellites:
+ * BlocklistIndividualSatellites:
  *
  * 1) Turns on location, waits for 3 locations, ensuring they are valid, and checks corresponding
  * GnssStatus for common satellites (strongest and one other.)
- * 2a & b) Turns off location, and blacklists common satellites.
+ * 2a & b) Turns off location, and blocklists common satellites.
  * 3) Restart location, wait for 3 locations, ensuring they are valid, and checks corresponding
  * GnssStatus does not use those satellites.
- * 4a & b) Turns off location, and send in empty blacklist.
+ * 4a & b) Turns off location, and send in empty blocklist.
  * 5a) Restart location, wait for 3 locations, ensuring they are valid, and checks corresponding
  * GnssStatus does re-use at least the previously strongest satellite
  * 5b) Retry a few times, in case GNSS search strategy takes a while to reacquire even the
  * formerly strongest satellite
  */
-TEST_P(GnssHalTest, BlacklistIndividualSatellites) {
+TEST_P(GnssHalTest, BlocklistIndividualSatellites) {
+    if (!IsGnssHalVersion_2_1()) {
+        ALOGI("Test BlocklistIndividualSatellites skipped. GNSS HAL version is greater than 2.1.");
+        return;
+    }
     if (!(gnss_cb_->last_capabilities_ & IGnssCallback_2_1::Capabilities::SATELLITE_BLACKLIST)) {
         ALOGI("Test BlacklistIndividualSatellites skipped. SATELLITE_BLACKLIST capability not "
               "supported.");
@@ -509,16 +517,21 @@
 }
 
 /*
- * BlacklistConstellationLocationOff:
+ * BlocklistConstellationLocationOff:
  *
  * 1) Turns on location, waits for 3 locations, ensuring they are valid, and checks corresponding
  * GnssStatus for any non-GPS constellations.
- * 2a & b) Turns off location, and blacklist first non-GPS constellations.
+ * 2a & b) Turns off location, and blocklist first non-GPS constellations.
  * 3) Restart location, wait for 3 locations, ensuring they are valid, and checks corresponding
  * GnssStatus does not use any constellation but GPS.
- * 4a & b) Clean up by turning off location, and send in empty blacklist.
+ * 4a & b) Clean up by turning off location, and send in empty blocklist.
  */
-TEST_P(GnssHalTest, BlacklistConstellationLocationOff) {
+TEST_P(GnssHalTest, BlocklistConstellationLocationOff) {
+    if (!IsGnssHalVersion_2_1()) {
+        ALOGI("Test BlocklistConstellationLocationOff skipped. GNSS HAL version is greater than "
+              "2.1.");
+        return;
+    }
     if (!(gnss_cb_->last_capabilities_ & IGnssCallback_2_1::Capabilities::SATELLITE_BLACKLIST)) {
         ALOGI("Test BlacklistConstellationLocationOff skipped. SATELLITE_BLACKLIST capability not "
               "supported.");
@@ -591,16 +604,21 @@
 }
 
 /*
- * BlacklistConstellationLocationOn:
+ * BlocklistConstellationLocationOn:
  *
  * 1) Turns on location, waits for 3 locations, ensuring they are valid, and checks corresponding
  * GnssStatus for any non-GPS constellations.
- * 2a & b) Blacklist first non-GPS constellation, and turn off location.
+ * 2a & b) Blocklist first non-GPS constellation, and turn off location.
  * 3) Restart location, wait for 3 locations, ensuring they are valid, and checks corresponding
  * GnssStatus does not use any constellation but GPS.
- * 4a & b) Clean up by turning off location, and send in empty blacklist.
+ * 4a & b) Clean up by turning off location, and send in empty blocklist.
  */
-TEST_P(GnssHalTest, BlacklistConstellationLocationOn) {
+TEST_P(GnssHalTest, BlocklistConstellationLocationOn) {
+    if (!IsGnssHalVersion_2_1()) {
+        ALOGI("Test BlocklistConstellationLocationOn skipped. GNSS HAL version is greater than "
+              "2.1.");
+        return;
+    }
     if (!(gnss_cb_->last_capabilities_ & IGnssCallback_2_1::Capabilities::SATELLITE_BLACKLIST)) {
         ALOGI("Test BlacklistConstellationLocationOn skipped. SATELLITE_BLACKLIST capability not "
               "supported.");