From 8a6a1d38dc7a761e1477f1e9aedca7f3cbdfbae3 Mon Sep 17 00:00:00 2001 From: Tim Lin Date: Thu, 31 Mar 2022 21:06:57 +0800 Subject: [PATCH] fix SIM related VTS failures 1. Add 6s delay after setSimSlotsMapping because modem needs time to process SIM configuration change. The next TC could fail at checking SIM status if there is no delay. The default SIM configuration on my test device is that physical#0 maps to logical#1 and physical#1 maps to logical#0. When running setSimSlotsMapping, it then becomes physical#0 maps to logical#0 and physical#1 maps to logical#1. 2. Support DSDS case and TSTS case for setSimSlotsMapping. The original code only set for 1 slot and it caused 2nd slot SIM absent when testing with DSDS enabled. 3. Set slotStatus from corresponding physical slot for setSimCardPower. Bug: 227579281 Test: run vts -m VtsHalRadioTargetTest Change-Id: I8c12cb1dbc439655f9de88b1e217b3f34e44ebeb --- radio/aidl/vts/radio_aidl_hal_utils.cpp | 7 +++---- radio/aidl/vts/radio_aidl_hal_utils.h | 3 ++- radio/aidl/vts/radio_config_test.cpp | 12 ++++++++++++ radio/aidl/vts/radio_sim_test.cpp | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/radio/aidl/vts/radio_aidl_hal_utils.cpp b/radio/aidl/vts/radio_aidl_hal_utils.cpp index 861885111f..efc4f26dad 100644 --- a/radio/aidl/vts/radio_aidl_hal_utils.cpp +++ b/radio/aidl/vts/radio_aidl_hal_utils.cpp @@ -206,7 +206,7 @@ void RadioServiceTest::updateSimCardStatus() { EXPECT_EQ(RadioError::NONE, radioSimRsp->rspInfo.error); } -void RadioServiceTest::updateSimSlotStatus() { +void RadioServiceTest::updateSimSlotStatus(int physicalSlotId) { // Update SimSlotStatus from RadioConfig std::shared_ptr radioConfigRsp = ndk::SharedRefBase::make(*this); @@ -219,8 +219,7 @@ void RadioServiceTest::updateSimSlotStatus() { EXPECT_EQ(RadioResponseType::SOLICITED, radioConfigRsp->rspInfo.type); EXPECT_EQ(serial, radioConfigRsp->rspInfo.serial); EXPECT_EQ(RadioError::NONE, radioConfigRsp->rspInfo.error); - // assuming only 1 slot - for (const SimSlotStatus& slotStatusResponse : radioConfigRsp->simSlotStatus) { - slotStatus = slotStatusResponse; + if (radioConfigRsp->simSlotStatus.size() > physicalSlotId) { + slotStatus = radioConfigRsp->simSlotStatus[physicalSlotId]; } } diff --git a/radio/aidl/vts/radio_aidl_hal_utils.h b/radio/aidl/vts/radio_aidl_hal_utils.h index d6f7bf75b6..47976b9099 100644 --- a/radio/aidl/vts/radio_aidl_hal_utils.h +++ b/radio/aidl/vts/radio_aidl_hal_utils.h @@ -70,6 +70,7 @@ static constexpr const char* FEATURE_TELEPHONY_CDMA = "android.hardware.telephon #define MODEM_EMERGENCY_CALL_ESTABLISH_TIME 3 #define MODEM_EMERGENCY_CALL_DISCONNECT_TIME 3 #define MODEM_SET_SIM_POWER_DELAY_IN_SECONDS 2 +#define MODEM_SET_SIM_SLOT_MAPPING_DELAY_IN_SECONDS 6 #define RADIO_SERVICE_SLOT1_NAME "slot1" // HAL instance name for SIM slot 1 or single SIM device #define RADIO_SERVICE_SLOT2_NAME "slot2" // HAL instance name for SIM slot 2 on dual SIM device @@ -146,5 +147,5 @@ class RadioServiceTest { void updateSimCardStatus(); /* Update SIM slot status */ - void updateSimSlotStatus(); + void updateSimSlotStatus(int physicalSlotId); }; diff --git a/radio/aidl/vts/radio_config_test.cpp b/radio/aidl/vts/radio_config_test.cpp index 83c4de0090..5e1c811d91 100644 --- a/radio/aidl/vts/radio_config_test.cpp +++ b/radio/aidl/vts/radio_config_test.cpp @@ -171,6 +171,15 @@ TEST_P(RadioConfigTest, setSimSlotsMapping) { slotPortMapping.physicalSlotId = 0; slotPortMapping.portId = 0; std::vector slotPortMappingList = {slotPortMapping}; + if (isDsDsEnabled()) { + slotPortMapping.physicalSlotId = 1; + slotPortMappingList.push_back(slotPortMapping); + } else if (isTsTsEnabled()) { + slotPortMapping.physicalSlotId = 1; + slotPortMappingList.push_back(slotPortMapping); + slotPortMapping.physicalSlotId = 2; + slotPortMappingList.push_back(slotPortMapping); + } ndk::ScopedAStatus res = radio_config->setSimSlotsMapping(serial, slotPortMappingList); ASSERT_OK(res); EXPECT_EQ(std::cv_status::no_timeout, wait()); @@ -179,6 +188,9 @@ TEST_P(RadioConfigTest, setSimSlotsMapping) { ALOGI("setSimSlotsMapping, rspInfo.error = %s\n", toString(radioRsp_config->rspInfo.error).c_str()); ASSERT_TRUE(CheckAnyOfErrors(radioRsp_config->rspInfo.error, {RadioError::NONE})); + + // Give some time for modem to fully switch SIM configuration + sleep(MODEM_SET_SIM_SLOT_MAPPING_DELAY_IN_SECONDS); } /* diff --git a/radio/aidl/vts/radio_sim_test.cpp b/radio/aidl/vts/radio_sim_test.cpp index f94a2a05b4..e69247d135 100644 --- a/radio/aidl/vts/radio_sim_test.cpp +++ b/radio/aidl/vts/radio_sim_test.cpp @@ -108,7 +108,7 @@ TEST_P(RadioSimTest, setSimCardPower) { // have CardStatus::STATE_PRESENT after turning the power back on if (radioRsp_sim->rspInfo.error == RadioError::NONE) { updateSimCardStatus(); - updateSimSlotStatus(); + updateSimSlotStatus(cardStatus.slotMap.physicalSlotId); EXPECT_EQ(CardStatus::STATE_PRESENT, cardStatus.cardState); EXPECT_EQ(CardStatus::STATE_PRESENT, slotStatus.cardState); if (CardStatus::STATE_PRESENT == slotStatus.cardState) {