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

Commit 44eb2e3d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Avoid injected location fused in GNSS location"

parents ca969d89 b20389e2
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