From 1512edb314e42dbae1e7b55971d466904ed88e13 Mon Sep 17 00:00:00 2001 From: Sanket Padawe Date: Thu, 23 Feb 2017 12:31:09 -0800 Subject: [PATCH] VTS for icc radio hal Apis (patch 2). Test: vts Change-Id: I24a08f82bcca5bd48c268d72c75059e614931ea0 --- .../1.0/vts/functional/radio_hidl_hal_icc.cpp | 263 +++++++++++++++--- .../vts/functional/radio_hidl_hal_test.cpp | 6 + .../1.0/vts/functional/radio_hidl_hal_utils.h | 9 +- radio/1.0/vts/functional/radio_response.cpp | 22 ++ 4 files changed, 260 insertions(+), 40 deletions(-) diff --git a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp index 9b540e8ace..bd979b0f74 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp @@ -20,86 +20,271 @@ * Test IRadio.getIccCardStatus() for the response returned. */ TEST_F(RadioHidlTest, getIccCardStatus) { - radio->getIccCardStatus(1); - EXPECT_EQ(std::cv_status::no_timeout, wait()); - EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); - EXPECT_EQ(1, radioRsp->rspInfo.serial); - EXPECT_EQ(radioRsp->rspInfo.error, RadioError::NONE); - - EXPECT_LE(radioRsp->cardStatus.applications.size(), (unsigned int) RadioConst::CARD_MAX_APPS); - EXPECT_LT(radioRsp->cardStatus.gsmUmtsSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS); - EXPECT_LT(radioRsp->cardStatus.cdmaSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS); - EXPECT_LT(radioRsp->cardStatus.imsSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS); + EXPECT_LE(cardStatus.applications.size(), (unsigned int) RadioConst::CARD_MAX_APPS); + EXPECT_LT(cardStatus.gsmUmtsSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS); + EXPECT_LT(cardStatus.cdmaSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS); + EXPECT_LT(cardStatus.imsSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS); } /* - * Test IRadio.supplyIccPinForApp() for the response returned. + * Test IRadio.supplyIccPinForApp() for the response returned */ TEST_F(RadioHidlTest, supplyIccPinForApp) { - radio->supplyIccPinForApp(2, hidl_string("test1"), hidl_string()); - EXPECT_EQ(std::cv_status::no_timeout, wait()); - EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); - EXPECT_EQ(2, radioRsp->rspInfo.serial); + int serial = 1; - EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT); + // 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 == AppType::SIM + || cardStatus.applications[i].appType == AppType::USIM + || cardStatus.applications[i].appType == AppType::RUIM + || cardStatus.applications[i].appType == AppType::CSIM) { + radio->supplyIccPinForApp(++serial, hidl_string("test1"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error); + } + } } /* * Test IRadio.supplyIccPukForApp() for the response returned. */ TEST_F(RadioHidlTest, supplyIccPukForApp) { - radio->supplyIccPukForApp(3, hidl_string("test1"), hidl_string("test2"), hidl_string()); - EXPECT_EQ(std::cv_status::no_timeout, wait()); - EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); - EXPECT_EQ(3, radioRsp->rspInfo.serial); + int serial = 1; - EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT); + // 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 == AppType::SIM + || cardStatus.applications[i].appType == AppType::USIM + || cardStatus.applications[i].appType == AppType::RUIM + || cardStatus.applications[i].appType == AppType::CSIM) { + radio->supplyIccPukForApp(++serial, hidl_string("test1"), hidl_string("test2"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error); + } + } } /* * Test IRadio.supplyIccPin2ForApp() for the response returned. */ TEST_F(RadioHidlTest, supplyIccPin2ForApp) { - radio->supplyIccPin2ForApp(4, hidl_string("test1"), hidl_string()); - EXPECT_EQ(std::cv_status::no_timeout, wait()); - EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); - EXPECT_EQ(4, radioRsp->rspInfo.serial); + int serial = 1; - EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT); + // 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 == AppType::SIM + || cardStatus.applications[i].appType == AppType::USIM + || cardStatus.applications[i].appType == AppType::RUIM + || cardStatus.applications[i].appType == AppType::CSIM) { + radio->supplyIccPin2ForApp(++serial, hidl_string("test1"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error); + } + } } /* * Test IRadio.supplyIccPuk2ForApp() for the response returned. */ TEST_F(RadioHidlTest, supplyIccPuk2ForApp) { - radio->supplyIccPuk2ForApp(5, hidl_string("test1"), hidl_string("test2"), hidl_string()); - EXPECT_EQ(std::cv_status::no_timeout, wait()); - EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); - EXPECT_EQ(5, radioRsp->rspInfo.serial); + int serial = 1; - EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT); + // 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 == AppType::SIM + || cardStatus.applications[i].appType == AppType::USIM + || cardStatus.applications[i].appType == AppType::RUIM + || cardStatus.applications[i].appType == AppType::CSIM) { + radio->supplyIccPuk2ForApp(++serial, hidl_string("test1"), hidl_string("test2"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error); + } + } } /* * Test IRadio.changeIccPinForApp() for the response returned. */ TEST_F(RadioHidlTest, changeIccPinForApp) { - radio->changeIccPinForApp(6, hidl_string("test1"), hidl_string("test2"), hidl_string()); - EXPECT_EQ(std::cv_status::no_timeout, wait()); - EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); - EXPECT_EQ(6, radioRsp->rspInfo.serial); + int serial = 1; - EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT); + // 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 == AppType::SIM + || cardStatus.applications[i].appType == AppType::USIM + || cardStatus.applications[i].appType == AppType::RUIM + || cardStatus.applications[i].appType == AppType::CSIM) { + radio->changeIccPinForApp(++serial, hidl_string("test1"), hidl_string("test2"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error); + } + } } /* * Test IRadio.changeIccPin2ForApp() for the response returned. */ TEST_F(RadioHidlTest, changeIccPin2ForApp) { - radio->changeIccPin2ForApp(7, hidl_string("test1"), hidl_string("test2"), hidl_string()); + int serial = 1; + + // 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 == AppType::SIM + || cardStatus.applications[i].appType == AppType::USIM + || cardStatus.applications[i].appType == AppType::RUIM + || cardStatus.applications[i].appType == AppType::CSIM) { + radio->changeIccPin2ForApp(++serial, hidl_string("test1"), hidl_string("test2"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error); + } + } +} + +/* + * Test IRadio.getImsiForApp() for the response returned. + */ +TEST_F(RadioHidlTest, getImsiForApp) { + int serial = 1; + + // 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 == AppType::SIM + || cardStatus.applications[i].appType == AppType::USIM + || cardStatus.applications[i].appType == AppType::RUIM + || cardStatus.applications[i].appType == AppType::CSIM) { + radio->getImsiForApp(++serial, cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); + EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error); + + // IMSI (MCC+MNC+MSIN) is at least 6 digits, but not more than 15 + if (radioRsp->rspInfo.error == RadioError::NONE) { + EXPECT_NE(radioRsp->imsi, hidl_string()); + EXPECT_GE((int) (radioRsp->imsi).size(), 6); + EXPECT_LE((int) (radioRsp->imsi).size(), 15); + } + } + } +} + +/* + * Test IRadio.iccIOForApp() for the response returned. + */ +TEST_F(RadioHidlTest, iccIOForApp) { + int serial = 1; + + for (int i = 0; i < (int) cardStatus.applications.size(); i++) { + IccIo iccIo; + iccIo.command = 0xc0; + iccIo.fileId = 0x6f11; + iccIo.path = hidl_string("3F007FFF"); + iccIo.p1 = 0; + iccIo.p2 = 0; + iccIo.p3 = 0; + iccIo.data = hidl_string(); + iccIo.pin2 = hidl_string(); + iccIo.aid = cardStatus.applications[i].aidPtr; + + radio->iccIOForApp(++serial, iccIo); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); + } +} + +/* + * Test IRadio.iccTransmitApduBasicChannel() for the response returned. + */ +TEST_F(RadioHidlTest, iccTransmitApduBasicChannel) { + int serial = 1; + SimApdu msg; + memset(&msg, 0, sizeof(msg)); + msg.data = hidl_string(); + + radio->iccTransmitApduBasicChannel(serial, msg); EXPECT_EQ(std::cv_status::no_timeout, wait()); EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); - EXPECT_EQ(7, radioRsp->rspInfo.serial); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); - EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT); + // TODO(sanketpadawe): Add test for error code } + +/* + * Test IRadio.iccOpenLogicalChannel() for the response returned. + */ +TEST_F(RadioHidlTest, iccOpenLogicalChannel) { + int serial = 1; + + for (int i = 0; i < (int) cardStatus.applications.size(); i++) { + radio->iccOpenLogicalChannel(++serial, cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + } +} + +/* + * Test IRadio.iccCloseLogicalChannel() for the response returned. + */ +TEST_F(RadioHidlTest, iccCloseLogicalChannel) { + int serial = 1; + // Try closing invalid channel and check INVALID_ARGUMENTS returned as error + radio->iccCloseLogicalChannel(serial, 0); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); + + EXPECT_EQ(RadioError::INVALID_ARGUMENTS, radioRsp->rspInfo.error); +} + +/* + * Test IRadio.iccTransmitApduLogicalChannel() for the response returned. + */ +TEST_F(RadioHidlTest, iccTransmitApduLogicalChannel) { + SimApdu msg; + memset(&msg, 0, sizeof(msg)); + msg.data = hidl_string(); + + radio->iccTransmitApduLogicalChannel(1, msg); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(1, radioRsp->rspInfo.serial); + + // TODO(sanketpadawe): Add test for error code +} + +/* + * Test IRadio.requestIccSimAuthentication() for the response returned. + */ +TEST_F(RadioHidlTest, requestIccSimAuthentication) { + int serial = 1; + + // Pass wrong challenge string and check RadioError::INVALID_ARGUMENTS returned as error. + for (int i = 0; i < (int) cardStatus.applications.size(); i++) { + radio->requestIccSimAuthentication(++serial, 0, hidl_string("test"), + cardStatus.applications[i].aidPtr); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(serial, radioRsp->rspInfo.serial); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(RadioError::INVALID_ARGUMENTS, radioRsp->rspInfo.error); + } +} \ No newline at end of file diff --git a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp index 3bb786d1b9..50b27e956c 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp @@ -27,6 +27,12 @@ void RadioHidlTest::SetUp() { radioInd = NULL; radio->setResponseFunctions(radioRsp, radioInd); + + radio->getIccCardStatus(1); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); + EXPECT_EQ(1, radioRsp->rspInfo.serial); + EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error); } void RadioHidlTest::TearDown() { diff --git a/radio/1.0/vts/functional/radio_hidl_hal_utils.h b/radio/1.0/vts/functional/radio_hidl_hal_utils.h index 732d88e8c8..04292262af 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_utils.h +++ b/radio/1.0/vts/functional/radio_hidl_hal_utils.h @@ -27,6 +27,7 @@ #include using ::android::hardware::radio::V1_0::ActivityStatsInfo; +using ::android::hardware::radio::V1_0::AppType; using ::android::hardware::radio::V1_0::CardStatus; using ::android::hardware::radio::V1_0::Call; using ::android::hardware::radio::V1_0::CallForwardInfo; @@ -39,6 +40,7 @@ using ::android::hardware::radio::V1_0::ClipStatus; using ::android::hardware::radio::V1_0::DataRegStateResult; using ::android::hardware::radio::V1_0::GsmBroadcastSmsConfigInfo; using ::android::hardware::radio::V1_0::HardwareConfig; +using ::android::hardware::radio::V1_0::IccIo; using ::android::hardware::radio::V1_0::IccIoResult; using ::android::hardware::radio::V1_0::IRadio; using ::android::hardware::radio::V1_0::IRadioResponse; @@ -60,6 +62,7 @@ using ::android::hardware::radio::V1_0::RadioTechnologyFamily; using ::android::hardware::radio::V1_0::SendSmsResult; using ::android::hardware::radio::V1_0::SetupDataCallResult; using ::android::hardware::radio::V1_0::SignalStrength; +using ::android::hardware::radio::V1_0::SimApdu; using ::android::hardware::radio::V1_0::TtyMode; using ::android::hardware::radio::V1_0::VoiceRegStateResult; @@ -71,6 +74,7 @@ using ::android::sp; #define TIMEOUT_PERIOD 20 class RadioHidlTest; +extern CardStatus cardStatus; /* Callback class for radio response */ class RadioResponse : public IRadioResponse { @@ -79,7 +83,9 @@ private: public: RadioResponseInfo rspInfo; - CardStatus cardStatus; + hidl_string imsi; + IccIoResult iccIoResult; + int channelId; RadioResponse(RadioHidlTest& parent); @@ -443,6 +449,7 @@ public: sp radio; sp radioRsp; sp radioInd; + }; // A class for test environment setup diff --git a/radio/1.0/vts/functional/radio_response.cpp b/radio/1.0/vts/functional/radio_response.cpp index b2a74f4e0c..c1fec2aa56 100644 --- a/radio/1.0/vts/functional/radio_response.cpp +++ b/radio/1.0/vts/functional/radio_response.cpp @@ -16,6 +16,8 @@ #include +CardStatus cardStatus; + RadioResponse::RadioResponse(RadioHidlTest& parent) : parent(parent) { } @@ -85,6 +87,9 @@ Return RadioResponse::dialResponse(const RadioResponseInfo& info) { Return RadioResponse::getIMSIForAppResponse( const RadioResponseInfo& info, const ::android::hardware::hidl_string& imsi) { + rspInfo = info; + this->imsi = imsi; + parent.notify(); return Void(); } @@ -170,6 +175,9 @@ Return RadioResponse::setupDataCallResponse( Return RadioResponse::iccIOForAppResponse( const RadioResponseInfo& info, const IccIoResult& iccIo) { + rspInfo = info; + this->iccIoResult = iccIo; + parent.notify(); return Void(); } @@ -543,21 +551,32 @@ Return RadioResponse::sendImsSmsResponse( Return RadioResponse::iccTransmitApduBasicChannelResponse( const RadioResponseInfo& info, const IccIoResult& result) { + rspInfo = info; + this->iccIoResult = result; + parent.notify(); return Void(); } Return RadioResponse::iccOpenLogicalChannelResponse( const RadioResponseInfo& info, int32_t channelId, const ::android::hardware::hidl_vec& selectResponse) { + rspInfo = info; + this->channelId = channelId; + parent.notify(); return Void(); } Return RadioResponse::iccCloseLogicalChannelResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent.notify(); return Void(); } Return RadioResponse::iccTransmitApduLogicalChannelResponse( const RadioResponseInfo& info, const IccIoResult& result) { + rspInfo = info; + this->iccIoResult = result; + parent.notify(); return Void(); } @@ -594,6 +613,9 @@ Return RadioResponse::getHardwareConfigResponse( Return RadioResponse::requestIccSimAuthenticationResponse( const RadioResponseInfo& info, const IccIoResult& result) { + rspInfo = info; + this->iccIoResult = result; + parent.notify(); return Void(); }