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

Commit 17520266 authored by Anil Admal's avatar Anil Admal Committed by android-build-merger
Browse files

Add GetLocationLowPower VTS 2.0 test

am: 02376b9e

Change-Id: I8155f57d03c29991451622d8ae68784c213db332
parents 05d36f94 02376b9e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -66,6 +66,11 @@ TEST_F(GnssHalTest, TestGnssMeasurementCallback) {
 * each received location.
 */
TEST_F(GnssHalTest, GetLocationLowPower) {
    if (!IsGnssHalVersion_1_1()) {
        ALOGI("Test GetLocationLowPower skipped. GNSS HAL version is greater than 1.1.");
        return;
    }

    const int kMinIntervalMsec = 5000;
    const int kLocationTimeoutSubsequentSec = (kMinIntervalMsec / 1000) * 2;
    const int kNoLocationPeriodSec = (kMinIntervalMsec / 1000) / 2;
+68 −1
Original line number Diff line number Diff line
@@ -415,6 +415,70 @@ TEST_F(GnssHalTest, TestGnssBatchingExtension) {
    ASSERT_TRUE(gnssBatching_2_0.isOk());
}

/*
 * 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_F(GnssHalTest, GetLocationLowPower) {
    if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::LOW_POWER_MODE)) {
        ALOGI("Test GetLocationLowPower skipped. LOW_POWER_MODE capability not supported.");
        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
    gnss_cb_->location_cbq_.reset();
    StartAndCheckLocations(kLocationsToCheck);
    StopAndClearLocations();
    gnss_cb_->location_cbq_.reset();

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

    // 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

        gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, kNoLocationPeriodSec);
        const int locationCalledCount = 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) && (locationCalledCount == 2)) {
            CheckLocation(gnss_cb_->last_location_, true);
            continue;  // restart the quiet wait period after this too-fast location
        }
        EXPECT_LE(locationCalledCount, i);
        if (locationCalledCount != i) {
            ALOGW("GetLocationLowPower test - not enough locations received. %d vs. %d expected ",
                  locationCalledCount, i);
        }

        if (!gnss_cb_->location_cbq_.retrieve(
                    gnss_cb_->last_location_,
                    kLocationTimeoutSubsequentSec - kNoLocationPeriodSec)) {
            ALOGW("GetLocationLowPower test - timeout awaiting location %d", i);
        } else {
            CheckLocation(gnss_cb_->last_location_, true);
        }
    }

    StopAndClearLocations();
}

/*
 * MapConstellationType:
 * Given a GnssConstellationType_2_0 type constellation, maps to its equivalent
@@ -537,6 +601,8 @@ IGnssConfiguration_1_1::BlacklistedSource FindStrongFrequentNonGpsSource(
 */
TEST_F(GnssHalTest, BlacklistIndividualSatellites) {
    if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::SATELLITE_BLACKLIST)) {
        ALOGI("Test BlacklistIndividualSatellites skipped. SATELLITE_BLACKLIST capability"
              " not supported.");
        return;
    }

@@ -680,6 +746,7 @@ TEST_F(GnssHalTest, BlacklistIndividualSatellites) {
 */
TEST_F(GnssHalTest, BlacklistConstellation) {
    if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::SATELLITE_BLACKLIST)) {
        ALOGI("Test BlacklistConstellation skipped. SATELLITE_BLACKLIST capability not supported.");
        return;
    }