Add GNSS AIDL VTS tests
Copy existing VTS tests from HIDL HALs to AIDL, to make sure AIDL has at
least the same API coverage.
Bug: 216523795
Test: atest VtsHalGnssTargetTest
Change-Id: I0f09ba2b5541e19f28b8689ec93ce6c2ba6798ff
diff --git a/gnss/aidl/default/Gnss.cpp b/gnss/aidl/default/Gnss.cpp
index a861957..7855b51 100644
--- a/gnss/aidl/default/Gnss.cpp
+++ b/gnss/aidl/default/Gnss.cpp
@@ -53,17 +53,26 @@
ALOGE("%s: Null callback ignored", __func__);
return ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
}
-
sGnssCallback = callback;
- int capabilities = (int)(IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST |
- IGnssCallback::CAPABILITY_SATELLITE_PVT |
- IGnssCallback::CAPABILITY_CORRELATION_VECTOR |
- IGnssCallback::CAPABILITY_ANTENNA_INFO);
-
+ int capabilities =
+ (int)(IGnssCallback::CAPABILITY_MEASUREMENTS | IGnssCallback::CAPABILITY_SCHEDULING |
+ IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST |
+ IGnssCallback::CAPABILITY_SATELLITE_PVT |
+ IGnssCallback::CAPABILITY_CORRELATION_VECTOR |
+ IGnssCallback::CAPABILITY_ANTENNA_INFO);
auto status = sGnssCallback->gnssSetCapabilitiesCb(capabilities);
if (!status.isOk()) {
- ALOGE("%s: Unable to invoke callback.gnssSetCapabilities", __func__);
+ ALOGE("%s: Unable to invoke callback.gnssSetCapabilitiesCb", __func__);
+ }
+
+ IGnssCallback::GnssSystemInfo systemInfo = {
+ .yearOfHw = 2022,
+ .name = "Google Mock GNSS Implementation AIDL v2",
+ };
+ status = sGnssCallback->gnssSetSystemInfoCb(systemInfo);
+ if (!status.isOk()) {
+ ALOGE("%s: Unable to invoke callback.gnssSetSystemInfoCb", __func__);
}
return ScopedAStatus::ok();
diff --git a/gnss/aidl/vts/gnss_hal_test.cpp b/gnss/aidl/vts/gnss_hal_test.cpp
index c1128ba..f184f81 100644
--- a/gnss/aidl/vts/gnss_hal_test.cpp
+++ b/gnss/aidl/vts/gnss_hal_test.cpp
@@ -33,7 +33,7 @@
ASSERT_NE(aidl_gnss_hal_, nullptr);
ALOGD("AIDL Interface Version = %d", aidl_gnss_hal_->getInterfaceVersion());
- if (aidl_gnss_hal_->getInterfaceVersion() == 1) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
const auto& hidlInstanceNames = android::hardware::getAllHalInstanceNames(
android::hardware::gnss::V2_1::IGnss::descriptor);
gnss_hal_ = IGnss_V2_1::getService(hidlInstanceNames[0]);
@@ -60,9 +60,15 @@
TIMEOUT_SEC));
EXPECT_EQ(aidl_gnss_cb_->capabilities_cbq_.calledCount(), 1);
- if (aidl_gnss_hal_->getInterfaceVersion() == 1) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
// Invoke the super method.
GnssHalTestTemplate<IGnss_V2_1>::SetUpGnssCallback();
+ } else {
+ /*
+ * SystemInfo callback should trigger
+ */
+ EXPECT_TRUE(aidl_gnss_cb_->info_cbq_.retrieve(aidl_gnss_cb_->last_info_, TIMEOUT_SEC));
+ EXPECT_EQ(aidl_gnss_cb_->info_cbq_.calledCount(), 1);
}
}
@@ -71,7 +77,7 @@
}
void GnssHalTest::SetPositionMode(const int min_interval_msec, const bool low_power_mode) {
- if (aidl_gnss_hal_->getInterfaceVersion() == 1) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
// Invoke the super method.
return GnssHalTestTemplate<IGnss_V2_1>::SetPositionMode(min_interval_msec, low_power_mode);
}
@@ -93,7 +99,7 @@
bool GnssHalTest::StartAndCheckFirstLocation(const int min_interval_msec,
const bool low_power_mode) {
- if (aidl_gnss_hal_->getInterfaceVersion() == 1) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
// Invoke the super method.
return GnssHalTestTemplate<IGnss_V2_1>::StartAndCheckFirstLocation(min_interval_msec,
low_power_mode);
@@ -127,7 +133,7 @@
void GnssHalTest::StopAndClearLocations() {
ALOGD("StopAndClearLocations");
- if (aidl_gnss_hal_->getInterfaceVersion() == 1) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
// Invoke the super method.
return GnssHalTestTemplate<IGnss_V2_1>::StopAndClearLocations();
}
@@ -148,7 +154,7 @@
}
void GnssHalTest::StartAndCheckLocations(int count) {
- if (aidl_gnss_hal_->getInterfaceVersion() == 1) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
// Invoke the super method.
return GnssHalTestTemplate<IGnss_V2_1>::StartAndCheckLocations(count);
}
@@ -264,7 +270,7 @@
GnssConstellationType GnssHalTest::startLocationAndGetNonGpsConstellation(
const int locations_to_await, const int gnss_sv_info_list_timeout) {
- if (aidl_gnss_hal_->getInterfaceVersion() == 1) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
return static_cast<GnssConstellationType>(
GnssHalTestTemplate<IGnss_V2_1>::startLocationAndGetNonGpsConstellation(
locations_to_await, gnss_sv_info_list_timeout));
diff --git a/gnss/aidl/vts/gnss_hal_test_cases.cpp b/gnss/aidl/vts/gnss_hal_test_cases.cpp
index 8e51b44..365f9d3 100644
--- a/gnss/aidl/vts/gnss_hal_test_cases.cpp
+++ b/gnss/aidl/vts/gnss_hal_test_cases.cpp
@@ -28,6 +28,7 @@
#include <android/hardware/gnss/measurement_corrections/IMeasurementCorrectionsInterface.h>
#include <android/hardware/gnss/visibility_control/IGnssVisibilityControl.h>
#include <cutils/properties.h>
+#include <cmath>
#include "AGnssCallbackAidl.h"
#include "AGnssRilCallbackAidl.h"
#include "GnssAntennaInfoCallbackAidl.h"
@@ -45,7 +46,9 @@
using android::hardware::gnss::BlocklistedSource;
using android::hardware::gnss::ElapsedRealtime;
using android::hardware::gnss::GnssClock;
+using android::hardware::gnss::GnssConstellationType;
using android::hardware::gnss::GnssData;
+using android::hardware::gnss::GnssLocation;
using android::hardware::gnss::GnssMeasurement;
using android::hardware::gnss::GnssPowerStats;
using android::hardware::gnss::IAGnss;
@@ -72,7 +75,6 @@
using android::hardware::gnss::visibility_control::IGnssVisibilityControl;
using GnssConstellationTypeV2_0 = android::hardware::gnss::V2_0::GnssConstellationType;
-using GnssConstellationTypeAidl = android::hardware::gnss::GnssConstellationType;
static bool IsAutomotiveDevice() {
char buffer[PROPERTY_VALUE_MAX] = {0};
@@ -89,6 +91,222 @@
TEST_P(GnssHalTest, SetupTeardownCreateCleanup) {}
/*
+ * GetLocation:
+ * Turns on location, waits 75 second for at least 5 locations,
+ * and checks them for reasonable validity.
+ */
+TEST_P(GnssHalTest, GetLocations) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
+ return;
+ }
+ const int kMinIntervalMsec = 500;
+ const int kLocationsToCheck = 5;
+
+ SetPositionMode(kMinIntervalMsec, /* low_power_mode= */ false);
+ StartAndCheckLocations(kLocationsToCheck);
+ StopAndClearLocations();
+}
+
+/*
+ * InjectDelete:
+ * Ensures that calls to inject and/or delete information state are handled.
+ */
+TEST_P(GnssHalTest, InjectDelete) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
+ return;
+ }
+ // Confidently, well north of Alaska
+ auto status = aidl_gnss_hal_->injectLocation(Utils::getMockLocation(80.0, -170.0, 150.0));
+ ASSERT_TRUE(status.isOk());
+
+ // Fake time, but generally reasonable values (time in Aug. 2018)
+ status =
+ aidl_gnss_hal_->injectTime(/* timeMs= */ 1534567890123L,
+ /* timeReferenceMs= */ 123456L, /* uncertaintyMs= */ 10000L);
+ ASSERT_TRUE(status.isOk());
+
+ status = aidl_gnss_hal_->deleteAidingData(IGnss::GnssAidingData::POSITION);
+ ASSERT_TRUE(status.isOk());
+
+ status = aidl_gnss_hal_->deleteAidingData(IGnss::GnssAidingData::TIME);
+ ASSERT_TRUE(status.isOk());
+
+ // Ensure we can get a good location after a bad injection has been deleted
+ StartAndCheckFirstLocation(/* min_interval_msec= */ 1000, /* low_power_mode= */ false);
+ StopAndClearLocations();
+}
+
+/*
+ * InjectSeedLocation:
+ * Injects a seed location and ensures the injected seed location is not fused in the resulting
+ * GNSS location.
+ */
+TEST_P(GnssHalTest, InjectSeedLocation) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
+ return;
+ }
+ // An arbitrary position in North Pacific Ocean (where no VTS labs will ever likely be located).
+ const double seedLatDegrees = 32.312894;
+ const double seedLngDegrees = -172.954117;
+ const float seedAccuracyMeters = 150.0;
+
+ auto status = aidl_gnss_hal_->injectLocation(
+ Utils::getMockLocation(seedLatDegrees, seedLngDegrees, seedAccuracyMeters));
+ ASSERT_TRUE(status.isOk());
+
+ StartAndCheckFirstLocation(/* min_interval_msec= */ 1000, /* low_power_mode= */ false);
+
+ // Ensure we don't get a location anywhere within 111km (1 degree of lat or lng) of the seed
+ // location.
+ EXPECT_TRUE(std::abs(aidl_gnss_cb_->last_location_.latitudeDegrees - seedLatDegrees) > 1.0 ||
+ std::abs(aidl_gnss_cb_->last_location_.longitudeDegrees - seedLngDegrees) > 1.0);
+
+ StopAndClearLocations();
+
+ status = aidl_gnss_hal_->deleteAidingData(IGnss::GnssAidingData::POSITION);
+ ASSERT_TRUE(status.isOk());
+}
+
+/*
+ * GnssCapabilities:
+ * 1. Verifies that GNSS hardware supports measurement capabilities.
+ * 2. Verifies that GNSS hardware supports Scheduling capabilities.
+ */
+TEST_P(GnssHalTest, GnssCapabilites) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
+ return;
+ }
+ if (!IsAutomotiveDevice()) {
+ EXPECT_TRUE(aidl_gnss_cb_->last_capabilities_ & IGnssCallback::CAPABILITY_MEASUREMENTS);
+ }
+ EXPECT_TRUE(aidl_gnss_cb_->last_capabilities_ & IGnssCallback::CAPABILITY_SCHEDULING);
+}
+
+/*
+ * GetLocationLowPower:
+ * Turns on location, waits for at least 5 locations allowing max of LOCATION_TIMEOUT_SUBSEQUENT_SEC
+ * between one location and the next. Also ensure that MIN_INTERVAL_MSEC is respected by waiting
+ * NO_LOCATION_PERIOD_SEC and verfiy that no location is received. Also perform validity checks on
+ * each received location.
+ */
+TEST_P(GnssHalTest, GetLocationLowPower) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
+ return;
+ }
+
+ const int kMinIntervalMsec = 5000;
+ const int kLocationTimeoutSubsequentSec = (kMinIntervalMsec / 1000) * 2;
+ const int kNoLocationPeriodSec = (kMinIntervalMsec / 1000) / 2;
+ const int kLocationsToCheck = 5;
+ const bool kLowPowerMode = true;
+
+ // Warmup period - VTS doesn't have AGPS access via GnssLocationProvider
+ aidl_gnss_cb_->location_cbq_.reset();
+ StartAndCheckLocations(kLocationsToCheck);
+ StopAndClearLocations();
+ aidl_gnss_cb_->location_cbq_.reset();
+
+ // Start of Low Power Mode test
+ // Don't expect true - as without AGPS access
+ if (!StartAndCheckFirstLocation(kMinIntervalMsec, kLowPowerMode)) {
+ ALOGW("GetLocationLowPower test - no first low power location received.");
+ }
+
+ for (int i = 1; i < kLocationsToCheck; i++) {
+ // Verify that kMinIntervalMsec is respected by waiting kNoLocationPeriodSec and
+ // ensure that no location is received yet
+
+ aidl_gnss_cb_->location_cbq_.retrieve(aidl_gnss_cb_->last_location_, kNoLocationPeriodSec);
+ const int location_called_count = aidl_gnss_cb_->location_cbq_.calledCount();
+ // Tolerate (ignore) one extra location right after the first one
+ // to handle startup edge case scheduling limitations in some implementations
+ if ((i == 1) && (location_called_count == 2)) {
+ CheckLocation(aidl_gnss_cb_->last_location_, true);
+ continue; // restart the quiet wait period after this too-fast location
+ }
+ EXPECT_LE(location_called_count, i);
+ if (location_called_count != i) {
+ ALOGW("GetLocationLowPower test - not enough locations received. %d vs. %d expected ",
+ location_called_count, i);
+ }
+
+ if (!aidl_gnss_cb_->location_cbq_.retrieve(
+ aidl_gnss_cb_->last_location_,
+ kLocationTimeoutSubsequentSec - kNoLocationPeriodSec)) {
+ ALOGW("GetLocationLowPower test - timeout awaiting location %d", i);
+ } else {
+ CheckLocation(aidl_gnss_cb_->last_location_, true);
+ }
+ }
+
+ StopAndClearLocations();
+}
+
+/*
+ * InjectBestLocation
+ *
+ * Ensure successfully injecting a location.
+ */
+TEST_P(GnssHalTest, InjectBestLocation) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
+ return;
+ }
+ StartAndCheckLocations(1);
+ GnssLocation gnssLocation = aidl_gnss_cb_->last_location_;
+ CheckLocation(gnssLocation, true);
+
+ auto status = aidl_gnss_hal_->injectBestLocation(gnssLocation);
+
+ ASSERT_TRUE(status.isOk());
+
+ status = aidl_gnss_hal_->deleteAidingData(IGnss::GnssAidingData::POSITION);
+
+ ASSERT_TRUE(status.isOk());
+}
+
+/*
+ * TestGnssSvInfoFields:
+ * Gets 1 location and a (non-empty) GnssSvInfo, and verifies basebandCN0DbHz is valid.
+ */
+TEST_P(GnssHalTest, TestGnssSvInfoFields) {
+ if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
+ return;
+ }
+ aidl_gnss_cb_->location_cbq_.reset();
+ aidl_gnss_cb_->sv_info_list_cbq_.reset();
+ StartAndCheckFirstLocation(/* min_interval_msec= */ 1000, /* low_power_mode= */ false);
+ int location_called_count = aidl_gnss_cb_->location_cbq_.calledCount();
+ ALOGD("Observed %d GnssSvStatus, while awaiting one location (%d received)",
+ aidl_gnss_cb_->sv_info_list_cbq_.size(), location_called_count);
+
+ // Wait for up to kNumSvInfoLists events for kTimeoutSeconds for each event.
+ int kTimeoutSeconds = 2;
+ int kNumSvInfoLists = 4;
+ std::list<std::vector<IGnssCallback::GnssSvInfo>> sv_info_lists;
+ std::vector<IGnssCallback::GnssSvInfo> last_sv_info_list;
+
+ do {
+ EXPECT_GT(aidl_gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_lists, kNumSvInfoLists,
+ kTimeoutSeconds),
+ 0);
+ last_sv_info_list = sv_info_lists.back();
+ } while (last_sv_info_list.size() == 0);
+
+ ALOGD("last_sv_info size = %d", (int)last_sv_info_list.size());
+ bool nonZeroCn0Found = false;
+ for (auto sv_info : last_sv_info_list) {
+ EXPECT_TRUE(sv_info.basebandCN0DbHz >= 0.0 && sv_info.basebandCN0DbHz <= 65.0);
+ if (sv_info.basebandCN0DbHz > 0.0) {
+ nonZeroCn0Found = true;
+ }
+ }
+ // Assert at least one value is non-zero. Zero is ok in status as it's possibly
+ // reporting a searched but not found satellite.
+ EXPECT_TRUE(nonZeroCn0Found);
+ StopAndClearLocations();
+}
+
+/*
* TestPsdsExtension:
* 1. Gets the PsdsExtension
* 2. Injects empty PSDS data and verifies that it returns an error.
@@ -158,15 +376,7 @@
}
void CheckGnssMeasurementClockFields(const GnssData& measurement) {
- ASSERT_TRUE(measurement.elapsedRealtime.flags >= 0 &&
- measurement.elapsedRealtime.flags <= (ElapsedRealtime::HAS_TIMESTAMP_NS |
- ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS));
- if (measurement.elapsedRealtime.flags & ElapsedRealtime::HAS_TIMESTAMP_NS) {
- ASSERT_TRUE(measurement.elapsedRealtime.timestampNs > 0);
- }
- if (measurement.elapsedRealtime.flags & ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS) {
- ASSERT_TRUE(measurement.elapsedRealtime.timeUncertaintyNs > 0);
- }
+ Utils::checkElapsedRealtime(measurement.elapsedRealtime);
ASSERT_TRUE(measurement.clock.gnssClockFlags >= 0 &&
measurement.clock.gnssClockFlags <=
(GnssClock::HAS_LEAP_SECOND | GnssClock::HAS_TIME_UNCERTAINTY |
@@ -189,6 +399,34 @@
GnssMeasurement::HAS_CORRELATION_VECTOR));
}
+void CheckGnssMeasurementFields(const GnssMeasurement& measurement, const GnssData& data) {
+ CheckGnssMeasurementFlags(measurement);
+ // Verify CodeType is valid.
+ ASSERT_NE(measurement.signalType.codeType, "");
+ // Verify basebandCn0DbHz is valid.
+ ASSERT_TRUE(measurement.basebandCN0DbHz > 0.0 && measurement.basebandCN0DbHz <= 65.0);
+
+ if (((measurement.flags & GnssMeasurement::HAS_FULL_ISB) > 0) &&
+ ((measurement.flags & GnssMeasurement::HAS_FULL_ISB_UNCERTAINTY) > 0) &&
+ ((measurement.flags & GnssMeasurement::HAS_SATELLITE_ISB) > 0) &&
+ ((measurement.flags & GnssMeasurement::HAS_SATELLITE_ISB_UNCERTAINTY) > 0)) {
+ GnssConstellationType referenceConstellation =
+ data.clock.referenceSignalTypeForIsb.constellation;
+ double carrierFrequencyHz = data.clock.referenceSignalTypeForIsb.carrierFrequencyHz;
+ std::string codeType = data.clock.referenceSignalTypeForIsb.codeType;
+
+ ASSERT_TRUE(referenceConstellation >= GnssConstellationType::UNKNOWN &&
+ referenceConstellation <= GnssConstellationType::IRNSS);
+ ASSERT_TRUE(carrierFrequencyHz > 0);
+ ASSERT_NE(codeType, "");
+
+ ASSERT_TRUE(std::abs(measurement.fullInterSignalBiasNs) < 1.0e6);
+ ASSERT_TRUE(measurement.fullInterSignalBiasUncertaintyNs >= 0);
+ ASSERT_TRUE(std::abs(measurement.satelliteInterSignalBiasNs) < 1.0e6);
+ ASSERT_TRUE(measurement.satelliteInterSignalBiasUncertaintyNs >= 0);
+ }
+}
+
/*
* TestGnssMeasurementExtensionAndSatellitePvt:
* 1. Gets the GnssMeasurementExtension and verifies that it returns a non-null extension.
@@ -229,7 +467,7 @@
CheckGnssMeasurementClockFields(lastMeasurement);
for (const auto& measurement : lastMeasurement.measurements) {
- CheckGnssMeasurementFlags(measurement);
+ CheckGnssMeasurementFields(measurement, lastMeasurement);
if (measurement.flags & GnssMeasurement::HAS_SATELLITE_PVT &&
kIsSatellitePvtSupported == true) {
ALOGD("Found a measurement with SatellitePvt");
@@ -289,7 +527,7 @@
CheckGnssMeasurementClockFields(lastMeasurement);
for (const auto& measurement : lastMeasurement.measurements) {
- CheckGnssMeasurementFlags(measurement);
+ CheckGnssMeasurementFields(measurement, lastMeasurement);
if (measurement.flags & GnssMeasurement::HAS_CORRELATION_VECTOR) {
correlationVectorFound = true;
ASSERT_TRUE(measurement.correlationVectors.size() > 0);
@@ -466,7 +704,7 @@
FindStrongFrequentNonGpsSource(sv_info_vec_list, kLocationsToAwait - 1);
}
- if (source_to_blocklist.constellation == GnssConstellationTypeAidl::UNKNOWN) {
+ if (source_to_blocklist.constellation == GnssConstellationType::UNKNOWN) {
// Cannot find a non-GPS satellite. Let the test pass.
ALOGD("Cannot find a non-GPS satellite. Letting the test pass.");
return;
@@ -522,7 +760,7 @@
auto& gnss_sv = sv_info_vec[iSv];
EXPECT_FALSE(
(gnss_sv.v2_0.v1_0.svid == source_to_blocklist.svid) &&
- (static_cast<GnssConstellationTypeAidl>(gnss_sv.v2_0.constellation) ==
+ (static_cast<GnssConstellationType>(gnss_sv.v2_0.constellation) ==
source_to_blocklist.constellation) &&
(gnss_sv.v2_0.v1_0.svFlag & IGnssCallback_1_0::GnssSvFlags::USED_IN_FIX));
}
@@ -584,7 +822,7 @@
for (uint32_t iSv = 0; iSv < sv_info_vec.size(); iSv++) {
auto& gnss_sv = sv_info_vec[iSv];
if ((gnss_sv.v2_0.v1_0.svid == source_to_blocklist.svid) &&
- (static_cast<GnssConstellationTypeAidl>(gnss_sv.v2_0.constellation) ==
+ (static_cast<GnssConstellationType>(gnss_sv.v2_0.constellation) ==
source_to_blocklist.constellation) &&
(gnss_sv.v2_0.v1_0.svFlag & IGnssCallback_1_0::GnssSvFlags::USED_IN_FIX)) {
strongest_sv_is_reobserved = true;
@@ -633,7 +871,7 @@
const int kGnssSvInfoListTimeout = 2;
// Find first non-GPS constellation to blocklist
- GnssConstellationTypeAidl constellation_to_blocklist = static_cast<GnssConstellationTypeAidl>(
+ GnssConstellationType constellation_to_blocklist = static_cast<GnssConstellationType>(
startLocationAndGetNonGpsConstellation(kLocationsToAwait, kGnssSvInfoListTimeout));
// Turns off location
@@ -646,7 +884,7 @@
// IRNSS was added in 2.0. Always attempt to blocklist IRNSS to verify that the new enum is
// supported.
BlocklistedSource source_to_blocklist_2;
- source_to_blocklist_2.constellation = GnssConstellationTypeAidl::IRNSS;
+ source_to_blocklist_2.constellation = GnssConstellationType::IRNSS;
source_to_blocklist_2.svid = 0; // documented wildcard for all satellites in this constellation
sp<IGnssConfiguration> gnss_configuration_hal;
@@ -686,11 +924,11 @@
for (uint32_t iSv = 0; iSv < sv_info_vec.size(); iSv++) {
const auto& gnss_sv = sv_info_vec[iSv];
EXPECT_FALSE(
- (static_cast<GnssConstellationTypeAidl>(gnss_sv.v2_0.constellation) ==
+ (static_cast<GnssConstellationType>(gnss_sv.v2_0.constellation) ==
source_to_blocklist_1.constellation) &&
(gnss_sv.v2_0.v1_0.svFlag & IGnssCallback_1_0::GnssSvFlags::USED_IN_FIX));
EXPECT_FALSE(
- (static_cast<GnssConstellationTypeAidl>(gnss_sv.v2_0.constellation) ==
+ (static_cast<GnssConstellationType>(gnss_sv.v2_0.constellation) ==
source_to_blocklist_2.constellation) &&
(gnss_sv.v2_0.v1_0.svFlag & IGnssCallback_1_0::GnssSvFlags::USED_IN_FIX));
}
@@ -736,7 +974,7 @@
const int kGnssSvInfoListTimeout = 2;
// Find first non-GPS constellation to blocklist
- GnssConstellationTypeAidl constellation_to_blocklist = static_cast<GnssConstellationTypeAidl>(
+ GnssConstellationType constellation_to_blocklist = static_cast<GnssConstellationType>(
startLocationAndGetNonGpsConstellation(kLocationsToAwait, kGnssSvInfoListTimeout));
BlocklistedSource source_to_blocklist_1;
@@ -746,7 +984,7 @@
// IRNSS was added in 2.0. Always attempt to blocklist IRNSS to verify that the new enum is
// supported.
BlocklistedSource source_to_blocklist_2;
- source_to_blocklist_2.constellation = GnssConstellationTypeAidl::IRNSS;
+ source_to_blocklist_2.constellation = GnssConstellationType::IRNSS;
source_to_blocklist_2.svid = 0; // documented wildcard for all satellites in this constellation
sp<IGnssConfiguration> gnss_configuration_hal;
@@ -789,11 +1027,11 @@
for (uint32_t iSv = 0; iSv < sv_info_vec.size(); iSv++) {
const auto& gnss_sv = sv_info_vec[iSv];
EXPECT_FALSE(
- (static_cast<GnssConstellationTypeAidl>(gnss_sv.v2_0.constellation) ==
+ (static_cast<GnssConstellationType>(gnss_sv.v2_0.constellation) ==
source_to_blocklist_1.constellation) &&
(gnss_sv.v2_0.v1_0.svFlag & IGnssCallback_1_0::GnssSvFlags::USED_IN_FIX));
EXPECT_FALSE(
- (static_cast<GnssConstellationTypeAidl>(gnss_sv.v2_0.constellation) ==
+ (static_cast<GnssConstellationType>(gnss_sv.v2_0.constellation) ==
source_to_blocklist_2.constellation) &&
(gnss_sv.v2_0.v1_0.svFlag & IGnssCallback_1_0::GnssSvFlags::USED_IN_FIX));
}
@@ -884,7 +1122,8 @@
* TestAGnssRilExtension:
* 1. Gets the IAGnssRil extension.
* 2. Sets AGnssRilCallback.
- * 3. Sets reference location.
+ * 3. Update network state to connected and then disconnected.
+ * 4. Sets reference location.
*/
TEST_P(GnssHalTest, TestAGnssRilExtension) {
if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
@@ -899,6 +1138,20 @@
status = iAGnssRil->setCallback(agnssRilCallback);
ASSERT_TRUE(status.isOk());
+ // Update GNSS HAL that a network has connected.
+ IAGnssRil::NetworkAttributes networkAttributes;
+ networkAttributes.networkHandle = 7700664333L;
+ networkAttributes.isConnected = true;
+ networkAttributes.capabilities = IAGnssRil::NETWORK_CAPABILITY_NOT_ROAMING;
+ networkAttributes.apn = "placeholder-apn";
+ status = iAGnssRil->updateNetworkState(networkAttributes);
+ ASSERT_TRUE(status.isOk());
+
+ // Update GNSS HAL that network has disconnected.
+ networkAttributes.isConnected = false;
+ status = iAGnssRil->updateNetworkState(networkAttributes);
+ ASSERT_TRUE(status.isOk());
+
// Set RefLocation
IAGnssRil::AGnssRefLocationCellID agnssReflocationCellId;
agnssReflocationCellId.type = IAGnssRil::AGnssRefLocationType::LTE_CELLID;
@@ -1020,6 +1273,9 @@
// Validity check GnssData fields
CheckGnssMeasurementClockFields(lastMeasurement);
+ for (const auto& measurement : lastMeasurement.measurements) {
+ CheckGnssMeasurementFields(measurement, lastMeasurement);
+ }
}
status = iGnssMeasurement->close();
@@ -1076,12 +1332,11 @@
* PhaseCenterVariationCorrections and SignalGainCorrections are optional.
*/
TEST_P(GnssHalTest, TestGnssAntennaInfo) {
- const int kAntennaInfoTimeoutSeconds = 2;
-
if (aidl_gnss_hal_->getInterfaceVersion() <= 1) {
return;
}
+ const int kAntennaInfoTimeoutSeconds = 2;
sp<IGnssAntennaInfo> iGnssAntennaInfo;
auto status = aidl_gnss_hal_->getExtensionGnssAntennaInfo(&iGnssAntennaInfo);
ASSERT_TRUE(status.isOk());
diff --git a/gnss/common/utils/default/Utils.cpp b/gnss/common/utils/default/Utils.cpp
index 4e6a718..a519d3a 100644
--- a/gnss/common/utils/default/Utils.cpp
+++ b/gnss/common/utils/default/Utils.cpp
@@ -217,7 +217,8 @@
.biasUncertaintyNs = 47514.989972114563,
.driftNsps = -51.757811607455452,
.driftUncertaintyNsps = 310.64968328491528,
- .hwClockDiscontinuityCount = 1};
+ .hwClockDiscontinuityCount = 1,
+ .referenceSignalTypeForIsb = signalType};
ElapsedRealtime timestamp = {
.flags = ElapsedRealtime::HAS_TIMESTAMP_NS | ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS,
diff --git a/gnss/common/utils/vts/Utils.cpp b/gnss/common/utils/vts/Utils.cpp
index da4c07f..4c725a8 100644
--- a/gnss/common/utils/vts/Utils.cpp
+++ b/gnss/common/utils/vts/Utils.cpp
@@ -20,12 +20,16 @@
#include "gtest/gtest.h"
#include <cutils/properties.h>
+#include <utils/SystemClock.h>
namespace android {
namespace hardware {
namespace gnss {
namespace common {
+using android::hardware::gnss::ElapsedRealtime;
+using android::hardware::gnss::GnssLocation;
+
using namespace measurement_corrections::V1_0;
using V1_0::GnssLocationFlags;
@@ -45,6 +49,50 @@
return location.timestamp;
}
+template <>
+void Utils::checkLocationElapsedRealtime(const V1_0::GnssLocation&) {}
+
+template <>
+void Utils::checkLocationElapsedRealtime(const android::hardware::gnss::GnssLocation& location) {
+ checkElapsedRealtime(location.elapsedRealtime);
+}
+
+void Utils::checkElapsedRealtime(const ElapsedRealtime& elapsedRealtime) {
+ ASSERT_TRUE(elapsedRealtime.flags >= 0 &&
+ elapsedRealtime.flags <= (ElapsedRealtime::HAS_TIMESTAMP_NS |
+ ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS));
+ if (elapsedRealtime.flags & ElapsedRealtime::HAS_TIMESTAMP_NS) {
+ ASSERT_TRUE(elapsedRealtime.timestampNs > 0);
+ }
+ if (elapsedRealtime.flags & ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS) {
+ ASSERT_TRUE(elapsedRealtime.timeUncertaintyNs > 0);
+ }
+}
+
+const GnssLocation Utils::getMockLocation(double latitudeDegrees, double longitudeDegrees,
+ double horizontalAccuracyMeters) {
+ ElapsedRealtime elapsedRealtime;
+ elapsedRealtime.flags =
+ ElapsedRealtime::HAS_TIMESTAMP_NS | ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS;
+ elapsedRealtime.timestampNs = ::android::elapsedRealtimeNano();
+ elapsedRealtime.timeUncertaintyNs = 1000;
+ GnssLocation location;
+ location.gnssLocationFlags = 0xFF;
+ location.latitudeDegrees = latitudeDegrees;
+ location.longitudeDegrees = longitudeDegrees;
+ location.altitudeMeters = 500.0;
+ location.speedMetersPerSec = 0.0;
+ location.bearingDegrees = 0.0;
+ location.horizontalAccuracyMeters = horizontalAccuracyMeters;
+ location.verticalAccuracyMeters = 1000.0;
+ location.speedAccuracyMetersPerSecond = 1000.0;
+ location.bearingAccuracyDegrees = 90.0;
+ location.timestampMillis =
+ static_cast<int64_t>(kMockTimestamp + ::android::elapsedRealtimeNano() * 1e-6);
+ location.elapsedRealtime = elapsedRealtime;
+ return location;
+}
+
const MeasurementCorrections Utils::getMockMeasurementCorrections() {
ReflectingPlane reflectingPlane = {
.latitudeDegrees = 37.4220039,
diff --git a/gnss/common/utils/vts/include/Utils.h b/gnss/common/utils/vts/include/Utils.h
index 4ea6cd6..7b89078 100644
--- a/gnss/common/utils/vts/include/Utils.h
+++ b/gnss/common/utils/vts/include/Utils.h
@@ -19,11 +19,13 @@
#include <android/hardware/gnss/1.0/IGnss.h>
#include <android/hardware/gnss/2.0/IGnss.h>
+#include <android/hardware/gnss/IGnss.h>
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrections.h>
#include <android/hardware/gnss/measurement_corrections/1.1/IMeasurementCorrections.h>
#include <android/hardware/gnss/measurement_corrections/BnMeasurementCorrectionsInterface.h>
#include <gtest/gtest.h>
+#include <type_traits>
namespace android {
namespace hardware {
@@ -32,8 +34,18 @@
struct Utils {
public:
+ static const int64_t kMockTimestamp = 1519930775453L;
+
template <class T>
static void checkLocation(const T& location, bool check_speed, bool check_more_accuracies);
+ template <class T>
+ static void checkLocationElapsedRealtime(const T& location);
+
+ static void checkElapsedRealtime(
+ const android::hardware::gnss::ElapsedRealtime& elapsedRealtime);
+
+ static const android::hardware::gnss::GnssLocation getMockLocation(
+ double latitudeDegrees, double longitudeDegrees, double horizontalAccuracyMeters);
static const measurement_corrections::V1_0::MeasurementCorrections
getMockMeasurementCorrections();
static const measurement_corrections::V1_1::MeasurementCorrections
@@ -117,6 +129,8 @@
// Check timestamp > 1.48e12 (47 years in msec - 1970->2017+)
EXPECT_GT(getLocationTimestampMillis(location), 1.48e12);
+
+ checkLocationElapsedRealtime(location);
}
} // namespace common