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

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

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
parent 5194b353
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -53,17 +53,26 @@ ScopedAStatus Gnss::setCallback(const std::shared_ptr<IGnssCallback>& callback)
        ALOGE("%s: Null callback ignored", __func__);
        return ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
    }

    sGnssCallback = callback;

    int capabilities = (int)(IGnssCallback::CAPABILITY_SATELLITE_BLOCKLIST |
    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();
+13 −7
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ void GnssHalTest::SetUp() {
    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 @@ void GnssHalTest::SetUpGnssCallback() {
                                                          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::CheckLocation(const GnssLocation& location, bool check_speed)
}

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 @@ void GnssHalTest::SetPositionMode(const int min_interval_msec, const bool low_po

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 @@ bool GnssHalTest::StartAndCheckFirstLocation(const int min_interval_msec,

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::StopAndClearLocations() {
}

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 @@ BlocklistedSource GnssHalTest::FindStrongFrequentNonGpsSource(

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));
+281 −26

File changed.

Preview size limit exceeded, changes collapsed.

+2 −1
Original line number Diff line number Diff line
@@ -217,7 +217,8 @@ GnssData Utils::getMockMeasurement(const bool enableCorrVecOutputs) {
                       .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,
+48 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading