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

Commit b20389e2 authored by Yu-Han Yang's avatar Yu-Han Yang
Browse files

Avoid injected location fused in GNSS location

Bug: 144104269
Test: atest VtsHalGnssV1_0TargetTest
Change-Id: I1266c6b7118d83e24a40dfe4ce4d4ba53a053343
parent bdc9434b
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <log/log.h>

#include <chrono>
#include <cmath>
#include <condition_variable>
#include <mutex>

@@ -402,6 +403,34 @@ TEST_P(GnssHalTest, InjectDelete) {
  StopAndClearLocations();
}

/*
 * InjectSeedLocation:
 * Injects a seed location and ensures the injected seed location is not fused in the resulting
 * GNSS location.
 */
TEST_P(GnssHalTest, InjectSeedLocation) {
    // 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 result = gnss_hal_->injectLocation(seedLatDegrees, seedLngDegrees, seedAccuracyMeters);
    ASSERT_TRUE(result.isOk());
    EXPECT_TRUE(result);

    StartAndGetSingleLocation(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(last_location_.latitudeDegrees - seedLatDegrees) > 1.0 ||
                std::abs(last_location_.longitudeDegrees - seedLngDegrees) > 1.0);

    StopAndClearLocations();

    auto resultVoid = gnss_hal_->deleteAidingData(IGnss::GnssAidingData::DELETE_POSITION);
    ASSERT_TRUE(resultVoid.isOk());
}

/*
 * GetAllExtentions:
 * Tries getting all optional extensions, and ensures a valid return