Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ea5dda2 authored by WyattRiley's avatar WyattRiley
Browse files

Improve VTS GNSS 1.1 reliability.

Allow VTS test for low power mode to handle
certain vendor issues that supply one extra location
at the start of low power mode.

Allow more time for GNSS first fix, and warmup as
needed given limited VTS access to AGPS.

Bug: 110626730
Bug: 110987651
Test: (TODO) Passes on device.
Change-Id: Ieeefd7fcd45890b03dffbbee965e1d9b17805c4c
parent d33b77a1
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ void GnssHalTest::StopAndClearLocations() {
     */
    while (wait(TIMEOUT_SEC) == std::cv_status::no_timeout) {
    }
    location_called_count_ = 0;
}

void GnssHalTest::SetPositionMode(const int min_interval_msec, const bool low_power_mode) {
@@ -97,17 +98,17 @@ void GnssHalTest::SetPositionMode(const int min_interval_msec, const bool low_po
    EXPECT_TRUE(result);
}

bool GnssHalTest::StartAndGetSingleLocation() {
bool GnssHalTest::StartAndCheckFirstLocation() {
    auto result = gnss_hal_->start();

    EXPECT_TRUE(result.isOk());
    EXPECT_TRUE(result);

    /*
     * GPS signals initially optional for this test, so don't expect fast fix,
     * or no timeout, unless signal is present
     * GnssLocationProvider support of AGPS SUPL & XtraDownloader is not available in VTS,
     * so allow time to demodulate ephemeris over the air.
     */
    const int kFirstGnssLocationTimeoutSeconds = 15;
    const int kFirstGnssLocationTimeoutSeconds = 75;

    wait(kFirstGnssLocationTimeoutSeconds);
    EXPECT_EQ(location_called_count_, 1);
@@ -195,7 +196,7 @@ void GnssHalTest::StartAndCheckLocations(int count) {

    SetPositionMode(kMinIntervalMsec, kLowPowerMode);

    EXPECT_TRUE(StartAndGetSingleLocation());
    EXPECT_TRUE(StartAndCheckFirstLocation());

    for (int i = 1; i < count; i++) {
        EXPECT_EQ(std::cv_status::no_timeout, wait(kLocationTimeoutSubsequentSec));
+6 −3
Original line number Diff line number Diff line
@@ -107,12 +107,15 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
    void SetUpGnssCallback();

    /*
     * StartAndGetSingleLocation:
     * Helper function to get one Location and check fields
     * StartAndCheckFirstLocation:
     *   Helper function to start location, and check the first one.
     *
     *   <p> Note this leaves the Location request active, to enable Stop call vs. other call
     *   reordering tests.
     *
     * returns  true if a location was successfully generated
     */
    bool StartAndGetSingleLocation();
    bool StartAndCheckFirstLocation();

    /*
     * CheckLocation:
+30 −9
Original line number Diff line number Diff line
@@ -60,24 +60,46 @@ TEST_F(GnssHalTest, TestGnssMeasurementCallback) {
 */
TEST_F(GnssHalTest, GetLocationLowPower) {
    const int kMinIntervalMsec = 5000;
    const int kLocationTimeoutSubsequentSec = (kMinIntervalMsec / 1000) + 1;
    const int kNoLocationPeriodSec = 2;
    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
    StartAndCheckLocations(5);
    StopAndClearLocations();

    // Start of Low Power Mode test
    SetPositionMode(kMinIntervalMsec, kLowPowerMode);

    EXPECT_TRUE(StartAndGetSingleLocation());
    // Don't expect true - as without AGPS access
    if (!StartAndCheckFirstLocation()) {
        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

        wait(kNoLocationPeriodSec);
        EXPECT_EQ(location_called_count_, i);
        EXPECT_EQ(std::cv_status::no_timeout,
                  wait(kLocationTimeoutSubsequentSec - kNoLocationPeriodSec));
        EXPECT_EQ(location_called_count_, i + 1);
        // 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(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 (std::cv_status::no_timeout !=
            wait(kLocationTimeoutSubsequentSec - kNoLocationPeriodSec)) {
            ALOGW("GetLocationLowPower test - timeout awaiting location %d", i);
        } else {
            CheckLocation(last_location_, true);
        }
    }

    StopAndClearLocations();
@@ -236,7 +258,6 @@ TEST_F(GnssHalTest, BlacklistIndividualSatellites) {
    ASSERT_TRUE(result.isOk());
    EXPECT_TRUE(result);

    location_called_count_ = 0;
    StopAndClearLocations();
    list_gnss_sv_status_.clear();