From 72083ba9cdafa955d66d0c67b9f536e956c56ac1 Mon Sep 17 00:00:00 2001 From: Nathan Harold Date: Wed, 5 Feb 2020 19:07:12 -0800 Subject: [PATCH] Add a VTS test for BarringInfo Add a VTS that verifies polled BarringInfo is sanely constructed. Bug: 148646258 Test: make VtsHalRadioV1_5TargetTest Change-Id: Idf8d110efe8fa2289fbcc8ed7f0959f0bd51999e --- .../1.5/vts/functional/radio_hidl_hal_api.cpp | 107 ++++++++++++++++++ .../functional/radio_hidl_hal_utils_v1_5.h | 4 + radio/1.5/vts/functional/radio_response.cpp | 6 +- 3 files changed, 115 insertions(+), 2 deletions(-) diff --git a/radio/1.5/vts/functional/radio_hidl_hal_api.cpp b/radio/1.5/vts/functional/radio_hidl_hal_api.cpp index 621825fa52..55a0a3228f 100644 --- a/radio/1.5/vts/functional/radio_hidl_hal_api.cpp +++ b/radio/1.5/vts/functional/radio_hidl_hal_api.cpp @@ -1069,3 +1069,110 @@ TEST_F(RadioHidlTest_v1_5, sendCdmaSmsExpectMore) { CHECK_GENERAL_ERROR)); } } + +/* + * Test IRadio.getBarringInfo() for the response returned. + */ +TEST_F(RadioHidlTest_v1_5, getBarringInfo) { + serial = GetRandomSerialNumber(); + + Return res = radio_v1_5->getBarringInfo(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial); + + ASSERT_TRUE(radioRsp_v1_5->barringInfos.size() > 0); + + std::set reportedServices; + + // validate that the service types are in range + for (const auto& info : radioRsp_v1_5->barringInfos) { + ASSERT_TRUE((info.serviceType >= BarringInfo::ServiceType::CS_SERVICE && + info.serviceType <= BarringInfo::ServiceType::SMS) || + (info.serviceType >= BarringInfo::ServiceType::OPERATOR_1 && + info.serviceType <= BarringInfo::ServiceType::OPERATOR_32)); + reportedServices.insert(info.serviceType); + + // Any type that is "conditional" must have sane values for conditional barring + // factor and time. + switch (info.barringType) { + case BarringInfo::BarringType::NONE: // fall through + case BarringInfo::BarringType::UNCONDITIONAL: + break; + case BarringInfo::BarringType::CONDITIONAL: { + const int32_t barringFactor = info.barringTypeSpecificInfo.conditional().factor; + ASSERT_TRUE(barringFactor >= 0 && barringFactor <= 100); + ASSERT_TRUE(info.barringTypeSpecificInfo.conditional().timeSeconds > 0); + break; + } + default: + FAIL(); + } + } + + // Certain types of barring are relevant for certain RANs. Ensure that only the right + // types are reported. Note that no types are required, simply that for a given technology + // only certain types are valid. This is one way to sanity check that implementations are + // not providing information that they don't have. + static const std::set UTRA_SERVICES{ + BarringInfo::ServiceType::CS_SERVICE, BarringInfo::ServiceType::PS_SERVICE, + BarringInfo::ServiceType::CS_VOICE, BarringInfo::ServiceType::EMERGENCY, + BarringInfo::ServiceType::SMS, + }; + + static const std::set EUTRA_SERVICES{ + BarringInfo::ServiceType::MO_SIGNALLING, BarringInfo::ServiceType::MO_DATA, + BarringInfo::ServiceType::CS_FALLBACK, BarringInfo::ServiceType::MMTEL_VOICE, + BarringInfo::ServiceType::MMTEL_VIDEO, BarringInfo::ServiceType::EMERGENCY, + BarringInfo::ServiceType::SMS, + }; + + static const std::set NGRA_SERVICES = { + BarringInfo::ServiceType::MO_SIGNALLING, BarringInfo::ServiceType::MO_DATA, + BarringInfo::ServiceType::CS_FALLBACK, BarringInfo::ServiceType::MMTEL_VOICE, + BarringInfo::ServiceType::MMTEL_VIDEO, BarringInfo::ServiceType::EMERGENCY, + BarringInfo::ServiceType::SMS, BarringInfo::ServiceType::OPERATOR_1, + BarringInfo::ServiceType::OPERATOR_2, BarringInfo::ServiceType::OPERATOR_3, + BarringInfo::ServiceType::OPERATOR_4, BarringInfo::ServiceType::OPERATOR_5, + BarringInfo::ServiceType::OPERATOR_6, BarringInfo::ServiceType::OPERATOR_7, + BarringInfo::ServiceType::OPERATOR_8, BarringInfo::ServiceType::OPERATOR_9, + BarringInfo::ServiceType::OPERATOR_10, BarringInfo::ServiceType::OPERATOR_11, + BarringInfo::ServiceType::OPERATOR_12, BarringInfo::ServiceType::OPERATOR_13, + BarringInfo::ServiceType::OPERATOR_14, BarringInfo::ServiceType::OPERATOR_15, + BarringInfo::ServiceType::OPERATOR_16, BarringInfo::ServiceType::OPERATOR_17, + BarringInfo::ServiceType::OPERATOR_18, BarringInfo::ServiceType::OPERATOR_19, + BarringInfo::ServiceType::OPERATOR_20, BarringInfo::ServiceType::OPERATOR_21, + BarringInfo::ServiceType::OPERATOR_22, BarringInfo::ServiceType::OPERATOR_23, + BarringInfo::ServiceType::OPERATOR_24, BarringInfo::ServiceType::OPERATOR_25, + BarringInfo::ServiceType::OPERATOR_26, BarringInfo::ServiceType::OPERATOR_27, + BarringInfo::ServiceType::OPERATOR_28, BarringInfo::ServiceType::OPERATOR_29, + BarringInfo::ServiceType::OPERATOR_30, BarringInfo::ServiceType::OPERATOR_31, + }; + + const std::set* compareTo = nullptr; + + switch (radioRsp_v1_5->barringCellIdentity.getDiscriminator()) { + case android::hardware::radio::V1_5::CellIdentity::hidl_discriminator::wcdma: + // fall through + case android::hardware::radio::V1_5::CellIdentity::hidl_discriminator::tdscdma: + compareTo = &UTRA_SERVICES; + break; + case android::hardware::radio::V1_5::CellIdentity::hidl_discriminator::lte: + compareTo = &EUTRA_SERVICES; + break; + case android::hardware::radio::V1_5::CellIdentity::hidl_discriminator::nr: + compareTo = &NGRA_SERVICES; + break; + + case android::hardware::radio::V1_5::CellIdentity::hidl_discriminator::cdma: + // fall through + default: + FAIL(); + break; + } + + std::set diff; + + std::set_difference(reportedServices.begin(), reportedServices.end(), compareTo->begin(), + compareTo->end(), std::inserter(diff, diff.begin())); +} diff --git a/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h b/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h index 6f65cbbdf2..caca7774bc 100644 --- a/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h +++ b/radio/1.5/vts/functional/radio_hidl_hal_utils_v1_5.h @@ -86,6 +86,10 @@ class RadioResponse_v1_5 : public ::android::hardware::radio::V1_5::IRadioRespon // Whether Uicc applications are enabled or not. bool areUiccApplicationsEnabled; + // Barring Info Response + ::android::hardware::radio::V1_5::CellIdentity barringCellIdentity; + ::android::hardware::hidl_vec<::android::hardware::radio::V1_5::BarringInfo> barringInfos; + RadioResponse_v1_5(RadioHidlTest_v1_5& parent_v1_5); virtual ~RadioResponse_v1_5() = default; diff --git a/radio/1.5/vts/functional/radio_response.cpp b/radio/1.5/vts/functional/radio_response.cpp index 17b294bbcd..7ad51caf04 100644 --- a/radio/1.5/vts/functional/radio_response.cpp +++ b/radio/1.5/vts/functional/radio_response.cpp @@ -963,9 +963,11 @@ Return RadioResponse_v1_5::setIndicationFilterResponse_1_5(const RadioResp Return RadioResponse_v1_5::getBarringInfoResponse( const RadioResponseInfo& info, - const ::android::hardware::radio::V1_5::CellIdentity& /*cellIdentity*/, + const ::android::hardware::radio::V1_5::CellIdentity& cellIdentity, const ::android::hardware::hidl_vec<::android::hardware::radio::V1_5::BarringInfo>& - /*barringInfos*/) { + barringInfos) { + this->barringCellIdentity = cellIdentity; + this->barringInfos = barringInfos; rspInfo = info; parent_v1_5.notify(info.serial); return Void();