From 62d2ca76874de7f9fd350cbba4718fd59a118973 Mon Sep 17 00:00:00 2001 From: Anil Admal Date: Wed, 1 May 2019 19:30:31 -0700 Subject: [PATCH] Update GNSS VTS 2.0 tests to address sub-HAL support requirements - IGnssConfiguration.hal@2.0 must be supported. - If IAGnss.hal is supported, it must be at IAGnss.hal@2.0 - If IAGnssRil.hal is supported, it must be at IAGnssRil.hal@2.0 - gnss.visibility_control sub-HAL is optional - gnss.measurement_corrections sub HAL is optional. - IGnssBatching.hal@2.0 support is optional. Bug: 70978505 Test: atest VtsHalGnssV2_0TargetTest Change-Id: Icf98c13ef32bdea7dafda8f79b685466712b16b6 --- .../vts/functional/gnss_hal_test_cases.cpp | 99 +++++++++---------- 1 file changed, 44 insertions(+), 55 deletions(-) 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 be182a9c52..7c253b0645 100644 --- a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp +++ b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp @@ -29,6 +29,7 @@ using IGnssMeasurement_2_0 = android::hardware::gnss::V2_0::IGnssMeasurement; using IGnssMeasurement_1_1 = android::hardware::gnss::V1_1::IGnssMeasurement; using IGnssMeasurement_1_0 = android::hardware::gnss::V1_0::IGnssMeasurement; using IAGnssRil_2_0 = android::hardware::gnss::V2_0::IAGnssRil; +using IAGnssRil_1_0 = android::hardware::gnss::V1_0::IAGnssRil; using IAGnss_2_0 = android::hardware::gnss::V2_0::IAGnss; using IAGnss_1_0 = android::hardware::gnss::V1_0::IAGnss; using IAGnssCallback_2_0 = android::hardware::gnss::V2_0::IAGnssCallback; @@ -125,16 +126,21 @@ TEST_F(GnssHalTest, TestGnssConfiguration_setGpsLock_Deprecation) { * TestAGnssRilExtension: * Gets the AGnssRilExtension and verifies that it returns an actual extension. * - * The GNSS HAL 2.0 implementation must support @2.0::IAGnssRil interface due to the deprecation - * of framework network API methods needed to support the @1.0::IAGnssRil interface. - * - * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later + * If IAGnssRil interface is supported, then the GNSS HAL 2.0 implementation must support + * @2.0::IAGnssRil interface due to the deprecation of framework network API methods needed + * to support the @1.0::IAGnssRil interface. */ TEST_F(GnssHalTest, TestAGnssRilExtension) { - auto agnssRil = gnss_hal_->getExtensionAGnssRil_2_0(); - ASSERT_TRUE(agnssRil.isOk()); - sp iAGnssRil = agnssRil; - ASSERT_NE(iAGnssRil, nullptr); + auto agnssRil_2_0 = gnss_hal_->getExtensionAGnssRil_2_0(); + ASSERT_TRUE(agnssRil_2_0.isOk()); + sp iAGnssRil_2_0 = agnssRil_2_0; + if (iAGnssRil_2_0 == nullptr) { + // Verify IAGnssRil 1.0 is not supported. + auto agnssRil_1_0 = gnss_hal_->getExtensionAGnssRil(); + ASSERT_TRUE(agnssRil_1_0.isOk()); + sp iAGnssRil_1_0 = agnssRil_1_0; + ASSERT_EQ(iAGnssRil_1_0, nullptr); + } } /* @@ -146,7 +152,9 @@ TEST_F(GnssHalTest, TestAGnssRil_UpdateNetworkState_2_0) { auto agnssRil = gnss_hal_->getExtensionAGnssRil_2_0(); ASSERT_TRUE(agnssRil.isOk()); sp iAGnssRil = agnssRil; - ASSERT_NE(iAGnssRil, nullptr); + if (iAGnssRil == nullptr) { + return; + } // Update GNSS HAL that a network has connected. IAGnssRil_2_0::NetworkAttributes networkAttributes = { @@ -219,44 +227,35 @@ TEST_F(GnssHalTest, TestGnssMeasurementFields) { /* * TestAGnssExtension: - * Gets the AGnssExtension and verifies that it supports @2.0::IAGnss interface by invoking - * a method. + * Gets the AGnssExtension and verifies that it returns an actual extension. * - * The GNSS HAL 2.0 implementation must support @2.0::IAGnss interface due to the deprecation - * of framework network API methods needed to support the @1.0::IAGnss interface. - * - * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later + * If IAGnss interface is supported, then the GNSS HAL 2.0 implementation must support + * @2.0::IAGnss interface due to the deprecation of framework network API methods needed + * to support the @1.0::IAGnss interface. */ TEST_F(GnssHalTest, TestAGnssExtension) { - // Verify IAGnss 2.0 is supported. - auto agnss = gnss_hal_->getExtensionAGnss_2_0(); - ASSERT_TRUE(agnss.isOk()); - sp iAGnss = agnss; - ASSERT_NE(iAGnss, nullptr); + auto agnss_2_0 = gnss_hal_->getExtensionAGnss_2_0(); + ASSERT_TRUE(agnss_2_0.isOk()); + sp iAGnss_2_0 = agnss_2_0; + if (iAGnss_2_0 == nullptr) { + // Verify IAGnss 1.0 is not supported. + auto agnss_1_0 = gnss_hal_->getExtensionAGnss(); + ASSERT_TRUE(agnss_1_0.isOk()); + sp iAGnss_1_0 = agnss_1_0; + ASSERT_EQ(iAGnss_1_0, nullptr); + return; + } // Set SUPL server host/port - auto result = iAGnss->setServer(IAGnssCallback_2_0::AGnssType::SUPL, "supl.google.com", 7275); + auto result = + iAGnss_2_0->setServer(IAGnssCallback_2_0::AGnssType::SUPL, "supl.google.com", 7275); ASSERT_TRUE(result.isOk()); EXPECT_TRUE(result); } -/* - * TestAGnssExtension_1_0_Deprecation: - * Gets the @1.0::IAGnss extension and verifies that it is a nullptr. - * - * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later - */ -TEST_F(GnssHalTest, TestAGnssExtension_1_0_Deprecation) { - // Verify IAGnss 1.0 is not supported. - auto agnss_1_0 = gnss_hal_->getExtensionAGnss(); - ASSERT_TRUE(!agnss_1_0.isOk() || ((sp)agnss_1_0) == nullptr); -} - /* * TestGnssNiExtension_Deprecation: * Gets the @1.0::IGnssNi extension and verifies that it is a nullptr. - * - * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later */ TEST_F(GnssHalTest, TestGnssNiExtension_Deprecation) { // Verify IGnssNi 1.0 is not supported. @@ -266,22 +265,19 @@ TEST_F(GnssHalTest, TestGnssNiExtension_Deprecation) { /* * TestGnssVisibilityControlExtension: - * Gets the GnssVisibilityControlExtension and verifies that it supports the - * gnss.visibility_control@1.0::IGnssVisibilityControl interface by invoking a method. - * - * The GNSS HAL 2.0 implementation must support gnss.visibility_control@1.0::IGnssVisibilityControl. - * - * TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later + * Gets the GnssVisibilityControlExtension and if it is not null, verifies that it supports + * the gnss.visibility_control@1.0::IGnssVisibilityControl interface by invoking a method. */ TEST_F(GnssHalTest, TestGnssVisibilityControlExtension) { - // Verify IGnssVisibilityControl is supported. auto gnssVisibilityControl = gnss_hal_->getExtensionVisibilityControl(); ASSERT_TRUE(gnssVisibilityControl.isOk()); sp iGnssVisibilityControl = gnssVisibilityControl; - ASSERT_NE(iGnssVisibilityControl, nullptr); + if (iGnssVisibilityControl == nullptr) { + return; + } // Set non-framework proxy apps. - hidl_vec proxyApps{"ims.example.com", "mdt.example.com"}; + hidl_vec proxyApps{"com.example.ims", "com.example.mdt"}; auto result = iGnssVisibilityControl->enableNfwLocationAccess(proxyApps); ASSERT_TRUE(result.isOk()); EXPECT_TRUE(result); @@ -408,17 +404,10 @@ TEST_F(GnssHalTest, TestInjectBestLocation_2_0) { /* * TestGnssBatchingExtension: - * Gets the GnssBatchingExtension and verifies that it supports either the @1.0::IGnssBatching - * or @2.0::IGnssBatching extension. + * Gets the @2.0::IGnssBatching extension and verifies that it doesn't return an error. Support + * for this interface is optional. */ TEST_F(GnssHalTest, TestGnssBatchingExtension) { - auto gnssBatching_V2_0 = gnss_hal_->getExtensionGnssBatching_2_0(); - ASSERT_TRUE(gnssBatching_V2_0.isOk()); - - auto gnssBatching_V1_0 = gnss_hal_->getExtensionGnssBatching(); - ASSERT_TRUE(gnssBatching_V1_0.isOk()); - - sp iGnssBatching_V1_0 = gnssBatching_V1_0; - sp iGnssBatching_V2_0 = gnssBatching_V2_0; - ASSERT_TRUE(iGnssBatching_V1_0 != nullptr || iGnssBatching_V2_0 != nullptr); + auto gnssBatching_2_0 = gnss_hal_->getExtensionGnssBatching_2_0(); + ASSERT_TRUE(gnssBatching_2_0.isOk()); }