Add all prior VTS tests
Test: atest VtsHalRadioTargetTest
Bug: 210712359
Change-Id: Ib7ace442ee2bf8d203df9899d8e8331b26af74ad
diff --git a/radio/aidl/vts/radio_sim_test.cpp b/radio/aidl/vts/radio_sim_test.cpp
index 5db77f6..146e86c 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 <aidl/android/hardware/radio/RadioConst.h>
#include <aidl/android/hardware/radio/config/IRadioConfig.h>
#include <android-base/logging.h>
#include <android/binder_manager.h>
@@ -260,3 +261,771 @@
}
}
}
+
+/*
+ * 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::seconds>(
+ 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::seconds>(
+ 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";
+}