diff --git a/gnss/1.1/vts/functional/Android.bp b/gnss/1.1/vts/functional/Android.bp index 0d540b7250..94bfb894d4 100644 --- a/gnss/1.1/vts/functional/Android.bp +++ b/gnss/1.1/vts/functional/Android.bp @@ -25,6 +25,7 @@ cc_test { static_libs: [ "android.hardware.gnss@1.0", "android.hardware.gnss@1.1", + "android.hardware.gnss@2.0", "android.hardware.gnss@common-vts-lib", ], shared_libs: [ diff --git a/gnss/2.0/vts/functional/gnss_hal_test.cpp b/gnss/2.0/vts/functional/gnss_hal_test.cpp index 59e18f3642..1cb44c5761 100644 --- a/gnss/2.0/vts/functional/gnss_hal_test.cpp +++ b/gnss/2.0/vts/functional/gnss_hal_test.cpp @@ -247,3 +247,46 @@ Return GnssHalTest::GnssMeasurementCorrectionsCallback::setCapabilitiesCb( capabilities_cbq_.store(capabilities); return Void(); } + +GnssConstellationType_1_0 GnssHalTest::startLocationAndGetNonGpsConstellation() { + const int kLocationsToAwait = 3; + + gnss_cb_->location_cbq_.reset(); + StartAndCheckLocations(kLocationsToAwait); + const int location_called_count = gnss_cb_->location_cbq_.calledCount(); + + // Tolerate 1 less sv status to handle edge cases in reporting. + int sv_info_list_cbq_size = gnss_cb_->sv_info_list_cbq_.size(); + EXPECT_GE(sv_info_list_cbq_size + 1, kLocationsToAwait); + ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations (%d received)", + sv_info_list_cbq_size, kLocationsToAwait, location_called_count); + + // Find first non-GPS constellation to blacklist. Exclude IRNSS in GnssConstellationType_2_0 + // as blacklisting of this constellation is not supported in gnss@2.0. + const int kGnssSvStatusTimeout = 2; + GnssConstellationType_1_0 constellation_to_blacklist = GnssConstellationType_1_0::UNKNOWN; + for (int i = 0; i < sv_info_list_cbq_size; ++i) { + hidl_vec sv_info_list; + gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_list, kGnssSvStatusTimeout); + for (IGnssCallback_2_0::GnssSvInfo sv_info : sv_info_list) { + if ((sv_info.v1_0.svFlag & IGnssCallback_2_0::GnssSvFlags::USED_IN_FIX) && + (sv_info.constellation != GnssConstellationType_2_0::UNKNOWN) && + (sv_info.constellation != GnssConstellationType_2_0::IRNSS) && + (sv_info.constellation != GnssConstellationType_2_0::GPS)) { + // found a non-GPS V1_0 constellation + constellation_to_blacklist = Utils::mapConstellationType(sv_info.constellation); + break; + } + } + if (constellation_to_blacklist != GnssConstellationType_1_0::UNKNOWN) { + break; + } + } + + if (constellation_to_blacklist == GnssConstellationType_1_0::UNKNOWN) { + ALOGI("No non-GPS constellations found, constellation blacklist test less effective."); + // Proceed functionally to blacklist something. + constellation_to_blacklist = GnssConstellationType_1_0::GLONASS; + } + return constellation_to_blacklist; +} diff --git a/gnss/2.0/vts/functional/gnss_hal_test.h b/gnss/2.0/vts/functional/gnss_hal_test.h index a02a9ff4a7..7fbd7350eb 100644 --- a/gnss/2.0/vts/functional/gnss_hal_test.h +++ b/gnss/2.0/vts/functional/gnss_hal_test.h @@ -31,6 +31,9 @@ using android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrec using android::hardware::gnss::V1_0::GnssLocationFlags; using android::hardware::gnss::V2_0::IGnss; +using GnssConstellationType_1_0 = android::hardware::gnss::V1_0::GnssConstellationType; +using GnssConstellationType_2_0 = android::hardware::gnss::V2_0::GnssConstellationType; + using GnssLocation_1_0 = android::hardware::gnss::V1_0::GnssLocation; using GnssLocation_2_0 = android::hardware::gnss::V2_0::GnssLocation; @@ -194,6 +197,16 @@ class GnssHalTest : public testing::TestWithParam { */ void SetPositionMode(const int min_interval_msec, const bool low_power_mode); + /* + * startLocationAndGetNonGpsConstellation: + * 1. Start location + * 2. Find and return first non-GPS constellation + * + * Note that location is not stopped in this method. The client should call + * StopAndClearLocations() after the call. + */ + GnssConstellationType_1_0 startLocationAndGetNonGpsConstellation(); + sp gnss_hal_; // GNSS HAL to call into sp gnss_cb_; // Primary callback interface }; 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 094c7c1e54..51dcf0d059 100644 --- a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp +++ b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp @@ -24,8 +24,6 @@ using android::hardware::hidl_string; using android::hardware::hidl_vec; -using GnssConstellationType_2_0 = android::hardware::gnss::V2_0::GnssConstellationType; -using GnssConstellationType_1_0 = android::hardware::gnss::V1_0::GnssConstellationType; using IGnssConfiguration_2_0 = android::hardware::gnss::V2_0::IGnssConfiguration; using IGnssConfiguration_1_1 = android::hardware::gnss::V1_1::IGnssConfiguration; using IAGnssRil_2_0 = android::hardware::gnss::V2_0::IAGnssRil; @@ -491,31 +489,6 @@ TEST_P(GnssHalTest, GetLocationLowPower) { StopAndClearLocations(); } -/* - * MapConstellationType: - * Given a GnssConstellationType_2_0 type constellation, maps to its equivalent - * GnssConstellationType_1_0 type constellation. For constellations that do not have - * an equivalent value, maps to GnssConstellationType_1_0::UNKNOWN - */ -GnssConstellationType_1_0 MapConstellationType(GnssConstellationType_2_0 constellation) { - switch (constellation) { - case GnssConstellationType_2_0::GPS: - return GnssConstellationType_1_0::GPS; - case GnssConstellationType_2_0::SBAS: - return GnssConstellationType_1_0::SBAS; - case GnssConstellationType_2_0::GLONASS: - return GnssConstellationType_1_0::GLONASS; - case GnssConstellationType_2_0::QZSS: - return GnssConstellationType_1_0::QZSS; - case GnssConstellationType_2_0::BEIDOU: - return GnssConstellationType_1_0::BEIDOU; - case GnssConstellationType_2_0::GALILEO: - return GnssConstellationType_1_0::GALILEO; - default: - return GnssConstellationType_1_0::UNKNOWN; - } -} - /* * FindStrongFrequentNonGpsSource: * @@ -555,7 +528,7 @@ IGnssConfiguration_1_1::BlacklistedSource FindStrongFrequentNonGpsSource( (sv_info.constellation != GnssConstellationType_2_0::GPS)) { ComparableBlacklistedSource source; source.id.svid = sv_info.v1_0.svid; - source.id.constellation = MapConstellationType(sv_info.constellation); + source.id.constellation = Utils::mapConstellationType(sv_info.constellation); const auto& itSignal = mapSignals.find(source); if (itSignal == mapSignals.end()) { @@ -694,7 +667,7 @@ TEST_P(GnssHalTest, BlacklistIndividualSatellites) { hidl_vec sv_info_list; gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_list, kGnssSvStatusTimeout); for (IGnssCallback_2_0::GnssSvInfo sv_info : sv_info_list) { - auto constellation = MapConstellationType(sv_info.constellation); + auto constellation = Utils::mapConstellationType(sv_info.constellation); EXPECT_FALSE((sv_info.v1_0.svid == source_to_blacklist.svid) && (constellation == source_to_blacklist.constellation) && (sv_info.v1_0.svFlag & IGnssCallback::GnssSvFlags::USED_IN_FIX)); @@ -736,7 +709,7 @@ TEST_P(GnssHalTest, BlacklistIndividualSatellites) { hidl_vec sv_info_list; gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_list, kGnssSvStatusTimeout); for (IGnssCallback_2_0::GnssSvInfo sv_info : sv_info_list) { - auto constellation = MapConstellationType(sv_info.constellation); + auto constellation = Utils::mapConstellationType(sv_info.constellation); if ((sv_info.v1_0.svid == source_to_blacklist.svid) && (constellation == source_to_blacklist.constellation) && (sv_info.v1_0.svFlag & IGnssCallback::GnssSvFlags::USED_IN_FIX)) { @@ -752,7 +725,7 @@ TEST_P(GnssHalTest, BlacklistIndividualSatellites) { } /* - * BlacklistConstellation: + * BlacklistConstellationWithLocationOff: * * 1) Turns on location, waits for 3 locations, ensuring they are valid, and checks corresponding * GnssStatus for any non-GPS constellations. @@ -761,12 +734,11 @@ TEST_P(GnssHalTest, BlacklistIndividualSatellites) { * GnssStatus does not use any constellation but GPS. * 4a & b) Clean up by turning off location, and send in empty blacklist. */ -TEST_P(GnssHalTest, BlacklistConstellation) { +TEST_P(GnssHalTest, BlacklistConstellationWithLocationOff) { if (!IsGnssHalVersion_2_0()) { ALOGI("Test BlacklistConstellation skipped. GNSS HAL version is greater than 2.0."); return; } - if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::SATELLITE_BLACKLIST)) { ALOGI("Test BlacklistConstellation skipped. SATELLITE_BLACKLIST capability not supported."); return; @@ -774,43 +746,12 @@ TEST_P(GnssHalTest, BlacklistConstellation) { const int kLocationsToAwait = 3; - gnss_cb_->location_cbq_.reset(); - StartAndCheckLocations(kLocationsToAwait); - const int location_called_count = gnss_cb_->location_cbq_.calledCount(); + // Find first non-GPS constellation to blacklist + GnssConstellationType_1_0 constellation_to_blacklist = startLocationAndGetNonGpsConstellation(); - // Tolerate 1 less sv status to handle edge cases in reporting. - int sv_info_list_cbq_size = gnss_cb_->sv_info_list_cbq_.size(); - EXPECT_GE(sv_info_list_cbq_size + 1, kLocationsToAwait); - ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations (%d received)", - sv_info_list_cbq_size, kLocationsToAwait, location_called_count); + // Turns off location + StopAndClearLocations(); - // Find first non-GPS constellation to blacklist. Exclude IRNSS in GnssConstellationType_2_0 - // as blacklisting of this constellation is not supported in gnss@2.0. - const int kGnssSvStatusTimeout = 2; - GnssConstellationType_1_0 constellation_to_blacklist = GnssConstellationType_1_0::UNKNOWN; - for (int i = 0; i < sv_info_list_cbq_size; ++i) { - hidl_vec sv_info_list; - gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_list, kGnssSvStatusTimeout); - for (IGnssCallback_2_0::GnssSvInfo sv_info : sv_info_list) { - if ((sv_info.v1_0.svFlag & IGnssCallback::GnssSvFlags::USED_IN_FIX) && - (sv_info.constellation != GnssConstellationType_2_0::UNKNOWN) && - (sv_info.constellation != GnssConstellationType_2_0::IRNSS) && - (sv_info.constellation != GnssConstellationType_2_0::GPS)) { - // found a non-GPS V1_0 constellation - constellation_to_blacklist = MapConstellationType(sv_info.constellation); - break; - } - } - if (constellation_to_blacklist != GnssConstellationType_1_0::UNKNOWN) { - break; - } - } - - if (constellation_to_blacklist == GnssConstellationType_1_0::UNKNOWN) { - ALOGI("No non-GPS constellations found, constellation blacklist test less effective."); - // Proceed functionally to blacklist something. - constellation_to_blacklist = GnssConstellationType_1_0::GLONASS; - } IGnssConfiguration_1_1::BlacklistedSource source_to_blacklist; source_to_blacklist.constellation = constellation_to_blacklist; source_to_blacklist.svid = 0; // documented wildcard for all satellites in this constellation @@ -824,6 +765,7 @@ TEST_P(GnssHalTest, BlacklistConstellation) { sources.resize(1); sources[0] = source_to_blacklist; + // setBlacklist when location is off. auto result = gnss_configuration_hal->setBlacklist(sources); ASSERT_TRUE(result.isOk()); EXPECT_TRUE(result); @@ -835,15 +777,93 @@ TEST_P(GnssHalTest, BlacklistConstellation) { StartAndCheckLocations(kLocationsToAwait); // Tolerate 1 less sv status to handle edge cases in reporting. - sv_info_list_cbq_size = gnss_cb_->sv_info_list_cbq_.size(); + int sv_info_list_cbq_size = gnss_cb_->sv_info_list_cbq_.size(); EXPECT_GE(sv_info_list_cbq_size + 1, kLocationsToAwait); ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", sv_info_list_cbq_size, kLocationsToAwait); + const int kGnssSvStatusTimeout = 2; for (int i = 0; i < sv_info_list_cbq_size; ++i) { hidl_vec sv_info_list; gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_list, kGnssSvStatusTimeout); for (IGnssCallback_2_0::GnssSvInfo sv_info : sv_info_list) { - auto constellation = MapConstellationType(sv_info.constellation); + auto constellation = Utils::mapConstellationType(sv_info.constellation); + EXPECT_FALSE((constellation == source_to_blacklist.constellation) && + (sv_info.v1_0.svFlag & IGnssCallback::GnssSvFlags::USED_IN_FIX)); + } + } + + // clean up + StopAndClearLocations(); + sources.resize(0); + result = gnss_configuration_hal->setBlacklist(sources); + ASSERT_TRUE(result.isOk()); + EXPECT_TRUE(result); +} + +/* + * BlacklistConstellationWithLocationOn: + * + * 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 constellations, and turns 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. + */ +TEST_P(GnssHalTest, BlacklistConstellationWithLocationOn) { + if (!IsGnssHalVersion_2_0()) { + ALOGI("Test BlacklistConstellation skipped. GNSS HAL version is greater than 2.0."); + return; + } + + if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::SATELLITE_BLACKLIST)) { + ALOGI("Test BlacklistConstellation skipped. SATELLITE_BLACKLIST capability not supported."); + return; + } + + const int kLocationsToAwait = 3; + + // Find first non-GPS constellation to blacklist + GnssConstellationType_1_0 constellation_to_blacklist = startLocationAndGetNonGpsConstellation(); + + IGnssConfiguration_1_1::BlacklistedSource source_to_blacklist; + source_to_blacklist.constellation = constellation_to_blacklist; + source_to_blacklist.svid = 0; // documented wildcard for all satellites in this constellation + + auto gnss_configuration_hal_return = gnss_hal_->getExtensionGnssConfiguration_1_1(); + ASSERT_TRUE(gnss_configuration_hal_return.isOk()); + sp gnss_configuration_hal = gnss_configuration_hal_return; + ASSERT_NE(gnss_configuration_hal, nullptr); + + hidl_vec sources; + sources.resize(1); + sources[0] = source_to_blacklist; + + // setBlacklist when location is on. + auto result = gnss_configuration_hal->setBlacklist(sources); + ASSERT_TRUE(result.isOk()); + EXPECT_TRUE(result); + + // Turns off location + StopAndClearLocations(); + + // retry and ensure constellation not used + gnss_cb_->sv_info_list_cbq_.reset(); + + gnss_cb_->location_cbq_.reset(); + StartAndCheckLocations(kLocationsToAwait); + + // Tolerate 1 less sv status to handle edge cases in reporting. + int sv_info_list_cbq_size = gnss_cb_->sv_info_list_cbq_.size(); + EXPECT_GE(sv_info_list_cbq_size + 1, kLocationsToAwait); + ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", sv_info_list_cbq_size, + kLocationsToAwait); + const int kGnssSvStatusTimeout = 2; + for (int i = 0; i < sv_info_list_cbq_size; ++i) { + hidl_vec sv_info_list; + gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_list, kGnssSvStatusTimeout); + for (IGnssCallback_2_0::GnssSvInfo sv_info : sv_info_list) { + auto constellation = Utils::mapConstellationType(sv_info.constellation); EXPECT_FALSE((constellation == source_to_blacklist.constellation) && (sv_info.v1_0.svFlag & IGnssCallback::GnssSvFlags::USED_IN_FIX)); } diff --git a/gnss/common/utils/vts/Android.bp b/gnss/common/utils/vts/Android.bp index fd9613b02a..4c6d4439bc 100644 --- a/gnss/common/utils/vts/Android.bp +++ b/gnss/common/utils/vts/Android.bp @@ -29,6 +29,7 @@ cc_library_static { export_include_dirs: ["include"], shared_libs: [ "android.hardware.gnss@1.0", + "android.hardware.gnss@2.0", "android.hardware.gnss.measurement_corrections@1.0", "android.hardware.gnss.measurement_corrections@1.1", ], diff --git a/gnss/common/utils/vts/Utils.cpp b/gnss/common/utils/vts/Utils.cpp index 4b5a50f5bd..9bf68e609f 100644 --- a/gnss/common/utils/vts/Utils.cpp +++ b/gnss/common/utils/vts/Utils.cpp @@ -169,6 +169,31 @@ const MeasurementCorrections_1_1 Utils::getMockMeasurementCorrections_1_1() { return mockCorrections_1_1; } +/* + * MapConstellationType: + * Given a GnssConstellationType_2_0 type constellation, maps to its equivalent + * GnssConstellationType_1_0 type constellation. For constellations that do not have + * an equivalent value, maps to GnssConstellationType_1_0::UNKNOWN + */ +GnssConstellationType_1_0 Utils::mapConstellationType(GnssConstellationType_2_0 constellation) { + switch (constellation) { + case GnssConstellationType_2_0::GPS: + return GnssConstellationType_1_0::GPS; + case GnssConstellationType_2_0::SBAS: + return GnssConstellationType_1_0::SBAS; + case GnssConstellationType_2_0::GLONASS: + return GnssConstellationType_1_0::GLONASS; + case GnssConstellationType_2_0::QZSS: + return GnssConstellationType_1_0::QZSS; + case GnssConstellationType_2_0::BEIDOU: + return GnssConstellationType_1_0::BEIDOU; + case GnssConstellationType_2_0::GALILEO: + return GnssConstellationType_1_0::GALILEO; + default: + return GnssConstellationType_1_0::UNKNOWN; + } +} + } // namespace common } // namespace gnss } // namespace hardware diff --git a/gnss/common/utils/vts/include/Utils.h b/gnss/common/utils/vts/include/Utils.h index c3cdd18b77..9c838b290a 100644 --- a/gnss/common/utils/vts/include/Utils.h +++ b/gnss/common/utils/vts/include/Utils.h @@ -18,9 +18,12 @@ #define android_hardware_gnss_common_vts_Utils_H_ #include +#include #include #include +using GnssConstellationType_1_0 = android::hardware::gnss::V1_0::GnssConstellationType; +using GnssConstellationType_2_0 = android::hardware::gnss::V2_0::GnssConstellationType; using GnssLocation = ::android::hardware::gnss::V1_0::GnssLocation; using namespace android::hardware::gnss::measurement_corrections::V1_0; @@ -44,6 +47,8 @@ struct Utils { bool check_more_accuracies); static const MeasurementCorrections_1_0 getMockMeasurementCorrections(); static const MeasurementCorrections_1_1 getMockMeasurementCorrections_1_1(); + + static GnssConstellationType_1_0 mapConstellationType(GnssConstellationType_2_0 constellation); }; } // namespace common