diff --git a/radio/aidl/vts/radio_config_response.cpp b/radio/aidl/vts/radio_config_response.cpp index 1a152fb712..8d8160519a 100644 --- a/radio/aidl/vts/radio_config_response.cpp +++ b/radio/aidl/vts/radio_config_response.cpp @@ -19,12 +19,15 @@ RadioConfigResponse::RadioConfigResponse(RadioServiceTest& parent) : parent_config(parent) {} ndk::ScopedAStatus RadioConfigResponse::getSimSlotsStatusResponse( - const RadioResponseInfo& /* info */, const std::vector& /* slotStatus */) { + const RadioResponseInfo& info, const std::vector& /* slotStatus */) { + rspInfo = info; + parent_config.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioConfigResponse::setSimSlotsMappingResponse( - const RadioResponseInfo& /* info */) { +ndk::ScopedAStatus RadioConfigResponse::setSimSlotsMappingResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_config.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -37,22 +40,28 @@ ndk::ScopedAStatus RadioConfigResponse::getPhoneCapabilityResponse( } ndk::ScopedAStatus RadioConfigResponse::setPreferredDataModemResponse( - const RadioResponseInfo& /* info */) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_config.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioConfigResponse::getNumOfLiveModemsResponse( - const RadioResponseInfo& /* info */, const int8_t /* numOfLiveModems */) { + const RadioResponseInfo& info, const int8_t /* numOfLiveModems */) { + rspInfo = info; + parent_config.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioConfigResponse::setNumOfLiveModemsResponse( - const RadioResponseInfo& /* info */) { +ndk::ScopedAStatus RadioConfigResponse::setNumOfLiveModemsResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_config.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioConfigResponse::getHalDeviceCapabilitiesResponse( const RadioResponseInfo& info, bool modemReducedFeatures) { + rspInfo = info; modemReducedFeatureSet1 = modemReducedFeatures; parent_config.notify(info.serial); return ndk::ScopedAStatus::ok(); diff --git a/radio/aidl/vts/radio_config_test.cpp b/radio/aidl/vts/radio_config_test.cpp index 2d7fe01575..a271b8af52 100644 --- a/radio/aidl/vts/radio_config_test.cpp +++ b/radio/aidl/vts/radio_config_test.cpp @@ -54,3 +54,102 @@ TEST_P(RadioConfigTest, getHalDeviceCapabilities) { ALOGI("getHalDeviceCapabilities, rspInfo.error = %s\n", toString(radioRsp_config->rspInfo.error).c_str()); } + +/* + * Test IRadioConfig.getSimSlotsStatus() for the response returned. + */ +TEST_P(RadioConfigTest, getSimSlotsStatus) { + serial = GetRandomSerialNumber(); + ndk::ScopedAStatus res = radio_config->getSimSlotsStatus(serial); + ASSERT_OK(res); + ALOGI("getSimSlotsStatus, rspInfo.error = %s\n", + toString(radioRsp_config->rspInfo.error).c_str()); +} + +/* + * Test IRadioConfig.getPhoneCapability() for the response returned. + */ +TEST_P(RadioConfigTest, getPhoneCapability) { + serial = GetRandomSerialNumber(); + ndk::ScopedAStatus res = radio_config->getPhoneCapability(serial); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_config->rspInfo.type); + EXPECT_EQ(serial, radioRsp_config->rspInfo.serial); + ALOGI("getPhoneCapability, rspInfo.error = %s\n", + toString(radioRsp_config->rspInfo.error).c_str()); + + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_config->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR})); + + if (radioRsp_config->rspInfo.error == RadioError ::NONE) { + // maxActiveData should be greater than or equal to maxActiveInternetData. + EXPECT_GE(radioRsp_config->phoneCap.maxActiveData, + radioRsp_config->phoneCap.maxActiveInternetData); + // maxActiveData and maxActiveInternetData should be 0 or positive numbers. + EXPECT_GE(radioRsp_config->phoneCap.maxActiveInternetData, 0); + } +} + +/* + * Test IRadioConfig.setPreferredDataModem() for the response returned. + */ +TEST_P(RadioConfigTest, setPreferredDataModem) { + serial = GetRandomSerialNumber(); + ndk::ScopedAStatus res = radio_config->getPhoneCapability(serial); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_config->rspInfo.type); + EXPECT_EQ(serial, radioRsp_config->rspInfo.serial); + ALOGI("getPhoneCapability, rspInfo.error = %s\n", + toString(radioRsp_config->rspInfo.error).c_str()); + + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_config->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR})); + + if (radioRsp_config->rspInfo.error != RadioError ::NONE) { + return; + } + + if (radioRsp_config->phoneCap.logicalModemIds.size() == 0) { + return; + } + + // We get phoneCapability. Send setPreferredDataModem command + serial = GetRandomSerialNumber(); + uint8_t modemId = radioRsp_config->phoneCap.logicalModemIds[0]; + res = radio_config->setPreferredDataModem(serial, modemId); + + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_config->rspInfo.type); + EXPECT_EQ(serial, radioRsp_config->rspInfo.serial); + ALOGI("setPreferredDataModem, rspInfo.error = %s\n", + toString(radioRsp_config->rspInfo.error).c_str()); + + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_config->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR})); +} + +/* + * Test IRadioConfig.setPreferredDataModem() with invalid arguments. + */ +TEST_P(RadioConfigTest, setPreferredDataModem_invalidArgument) { + serial = GetRandomSerialNumber(); + uint8_t modemId = -1; + ndk::ScopedAStatus res = radio_config->setPreferredDataModem(serial, modemId); + + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_config->rspInfo.type); + EXPECT_EQ(serial, radioRsp_config->rspInfo.serial); + ALOGI("setPreferredDataModem, rspInfo.error = %s\n", + toString(radioRsp_config->rspInfo.error).c_str()); + + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_config->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::RADIO_NOT_AVAILABLE, + RadioError::INTERNAL_ERR})); +} diff --git a/radio/aidl/vts/radio_data_response.cpp b/radio/aidl/vts/radio_data_response.cpp index 9b17bfb380..8d51760295 100644 --- a/radio/aidl/vts/radio_data_response.cpp +++ b/radio/aidl/vts/radio_data_response.cpp @@ -36,8 +36,9 @@ ndk::ScopedAStatus RadioDataResponse::cancelHandoverResponse(const RadioResponse return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioDataResponse::deactivateDataCallResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioDataResponse::deactivateDataCallResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_data.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -61,11 +62,15 @@ ndk::ScopedAStatus RadioDataResponse::releasePduSessionIdResponse(const RadioRes return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioDataResponse::setDataAllowedResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioDataResponse::setDataAllowedResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_data.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioDataResponse::setDataProfileResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioDataResponse::setDataProfileResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_data.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -75,8 +80,9 @@ ndk::ScopedAStatus RadioDataResponse::setDataThrottlingResponse(const RadioRespo return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioDataResponse::setInitialAttachApnResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioDataResponse::setInitialAttachApnResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_data.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -94,11 +100,15 @@ ndk::ScopedAStatus RadioDataResponse::startHandoverResponse(const RadioResponseI return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioDataResponse::startKeepaliveResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioDataResponse::startKeepaliveResponse(const RadioResponseInfo& info, const KeepaliveStatus& /*status*/) { + rspInfo = info; + parent_data.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioDataResponse::stopKeepaliveResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioDataResponse::stopKeepaliveResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_data.notify(info.serial); return ndk::ScopedAStatus::ok(); } diff --git a/radio/aidl/vts/radio_data_test.cpp b/radio/aidl/vts/radio_data_test.cpp index 8547e9d4db..616e3391a3 100644 --- a/radio/aidl/vts/radio_data_test.cpp +++ b/radio/aidl/vts/radio_data_test.cpp @@ -309,3 +309,280 @@ TEST_P(RadioDataTest, setDataThrottling) { sleep(1); } + +/* + * Test IRadioData.setInitialAttachApn() for the response returned. + */ +TEST_P(RadioDataTest, setInitialAttachApn) { + serial = GetRandomSerialNumber(); + + // Create a dataProfileInfo + DataProfileInfo dataProfileInfo; + memset(&dataProfileInfo, 0, sizeof(dataProfileInfo)); + dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT; + dataProfileInfo.apn = std::string("internet"); + dataProfileInfo.protocol = PdpProtocolType::IPV4V6; + dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6; + dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP; + dataProfileInfo.user = std::string("username"); + dataProfileInfo.password = std::string("password"); + dataProfileInfo.type = DataProfileInfo::TYPE_THREE_GPP; + dataProfileInfo.maxConnsTime = 300; + dataProfileInfo.maxConns = 20; + dataProfileInfo.waitTime = 0; + dataProfileInfo.enabled = true; + dataProfileInfo.supportedApnTypesBitmap = 320; + dataProfileInfo.bearerBitmap = 161543; + dataProfileInfo.mtuV4 = 0; + dataProfileInfo.mtuV6 = 0; + dataProfileInfo.preferred = true; + dataProfileInfo.persistent = false; + + radio_data->setInitialAttachApn(serial, dataProfileInfo); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); + EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, + {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE})); + } +} + +/* + * Test IRadioData.setDataProfile() for the response returned. + */ +TEST_P(RadioDataTest, setDataProfile) { + serial = GetRandomSerialNumber(); + + // Create a dataProfileInfo + DataProfileInfo dataProfileInfo; + memset(&dataProfileInfo, 0, sizeof(dataProfileInfo)); + dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT; + dataProfileInfo.apn = std::string("internet"); + dataProfileInfo.protocol = PdpProtocolType::IPV4V6; + dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6; + dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP; + dataProfileInfo.user = std::string("username"); + dataProfileInfo.password = std::string("password"); + dataProfileInfo.type = DataProfileInfo::TYPE_THREE_GPP; + dataProfileInfo.maxConnsTime = 300; + dataProfileInfo.maxConns = 20; + dataProfileInfo.waitTime = 0; + dataProfileInfo.enabled = true; + dataProfileInfo.supportedApnTypesBitmap = 320; + dataProfileInfo.bearerBitmap = 161543; + dataProfileInfo.mtuV4 = 0; + dataProfileInfo.mtuV6 = 0; + dataProfileInfo.preferred = true; + dataProfileInfo.persistent = true; + + // Create a dataProfileInfoList + std::vector dataProfileInfoList = {dataProfileInfo}; + + radio_data->setDataProfile(serial, dataProfileInfoList); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); + EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, + {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE})); + } +} + +/* + * Test IRadioData.deactivateDataCall() for the response returned. + */ +TEST_P(RadioDataTest, deactivateDataCall) { + serial = GetRandomSerialNumber(); + int cid = 1; + DataRequestReason reason = DataRequestReason::NORMAL; + + ndk::ScopedAStatus res = radio_data->deactivateDataCall(serial, cid, reason); + ASSERT_OK(res); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); + EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_data->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, + RadioError::INVALID_CALL_ID, RadioError::INVALID_STATE, + RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED, + RadioError::CANCELLED, RadioError::SIM_ABSENT})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_data->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_CALL_ID, + RadioError::INVALID_STATE, RadioError::INVALID_ARGUMENTS, + RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED})); + } +} + +/* + * Test IRadioData.startKeepalive() for the response returned. + */ +TEST_P(RadioDataTest, startKeepalive) { + std::vector requests = { + { + // Invalid IPv4 source address + KeepaliveRequest::TYPE_NATT_IPV4, + {192, 168, 0 /*, 100*/}, + 1234, + {8, 8, 4, 4}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid IPv4 destination address + KeepaliveRequest::TYPE_NATT_IPV4, + {192, 168, 0, 100}, + 1234, + {8, 8, 4, 4, 1, 2, 3, 4}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid Keepalive Type + -1, + {192, 168, 0, 100}, + 1234, + {8, 8, 4, 4}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid IPv6 source address + KeepaliveRequest::TYPE_NATT_IPV6, + {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, + 0xED, 0xBE, 0xEF, 0xBD}, + 1234, + {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x88, 0x44}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid IPv6 destination address + KeepaliveRequest::TYPE_NATT_IPV6, + {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, + 0xED, 0xBE, 0xEF}, + 1234, + {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x88, + /*0x44*/}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid Context ID (cid), this should survive the initial + // range checking and fail in the modem data layer + KeepaliveRequest::TYPE_NATT_IPV4, + {192, 168, 0, 100}, + 1234, + {8, 8, 4, 4}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid Context ID (cid), this should survive the initial + // range checking and fail in the modem data layer + KeepaliveRequest::TYPE_NATT_IPV6, + {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, + 0xED, 0xBE, 0xEF}, + 1234, + {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x88, 0x44}, + 4500, + 20000, + 0xBAD, + }}; + + for (auto req = requests.begin(); req != requests.end(); req++) { + serial = GetRandomSerialNumber(); + radio_data->startKeepalive(serial, *req); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); + EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); + + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_data->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_ARGUMENTS, + RadioError::REQUEST_NOT_SUPPORTED})); + } +} + +/* + * Test IRadioData.stopKeepalive() for the response returned. + */ +TEST_P(RadioDataTest, stopKeepalive) { + serial = GetRandomSerialNumber(); + + radio_data->stopKeepalive(serial, 0xBAD); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); + EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); + + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_data->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, + RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); +} + +/* + * Test IRadioData.getDataCallList() for the response returned. + */ +TEST_P(RadioDataTest, getDataCallList) { + LOG(DEBUG) << "getDataCallList"; + serial = GetRandomSerialNumber(); + + radio_data->getDataCallList(serial); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); + EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_data->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::SIM_ABSENT})); + } + LOG(DEBUG) << "getDataCallList finished"; +} + +/* + * Test IRadioData.setDataAllowed() for the response returned. + */ +TEST_P(RadioDataTest, setDataAllowed) { + LOG(DEBUG) << "setDataAllowed"; + serial = GetRandomSerialNumber(); + bool allow = true; + + radio_data->setDataAllowed(serial, allow); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); + EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_data->rspInfo.error); + } + LOG(DEBUG) << "setDataAllowed finished"; +} diff --git a/radio/aidl/vts/radio_messaging_response.cpp b/radio/aidl/vts/radio_messaging_response.cpp index 718df7e60b..451a10c8cf 100644 --- a/radio/aidl/vts/radio_messaging_response.cpp +++ b/radio/aidl/vts/radio_messaging_response.cpp @@ -20,17 +20,23 @@ RadioMessagingResponse::RadioMessagingResponse(RadioServiceTest& parent) : parent_messaging(parent) {} ndk::ScopedAStatus RadioMessagingResponse::acknowledgeIncomingGsmSmsWithPduResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioMessagingResponse::acknowledgeLastIncomingCdmaSmsResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioMessagingResponse::acknowledgeLastIncomingGsmSmsResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -39,39 +45,49 @@ ndk::ScopedAStatus RadioMessagingResponse::acknowledgeRequest(int32_t /*serial*/ } ndk::ScopedAStatus RadioMessagingResponse::cancelPendingUssdResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioMessagingResponse::deleteSmsOnRuimResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioMessagingResponse::deleteSmsOnRuimResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioMessagingResponse::deleteSmsOnSimResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioMessagingResponse::deleteSmsOnSimResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioMessagingResponse::getCdmaBroadcastConfigResponse( - const RadioResponseInfo& /*info*/, - const std::vector& /*configs*/) { + const RadioResponseInfo& info, const std::vector& /*configs*/) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioMessagingResponse::getGsmBroadcastConfigResponse( - const RadioResponseInfo& /*info*/, - const std::vector& /*configs*/) { + const RadioResponseInfo& info, const std::vector& /*configs*/) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioMessagingResponse::getSmscAddressResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioMessagingResponse::getSmscAddressResponse(const RadioResponseInfo& info, const std::string& /*smsc*/) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioMessagingResponse::reportSmsMemoryStatusResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -91,8 +107,10 @@ ndk::ScopedAStatus RadioMessagingResponse::sendCdmaSmsResponse(const RadioRespon return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioMessagingResponse::sendImsSmsResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioMessagingResponse::sendImsSmsResponse(const RadioResponseInfo& info, const SendSmsResult& /*sms*/) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -112,41 +130,56 @@ ndk::ScopedAStatus RadioMessagingResponse::sendSmsResponse(const RadioResponseIn return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioMessagingResponse::sendUssdResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioMessagingResponse::sendUssdResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioMessagingResponse::setCdmaBroadcastActivationResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioMessagingResponse::setCdmaBroadcastConfigResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioMessagingResponse::setGsmBroadcastActivationResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioMessagingResponse::setGsmBroadcastConfigResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioMessagingResponse::setSmscAddressResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioMessagingResponse::setSmscAddressResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioMessagingResponse::writeSmsToRuimResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioMessagingResponse::writeSmsToRuimResponse(const RadioResponseInfo& info, int32_t /*index*/) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioMessagingResponse::writeSmsToSimResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioMessagingResponse::writeSmsToSimResponse(const RadioResponseInfo& info, int32_t /*index*/) { + rspInfo = info; + parent_messaging.notify(info.serial); return ndk::ScopedAStatus::ok(); } diff --git a/radio/aidl/vts/radio_messaging_test.cpp b/radio/aidl/vts/radio_messaging_test.cpp index 8abd91d709..0abdfbc435 100644 --- a/radio/aidl/vts/radio_messaging_test.cpp +++ b/radio/aidl/vts/radio_messaging_test.cpp @@ -197,3 +197,574 @@ TEST_P(RadioMessagingTest, sendCdmaSmsExpectMore) { CHECK_GENERAL_ERROR)); } } + +/* + * Test IRadioMessaging.setGsmBroadcastConfig() for the response returned. + */ +TEST_P(RadioMessagingTest, setGsmBroadcastConfig) { + LOG(DEBUG) << "setGsmBroadcastConfig"; + serial = GetRandomSerialNumber(); + + // Create GsmBroadcastSmsConfigInfo #1 + GsmBroadcastSmsConfigInfo gbSmsConfig1; + gbSmsConfig1.fromServiceId = 4352; + gbSmsConfig1.toServiceId = 4354; + gbSmsConfig1.fromCodeScheme = 0; + gbSmsConfig1.toCodeScheme = 255; + gbSmsConfig1.selected = true; + + // Create GsmBroadcastSmsConfigInfo #2 + GsmBroadcastSmsConfigInfo gbSmsConfig2; + gbSmsConfig2.fromServiceId = 4356; + gbSmsConfig2.toServiceId = 4356; + gbSmsConfig2.fromCodeScheme = 0; + gbSmsConfig2.toCodeScheme = 255; + gbSmsConfig2.selected = true; + + // Create GsmBroadcastSmsConfigInfo #3 + GsmBroadcastSmsConfigInfo gbSmsConfig3; + gbSmsConfig3.fromServiceId = 4370; + gbSmsConfig3.toServiceId = 4379; + gbSmsConfig3.fromCodeScheme = 0; + gbSmsConfig3.toCodeScheme = 255; + gbSmsConfig3.selected = true; + + // Create GsmBroadcastSmsConfigInfo #4 + GsmBroadcastSmsConfigInfo gbSmsConfig4; + gbSmsConfig4.fromServiceId = 4383; + gbSmsConfig4.toServiceId = 4391; + gbSmsConfig4.fromCodeScheme = 0; + gbSmsConfig4.toCodeScheme = 255; + gbSmsConfig4.selected = true; + + // Create GsmBroadcastSmsConfigInfo #5 + GsmBroadcastSmsConfigInfo gbSmsConfig5; + gbSmsConfig5.fromServiceId = 4392; + gbSmsConfig5.toServiceId = 4392; + gbSmsConfig5.fromCodeScheme = 0; + gbSmsConfig5.toCodeScheme = 255; + gbSmsConfig5.selected = true; + + std::vector gsmBroadcastSmsConfigsInfoList = { + gbSmsConfig1, gbSmsConfig2, gbSmsConfig3, gbSmsConfig4, gbSmsConfig5}; + + radio_messaging->setGsmBroadcastConfig(serial, gsmBroadcastSmsConfigsInfoList); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_messaging->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, + RadioError::INVALID_MODEM_STATE, RadioError::INVALID_STATE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setGsmBroadcastConfig finished"; +} + +/* + * Test IRadioMessaging.getGsmBroadcastConfig() for the response returned. + */ +TEST_P(RadioMessagingTest, getGsmBroadcastConfig) { + LOG(DEBUG) << "getGsmBroadcastConfig"; + serial = GetRandomSerialNumber(); + + radio_messaging->getGsmBroadcastConfig(serial); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_messaging->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_MODEM_STATE, RadioError::INVALID_STATE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "getGsmBroadcastConfig finished"; +} + +/* + * Test IRadioMessaging.setCdmaBroadcastConfig() for the response returned. + */ +TEST_P(RadioMessagingTest, setCdmaBroadcastConfig) { + LOG(DEBUG) << "setCdmaBroadcastConfig"; + serial = GetRandomSerialNumber(); + + CdmaBroadcastSmsConfigInfo cbSmsConfig; + cbSmsConfig.serviceCategory = 4096; + cbSmsConfig.language = 1; + cbSmsConfig.selected = true; + + std::vector cdmaBroadcastSmsConfigInfoList = {cbSmsConfig}; + + radio_messaging->setCdmaBroadcastConfig(serial, cdmaBroadcastSmsConfigInfoList); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_messaging->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_MODEM_STATE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setCdmaBroadcastConfig finished"; +} + +/* + * Test IRadioMessaging.getCdmaBroadcastConfig() for the response returned. + */ +TEST_P(RadioMessagingTest, getCdmaBroadcastConfig) { + LOG(DEBUG) << "getCdmaBroadcastConfig"; + serial = GetRandomSerialNumber(); + + radio_messaging->getCdmaBroadcastConfig(serial); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_messaging->rspInfo.error, {RadioError::NONE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "getCdmaBroadcastConfig finished"; +} + +/* + * Test IRadioMessaging.setCdmaBroadcastActivation() for the response returned. + */ +TEST_P(RadioMessagingTest, setCdmaBroadcastActivation) { + LOG(DEBUG) << "setCdmaBroadcastActivation"; + serial = GetRandomSerialNumber(); + bool activate = false; + + radio_messaging->setCdmaBroadcastActivation(serial, activate); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_messaging->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setCdmaBroadcastActivation finished"; +} + +/* + * Test IRadioMessaging.setGsmBroadcastActivation() for the response returned. + */ +TEST_P(RadioMessagingTest, setGsmBroadcastActivation) { + LOG(DEBUG) << "setGsmBroadcastActivation"; + serial = GetRandomSerialNumber(); + bool activate = false; + + radio_messaging->setGsmBroadcastActivation(serial, activate); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_messaging->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INVALID_MODEM_STATE, + RadioError::INVALID_STATE, RadioError::OPERATION_NOT_ALLOWED}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setGsmBroadcastActivation finished"; +} + +/* + * Test IRadioMessaging.acknowledgeLastIncomingGsmSms() for the response returned. + */ +TEST_P(RadioMessagingTest, acknowledgeLastIncomingGsmSms) { + LOG(DEBUG) << "acknowledgeLastIncomingGsmSms"; + serial = GetRandomSerialNumber(); + bool success = true; + + radio_messaging->acknowledgeLastIncomingGsmSms( + serial, success, SmsAcknowledgeFailCause::MEMORY_CAPACITY_EXCEEDED); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_messaging->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "acknowledgeLastIncomingGsmSms finished"; +} + +/* + * Test IRadioMessaging.acknowledgeIncomingGsmSmsWithPdu() for the response returned. + */ +TEST_P(RadioMessagingTest, acknowledgeIncomingGsmSmsWithPdu) { + LOG(DEBUG) << "acknowledgeIncomingGsmSmsWithPdu"; + serial = GetRandomSerialNumber(); + bool success = true; + std::string ackPdu = ""; + + radio_messaging->acknowledgeIncomingGsmSmsWithPdu(serial, success, ackPdu); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + // TODO(shuoq): Will add error check when we know the expected error from QC + } + LOG(DEBUG) << "acknowledgeIncomingGsmSmsWithPdu finished"; +} + +/* + * Test IRadioMessaging.acknowledgeLastIncomingCdmaSms() for the response returned. + */ +TEST_P(RadioMessagingTest, acknowledgeLastIncomingCdmaSms) { + LOG(DEBUG) << "acknowledgeLastIncomingCdmaSms"; + serial = GetRandomSerialNumber(); + + // Create a CdmaSmsAck + CdmaSmsAck cdmaSmsAck; + cdmaSmsAck.errorClass = false; + cdmaSmsAck.smsCauseCode = 1; + + radio_messaging->acknowledgeLastIncomingCdmaSms(serial, cdmaSmsAck); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_messaging->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::NO_SMS_TO_ACK}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "acknowledgeLastIncomingCdmaSms finished"; +} + +/* + * Test IRadioMessaging.sendImsSms() for the response returned. + */ +TEST_P(RadioMessagingTest, sendImsSms) { + LOG(DEBUG) << "sendImsSms"; + serial = GetRandomSerialNumber(); + + // Create a CdmaSmsAddress + CdmaSmsAddress cdmaSmsAddress; + cdmaSmsAddress.digitMode = CdmaSmsAddress::DIGIT_MODE_FOUR_BIT; + cdmaSmsAddress.isNumberModeDataNetwork = false; + cdmaSmsAddress.numberType = CdmaSmsAddress::NUMBER_TYPE_UNKNOWN; + cdmaSmsAddress.numberPlan = CdmaSmsAddress::NUMBER_PLAN_UNKNOWN; + cdmaSmsAddress.digits = (std::vector){11, 1, 6, 5, 10, 7, 7, 2, 10, 3, 10, 3}; + + // Create a CdmaSmsSubAddress + CdmaSmsSubaddress cdmaSmsSubaddress; + cdmaSmsSubaddress.subaddressType = CdmaSmsSubaddress::SUBADDRESS_TYPE_NSAP; + cdmaSmsSubaddress.odd = false; + cdmaSmsSubaddress.digits = (std::vector){}; + + // Create a CdmaSmsMessage + CdmaSmsMessage cdmaSmsMessage; + cdmaSmsMessage.teleserviceId = 4098; + cdmaSmsMessage.isServicePresent = false; + cdmaSmsMessage.serviceCategory = 0; + cdmaSmsMessage.address = cdmaSmsAddress; + cdmaSmsMessage.subAddress = cdmaSmsSubaddress; + cdmaSmsMessage.bearerData = + (std::vector){15, 0, 3, 32, 3, 16, 1, 8, 16, 53, 76, 68, 6, 51, 106, 0}; + + // Creata an ImsSmsMessage + ImsSmsMessage msg; + msg.tech = RadioTechnologyFamily::THREE_GPP2; + msg.retry = false; + msg.messageRef = 0; + msg.cdmaMessage = (std::vector){cdmaSmsMessage}; + msg.gsmMessage = (std::vector){}; + + radio_messaging->sendImsSms(serial, msg); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_messaging->rspInfo.error, + {RadioError::INVALID_ARGUMENTS}, CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "sendImsSms finished"; +} + +/* + * Test IRadioMessaging.getSmscAddress() for the response returned. + */ +TEST_P(RadioMessagingTest, getSmscAddress) { + LOG(DEBUG) << "getSmscAddress"; + serial = GetRandomSerialNumber(); + + radio_messaging->getSmscAddress(serial); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_messaging->rspInfo.error, + {RadioError::INVALID_MODEM_STATE, RadioError::INVALID_STATE, + RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "getSmscAddress finished"; +} + +/* + * Test IRadioMessaging.setSmscAddress() for the response returned. + */ +TEST_P(RadioMessagingTest, setSmscAddress) { + LOG(DEBUG) << "setSmscAddress"; + serial = GetRandomSerialNumber(); + std::string address = std::string("smscAddress"); + + radio_messaging->setSmscAddress(serial, address); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_messaging->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_SMS_FORMAT, + RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setSmscAddress finished"; +} + +/* + * Test IRadioMessaging.writeSmsToSim() for the response returned. + */ +TEST_P(RadioMessagingTest, writeSmsToSim) { + LOG(DEBUG) << "writeSmsToSim"; + serial = GetRandomSerialNumber(); + SmsWriteArgs smsWriteArgs; + smsWriteArgs.status = SmsWriteArgs::STATUS_REC_UNREAD; + smsWriteArgs.smsc = ""; + smsWriteArgs.pdu = "01000b916105770203f3000006d4f29c3e9b01"; + + radio_messaging->writeSmsToSim(serial, smsWriteArgs); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_messaging->rspInfo.error, + {RadioError::NONE, RadioError::ENCODING_ERR, RadioError::INVALID_ARGUMENTS, + RadioError::INVALID_SMSC_ADDRESS, RadioError::MODEM_ERR, + RadioError::NETWORK_NOT_READY, RadioError::NO_RESOURCES, RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "writeSmsToSim finished"; +} + +/* + * Test IRadioMessaging.deleteSmsOnSim() for the response returned. + */ +TEST_P(RadioMessagingTest, deleteSmsOnSim) { + LOG(DEBUG) << "deleteSmsOnSim"; + serial = GetRandomSerialNumber(); + int index = 1; + + radio_messaging->deleteSmsOnSim(serial, index); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_messaging->rspInfo.error, + {RadioError::NONE, RadioError::ENCODING_ERR, RadioError::INVALID_ARGUMENTS, + RadioError::INVALID_MODEM_STATE, RadioError::NO_SUCH_ENTRY, RadioError::MODEM_ERR, + RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "deleteSmsOnSim finished"; +} + +/* + * Test IRadioMessaging.writeSmsToRuim() for the response returned. + */ +TEST_P(RadioMessagingTest, writeSmsToRuim) { + LOG(DEBUG) << "writeSmsToRuim"; + serial = GetRandomSerialNumber(); + + // Create a CdmaSmsAddress + CdmaSmsAddress cdmaSmsAddress; + cdmaSmsAddress.digitMode = CdmaSmsAddress::DIGIT_MODE_FOUR_BIT; + cdmaSmsAddress.isNumberModeDataNetwork = false; + cdmaSmsAddress.numberType = CdmaSmsAddress::NUMBER_TYPE_UNKNOWN; + cdmaSmsAddress.numberPlan = CdmaSmsAddress::NUMBER_PLAN_UNKNOWN; + cdmaSmsAddress.digits = (std::vector){11, 1, 6, 5, 10, 7, 7, 2, 10, 3, 10, 3}; + + // Create a CdmaSmsSubAddress + CdmaSmsSubaddress cdmaSmsSubaddress; + cdmaSmsSubaddress.subaddressType = CdmaSmsSubaddress::SUBADDRESS_TYPE_NSAP; + cdmaSmsSubaddress.odd = false; + cdmaSmsSubaddress.digits = (std::vector){}; + + // Create a CdmaSmsMessage + CdmaSmsMessage cdmaSmsMessage; + cdmaSmsMessage.teleserviceId = 4098; + cdmaSmsMessage.isServicePresent = false; + cdmaSmsMessage.serviceCategory = 0; + cdmaSmsMessage.address = cdmaSmsAddress; + cdmaSmsMessage.subAddress = cdmaSmsSubaddress; + cdmaSmsMessage.bearerData = + (std::vector){15, 0, 3, 32, 3, 16, 1, 8, 16, 53, 76, 68, 6, 51, 106, 0}; + + // Create a CdmaSmsWriteArgs + CdmaSmsWriteArgs cdmaSmsWriteArgs; + cdmaSmsWriteArgs.status = CdmaSmsWriteArgs::STATUS_REC_UNREAD; + cdmaSmsWriteArgs.message = cdmaSmsMessage; + + radio_messaging->writeSmsToRuim(serial, cdmaSmsWriteArgs); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_messaging->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INVALID_SMS_FORMAT, + RadioError::INVALID_SMSC_ADDRESS, RadioError::INVALID_STATE, RadioError::MODEM_ERR, + RadioError::NO_SUCH_ENTRY, RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "writeSmsToRuim finished"; +} + +/* + * Test IRadioMessaging.deleteSmsOnRuim() for the response returned. + */ +TEST_P(RadioMessagingTest, deleteSmsOnRuim) { + LOG(DEBUG) << "deleteSmsOnRuim"; + serial = GetRandomSerialNumber(); + int index = 1; + + // Create a CdmaSmsAddress + CdmaSmsAddress cdmaSmsAddress; + cdmaSmsAddress.digitMode = CdmaSmsAddress::DIGIT_MODE_FOUR_BIT; + cdmaSmsAddress.isNumberModeDataNetwork = false; + cdmaSmsAddress.numberType = CdmaSmsAddress::NUMBER_TYPE_UNKNOWN; + cdmaSmsAddress.numberPlan = CdmaSmsAddress::NUMBER_PLAN_UNKNOWN; + cdmaSmsAddress.digits = (std::vector){11, 1, 6, 5, 10, 7, 7, 2, 10, 3, 10, 3}; + + // Create a CdmaSmsSubAddress + CdmaSmsSubaddress cdmaSmsSubaddress; + cdmaSmsSubaddress.subaddressType = CdmaSmsSubaddress::SUBADDRESS_TYPE_NSAP; + cdmaSmsSubaddress.odd = false; + cdmaSmsSubaddress.digits = (std::vector){}; + + // Create a CdmaSmsMessage + CdmaSmsMessage cdmaSmsMessage; + cdmaSmsMessage.teleserviceId = 4098; + cdmaSmsMessage.isServicePresent = false; + cdmaSmsMessage.serviceCategory = 0; + cdmaSmsMessage.address = cdmaSmsAddress; + cdmaSmsMessage.subAddress = cdmaSmsSubaddress; + cdmaSmsMessage.bearerData = + (std::vector){15, 0, 3, 32, 3, 16, 1, 8, 16, 53, 76, 68, 6, 51, 106, 0}; + + // Create a CdmaSmsWriteArgs + CdmaSmsWriteArgs cdmaSmsWriteArgs; + cdmaSmsWriteArgs.status = CdmaSmsWriteArgs::STATUS_REC_UNREAD; + cdmaSmsWriteArgs.message = cdmaSmsMessage; + + radio_messaging->deleteSmsOnRuim(serial, index); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_messaging->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INVALID_MODEM_STATE, + RadioError::MODEM_ERR, RadioError::NO_SUCH_ENTRY, RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "deleteSmsOnRuim finished"; +} + +/* + * Test IRadioMessaging.reportSmsMemoryStatus() for the response returned. + */ +TEST_P(RadioMessagingTest, reportSmsMemoryStatus) { + LOG(DEBUG) << "reportSmsMemoryStatus"; + serial = GetRandomSerialNumber(); + bool available = true; + + radio_messaging->reportSmsMemoryStatus(serial, available); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_messaging->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, + RadioError::MODEM_ERR, RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "reportSmsMemoryStatus finished"; +} + +/* + * Test IRadioMessaging.sendUssd() for the response returned. + */ +TEST_P(RadioMessagingTest, sendUssd) { + LOG(DEBUG) << "sendUssd"; + serial = GetRandomSerialNumber(); + radio_messaging->sendUssd(serial, std::string("test")); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_messaging->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "sendUssd finished"; +} + +/* + * Test IRadioMessaging.cancelPendingUssd() for the response returned. + */ +TEST_P(RadioMessagingTest, cancelPendingUssd) { + LOG(DEBUG) << "cancelPendingUssd"; + serial = GetRandomSerialNumber(); + + radio_messaging->cancelPendingUssd(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_messaging->rspInfo.type); + EXPECT_EQ(serial, radioRsp_messaging->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_messaging->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "cancelPendingUssd finished"; +} diff --git a/radio/aidl/vts/radio_modem_response.cpp b/radio/aidl/vts/radio_modem_response.cpp index 53bfab40a9..d2715a8198 100644 --- a/radio/aidl/vts/radio_modem_response.cpp +++ b/radio/aidl/vts/radio_modem_response.cpp @@ -22,70 +22,99 @@ ndk::ScopedAStatus RadioModemResponse::acknowledgeRequest(int32_t /*serial*/) { return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::enableModemResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioModemResponse::enableModemResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::getBasebandVersionResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioModemResponse::getBasebandVersionResponse(const RadioResponseInfo& info, const std::string& /*version*/) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::getDeviceIdentityResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioModemResponse::getDeviceIdentityResponse(const RadioResponseInfo& info, const std::string& /*imei*/, const std::string& /*imeisv*/, const std::string& /*esn*/, const std::string& /*meid*/) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioModemResponse::getHardwareConfigResponse( - const RadioResponseInfo& /*info*/, const std::vector& /*config*/) { + const RadioResponseInfo& info, const std::vector& /*config*/) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioModemResponse::getModemActivityInfoResponse( - const RadioResponseInfo& /*info*/, const ActivityStatsInfo& /*activityInfo*/) { + const RadioResponseInfo& info, const ActivityStatsInfo& /*activityInfo*/) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::getModemStackStatusResponse( - const RadioResponseInfo& /*info*/, const bool /*enabled*/) { +ndk::ScopedAStatus RadioModemResponse::getModemStackStatusResponse(const RadioResponseInfo& info, + const bool enabled) { + rspInfo = info; + isModemEnabled = enabled; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::getRadioCapabilityResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioModemResponse::getRadioCapabilityResponse(const RadioResponseInfo& info, const RadioCapability& /*rc*/) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::nvReadItemResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioModemResponse::nvReadItemResponse(const RadioResponseInfo& info, const std::string& /*result*/) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::nvResetConfigResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioModemResponse::nvResetConfigResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::nvWriteCdmaPrlResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioModemResponse::nvWriteCdmaPrlResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::nvWriteItemResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioModemResponse::nvWriteItemResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::requestShutdownResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioModemResponse::requestShutdownResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::sendDeviceStateResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioModemResponse::sendDeviceStateResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioModemResponse::setRadioCapabilityResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioModemResponse::setRadioCapabilityResponse(const RadioResponseInfo& info, const RadioCapability& /*rc*/) { + rspInfo = info; + parent_modem.notify(info.serial); return ndk::ScopedAStatus::ok(); } diff --git a/radio/aidl/vts/radio_modem_test.cpp b/radio/aidl/vts/radio_modem_test.cpp index b40bb7b573..f88da13af1 100644 --- a/radio/aidl/vts/radio_modem_test.cpp +++ b/radio/aidl/vts/radio_modem_test.cpp @@ -87,3 +87,301 @@ TEST_P(RadioModemTest, setRadioPower_emergencyCall_cancelled) { EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); EXPECT_EQ(RadioError::NONE, radioRsp_modem->rspInfo.error); } + +/* + * Test IRadioModem.enableModem() for the response returned. + */ +TEST_P(RadioModemTest, enableModem) { + serial = GetRandomSerialNumber(); + + if (isSsSsEnabled()) { + ALOGI("enableModem, no need to test in single SIM mode"); + return; + } + + bool responseToggle = radioRsp_modem->enableModemResponseToggle; + ndk::ScopedAStatus res = radio_modem->enableModem(serial, true); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + ALOGI("getModemStackStatus, rspInfo.error = %s\n", + toString(radioRsp_modem->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, + RadioError::MODEM_ERR, RadioError::INVALID_STATE})); + + // checking if getModemStackStatus returns true, as modem was enabled above + if (RadioError::NONE == radioRsp_modem->rspInfo.error) { + // wait until modem enabling is finished + while (responseToggle == radioRsp_modem->enableModemResponseToggle) { + sleep(1); + } + ndk::ScopedAStatus resEnabled = radio_modem->getModemStackStatus(serial); + ASSERT_OK(resEnabled); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + ALOGI("getModemStackStatus, rspInfo.error = %s\n", + toString(radioRsp_modem->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, + RadioError::MODEM_ERR, RadioError::INVALID_STATE})); + // verify that enableModem did set isEnabled correctly + EXPECT_EQ(true, radioRsp_modem->isModemEnabled); + } +} + +/* + * Test IRadioModem.getModemStackStatus() for the response returned. + */ +TEST_P(RadioModemTest, getModemStackStatus) { + serial = GetRandomSerialNumber(); + + ndk::ScopedAStatus res = radio_modem->getModemStackStatus(serial); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + ALOGI("getModemStackStatus, rspInfo.error = %s\n", + toString(radioRsp_modem->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_modem->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR})); +} + +/* + * Test IRadioModem.getBasebandVersion() for the response returned. + */ +TEST_P(RadioModemTest, getBasebandVersion) { + LOG(DEBUG) << "getBasebandVersion"; + serial = GetRandomSerialNumber(); + + radio_modem->getBasebandVersion(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_modem->rspInfo.error); + } + LOG(DEBUG) << "getBasebandVersion finished"; +} + +/* + * Test IRadioModem.getDeviceIdentity() for the response returned. + */ +TEST_P(RadioModemTest, getDeviceIdentity) { + LOG(DEBUG) << "getDeviceIdentity"; + serial = GetRandomSerialNumber(); + + radio_modem->getDeviceIdentity(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, + {RadioError::NONE, RadioError::EMPTY_RECORD})); + } + LOG(DEBUG) << "getDeviceIdentity finished"; +} + +/* + * Test IRadioModem.nvReadItem() for the response returned. + */ +TEST_P(RadioModemTest, nvReadItem) { + LOG(DEBUG) << "nvReadItem"; + serial = GetRandomSerialNumber(); + + radio_modem->nvReadItem(serial, NvItem::LTE_BAND_ENABLE_25); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, {RadioError::NONE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "nvReadItem finished"; +} + +/* + * Test IRadioModem.nvWriteItem() for the response returned. + */ +TEST_P(RadioModemTest, nvWriteItem) { + LOG(DEBUG) << "nvWriteItem"; + serial = GetRandomSerialNumber(); + NvWriteItem item; + memset(&item, 0, sizeof(item)); + item.value = std::string(); + + radio_modem->nvWriteItem(serial, item); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, {RadioError::NONE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "nvWriteItem finished"; +} + +/* + * Test IRadioModem.nvWriteCdmaPrl() for the response returned. + */ +TEST_P(RadioModemTest, nvWriteCdmaPrl) { + LOG(DEBUG) << "nvWriteCdmaPrl"; + serial = GetRandomSerialNumber(); + std::vector prl = {1, 2, 3, 4, 5}; + + radio_modem->nvWriteCdmaPrl(serial, std::vector(prl)); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, {RadioError::NONE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "nvWriteCdmaPrl finished"; +} + +/* + * Test IRadioModem.nvResetConfig() for the response returned. + */ +TEST_P(RadioModemTest, nvResetConfig) { + LOG(DEBUG) << "nvResetConfig"; + serial = GetRandomSerialNumber(); + + radio_modem->nvResetConfig(serial, ResetNvType::FACTORY_RESET); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); + } + LOG(DEBUG) << "nvResetConfig finished"; +} + +/* + * Test IRadioModem.getHardwareConfig() for the response returned. + */ +TEST_P(RadioModemTest, getHardwareConfig) { + LOG(DEBUG) << "getHardwareConfig"; + serial = GetRandomSerialNumber(); + + radio_modem->getHardwareConfig(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, {RadioError::NONE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "getHardwareConfig finished"; +} + +/* + * The following test is disabled due to b/64734869 + * + * Test IRadioModem.requestShutdown() for the response returned. + */ +TEST_P(RadioModemTest, DISABLED_requestShutdown) { + serial = GetRandomSerialNumber(); + + radio_modem->requestShutdown(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, {RadioError::NONE}, + CHECK_GENERAL_ERROR)); + } +} + +/* + * Test IRadioModem.getRadioCapability() for the response returned. + */ +TEST_P(RadioModemTest, getRadioCapability) { + LOG(DEBUG) << "getRadioCapability"; + serial = GetRandomSerialNumber(); + + radio_modem->getRadioCapability(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_modem->rspInfo.error); + } + LOG(DEBUG) << "getRadioCapability finished"; +} + +/* + * Test IRadioModem.setRadioCapability() for the response returned. + */ +TEST_P(RadioModemTest, setRadioCapability) { + LOG(DEBUG) << "setRadioCapability"; + serial = GetRandomSerialNumber(); + RadioCapability rc; + memset(&rc, 0, sizeof(rc)); + rc.logicalModemUuid = std::string(); + + radio_modem->setRadioCapability(serial, rc); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setRadioCapability finished"; +} + +/* + * Test IRadioModem.getModemActivityInfo() for the response returned. + */ +TEST_P(RadioModemTest, getModemActivityInfo) { + LOG(DEBUG) << "getModemActivityInfo"; + serial = GetRandomSerialNumber(); + + radio_modem->getModemActivityInfo(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); + } + LOG(DEBUG) << "getModemActivityInfo finished"; +} + +/* + * Test IRadioModem.sendDeviceState() for the response returned. + */ +TEST_P(RadioModemTest, sendDeviceState) { + LOG(DEBUG) << "sendDeviceState"; + serial = GetRandomSerialNumber(); + + radio_modem->sendDeviceState(serial, DeviceStateType::POWER_SAVE_MODE, true); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_modem->rspInfo.type); + EXPECT_EQ(serial, radioRsp_modem->rspInfo.serial); + + std::cout << static_cast(radioRsp_modem->rspInfo.error) << std::endl; + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); + } + LOG(DEBUG) << "sendDeviceState finished"; +} diff --git a/radio/aidl/vts/radio_network_response.cpp b/radio/aidl/vts/radio_network_response.cpp index ccae0f3458..666d617771 100644 --- a/radio/aidl/vts/radio_network_response.cpp +++ b/radio/aidl/vts/radio_network_response.cpp @@ -31,7 +31,10 @@ ndk::ScopedAStatus RadioNetworkResponse::getAllowedNetworkTypesBitmapResponse( } ndk::ScopedAStatus RadioNetworkResponse::getAvailableBandModesResponse( - const RadioResponseInfo& /*info*/, const std::vector& /*bandModes*/) { + const RadioResponseInfo& info, const std::vector& bandModes) { + rspInfo = info; + radioBandModes = bandModes; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -44,48 +47,64 @@ ndk::ScopedAStatus RadioNetworkResponse::getAvailableNetworksResponse( } ndk::ScopedAStatus RadioNetworkResponse::getBarringInfoResponse( - const RadioResponseInfo& /*info*/, const CellIdentity& /*cellIdentity*/, - const std::vector& /*barringInfos*/) { + const RadioResponseInfo& info, const CellIdentity& cellIdentity, + const std::vector& barringInfos) { + rspInfo = info; + barringCellIdentity = cellIdentity; + barringInfoList = barringInfos; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::getCdmaRoamingPreferenceResponse( - const RadioResponseInfo& /*info*/, CdmaRoamingType /*type*/) { - return ndk::ScopedAStatus::ok(); -} - -ndk::ScopedAStatus RadioNetworkResponse::getCellInfoListResponse( - const RadioResponseInfo& /*info*/, const std::vector& /*cellInfo*/) { - return ndk::ScopedAStatus::ok(); -} - -ndk::ScopedAStatus RadioNetworkResponse::getDataRegistrationStateResponse( - const RadioResponseInfo& info, const RegStateResult& /*regResponse*/) { + const RadioResponseInfo& info, CdmaRoamingType /*type*/) { rspInfo = info; parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } +ndk::ScopedAStatus RadioNetworkResponse::getCellInfoListResponse( + const RadioResponseInfo& info, const std::vector& /*cellInfo*/) { + rspInfo = info; + parent_network.notify(info.serial); + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus RadioNetworkResponse::getDataRegistrationStateResponse( + const RadioResponseInfo& info, const RegStateResult& regResponse) { + rspInfo = info; + dataRegResp = regResponse; + parent_network.notify(info.serial); + return ndk::ScopedAStatus::ok(); +} + ndk::ScopedAStatus RadioNetworkResponse::getImsRegistrationStateResponse( - const RadioResponseInfo& /*info*/, bool /*isRegistered*/, - RadioTechnologyFamily /*ratFamily*/) { + const RadioResponseInfo& info, bool /*isRegistered*/, RadioTechnologyFamily /*ratFamily*/) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::getNetworkSelectionModeResponse( - const RadioResponseInfo& /*info*/, bool /*manual*/) { + const RadioResponseInfo& info, bool /*manual*/) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioNetworkResponse::getOperatorResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioNetworkResponse::getOperatorResponse(const RadioResponseInfo& info, const std::string& /*longName*/, const std::string& /*shortName*/, const std::string& /*numeric*/) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::getSignalStrengthResponse( - const RadioResponseInfo& /*info*/, const SignalStrength& /*sig_strength*/) { + const RadioResponseInfo& info, const SignalStrength& /*sig_strength*/) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -105,14 +124,16 @@ ndk::ScopedAStatus RadioNetworkResponse::getUsageSettingResponse(const RadioResp } ndk::ScopedAStatus RadioNetworkResponse::getVoiceRadioTechnologyResponse( - const RadioResponseInfo& /*info*/, RadioTechnology /*rat*/) { + const RadioResponseInfo& info, RadioTechnology /*rat*/) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::getVoiceRegistrationStateResponse( const RadioResponseInfo& info, const RegStateResult& regResponse) { rspInfo = info; - voiceRegResp.regState = regResponse.regState; + voiceRegResp = regResponse; parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -132,47 +153,63 @@ ndk::ScopedAStatus RadioNetworkResponse::setAllowedNetworkTypesBitmapResponse( return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioNetworkResponse::setBandModeResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioNetworkResponse::setBandModeResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioNetworkResponse::setBarringPasswordResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioNetworkResponse::setBarringPasswordResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::setCdmaRoamingPreferenceResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::setCellInfoListRateResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::setIndicationFilterResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::setLinkCapacityReportingCriteriaResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioNetworkResponse::setLocationUpdatesResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioNetworkResponse::setLocationUpdatesResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::setNetworkSelectionModeAutomaticResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::setNetworkSelectionModeManualResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -184,17 +221,23 @@ ndk::ScopedAStatus RadioNetworkResponse::setNrDualConnectivityStateResponse( } ndk::ScopedAStatus RadioNetworkResponse::setSignalStrengthReportingCriteriaResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::setSuppServiceNotificationsResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::setSystemSelectionChannelsResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -204,17 +247,21 @@ ndk::ScopedAStatus RadioNetworkResponse::setUsageSettingResponse(const RadioResp return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioNetworkResponse::startNetworkScanResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioNetworkResponse::startNetworkScanResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioNetworkResponse::stopNetworkScanResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioNetworkResponse::stopNetworkScanResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioNetworkResponse::supplyNetworkDepersonalizationResponse( - const RadioResponseInfo& /*info*/, int32_t /*remainingRetries*/) { + const RadioResponseInfo& info, int32_t /*remainingRetries*/) { + rspInfo = info; + parent_network.notify(info.serial); return ndk::ScopedAStatus::ok(); } diff --git a/radio/aidl/vts/radio_network_test.cpp b/radio/aidl/vts/radio_network_test.cpp index 93c4c35686..1c2d50fd9b 100644 --- a/radio/aidl/vts/radio_network_test.cpp +++ b/radio/aidl/vts/radio_network_test.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -58,6 +59,12 @@ void RadioNetworkTest::SetUp() { ASSERT_NE(nullptr, radio_config.get()); } +void RadioNetworkTest::stopNetworkScan() { + serial = GetRandomSerialNumber(); + radio_network->stopNetworkScan(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); +} + /* * Test IRadioNetwork.setAllowedNetworkTypesBitmap for the response returned. */ @@ -263,3 +270,1485 @@ TEST_P(RadioNetworkTest, setUsageSetting) { // Check that indeed the original setting was reset. ASSERT_TRUE(originalSetting == radioRsp_network->usageSetting); } + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() with invalid hysteresisDb + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_invalidHysteresisDb) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSI; + signalThresholdInfo.hysteresisMs = 5000; + signalThresholdInfo.hysteresisDb = 10; // hysteresisDb too large given threshold list deltas + signalThresholdInfo.thresholds = {-109, -103, -97, -89}; + signalThresholdInfo.isEnabled = true; + signalThresholdInfo.ran = AccessNetwork::GERAN; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setSignalStrengthReportingCriteria_invalidHysteresisDb, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::INVALID_ARGUMENTS})); +} + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() with empty thresholds + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_EmptyThresholds) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSI; + signalThresholdInfo.hysteresisMs = 0; + signalThresholdInfo.hysteresisDb = 0; + signalThresholdInfo.isEnabled = true; + signalThresholdInfo.ran = AccessNetwork::GERAN; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setSignalStrengthReportingCriteria_EmptyParams, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE})); +} + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() for GERAN + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Geran) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSI; + signalThresholdInfo.hysteresisMs = 5000; + signalThresholdInfo.hysteresisDb = 2; + signalThresholdInfo.thresholds = {-109, -103, -97, -89}; + signalThresholdInfo.isEnabled = true; + signalThresholdInfo.ran = AccessNetwork::GERAN; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setSignalStrengthReportingCriteria_Geran, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE})); +} + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() for UTRAN + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Utran) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSCP; + signalThresholdInfo.hysteresisMs = 5000; + signalThresholdInfo.hysteresisDb = 2; + signalThresholdInfo.thresholds = {-110, -97, -73, -49, -25}; + signalThresholdInfo.isEnabled = true; + signalThresholdInfo.ran = AccessNetwork::UTRAN; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setSignalStrengthReportingCriteria_Utran, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE})); +} + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() for EUTRAN + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Eutran_RSRP) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSRP; + signalThresholdInfo.hysteresisMs = 5000; + signalThresholdInfo.hysteresisDb = 2; + signalThresholdInfo.thresholds = {-128, -108, -88, -68}; + signalThresholdInfo.isEnabled = true; + signalThresholdInfo.ran = AccessNetwork::EUTRAN; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setSignalStrengthReportingCriteria_Eutran, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE})); +} + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() for EUTRAN + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Eutran_RSRQ) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSRQ; + signalThresholdInfo.hysteresisMs = 5000; + signalThresholdInfo.hysteresisDb = 2; + signalThresholdInfo.thresholds = {-27, -20, -13, -6}; + signalThresholdInfo.isEnabled = true; + signalThresholdInfo.ran = AccessNetwork::EUTRAN; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setSignalStrengthReportingCriteria_Eutran, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE})); +} + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() for EUTRAN + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Eutran_RSSNR) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSNR; + signalThresholdInfo.hysteresisMs = 5000; + signalThresholdInfo.hysteresisDb = 2; + signalThresholdInfo.thresholds = {-10, 0, 10, 20}; + signalThresholdInfo.isEnabled = true; + signalThresholdInfo.ran = AccessNetwork::EUTRAN; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); +} + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() for CDMA2000 + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Cdma2000) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSI; + signalThresholdInfo.hysteresisMs = 5000; + signalThresholdInfo.hysteresisDb = 2; + signalThresholdInfo.thresholds = {-105, -90, -75, -65}; + signalThresholdInfo.isEnabled = true; + signalThresholdInfo.ran = AccessNetwork::CDMA2000; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setSignalStrengthReportingCriteria_Cdma2000, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE})); +} + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() for NGRAN_SSRSRP + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_NGRAN_SSRSRP) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_SSRSRP; + signalThresholdInfo.hysteresisMs = 5000; + signalThresholdInfo.hysteresisDb = 0; + signalThresholdInfo.thresholds = {-105, -90, -75, -65}; + signalThresholdInfo.isEnabled = true; + signalThresholdInfo.ran = AccessNetwork::NGRAN; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setSignalStrengthReportingCriteria_NGRAN_SSRSRP, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + + // Allow REQUEST_NOT_SUPPORTED because some non-5G device may not support NGRAN for + // setSignalStrengthReportingCriteria() + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); +} + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() for NGRAN_SSRSRQ + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_NGRAN_SSRSRQ) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_SSRSRQ; + signalThresholdInfo.hysteresisMs = 5000; + signalThresholdInfo.hysteresisDb = 0; + signalThresholdInfo.thresholds = {-43, -20, 0, 20}; + signalThresholdInfo.isEnabled = true; + signalThresholdInfo.ran = AccessNetwork::NGRAN; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setSignalStrengthReportingCriteria_NGRAN_SSRSRQ, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + + // Allow REQUEST_NOT_SUPPORTED because some non-5G device may not support NGRAN for + // setSignalStrengthReportingCriteria() + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); +} + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() for EUTRAN + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Disable_RSSNR) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSNR; + signalThresholdInfo.hysteresisMs = 5000; + signalThresholdInfo.hysteresisDb = 2; + signalThresholdInfo.thresholds = {-10, 0, 10, 20}; + signalThresholdInfo.isEnabled = false; + signalThresholdInfo.ran = AccessNetwork::EUTRAN; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); +} + +/* + * Test IRadioNetwork.setSignalStrengthReportingCriteria() for NGRAN_SSSINR + */ +TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_NGRAN_SSSINR) { + serial = GetRandomSerialNumber(); + + SignalThresholdInfo signalThresholdInfo; + signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_SSSINR; + signalThresholdInfo.hysteresisMs = 5000; + signalThresholdInfo.hysteresisDb = 0; + signalThresholdInfo.thresholds = {-10, 3, 16, 18}; + signalThresholdInfo.isEnabled = true; + signalThresholdInfo.ran = AccessNetwork::NGRAN; + + ndk::ScopedAStatus res = + radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setSignalStrengthReportingCriteria_NGRAN_SSSINR, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + + // Allow REQUEST_NOT_SUPPORTED because some non-5G device may not support NGRAN for + // setSignalStrengthReportingCriteria() + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); +} + +/* + * Test IRadioNetwork.setLinkCapacityReportingCriteria() invalid hysteresisDlKbps + */ +TEST_P(RadioNetworkTest, setLinkCapacityReportingCriteria_invalidHysteresisDlKbps) { + serial = GetRandomSerialNumber(); + + ndk::ScopedAStatus res = radio_network->setLinkCapacityReportingCriteria( + serial, 5000, + 5000, // hysteresisDlKbps too big for thresholds delta + 100, {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000}, AccessNetwork::GERAN); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setLinkCapacityReportingCriteria_invalidHysteresisDlKbps, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria() may not be supported + // for GERAN + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); +} + +/* + * Test IRadioNetwork.setLinkCapacityReportingCriteria() invalid hysteresisUlKbps + */ +TEST_P(RadioNetworkTest, setLinkCapacityReportingCriteria_invalidHysteresisUlKbps) { + serial = GetRandomSerialNumber(); + + ndk::ScopedAStatus res = radio_network->setLinkCapacityReportingCriteria( + serial, 5000, 500, 1000, // hysteresisUlKbps too big for thresholds delta + {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000}, AccessNetwork::GERAN); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setLinkCapacityReportingCriteria_invalidHysteresisUlKbps, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria() may not be supported + // for GERAN + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); +} + +/* + * Test IRadioNetwork.setLinkCapacityReportingCriteria() empty params + */ +TEST_P(RadioNetworkTest, setLinkCapacityReportingCriteria_emptyParams) { + serial = GetRandomSerialNumber(); + + ndk::ScopedAStatus res = radio_network->setLinkCapacityReportingCriteria( + serial, 0, 0, 0, {}, {}, AccessNetwork::GERAN); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setLinkCapacityReportingCriteria_emptyParams, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria() may not be supported + // for GERAN + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); +} + +/* + * Test IRadioNetwork.setLinkCapacityReportingCriteria() for GERAN + */ +TEST_P(RadioNetworkTest, setLinkCapacityReportingCriteria_Geran) { + serial = GetRandomSerialNumber(); + + ndk::ScopedAStatus res = radio_network->setLinkCapacityReportingCriteria( + serial, 5000, 500, 100, {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000}, + AccessNetwork::GERAN); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setLinkCapacityReportingCriteria_Geran, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria() may not be supported + // for GERAN + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); +} + +/* + * Test IRadioNetwork.setSystemSelectionChannels() for the response returned. + */ +TEST_P(RadioNetworkTest, setSystemSelectionChannels) { + serial = GetRandomSerialNumber(); + + RadioAccessSpecifierBands bandP900 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_P900}); + RadioAccessSpecifierBands band850 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_850}); + RadioAccessSpecifier specifierP900 = { + .accessNetwork = AccessNetwork::GERAN, .bands = bandP900, .channels = {1, 2}}; + RadioAccessSpecifier specifier850 = { + .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; + + ndk::ScopedAStatus res = + radio_network->setSystemSelectionChannels(serial, true, {specifierP900, specifier850}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("setSystemSelectionChannels, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR})); + + if (radioRsp_network->rspInfo.error == RadioError::NONE) { + serial = GetRandomSerialNumber(); + ndk::ScopedAStatus res = radio_network->setSystemSelectionChannels( + serial, false, {specifierP900, specifier850}); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("setSystemSelectionChannels, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + EXPECT_EQ(RadioError::NONE, radioRsp_network->rspInfo.error); + } +} + +/* + * Test IRadioNetwork.startNetworkScan() for the response returned. + */ +TEST_P(RadioNetworkTest, startNetworkScan) { + serial = GetRandomSerialNumber(); + + RadioAccessSpecifierBands bandP900 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_P900}); + RadioAccessSpecifierBands band850 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_850}); + RadioAccessSpecifier specifierP900 = { + .accessNetwork = AccessNetwork::GERAN, .bands = bandP900, .channels = {1, 2}}; + RadioAccessSpecifier specifier850 = { + .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; + + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, + .interval = 60, + .specifiers = {specifierP900, specifier850}, + .maxSearchTime = 60, + .incrementalResults = false, + .incrementalResultsPeriodicity = 1}; + + ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("startNetworkScan, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::SIM_ABSENT})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + // OPERATION_NOT_ALLOWED should not be allowed; however, some vendors do + // not support the required manual GSM search functionality. This is + // tracked in b/112206766. Modems have "GSM" rat scan need to + // support scanning requests combined with some parameters. + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::OPERATION_NOT_ALLOWED})); + } + + if (radioRsp_network->rspInfo.error == RadioError::NONE) { + ALOGI("Stop Network Scan"); + stopNetworkScan(); + } +} + +/* + * Test IRadioNetwork.startNetworkScan() with invalid specifier. + */ +TEST_P(RadioNetworkTest, startNetworkScan_InvalidArgument) { + serial = GetRandomSerialNumber(); + + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, .interval = 60}; + + ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("startNetworkScan_InvalidArgument, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); + } +} + +/* + * Test IRadioNetwork.startNetworkScan() with invalid interval (lower boundary). + */ +TEST_P(RadioNetworkTest, startNetworkScan_InvalidInterval1) { + serial = GetRandomSerialNumber(); + + RadioAccessSpecifierBands bandP900 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_P900}); + RadioAccessSpecifierBands band850 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_850}); + RadioAccessSpecifier specifierP900 = { + .accessNetwork = AccessNetwork::GERAN, .bands = bandP900, .channels = {1, 2}}; + RadioAccessSpecifier specifier850 = { + .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; + + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, + .interval = 4, + .specifiers = {specifierP900, specifier850}, + .maxSearchTime = 60, + .incrementalResults = false, + .incrementalResultsPeriodicity = 1}; + + ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("startNetworkScan_InvalidInterval1, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); + } +} + +/* + * Test IRadioNetwork.startNetworkScan() with invalid interval (upper boundary). + */ +TEST_P(RadioNetworkTest, startNetworkScan_InvalidInterval2) { + serial = GetRandomSerialNumber(); + + RadioAccessSpecifierBands bandP900 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_P900}); + RadioAccessSpecifierBands band850 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_850}); + RadioAccessSpecifier specifierP900 = { + .accessNetwork = AccessNetwork::GERAN, .bands = bandP900, .channels = {1, 2}}; + RadioAccessSpecifier specifier850 = { + .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; + + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, + .interval = 301, + .specifiers = {specifierP900, specifier850}, + .maxSearchTime = 60, + .incrementalResults = false, + .incrementalResultsPeriodicity = 1}; + + ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("startNetworkScan_InvalidInterval2, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); + } +} + +/* + * Test IRadioNetwork.startNetworkScan() with invalid max search time (lower boundary). + */ +TEST_P(RadioNetworkTest, startNetworkScan_InvalidMaxSearchTime1) { + serial = GetRandomSerialNumber(); + + RadioAccessSpecifierBands bandP900 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_P900}); + RadioAccessSpecifierBands band850 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_850}); + RadioAccessSpecifier specifierP900 = { + .accessNetwork = AccessNetwork::GERAN, .bands = bandP900, .channels = {1, 2}}; + RadioAccessSpecifier specifier850 = { + .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; + + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, + .interval = 60, + .specifiers = {specifierP900, specifier850}, + .maxSearchTime = 59, + .incrementalResults = false, + .incrementalResultsPeriodicity = 1}; + + ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("startNetworkScan_InvalidMaxSearchTime1, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); + } +} + +/* + * Test IRadioNetwork.startNetworkScan() with invalid max search time (upper boundary). + */ +TEST_P(RadioNetworkTest, startNetworkScan_InvalidMaxSearchTime2) { + serial = GetRandomSerialNumber(); + + RadioAccessSpecifierBands bandP900 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_P900}); + RadioAccessSpecifierBands band850 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_850}); + RadioAccessSpecifier specifierP900 = { + .accessNetwork = AccessNetwork::GERAN, .bands = bandP900, .channels = {1, 2}}; + RadioAccessSpecifier specifier850 = { + .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; + + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, + .interval = 60, + .specifiers = {specifierP900, specifier850}, + .maxSearchTime = 3601, + .incrementalResults = false, + .incrementalResultsPeriodicity = 1}; + + ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("startNetworkScan_InvalidMaxSearchTime2, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); + } +} + +/* + * Test IRadioNetwork.startNetworkScan() with invalid periodicity (lower boundary). + */ +TEST_P(RadioNetworkTest, startNetworkScan_InvalidPeriodicity1) { + serial = GetRandomSerialNumber(); + + RadioAccessSpecifierBands bandP900 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_P900}); + RadioAccessSpecifierBands band850 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_850}); + RadioAccessSpecifier specifierP900 = { + .accessNetwork = AccessNetwork::GERAN, .bands = bandP900, .channels = {1, 2}}; + RadioAccessSpecifier specifier850 = { + .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; + + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, + .interval = 60, + .specifiers = {specifierP900, specifier850}, + .maxSearchTime = 600, + .incrementalResults = true, + .incrementalResultsPeriodicity = 0}; + + ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("startNetworkScan_InvalidPeriodicity1, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); + } +} + +/* + * Test IRadioNetwork.startNetworkScan() with invalid periodicity (upper boundary). + */ +TEST_P(RadioNetworkTest, startNetworkScan_InvalidPeriodicity2) { + serial = GetRandomSerialNumber(); + + RadioAccessSpecifierBands bandP900 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_P900}); + RadioAccessSpecifierBands band850 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_850}); + RadioAccessSpecifier specifierP900 = { + .accessNetwork = AccessNetwork::GERAN, .bands = bandP900, .channels = {1, 2}}; + RadioAccessSpecifier specifier850 = { + .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; + + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, + .interval = 60, + .specifiers = {specifierP900, specifier850}, + .maxSearchTime = 600, + .incrementalResults = true, + .incrementalResultsPeriodicity = 11}; + + ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("startNetworkScan_InvalidPeriodicity2, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); + } +} + +/* + * Test IRadioNetwork.startNetworkScan() with valid periodicity + */ +TEST_P(RadioNetworkTest, startNetworkScan_GoodRequest1) { + serial = GetRandomSerialNumber(); + + RadioAccessSpecifierBands bandP900 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_P900}); + RadioAccessSpecifierBands band850 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_850}); + RadioAccessSpecifier specifierP900 = { + .accessNetwork = AccessNetwork::GERAN, .bands = bandP900, .channels = {1, 2}}; + RadioAccessSpecifier specifier850 = { + .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; + + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, + .interval = 60, + .specifiers = {specifierP900, specifier850}, + .maxSearchTime = 360, + .incrementalResults = false, + .incrementalResultsPeriodicity = 10}; + + ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("startNetworkScan_GoodRequest1, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::SIM_ABSENT})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, + RadioError::REQUEST_NOT_SUPPORTED})); + } + + if (radioRsp_network->rspInfo.error == RadioError::NONE) { + ALOGI("Stop Network Scan"); + stopNetworkScan(); + } +} + +/* + * Test IRadioNetwork.startNetworkScan() with valid periodicity and plmns + */ +TEST_P(RadioNetworkTest, startNetworkScan_GoodRequest2) { + serial = GetRandomSerialNumber(); + + RadioAccessSpecifierBands bandP900 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_P900}); + RadioAccessSpecifierBands band850 = + RadioAccessSpecifierBands::make( + {GeranBands::BAND_850}); + RadioAccessSpecifier specifierP900 = { + .accessNetwork = AccessNetwork::GERAN, .bands = bandP900, .channels = {1, 2}}; + RadioAccessSpecifier specifier850 = { + .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; + + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, + .interval = 60, + .specifiers = {specifierP900, specifier850}, + .maxSearchTime = 360, + .incrementalResults = false, + .incrementalResultsPeriodicity = 10, + .mccMncs = {"310410"}}; + + ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("startNetworkScan_GoodRequest2, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::SIM_ABSENT})); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, + RadioError::REQUEST_NOT_SUPPORTED})); + } + + if (radioRsp_network->rspInfo.error == RadioError::NONE) { + ALOGI("Stop Network Scan"); + stopNetworkScan(); + } +} + +/* + * Test IRadioNetwork.setNetworkSelectionModeManual() for the response returned. + */ +TEST_P(RadioNetworkTest, setNetworkSelectionModeManual) { + serial = GetRandomSerialNumber(); + + // can't camp on nonexistent MCCMNC, so we expect this to fail. + ndk::ScopedAStatus res = + radio_network->setNetworkSelectionModeManual(serial, "123456", AccessNetwork::GERAN); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::ILLEGAL_SIM_OR_ME, + RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE}, + CHECK_GENERAL_ERROR)); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, + RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE}, + CHECK_GENERAL_ERROR)); + } +} + +/* + * Test IRadioNetwork.getBarringInfo() for the response returned. + */ +TEST_P(RadioNetworkTest, getBarringInfo) { + serial = GetRandomSerialNumber(); + ndk::ScopedAStatus res = radio_network->getBarringInfo(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ASSERT_TRUE(radioRsp_network->barringInfoList.size() > 0); + + std::set reportedServices; + + // validate that the service types are in range + for (const auto& info : radioRsp_network->barringInfoList) { + ASSERT_TRUE((info.serviceType >= BarringInfo::SERVICE_TYPE_CS_SERVICE && + info.serviceType <= BarringInfo::SERVICE_TYPE_SMS) || + (info.serviceType >= BarringInfo::SERVICE_TYPE_OPERATOR_1 && + info.serviceType <= BarringInfo::SERVICE_TYPE_OPERATOR_32)); + reportedServices.insert(info.serviceType); + + // Any type that is "conditional" must have valid values for conditional barring + // factor and time. + switch (info.barringType) { + case BarringInfo::BARRING_TYPE_NONE: // fall through + case BarringInfo::BARRING_TYPE_UNCONDITIONAL: + break; + case BarringInfo::BARRING_TYPE_CONDITIONAL: { + const int32_t barringFactor = info.barringTypeSpecificInfo->factor; + ASSERT_TRUE(barringFactor >= 0 && barringFactor <= 100); + ASSERT_TRUE(info.barringTypeSpecificInfo->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 check that implementations are + // not providing information that they don't have. + static const std::set UTRA_SERVICES{ + BarringInfo::SERVICE_TYPE_CS_SERVICE, BarringInfo::SERVICE_TYPE_PS_SERVICE, + BarringInfo::SERVICE_TYPE_CS_VOICE, BarringInfo::SERVICE_TYPE_EMERGENCY, + BarringInfo::SERVICE_TYPE_SMS, + }; + + static const std::set EUTRA_SERVICES{ + BarringInfo::SERVICE_TYPE_MO_SIGNALLING, BarringInfo::SERVICE_TYPE_MO_DATA, + BarringInfo::SERVICE_TYPE_CS_FALLBACK, BarringInfo::SERVICE_TYPE_MMTEL_VOICE, + BarringInfo::SERVICE_TYPE_MMTEL_VIDEO, BarringInfo::SERVICE_TYPE_EMERGENCY, + BarringInfo::SERVICE_TYPE_SMS, + }; + + static const std::set NGRA_SERVICES = { + BarringInfo::SERVICE_TYPE_MO_SIGNALLING, BarringInfo::SERVICE_TYPE_MO_DATA, + BarringInfo::SERVICE_TYPE_CS_FALLBACK, BarringInfo::SERVICE_TYPE_MMTEL_VOICE, + BarringInfo::SERVICE_TYPE_MMTEL_VIDEO, BarringInfo::SERVICE_TYPE_EMERGENCY, + BarringInfo::SERVICE_TYPE_SMS, BarringInfo::SERVICE_TYPE_OPERATOR_1, + BarringInfo::SERVICE_TYPE_OPERATOR_2, BarringInfo::SERVICE_TYPE_OPERATOR_3, + BarringInfo::SERVICE_TYPE_OPERATOR_4, BarringInfo::SERVICE_TYPE_OPERATOR_5, + BarringInfo::SERVICE_TYPE_OPERATOR_6, BarringInfo::SERVICE_TYPE_OPERATOR_7, + BarringInfo::SERVICE_TYPE_OPERATOR_8, BarringInfo::SERVICE_TYPE_OPERATOR_9, + BarringInfo::SERVICE_TYPE_OPERATOR_10, BarringInfo::SERVICE_TYPE_OPERATOR_11, + BarringInfo::SERVICE_TYPE_OPERATOR_12, BarringInfo::SERVICE_TYPE_OPERATOR_13, + BarringInfo::SERVICE_TYPE_OPERATOR_14, BarringInfo::SERVICE_TYPE_OPERATOR_15, + BarringInfo::SERVICE_TYPE_OPERATOR_16, BarringInfo::SERVICE_TYPE_OPERATOR_17, + BarringInfo::SERVICE_TYPE_OPERATOR_18, BarringInfo::SERVICE_TYPE_OPERATOR_19, + BarringInfo::SERVICE_TYPE_OPERATOR_20, BarringInfo::SERVICE_TYPE_OPERATOR_21, + BarringInfo::SERVICE_TYPE_OPERATOR_22, BarringInfo::SERVICE_TYPE_OPERATOR_23, + BarringInfo::SERVICE_TYPE_OPERATOR_24, BarringInfo::SERVICE_TYPE_OPERATOR_25, + BarringInfo::SERVICE_TYPE_OPERATOR_26, BarringInfo::SERVICE_TYPE_OPERATOR_27, + BarringInfo::SERVICE_TYPE_OPERATOR_28, BarringInfo::SERVICE_TYPE_OPERATOR_29, + BarringInfo::SERVICE_TYPE_OPERATOR_30, BarringInfo::SERVICE_TYPE_OPERATOR_31, + }; + + const std::set* compareTo = nullptr; + + switch (radioRsp_network->barringCellIdentity.getTag()) { + case CellIdentity::Tag::wcdma: + // fall through + case CellIdentity::Tag::tdscdma: + compareTo = &UTRA_SERVICES; + break; + case CellIdentity::Tag::lte: + compareTo = &EUTRA_SERVICES; + break; + case CellIdentity::Tag::nr: + compareTo = &NGRA_SERVICES; + break; + case CellIdentity::Tag::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())); +} + +/* + * Test IRadioNetwork.getSignalStrength() for the response returned. + */ +TEST_P(RadioNetworkTest, getSignalStrength) { + serial = GetRandomSerialNumber(); + + radio_network->getSignalStrength(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_network->rspInfo.error); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE})); + } +} + +/* + * Test IRadioNetwork.getCellInfoList() for the response returned. + */ +TEST_P(RadioNetworkTest, getCellInfoList) { + serial = GetRandomSerialNumber(); + + ndk::ScopedAStatus res = radio_network->getCellInfoList(serial); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("getCellInfoList, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::NO_NETWORK_FOUND})); +} + +/* + * Test IRadioNetwork.getVoiceRegistrationState() for the response returned. + */ +TEST_P(RadioNetworkTest, getVoiceRegistrationState) { + serial = GetRandomSerialNumber(); + + ndk::ScopedAStatus res = radio_network->getVoiceRegistrationState(serial); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("getVoiceRegistrationStateResponse, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE})); +} + +/* + * Test IRadioNetwork.getDataRegistrationState() for the response returned. + */ +TEST_P(RadioNetworkTest, getDataRegistrationState) { + serial = GetRandomSerialNumber(); + + ndk::ScopedAStatus res = radio_network->getDataRegistrationState(serial); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("getDataRegistrationStateResponse, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::NOT_PROVISIONED})); + + // Check the mcc [0, 999] and mnc [0, 999]. + std::string mcc; + std::string mnc; + bool checkMccMnc = true; + CellIdentity cellIdentity = radioRsp_network->dataRegResp.cellIdentity; + switch (cellIdentity.getTag()) { + case CellIdentity::noinit: { + checkMccMnc = false; + break; + } + case CellIdentity::gsm: { + CellIdentityGsm cig = cellIdentity.get(); + mcc = cig.mcc; + mnc = cig.mnc; + break; + } + case CellIdentity::wcdma: { + CellIdentityWcdma ciw = cellIdentity.get(); + mcc = ciw.mcc; + mnc = ciw.mnc; + break; + } + case CellIdentity::tdscdma: { + CellIdentityTdscdma cit = cellIdentity.get(); + mcc = cit.mcc; + mnc = cit.mnc; + break; + } + case CellIdentity::cdma: { + // CellIdentityCdma has no mcc/mnc + CellIdentityCdma cic = cellIdentity.get(); + checkMccMnc = false; + break; + } + case CellIdentity::lte: { + CellIdentityLte cil = cellIdentity.get(); + mcc = cil.mcc; + mnc = cil.mnc; + break; + } + case CellIdentity::nr: { + CellIdentityNr cin = cellIdentity.get(); + mcc = cin.mcc; + mnc = cin.mnc; + break; + } + } + + // 32 bit system might return invalid mcc and mnc string "\xff\xff..." + if (checkMccMnc && mcc.size() < 4 && mnc.size() < 4) { + int mcc_int = stoi(mcc); + int mnc_int = stoi(mnc); + EXPECT_TRUE(mcc_int >= 0 && mcc_int <= 999); + EXPECT_TRUE(mnc_int >= 0 && mnc_int <= 999); + } + + // Check for access technology specific info + AccessTechnologySpecificInfo info = radioRsp_network->dataRegResp.accessTechnologySpecificInfo; + RadioTechnology rat = radioRsp_network->dataRegResp.rat; + // TODO: add logic for cdmaInfo + if (rat == RadioTechnology::LTE || rat == RadioTechnology::LTE_CA) { + ASSERT_EQ(info.getTag(), AccessTechnologySpecificInfo::eutranInfo); + } else if (rat == RadioTechnology::NR) { + ASSERT_EQ(info.getTag(), AccessTechnologySpecificInfo::ngranNrVopsInfo); + } +} + +/* + * Test IRadioNetwork.getAvailableBandModes() for the response returned. + */ +TEST_P(RadioNetworkTest, getAvailableBandModes) { + serial = GetRandomSerialNumber(); + + ndk::ScopedAStatus res = radio_network->getAvailableBandModes(serial); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ALOGI("getAvailableBandModes, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, + RadioError::MODEM_ERR, RadioError::INTERNAL_ERR, + // If REQUEST_NOT_SUPPORTED is returned, then it should also be + // returned for setBandMode(). + RadioError::REQUEST_NOT_SUPPORTED})); + bool hasUnspecifiedBandMode = false; + if (radioRsp_network->rspInfo.error == RadioError::NONE) { + for (const RadioBandMode& mode : radioRsp_network->radioBandModes) { + // Automatic mode selection must be supported + if (mode == RadioBandMode::BAND_MODE_UNSPECIFIED) hasUnspecifiedBandMode = true; + } + ASSERT_TRUE(hasUnspecifiedBandMode); + } +} + +/* + * Test IRadioNetwork.setIndicationFilter() + */ +TEST_P(RadioNetworkTest, setIndicationFilter) { + serial = GetRandomSerialNumber(); + + ndk::ScopedAStatus res = + radio_network->setIndicationFilter(serial, static_cast(IndicationFilter::ALL)); + ASSERT_OK(res); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + ALOGI("setIndicationFilter, rspInfo.error = %s\n", + toString(radioRsp_network->rspInfo.error).c_str()); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE})); +} + +/* + * Test IRadioNetwork.setBarringPassword() for the response returned. + */ +TEST_P(RadioNetworkTest, setBarringPassword) { + serial = GetRandomSerialNumber(); + std::string facility = ""; + std::string oldPassword = ""; + std::string newPassword = ""; + + radio_network->setBarringPassword(serial, facility, oldPassword, newPassword); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::FDN_CHECK_FAILURE, + RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } +} + +/* + * Test IRadioNetwork.setSuppServiceNotifications() for the response returned. + */ +TEST_P(RadioNetworkTest, setSuppServiceNotifications) { + serial = GetRandomSerialNumber(); + bool enable = false; + + radio_network->setSuppServiceNotifications(serial, enable); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::SIM_ABSENT})); + } +} + +/* + * Test IRadioNetwork.getImsRegistrationState() for the response returned. + */ +TEST_P(RadioNetworkTest, getImsRegistrationState) { + serial = GetRandomSerialNumber(); + + radio_network->getImsRegistrationState(serial); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::MODEM_ERR, RadioError::INVALID_MODEM_STATE}, + CHECK_GENERAL_ERROR)); + } +} + +/* + * Test IRadioNetwork.getOperator() for the response returned. + */ +TEST_P(RadioNetworkTest, getOperator) { + LOG(DEBUG) << "getOperator"; + serial = GetRandomSerialNumber(); + + radio_network->getOperator(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_network->rspInfo.error); + } + LOG(DEBUG) << "getOperator finished"; +} +/* + * Test IRadioNetwork.getNetworkSelectionMode() for the response returned. + */ +TEST_P(RadioNetworkTest, getNetworkSelectionMode) { + LOG(DEBUG) << "getNetworkSelectionMode"; + serial = GetRandomSerialNumber(); + + radio_network->getNetworkSelectionMode(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_network->rspInfo.error); + } + LOG(DEBUG) << "getNetworkSelectionMode finished"; +} + +/* + * Test IRadioNetwork.setNetworkSelectionModeAutomatic() for the response returned. + */ +TEST_P(RadioNetworkTest, setNetworkSelectionModeAutomatic) { + LOG(DEBUG) << "setNetworkSelectionModeAutomatic"; + serial = GetRandomSerialNumber(); + + radio_network->setNetworkSelectionModeAutomatic(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::ILLEGAL_SIM_OR_ME, + RadioError::OPERATION_NOT_ALLOWED}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setNetworkSelectionModeAutomatic finished"; +} + +/* + * Test IRadioNetwork.getAvailableNetworks() for the response returned. + */ +TEST_P(RadioNetworkTest, getAvailableNetworks) { + LOG(DEBUG) << "getAvailableNetworks"; + serial = GetRandomSerialNumber(); + + radio_network->getAvailableNetworks(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + ASSERT_TRUE(radioRsp_network->rspInfo.type == RadioResponseType::SOLICITED || + radioRsp_network->rspInfo.type == RadioResponseType::SOLICITED_ACK_EXP); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::CANCELLED, RadioError::DEVICE_IN_USE, + RadioError::MODEM_ERR, RadioError::OPERATION_NOT_ALLOWED}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "getAvailableNetworks finished"; +} + +/* + * Test IRadioNetwork.setBandMode() for the response returned. + */ +TEST_P(RadioNetworkTest, setBandMode) { + LOG(DEBUG) << "setBandMode"; + serial = GetRandomSerialNumber(); + + radio_network->setBandMode(serial, RadioBandMode::BAND_MODE_USA); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setBandMode finished"; +} + +/* + * Test IRadioNetwork.getNeighboringCids() for the response returned. + */ +TEST_P(RadioNetworkTest, getNeighboringCids) { + // TODO: add API for getNeighboringCids + /** + LOG(DEBUG) << "getNeighboringCids"; + serial = GetRandomSerialNumber(); + + radio_network->getNeighboringCids(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "getNeighboringCids finished"; + **/ +} + +/* + * Test IRadioNetwork.setLocationUpdates() for the response returned. + */ +TEST_P(RadioNetworkTest, setLocationUpdates) { + LOG(DEBUG) << "setLocationUpdates"; + serial = GetRandomSerialNumber(); + + radio_network->setLocationUpdates(serial, true); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::SIM_ABSENT})); + } + LOG(DEBUG) << "setLocationUpdates finished"; +} + +/* + * Test IRadioNetwork.setCdmaRoamingPreference() for the response returned. + */ +TEST_P(RadioNetworkTest, setCdmaRoamingPreference) { + LOG(DEBUG) << "setCdmaRoamingPreference"; + serial = GetRandomSerialNumber(); + + radio_network->setCdmaRoamingPreference(serial, CdmaRoamingType::HOME_NETWORK); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::SIM_ABSENT, RadioError::REQUEST_NOT_SUPPORTED})); + } + LOG(DEBUG) << "setCdmaRoamingPreference finished"; +} + +/* + * Test IRadioNetwork.getCdmaRoamingPreference() for the response returned. + */ +TEST_P(RadioNetworkTest, getCdmaRoamingPreference) { + LOG(DEBUG) << "getCdmaRoamingPreference"; + serial = GetRandomSerialNumber(); + + radio_network->getCdmaRoamingPreference(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::SIM_ABSENT, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "getCdmaRoamingPreference finished"; +} + +/* + * Test IRadioNetwork.getVoiceRadioTechnology() for the response returned. + */ +TEST_P(RadioNetworkTest, getVoiceRadioTechnology) { + LOG(DEBUG) << "getVoiceRadioTechnology"; + serial = GetRandomSerialNumber(); + + radio_network->getVoiceRadioTechnology(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_network->rspInfo.error); + } + LOG(DEBUG) << "getVoiceRadioTechnology finished"; +} + +/* + * Test IRadioNetwork.setCellInfoListRate() for the response returned. + */ +TEST_P(RadioNetworkTest, setCellInfoListRate) { + LOG(DEBUG) << "setCellInfoListRate"; + serial = GetRandomSerialNumber(); + + // TODO(sanketpadawe): RIL crashes with value of rate = 10 + radio_network->setCellInfoListRate(serial, 10); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); + } + LOG(DEBUG) << "setCellInfoListRate finished"; +} + +/* + * Test IRadioNetwork.supplyNetworkDepersonalization() for the response returned. + */ +TEST_P(RadioNetworkTest, supplyNetworkDepersonalization) { + LOG(DEBUG) << "supplyNetworkDepersonalization"; + serial = GetRandomSerialNumber(); + + radio_network->supplyNetworkDepersonalization(serial, std::string("test")); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); + EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_network->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INTERNAL_ERR, + RadioError::INVALID_SIM_STATE, RadioError::MODEM_ERR, RadioError::NO_MEMORY, + RadioError::PASSWORD_INCORRECT, RadioError::SIM_ABSENT, RadioError::SYSTEM_ERR})); + } + LOG(DEBUG) << "supplyNetworkDepersonalization finished"; +} \ No newline at end of file diff --git a/radio/aidl/vts/radio_network_utils.h b/radio/aidl/vts/radio_network_utils.h index 9f7676969d..29ba2f282e 100644 --- a/radio/aidl/vts/radio_network_utils.h +++ b/radio/aidl/vts/radio_network_utils.h @@ -41,8 +41,9 @@ class RadioNetworkResponse : public BnRadioNetworkResponse { bool isNrDualConnectivityEnabled; int networkTypeBitmapResponse; RegStateResult voiceRegResp; + RegStateResult dataRegResp; CellIdentity barringCellIdentity; - std::vector barringInfos; + std::vector barringInfoList; UsageSetting usageSetting; virtual ndk::ScopedAStatus acknowledgeRequest(int32_t serial) override; @@ -218,4 +219,6 @@ class RadioNetworkTest : public ::testing::TestWithParam, public Ra // Helper function to reduce copy+paste void testSetUsageSetting_InvalidValues(std::vector errors); + + void stopNetworkScan(); }; diff --git a/radio/aidl/vts/radio_sim_response.cpp b/radio/aidl/vts/radio_sim_response.cpp index a783f43e0a..391c9cb12d 100644 --- a/radio/aidl/vts/radio_sim_response.cpp +++ b/radio/aidl/vts/radio_sim_response.cpp @@ -23,44 +23,62 @@ ndk::ScopedAStatus RadioSimResponse::acknowledgeRequest(int32_t /*serial*/) { } ndk::ScopedAStatus RadioSimResponse::areUiccApplicationsEnabledResponse( - const RadioResponseInfo& /*info*/, bool /*enabled*/) { + const RadioResponseInfo& info, bool enabled) { + rspInfo = info; + areUiccApplicationsEnabled = enabled; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::changeIccPin2ForAppResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioSimResponse::changeIccPin2ForAppResponse(const RadioResponseInfo& info, int32_t /*remainingRetries*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::changeIccPinForAppResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioSimResponse::changeIccPinForAppResponse(const RadioResponseInfo& info, int32_t /*remainingRetries*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::enableUiccApplicationsResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioSimResponse::enableUiccApplicationsResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioSimResponse::getAllowedCarriersResponse( - const RadioResponseInfo& /*info*/, const CarrierRestrictions& /*carriers*/, - SimLockMultiSimPolicy /*multiSimPolicy*/) { + const RadioResponseInfo& info, const CarrierRestrictions& carriers, + SimLockMultiSimPolicy multiSimPolicy) { + rspInfo = info; + carrierRestrictionsResp = carriers; + multiSimPolicyResp = multiSimPolicy; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioSimResponse::getCdmaSubscriptionResponse( - const RadioResponseInfo& /*info*/, const std::string& /*mdn*/, const std::string& /*hSid*/, + const RadioResponseInfo& info, const std::string& /*mdn*/, const std::string& /*hSid*/, const std::string& /*hNid*/, const std::string& /*min*/, const std::string& /*prl*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioSimResponse::getCdmaSubscriptionSourceResponse( - const RadioResponseInfo& /*info*/, CdmaSubscriptionSource /*source*/) { + const RadioResponseInfo& info, CdmaSubscriptionSource /*source*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::getFacilityLockForAppResponse( - const RadioResponseInfo& /*info*/, int32_t /*response*/) { +ndk::ScopedAStatus RadioSimResponse::getFacilityLockForAppResponse(const RadioResponseInfo& info, + int32_t /*response*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -72,8 +90,11 @@ ndk::ScopedAStatus RadioSimResponse::getIccCardStatusResponse(const RadioRespons return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::getImsiForAppResponse(const RadioResponseInfo& /*info*/, - const std::string& /*imsi*/) { +ndk::ScopedAStatus RadioSimResponse::getImsiForAppResponse(const RadioResponseInfo& info, + const std::string& imsi_str) { + rspInfo = info; + imsi = imsi_str; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -91,58 +112,79 @@ ndk::ScopedAStatus RadioSimResponse::getSimPhonebookRecordsResponse(const RadioR return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::iccCloseLogicalChannelResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioSimResponse::iccCloseLogicalChannelResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::iccIoForAppResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioSimResponse::iccIoForAppResponse(const RadioResponseInfo& info, const IccIoResult& /*iccIo*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioSimResponse::iccOpenLogicalChannelResponse( - const RadioResponseInfo& /*info*/, int32_t /*channelId*/, + const RadioResponseInfo& info, int32_t /*channelId*/, const std::vector& /*selectResponse*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioSimResponse::iccTransmitApduBasicChannelResponse( - const RadioResponseInfo& /*info*/, const IccIoResult& /*result*/) { + const RadioResponseInfo& info, const IccIoResult& /*result*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioSimResponse::iccTransmitApduLogicalChannelResponse( - const RadioResponseInfo& /*info*/, const IccIoResult& /*result*/) { + const RadioResponseInfo& info, const IccIoResult& /*result*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioSimResponse::reportStkServiceIsRunningResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioSimResponse::requestIccSimAuthenticationResponse( - const RadioResponseInfo& /*info*/, const IccIoResult& /*result*/) { + const RadioResponseInfo& info, const IccIoResult& /*result*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::sendEnvelopeResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioSimResponse::sendEnvelopeResponse(const RadioResponseInfo& info, const std::string& /*commandResponse*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::sendEnvelopeWithStatusResponse( - const RadioResponseInfo& /*info*/, const IccIoResult& /*iccIo*/) { +ndk::ScopedAStatus RadioSimResponse::sendEnvelopeWithStatusResponse(const RadioResponseInfo& info, + const IccIoResult& /*iccIo*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioSimResponse::sendTerminalResponseToSimResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::setAllowedCarriersResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioSimResponse::setAllowedCarriersResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -154,12 +196,16 @@ ndk::ScopedAStatus RadioSimResponse::setCarrierInfoForImsiEncryptionResponse( } ndk::ScopedAStatus RadioSimResponse::setCdmaSubscriptionSourceResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::setFacilityLockForAppResponse( - const RadioResponseInfo& /*info*/, int32_t /*retry*/) { +ndk::ScopedAStatus RadioSimResponse::setFacilityLockForAppResponse(const RadioResponseInfo& info, + int32_t /*retry*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -169,34 +215,44 @@ ndk::ScopedAStatus RadioSimResponse::setSimCardPowerResponse(const RadioResponse return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::setUiccSubscriptionResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioSimResponse::setUiccSubscriptionResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::supplyIccPin2ForAppResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioSimResponse::supplyIccPin2ForAppResponse(const RadioResponseInfo& info, int32_t /*remainingRetries*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::supplyIccPinForAppResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioSimResponse::supplyIccPinForAppResponse(const RadioResponseInfo& info, int32_t /*remainingRetries*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::supplyIccPuk2ForAppResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioSimResponse::supplyIccPuk2ForAppResponse(const RadioResponseInfo& info, int32_t /*remainingRetries*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioSimResponse::supplyIccPukForAppResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioSimResponse::supplyIccPukForAppResponse(const RadioResponseInfo& info, int32_t /*remainingRetries*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioSimResponse::supplySimDepersonalizationResponse( - const RadioResponseInfo& /*info*/, PersoSubstate /*persoType*/, - int32_t /*remainingRetries*/) { + const RadioResponseInfo& info, PersoSubstate /*persoType*/, int32_t /*remainingRetries*/) { + rspInfo = info; + parent_sim.notify(info.serial); return ndk::ScopedAStatus::ok(); } diff --git a/radio/aidl/vts/radio_sim_test.cpp b/radio/aidl/vts/radio_sim_test.cpp index 5db77f6600..146e86c785 100644 --- a/radio/aidl/vts/radio_sim_test.cpp +++ b/radio/aidl/vts/radio_sim_test.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -260,3 +261,771 @@ TEST_P(RadioSimTest, updateSimPhonebookRecords) { } } } + +/* + * Test IRadioSim.enableUiccApplications() for the response returned. + * For SIM ABSENT case. + */ +TEST_P(RadioSimTest, togglingUiccApplicationsSimAbsent) { + // This test case only test SIM ABSENT case. + if (cardStatus.cardState != CardStatus::STATE_ABSENT) return; + + // Disable Uicc applications. + serial = GetRandomSerialNumber(); + radio_sim->enableUiccApplications(serial, false); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + // As SIM is absent, RadioError::SIM_ABSENT should be thrown. + EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_sim->rspInfo.error); + + // Query Uicc application enablement. + serial = GetRandomSerialNumber(); + radio_sim->areUiccApplicationsEnabled(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + // As SIM is absent, RadioError::SIM_ABSENT should be thrown. + EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_sim->rspInfo.error); +} + +/* + * Test IRadioSim.enableUiccApplications() for the response returned. + * For SIM PRESENT case. + */ +TEST_P(RadioSimTest, togglingUiccApplicationsSimPresent) { + // This test case only test SIM ABSENT case. + if (cardStatus.cardState != CardStatus::STATE_PRESENT) return; + if (cardStatus.applications.size() == 0) return; + + // Disable Uicc applications. + serial = GetRandomSerialNumber(); + radio_sim->enableUiccApplications(serial, false); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + // As SIM is present, there shouldn't be error. + EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); + + // Query Uicc application enablement. + serial = GetRandomSerialNumber(); + radio_sim->areUiccApplicationsEnabled(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + // As SIM is present, there shouldn't be error. + EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); + ASSERT_FALSE(radioRsp_sim->areUiccApplicationsEnabled); + + // Enable Uicc applications. + serial = GetRandomSerialNumber(); + radio_sim->enableUiccApplications(serial, true); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + // As SIM is present, there shouldn't be error. + EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); + + // Query Uicc application enablement. + serial = GetRandomSerialNumber(); + radio_sim->areUiccApplicationsEnabled(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + // As SIM is present, there shouldn't be error. + EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); + ASSERT_TRUE(radioRsp_sim->areUiccApplicationsEnabled); +} + +/* + * Test IRadioSim.areUiccApplicationsEnabled() for the response returned. + */ +TEST_P(RadioSimTest, areUiccApplicationsEnabled) { + // Disable Uicc applications. + serial = GetRandomSerialNumber(); + radio_sim->areUiccApplicationsEnabled(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + // If SIM is absent, RadioError::SIM_ABSENT should be thrown. Otherwise there shouldn't be any + // error. + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_sim->rspInfo.error); + } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); + } +} + +/* + * Test IRadioSim.getAllowedCarriers() for the response returned. + */ +TEST_P(RadioSimTest, getAllowedCarriers) { + serial = GetRandomSerialNumber(); + + radio_sim->getAllowedCarriers(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); +} + +/** + * Test IRadioSim.setAllowedCarriers() for the response returned. + */ +TEST_P(RadioSimTest, setAllowedCarriers) { + // TODO (b/210712359): remove once shim supports 1.4 or alternative is found + GTEST_SKIP(); + serial = GetRandomSerialNumber(); + CarrierRestrictions carrierRestrictions; + memset(&carrierRestrictions, 0, sizeof(carrierRestrictions)); + carrierRestrictions.allowedCarriers.resize(1); + carrierRestrictions.excludedCarriers.resize(0); + carrierRestrictions.allowedCarriers[0].mcc = std::string("123"); + carrierRestrictions.allowedCarriers[0].mnc = std::string("456"); + carrierRestrictions.allowedCarriers[0].matchType = Carrier::MATCH_TYPE_ALL; + carrierRestrictions.allowedCarriers[0].matchData = std::string(); + carrierRestrictions.priority = true; + carrierRestrictions.allowedCarriersPrioritized = true; + SimLockMultiSimPolicy multisimPolicy = SimLockMultiSimPolicy::NO_MULTISIM_POLICY; + + radio_sim->setAllowedCarriers(serial, carrierRestrictions, multisimPolicy); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); + + if (radioRsp_sim->rspInfo.error == RadioError::NONE) { + /* Verify the update of the SIM status. This might need some time */ + if (cardStatus.cardState != CardStatus::STATE_ABSENT) { + updateSimCardStatus(); + auto startTime = std::chrono::system_clock::now(); + while (cardStatus.cardState != CardStatus::STATE_RESTRICTED && + std::chrono::duration_cast( + std::chrono::system_clock::now() - startTime) + .count() < 30) { + /* Set 2 seconds as interval to check card status */ + sleep(2); + updateSimCardStatus(); + } + EXPECT_EQ(CardStatus::STATE_RESTRICTED, cardStatus.cardState); + } + + /* Verify that configuration was set correctly, retrieving it from the modem */ + serial = GetRandomSerialNumber(); + + radio_sim->getAllowedCarriers(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); + + EXPECT_EQ(1, radioRsp_sim->carrierRestrictionsResp.allowedCarriers.size()); + EXPECT_EQ(0, radioRsp_sim->carrierRestrictionsResp.excludedCarriers.size()); + ASSERT_TRUE(std::string("123") == + radioRsp_sim->carrierRestrictionsResp.allowedCarriers[0].mcc); + ASSERT_TRUE(std::string("456") == + radioRsp_sim->carrierRestrictionsResp.allowedCarriers[0].mnc); + EXPECT_EQ(Carrier::MATCH_TYPE_ALL, + radioRsp_sim->carrierRestrictionsResp.allowedCarriers[0].matchType); + ASSERT_TRUE(radioRsp_sim->carrierRestrictionsResp.allowedCarriersPrioritized); + EXPECT_EQ(SimLockMultiSimPolicy::NO_MULTISIM_POLICY, radioRsp_sim->multiSimPolicyResp); + + sleep(10); + + /** + * Another test case of the API to cover to allow carrier. + * If the API is supported, this is also used to reset to no carrier restriction + * status for cardStatus. + */ + memset(&carrierRestrictions, 0, sizeof(carrierRestrictions)); + carrierRestrictions.allowedCarriers.resize(0); + carrierRestrictions.excludedCarriers.resize(0); + carrierRestrictions.allowedCarriersPrioritized = false; + + serial = GetRandomSerialNumber(); + radio_sim->setAllowedCarriers(serial, carrierRestrictions, multisimPolicy); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); + + if (cardStatus.cardState != CardStatus::STATE_ABSENT) { + /* Resetting back to no carrier restriction needs some time */ + updateSimCardStatus(); + auto startTime = std::chrono::system_clock::now(); + while (cardStatus.cardState == CardStatus::STATE_RESTRICTED && + std::chrono::duration_cast( + std::chrono::system_clock::now() - startTime) + .count() < 10) { + /* Set 2 seconds as interval to check card status */ + sleep(2); + updateSimCardStatus(); + } + EXPECT_NE(CardStatus::STATE_RESTRICTED, cardStatus.cardState); + sleep(10); + } + } +} + +/* + * Test IRadioSim.getIccCardStatus() for the response returned. + */ +TEST_P(RadioSimTest, getIccCardStatus) { + LOG(DEBUG) << "getIccCardStatus"; + EXPECT_LE(cardStatus.applications.size(), RadioConst::CARD_MAX_APPS); + EXPECT_LT(cardStatus.gsmUmtsSubscriptionAppIndex, RadioConst::CARD_MAX_APPS); + EXPECT_LT(cardStatus.cdmaSubscriptionAppIndex, RadioConst::CARD_MAX_APPS); + EXPECT_LT(cardStatus.imsSubscriptionAppIndex, RadioConst::CARD_MAX_APPS); + LOG(DEBUG) << "getIccCardStatus finished"; +} + +/* + * Test IRadioSim.supplyIccPinForApp() for the response returned + */ +TEST_P(RadioSimTest, supplyIccPinForApp) { + LOG(DEBUG) << "supplyIccPinForApp"; + serial = GetRandomSerialNumber(); + + // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and + // 3GPP2 apps only + for (int i = 0; i < (int)cardStatus.applications.size(); i++) { + if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { + radio_sim->supplyIccPinForApp(serial, std::string("test1"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_sim->rspInfo.error, + {RadioError::PASSWORD_INCORRECT, RadioError::REQUEST_NOT_SUPPORTED})); + } + } + LOG(DEBUG) << "supplyIccPinForApp finished"; +} + +/* + * Test IRadioSim.supplyIccPukForApp() for the response returned. + */ +TEST_P(RadioSimTest, supplyIccPukForApp) { + LOG(DEBUG) << "supplyIccPukForApp"; + serial = GetRandomSerialNumber(); + + // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and + // 3GPP2 apps only + for (int i = 0; i < (int)cardStatus.applications.size(); i++) { + if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { + radio_sim->supplyIccPukForApp(serial, std::string("test1"), std::string("test2"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_sim->rspInfo.error, + {RadioError::PASSWORD_INCORRECT, RadioError::INVALID_SIM_STATE})); + } + } + LOG(DEBUG) << "supplyIccPukForApp finished"; +} + +/* + * Test IRadioSim.supplyIccPin2ForApp() for the response returned. + */ +TEST_P(RadioSimTest, supplyIccPin2ForApp) { + LOG(DEBUG) << "supplyIccPin2ForApp"; + serial = GetRandomSerialNumber(); + + // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and + // 3GPP2 apps only + for (int i = 0; i < (int)cardStatus.applications.size(); i++) { + if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { + radio_sim->supplyIccPin2ForApp(serial, std::string("test1"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_sim->rspInfo.error, + {RadioError::PASSWORD_INCORRECT, + RadioError::REQUEST_NOT_SUPPORTED, RadioError::SIM_PUK2})); + } + } + LOG(DEBUG) << "supplyIccPin2ForApp finished"; +} + +/* + * Test IRadioSim.supplyIccPuk2ForApp() for the response returned. + */ +TEST_P(RadioSimTest, supplyIccPuk2ForApp) { + LOG(DEBUG) << "supplyIccPuk2ForApp"; + serial = GetRandomSerialNumber(); + + // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and + // 3GPP2 apps only + for (int i = 0; i < (int)cardStatus.applications.size(); i++) { + if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { + radio_sim->supplyIccPuk2ForApp(serial, std::string("test1"), std::string("test2"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_sim->rspInfo.error, + {RadioError::PASSWORD_INCORRECT, RadioError::INVALID_SIM_STATE})); + } + } + LOG(DEBUG) << "supplyIccPuk2ForApp finished"; +} + +/* + * Test IRadioSim.changeIccPinForApp() for the response returned. + */ +TEST_P(RadioSimTest, changeIccPinForApp) { + LOG(DEBUG) << "changeIccPinForApp"; + serial = GetRandomSerialNumber(); + + // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and + // 3GPP2 apps only + for (int i = 0; i < (int)cardStatus.applications.size(); i++) { + if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { + radio_sim->changeIccPinForApp(serial, std::string("test1"), std::string("test2"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_sim->rspInfo.error, + {RadioError::PASSWORD_INCORRECT, RadioError::REQUEST_NOT_SUPPORTED})); + } + } + LOG(DEBUG) << "changeIccPinForApp finished"; +} + +/* + * Test IRadioSim.changeIccPin2ForApp() for the response returned. + */ +TEST_P(RadioSimTest, changeIccPin2ForApp) { + LOG(DEBUG) << "changeIccPin2ForApp"; + serial = GetRandomSerialNumber(); + + // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and + // 3GPP2 apps only + for (int i = 0; i < (int)cardStatus.applications.size(); i++) { + if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { + radio_sim->changeIccPin2ForApp(serial, std::string("test1"), std::string("test2"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_sim->rspInfo.error, + {RadioError::PASSWORD_INCORRECT, + RadioError::REQUEST_NOT_SUPPORTED, RadioError::SIM_PUK2})); + } + } + LOG(DEBUG) << "changeIccPin2ForApp finished"; +} + +/* + * The following test is disabled due to b/109889468 + * + * Test IRadioSim.getImsiForApp() for the response returned. + */ +TEST_P(RadioSimTest, DISABLED_getImsiForApp) { + LOG(DEBUG) << "DISABLED_getImsiForApp"; + serial = GetRandomSerialNumber(); + + // Check success returned while getting imsi for 3GPP and 3GPP2 apps only + for (int i = 0; i < (int)cardStatus.applications.size(); i++) { + if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || + cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { + radio_sim->getImsiForApp(serial, cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, {RadioError::NONE}, + CHECK_GENERAL_ERROR)); + + // IMSI (MCC+MNC+MSIN) is at least 6 digits, but not more than 15 + if (radioRsp_sim->rspInfo.error == RadioError::NONE) { + EXPECT_NE(radioRsp_sim->imsi, std::string()); + EXPECT_GE((int)(radioRsp_sim->imsi).size(), 6); + EXPECT_LE((int)(radioRsp_sim->imsi).size(), 15); + } + } + } + LOG(DEBUG) << "DISABLED_getImsiForApp finished"; +} + +/* + * Test IRadioSim.iccIoForApp() for the response returned. + */ +TEST_P(RadioSimTest, iccIoForApp) { + LOG(DEBUG) << "iccIoForApp"; + serial = GetRandomSerialNumber(); + + for (int i = 0; i < (int)cardStatus.applications.size(); i++) { + IccIo iccIo; + iccIo.command = 0xc0; + iccIo.fileId = 0x6f11; + iccIo.path = std::string("3F007FFF"); + iccIo.p1 = 0; + iccIo.p2 = 0; + iccIo.p3 = 0; + iccIo.data = std::string(); + iccIo.pin2 = std::string(); + iccIo.aid = cardStatus.applications[i].aidPtr; + + radio_sim->iccIoForApp(serial, iccIo); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + } + LOG(DEBUG) << "iccIoForApp finished"; +} + +/* + * Test IRadioSim.iccTransmitApduBasicChannel() for the response returned. + */ +TEST_P(RadioSimTest, iccTransmitApduBasicChannel) { + LOG(DEBUG) << "iccTransmitApduBasicChannel"; + serial = GetRandomSerialNumber(); + SimApdu msg; + memset(&msg, 0, sizeof(msg)); + msg.data = std::string(); + + radio_sim->iccTransmitApduBasicChannel(serial, msg); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + // TODO(sanketpadawe): Add test for error code + LOG(DEBUG) << "iccTransmitApduBasicChannel finished"; +} + +/* + * Test IRadioSim.iccOpenLogicalChannel() for the response returned. + */ +TEST_P(RadioSimTest, iccOpenLogicalChannel) { + LOG(DEBUG) << "iccOpenLogicalChannel"; + serial = GetRandomSerialNumber(); + int p2 = 0x04; + // Specified in ISO 7816-4 clause 7.1.1 0x04 means that FCP template is requested. + for (int i = 0; i < (int)cardStatus.applications.size(); i++) { + radio_sim->iccOpenLogicalChannel(serial, cardStatus.applications[i].aidPtr, p2); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + } + LOG(DEBUG) << "iccOpenLogicalChannel finished"; +} + +/* + * Test IRadioSim.iccCloseLogicalChannel() for the response returned. + */ +TEST_P(RadioSimTest, iccCloseLogicalChannel) { + LOG(DEBUG) << "iccCloseLogicalChannel"; + serial = GetRandomSerialNumber(); + // Try closing invalid channel and check INVALID_ARGUMENTS returned as error + radio_sim->iccCloseLogicalChannel(serial, 0); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + EXPECT_EQ(RadioError::INVALID_ARGUMENTS, radioRsp_sim->rspInfo.error); + LOG(DEBUG) << "iccCloseLogicalChannel finished"; +} + +/* + * Test IRadioSim.iccTransmitApduLogicalChannel() for the response returned. + */ +TEST_P(RadioSimTest, iccTransmitApduLogicalChannel) { + LOG(DEBUG) << "iccTransmitApduLogicalChannel"; + serial = GetRandomSerialNumber(); + SimApdu msg; + memset(&msg, 0, sizeof(msg)); + msg.data = std::string(); + + radio_sim->iccTransmitApduLogicalChannel(serial, msg); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + // TODO(sanketpadawe): Add test for error code + LOG(DEBUG) << "iccTransmitApduLogicalChannel finished"; +} + +/* + * Test IRadioSim.requestIccSimAuthentication() for the response returned. + */ +TEST_P(RadioSimTest, requestIccSimAuthentication) { + LOG(DEBUG) << "requestIccSimAuthentication"; + serial = GetRandomSerialNumber(); + + // Pass wrong challenge string and check RadioError::INVALID_ARGUMENTS + // or REQUEST_NOT_SUPPORTED returned as error. + for (int i = 0; i < (int)cardStatus.applications.size(); i++) { + radio_sim->requestIccSimAuthentication(serial, 0, std::string("test"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_sim->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); + } + LOG(DEBUG) << "requestIccSimAuthentication finished"; +} + +/* + * Test IRadioSim.getFacilityLockForApp() for the response returned. + */ +TEST_P(RadioSimTest, getFacilityLockForApp) { + serial = GetRandomSerialNumber(); + std::string facility = ""; + std::string password = ""; + int32_t serviceClass = 1; + std::string appId = ""; + + radio_sim->getFacilityLockForApp(serial, facility, password, serviceClass, appId); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } +} + +/* + * Test IRadioSim.setFacilityLockForApp() for the response returned. + */ +TEST_P(RadioSimTest, setFacilityLockForApp) { + serial = GetRandomSerialNumber(); + std::string facility = ""; + bool lockState = false; + std::string password = ""; + int32_t serviceClass = 1; + std::string appId = ""; + + radio_sim->setFacilityLockForApp(serial, facility, lockState, password, serviceClass, appId); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } +} + +/* + * Test IRadioSim.getCdmaSubscription() for the response returned. + */ +TEST_P(RadioSimTest, getCdmaSubscription) { + LOG(DEBUG) << "getCdmaSubscription"; + serial = GetRandomSerialNumber(); + + radio_sim->getCdmaSubscription(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_sim->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED, RadioError::SIM_ABSENT})); + } + LOG(DEBUG) << "getCdmaSubscription finished"; +} + +/* + * Test IRadioSim.getCdmaSubscriptionSource() for the response returned. + */ +TEST_P(RadioSimTest, getCdmaSubscriptionSource) { + LOG(DEBUG) << "getCdmaSubscriptionSource"; + serial = GetRandomSerialNumber(); + + radio_sim->getCdmaSubscriptionSource(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_sim->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED, RadioError::SIM_ABSENT})); + } + LOG(DEBUG) << "getCdmaSubscriptionSource finished"; +} + +/* + * Test IRadioSim.setCdmaSubscriptionSource() for the response returned. + */ +TEST_P(RadioSimTest, setCdmaSubscriptionSource) { + LOG(DEBUG) << "setCdmaSubscriptionSource"; + serial = GetRandomSerialNumber(); + + radio_sim->setCdmaSubscriptionSource(serial, CdmaSubscriptionSource::RUIM_SIM); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_sim->rspInfo.error, + {RadioError::NONE, RadioError::SIM_ABSENT, RadioError::SUBSCRIPTION_NOT_AVAILABLE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setCdmaSubscriptionSource finished"; +} + +/* + * Test IRadioSim.setUiccSubscription() for the response returned. + */ +TEST_P(RadioSimTest, setUiccSubscription) { + LOG(DEBUG) << "setUiccSubscription"; + serial = GetRandomSerialNumber(); + SelectUiccSub item; + memset(&item, 0, sizeof(item)); + + radio_sim->setUiccSubscription(serial, item); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE( + CheckAnyOfErrors(radioRsp_sim->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, + RadioError::MODEM_ERR, RadioError::SUBSCRIPTION_NOT_SUPPORTED}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setUiccSubscription finished"; +} + +/* + * Test IRadioSim.sendEnvelope() for the response returned. + */ +TEST_P(RadioSimTest, sendEnvelope) { + LOG(DEBUG) << "sendEnvelope"; + serial = GetRandomSerialNumber(); + + // Test with sending empty string + std::string content = ""; + + radio_sim->sendEnvelope(serial, content); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, + RadioError::MODEM_ERR, RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "sendEnvelope finished"; +} + +/* + * Test IRadioSim.sendTerminalResponseToSim() for the response returned. + */ +TEST_P(RadioSimTest, sendTerminalResponseToSim) { + LOG(DEBUG) << "sendTerminalResponseToSim"; + serial = GetRandomSerialNumber(); + + // Test with sending empty string + std::string commandResponse = ""; + + radio_sim->sendTerminalResponseToSim(serial, commandResponse); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_sim->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "sendTerminalResponseToSim finished"; +} + +/* + * Test IRadioSim.reportStkServiceIsRunning() for the response returned. + */ +TEST_P(RadioSimTest, reportStkServiceIsRunning) { + LOG(DEBUG) << "reportStkServiceIsRunning"; + serial = GetRandomSerialNumber(); + + radio_sim->reportStkServiceIsRunning(serial); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, {RadioError::NONE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "reportStkServiceIsRunning finished"; +} + +/* + * Test IRadioSim.sendEnvelopeWithStatus() for the response returned with empty + * string. + */ +TEST_P(RadioSimTest, sendEnvelopeWithStatus) { + LOG(DEBUG) << "sendEnvelopeWithStatus"; + serial = GetRandomSerialNumber(); + + // Test with sending empty string + std::string contents = ""; + + radio_sim->sendEnvelopeWithStatus(serial, contents); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); + EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_sim->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR, RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "sendEnvelopeWithStatus finished"; +} diff --git a/radio/aidl/vts/radio_sim_utils.h b/radio/aidl/vts/radio_sim_utils.h index b5e365d436..83f1cbc1ae 100644 --- a/radio/aidl/vts/radio_sim_utils.h +++ b/radio/aidl/vts/radio_sim_utils.h @@ -42,6 +42,7 @@ class RadioSimResponse : public BnRadioSimResponse { bool areUiccApplicationsEnabled; PhonebookCapacity capacity; int32_t updatedRecordIndex; + std::string imsi; virtual ndk::ScopedAStatus acknowledgeRequest(int32_t serial) override; diff --git a/radio/aidl/vts/radio_voice_response.cpp b/radio/aidl/vts/radio_voice_response.cpp index a491613b60..95b2d4e72e 100644 --- a/radio/aidl/vts/radio_voice_response.cpp +++ b/radio/aidl/vts/radio_voice_response.cpp @@ -18,7 +18,9 @@ RadioVoiceResponse::RadioVoiceResponse(RadioServiceTest& parent) : parent_voice(parent) {} -ndk::ScopedAStatus RadioVoiceResponse::acceptCallResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::acceptCallResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -26,11 +28,15 @@ ndk::ScopedAStatus RadioVoiceResponse::acknowledgeRequest(int32_t /*serial*/) { return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::conferenceResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::conferenceResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::dialResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::dialResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -41,34 +47,44 @@ ndk::ScopedAStatus RadioVoiceResponse::emergencyDialResponse(const RadioResponse } ndk::ScopedAStatus RadioVoiceResponse::exitEmergencyCallbackModeResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::explicitCallTransferResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::explicitCallTransferResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioVoiceResponse::getCallForwardStatusResponse( - const RadioResponseInfo& /*info*/, - const std::vector& /*callForwardInfos*/) { + const RadioResponseInfo& info, const std::vector& /*callForwardInfos*/) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::getCallWaitingResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioVoiceResponse::getCallWaitingResponse(const RadioResponseInfo& info, bool /*enable*/, int32_t /*serviceClass*/) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::getClipResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioVoiceResponse::getClipResponse(const RadioResponseInfo& info, ClipStatus /*status*/) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::getClirResponse(const RadioResponseInfo& /*info*/, - int32_t /*n*/, int32_t /*m*/) { +ndk::ScopedAStatus RadioVoiceResponse::getClirResponse(const RadioResponseInfo& info, int32_t /*n*/, + int32_t /*m*/) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -81,27 +97,37 @@ ndk::ScopedAStatus RadioVoiceResponse::getCurrentCallsResponse(const RadioRespon } ndk::ScopedAStatus RadioVoiceResponse::getLastCallFailCauseResponse( - const RadioResponseInfo& /*info*/, const LastCallFailCauseInfo& /*failCauseInfo*/) { + const RadioResponseInfo& info, const LastCallFailCauseInfo& /*failCauseInfo*/) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::getMuteResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioVoiceResponse::getMuteResponse(const RadioResponseInfo& info, bool /*enable*/) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioVoiceResponse::getPreferredVoicePrivacyResponse( - const RadioResponseInfo& /*info*/, bool /*enable*/) { + const RadioResponseInfo& info, bool /*enable*/) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::getTtyModeResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioVoiceResponse::getTtyModeResponse(const RadioResponseInfo& info, TtyMode /*mode*/) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioVoiceResponse::handleStkCallSetupRequestFromSimResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } @@ -112,80 +138,114 @@ ndk::ScopedAStatus RadioVoiceResponse::hangupConnectionResponse(const RadioRespo } ndk::ScopedAStatus RadioVoiceResponse::hangupForegroundResumeBackgroundResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioVoiceResponse::hangupWaitingOrBackgroundResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::isVoNrEnabledResponse(const RadioResponseInfo& /*info*/, +ndk::ScopedAStatus RadioVoiceResponse::isVoNrEnabledResponse(const RadioResponseInfo& info, bool /*enabled*/) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::rejectCallResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::rejectCallResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::sendBurstDtmfResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::sendBurstDtmfResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::sendCdmaFeatureCodeResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::sendCdmaFeatureCodeResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::sendDtmfResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::sendDtmfResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::separateConnectionResponse( - const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::separateConnectionResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::setCallForwardResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::setCallForwardResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::setCallWaitingResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::setCallWaitingResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::setClirResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::setClirResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::setMuteResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::setMuteResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioVoiceResponse::setPreferredVoicePrivacyResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::setTtyModeResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::setTtyModeResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::setVoNrEnabledResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::setVoNrEnabledResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::startDtmfResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::startDtmfResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus RadioVoiceResponse::stopDtmfResponse(const RadioResponseInfo& /*info*/) { +ndk::ScopedAStatus RadioVoiceResponse::stopDtmfResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus RadioVoiceResponse::switchWaitingOrHoldingAndActiveResponse( - const RadioResponseInfo& /*info*/) { + const RadioResponseInfo& info) { + rspInfo = info; + parent_voice.notify(info.serial); return ndk::ScopedAStatus::ok(); } diff --git a/radio/aidl/vts/radio_voice_test.cpp b/radio/aidl/vts/radio_voice_test.cpp index 717f3f0be9..0556938620 100644 --- a/radio/aidl/vts/radio_voice_test.cpp +++ b/radio/aidl/vts/radio_voice_test.cpp @@ -265,3 +265,640 @@ TEST_P(RadioVoiceTest, getCurrentCalls) { EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); EXPECT_EQ(RadioError::NONE, radioRsp_voice->rspInfo.error); } + +/* + * Test IRadioVoice.getClir() for the response returned. + */ +TEST_P(RadioVoiceTest, getClir) { + serial = GetRandomSerialNumber(); + + radio_voice->getClir(serial); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, {RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } +} + +/* + * Test IRadioVoice.setClir() for the response returned. + */ +TEST_P(RadioVoiceTest, setClir) { + serial = GetRandomSerialNumber(); + int32_t status = 1; + + radio_voice->setClir(serial, status); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_voice->rspInfo.error); + } +} + +/* + * Test IRadioVoice.getClip() for the response returned. + */ +TEST_P(RadioVoiceTest, getClip) { + serial = GetRandomSerialNumber(); + + radio_voice->getClip(serial); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, {RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } +} + +/* + * Test IRadioVoice.getTtyMode() for the response returned. + */ +TEST_P(RadioVoiceTest, getTtyMode) { + LOG(DEBUG) << "getTTYMode"; + serial = GetRandomSerialNumber(); + + radio_voice->getTtyMode(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_voice->rspInfo.error); + } + LOG(DEBUG) << "getTTYMode finished"; +} + +/* + * Test IRadioVoice.setTtyMode() for the response returned. + */ +TEST_P(RadioVoiceTest, setTtyMode) { + LOG(DEBUG) << "setTtyMode"; + serial = GetRandomSerialNumber(); + + radio_voice->setTtyMode(serial, TtyMode::OFF); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_voice->rspInfo.error); + } + LOG(DEBUG) << "setTtyMode finished"; +} + +/* + * Test IRadioVoice.setPreferredVoicePrivacy() for the response returned. + */ +TEST_P(RadioVoiceTest, setPreferredVoicePrivacy) { + LOG(DEBUG) << "setPreferredVoicePrivacy"; + serial = GetRandomSerialNumber(); + + radio_voice->setPreferredVoicePrivacy(serial, true); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); + } + LOG(DEBUG) << "setPreferredVoicePrivacy finished"; +} + +/* + * Test IRadioVoice.getPreferredVoicePrivacy() for the response returned. + */ +TEST_P(RadioVoiceTest, getPreferredVoicePrivacy) { + LOG(DEBUG) << "getPreferredVoicePrivacy"; + serial = GetRandomSerialNumber(); + + radio_voice->getPreferredVoicePrivacy(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); + } + LOG(DEBUG) << "getPreferredVoicePrivacy finished"; +} + +/* + * Test IRadioVoice.exitEmergencyCallbackMode() for the response returned. + */ +TEST_P(RadioVoiceTest, exitEmergencyCallbackMode) { + LOG(DEBUG) << "exitEmergencyCallbackMode"; + serial = GetRandomSerialNumber(); + + radio_voice->exitEmergencyCallbackMode(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_voice->rspInfo.error, + {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED, RadioError::SIM_ABSENT})); + } + LOG(DEBUG) << "exitEmergencyCallbackMode finished"; +} + +/* + * Test IRadioVoice.handleStkCallSetupRequestFromSim() for the response returned. + */ +TEST_P(RadioVoiceTest, handleStkCallSetupRequestFromSim) { + LOG(DEBUG) << "handleStkCallSetupRequestFromSim"; + serial = GetRandomSerialNumber(); + bool accept = false; + + radio_voice->handleStkCallSetupRequestFromSim(serial, accept); + + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, + RadioError::MODEM_ERR, RadioError::SIM_ABSENT}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "handleStkCallSetupRequestFromSim finished"; +} + +/* + * Test IRadioVoice.dial() for the response returned. + */ +TEST_P(RadioVoiceTest, dial) { + LOG(DEBUG) << "dial"; + serial = GetRandomSerialNumber(); + + Dial dialInfo; + memset(&dialInfo, 0, sizeof(dialInfo)); + dialInfo.address = std::string("123456789"); + + radio_voice->dial(serial, dialInfo); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_voice->rspInfo.error, + {RadioError::CANCELLED, RadioError::DEVICE_IN_USE, RadioError::FDN_CHECK_FAILURE, + RadioError::INVALID_ARGUMENTS, RadioError::INVALID_CALL_ID, + RadioError::INVALID_MODEM_STATE, RadioError::INVALID_STATE, RadioError::MODEM_ERR, + RadioError::NO_NETWORK_FOUND, RadioError::NO_SUBSCRIPTION, + RadioError::OPERATION_NOT_ALLOWED}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "dial finished"; +} + +/* + * Test IRadioVoice.hangup() for the response returned. + */ +TEST_P(RadioVoiceTest, hangup) { + LOG(DEBUG) << "hangup"; + serial = GetRandomSerialNumber(); + + radio_voice->hangup(serial, 1); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_voice->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "hangup finished"; +} + +/* + * Test IRadioVoice.hangupWaitingOrBackground() for the response returned. + */ +TEST_P(RadioVoiceTest, hangupWaitingOrBackground) { + LOG(DEBUG) << "hangupWaitingOrBackground"; + serial = GetRandomSerialNumber(); + + radio_voice->hangupWaitingOrBackground(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "hangupWaitingOrBackground finished"; +} + +/* + * Test IRadioVoice.hangupForegroundResumeBackground() for the response returned. + */ +TEST_P(RadioVoiceTest, hangupForegroundResumeBackground) { + LOG(DEBUG) << "hangupForegroundResumeBackground"; + serial = GetRandomSerialNumber(); + + radio_voice->hangupForegroundResumeBackground(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "hangupForegroundResumeBackground finished"; +} + +/* + * Test IRadioVoice.switchWaitingOrHoldingAndActive() for the response returned. + */ +TEST_P(RadioVoiceTest, switchWaitingOrHoldingAndActive) { + LOG(DEBUG) << "switchWaitingOrHoldingAndActive"; + serial = GetRandomSerialNumber(); + + radio_voice->switchWaitingOrHoldingAndActive(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "switchWaitingOrHoldingAndActive finished"; +} + +/* + * Test IRadioVoice.conference() for the response returned. + */ +TEST_P(RadioVoiceTest, conference) { + LOG(DEBUG) << "conference"; + serial = GetRandomSerialNumber(); + + radio_voice->conference(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "conference finished"; +} + +/* + * Test IRadioVoice.rejectCall() for the response returned. + */ +TEST_P(RadioVoiceTest, rejectCall) { + LOG(DEBUG) << "rejectCall"; + serial = GetRandomSerialNumber(); + + radio_voice->rejectCall(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "rejectCall finished"; +} + +/* + * Test IRadioVoice.getLastCallFailCause() for the response returned. + */ +TEST_P(RadioVoiceTest, getLastCallFailCause) { + LOG(DEBUG) << "getLastCallFailCause"; + serial = GetRandomSerialNumber(); + + radio_voice->getLastCallFailCause(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, {RadioError::NONE}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "getLastCallFailCause finished"; +} + +/* + * Test IRadioVoice.getCallForwardStatus() for the response returned. + */ +TEST_P(RadioVoiceTest, getCallForwardStatus) { + LOG(DEBUG) << "getCallForwardStatus"; + serial = GetRandomSerialNumber(); + CallForwardInfo callInfo; + memset(&callInfo, 0, sizeof(callInfo)); + callInfo.number = std::string(); + + radio_voice->getCallForwardStatus(serial, callInfo); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_voice->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "getCallForwardStatus finished"; +} + +/* + * Test IRadioVoice.setCallForward() for the response returned. + */ +TEST_P(RadioVoiceTest, setCallForward) { + LOG(DEBUG) << "setCallForward"; + serial = GetRandomSerialNumber(); + CallForwardInfo callInfo; + memset(&callInfo, 0, sizeof(callInfo)); + callInfo.number = std::string(); + + radio_voice->setCallForward(serial, callInfo); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_voice->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setCallForward finished"; +} + +/* + * Test IRadioVoice.getCallWaiting() for the response returned. + */ +TEST_P(RadioVoiceTest, getCallWaiting) { + LOG(DEBUG) << "getCallWaiting"; + serial = GetRandomSerialNumber(); + + radio_voice->getCallWaiting(serial, 1); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_voice->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "getCallWaiting finished"; +} + +/* + * Test IRadioVoice.setCallWaiting() for the response returned. + */ +TEST_P(RadioVoiceTest, setCallWaiting) { + LOG(DEBUG) << "setCallWaiting"; + serial = GetRandomSerialNumber(); + + radio_voice->setCallWaiting(serial, true, 1); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_voice->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setCallWaiting finished"; +} + +/* + * Test IRadioVoice.acceptCall() for the response returned. + */ +TEST_P(RadioVoiceTest, acceptCall) { + LOG(DEBUG) << "acceptCall"; + serial = GetRandomSerialNumber(); + + radio_voice->acceptCall(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "acceptCall finished"; +} + +/* + * Test IRadioVoice.separateConnection() for the response returned. + */ +TEST_P(RadioVoiceTest, separateConnection) { + LOG(DEBUG) << "separateConnection"; + serial = GetRandomSerialNumber(); + + radio_voice->separateConnection(serial, 1); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_voice->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "separateConnection finished"; +} + +/* + * Test IRadioVoice.explicitCallTransfer() for the response returned. + */ +TEST_P(RadioVoiceTest, explicitCallTransfer) { + LOG(DEBUG) << "explicitCallTransfer"; + serial = GetRandomSerialNumber(); + + radio_voice->explicitCallTransfer(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::INVALID_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "explicitCallTransfer finished"; +} + +/* + * Test IRadioVoice.sendCdmaFeatureCode() for the response returned. + */ +TEST_P(RadioVoiceTest, sendCdmaFeatureCode) { + LOG(DEBUG) << "sendCdmaFeatureCode"; + serial = GetRandomSerialNumber(); + + radio_voice->sendCdmaFeatureCode(serial, std::string()); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, + RadioError::INVALID_CALL_ID, RadioError::INVALID_MODEM_STATE, + RadioError::MODEM_ERR, RadioError::OPERATION_NOT_ALLOWED}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "sendCdmaFeatureCode finished"; +} + +/* + * Test IRadioVoice.sendDtmf() for the response returned. + */ +TEST_P(RadioVoiceTest, sendDtmf) { + LOG(DEBUG) << "sendDtmf"; + serial = GetRandomSerialNumber(); + + radio_voice->sendDtmf(serial, "1"); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_voice->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INVALID_CALL_ID, + RadioError::INVALID_MODEM_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "sendDtmf finished"; +} + +/* + * Test IRadioVoice.startDtmf() for the response returned. + */ +TEST_P(RadioVoiceTest, startDtmf) { + LOG(DEBUG) << "startDtmf"; + serial = GetRandomSerialNumber(); + + radio_voice->startDtmf(serial, "1"); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors( + radioRsp_voice->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INVALID_CALL_ID, + RadioError::INVALID_MODEM_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "startDtmf finished"; +} + +/* + * Test IRadioVoice.stopDtmf() for the response returned. + */ +TEST_P(RadioVoiceTest, stopDtmf) { + LOG(DEBUG) << "stopDtmf"; + serial = GetRandomSerialNumber(); + + radio_voice->stopDtmf(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_CALL_ID, + RadioError::INVALID_MODEM_STATE, RadioError::MODEM_ERR}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "stopDtmf finished"; +} + +/* + * Test IRadioVoice.setMute() for the response returned. + */ +TEST_P(RadioVoiceTest, setMute) { + LOG(DEBUG) << "setMute"; + serial = GetRandomSerialNumber(); + + radio_voice->setMute(serial, true); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::NONE, RadioError::INVALID_ARGUMENTS}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "setMute finished"; +} + +/* + * Test IRadioVoice.getMute() for the response returned. + */ +TEST_P(RadioVoiceTest, getMute) { + LOG(DEBUG) << "getMute"; + serial = GetRandomSerialNumber(); + + radio_voice->getMute(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + EXPECT_EQ(RadioError::NONE, radioRsp_voice->rspInfo.error); + } + LOG(DEBUG) << "getMute finished"; +} + +/* + * Test IRadioVoice.sendBurstDtmf() for the response returned. + */ +TEST_P(RadioVoiceTest, sendBurstDtmf) { + LOG(DEBUG) << "sendBurstDtmf"; + serial = GetRandomSerialNumber(); + + radio_voice->sendBurstDtmf(serial, "1", 0, 0); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type); + EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial); + + if (cardStatus.cardState == CardStatus::STATE_ABSENT) { + ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error, + {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, + RadioError::MODEM_ERR, RadioError::OPERATION_NOT_ALLOWED}, + CHECK_GENERAL_ERROR)); + } + LOG(DEBUG) << "sendBurstDtmf finished"; +}