Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 17 | #include <aidl/android/hardware/radio/RadioConst.h> |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 18 | #include <aidl/android/hardware/radio/config/IRadioConfig.h> |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 19 | #include <android/binder_manager.h> |
| 20 | |
| 21 | #include "radio_sim_utils.h" |
| 22 | |
| 23 | #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk()) |
| 24 | |
| 25 | void RadioSimTest::SetUp() { |
Sarah Chin | a1efe7a | 2023-05-02 21:11:41 -0700 | [diff] [blame] | 26 | RadioServiceTest::SetUp(); |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 27 | std::string serviceName = GetParam(); |
| 28 | |
| 29 | if (!isServiceValidForDeviceConfiguration(serviceName)) { |
| 30 | ALOGI("Skipped the test due to device configuration."); |
| 31 | GTEST_SKIP(); |
| 32 | } |
| 33 | |
| 34 | radio_sim = IRadioSim::fromBinder( |
| 35 | ndk::SpAIBinder(AServiceManager_waitForService(GetParam().c_str()))); |
| 36 | ASSERT_NE(nullptr, radio_sim.get()); |
| 37 | |
| 38 | radioRsp_sim = ndk::SharedRefBase::make<RadioSimResponse>(*this); |
| 39 | ASSERT_NE(nullptr, radioRsp_sim.get()); |
| 40 | |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 41 | radioInd_sim = ndk::SharedRefBase::make<RadioSimIndication>(*this); |
| 42 | ASSERT_NE(nullptr, radioInd_sim.get()); |
| 43 | |
| 44 | radio_sim->setResponseFunctions(radioRsp_sim, radioInd_sim); |
Sarah Chin | c83bce4 | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 45 | // Assert SIM is present before testing |
| 46 | updateSimCardStatus(); |
| 47 | EXPECT_EQ(CardStatus::STATE_PRESENT, cardStatus.cardState); |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 48 | |
| 49 | // Assert IRadioConfig exists before testing |
Sarah Chin | c83bce4 | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 50 | radio_config = config::IRadioConfig::fromBinder(ndk::SpAIBinder( |
| 51 | AServiceManager_waitForService("android.hardware.radio.config.IRadioConfig/default"))); |
| 52 | ASSERT_NE(nullptr, radio_config.get()); |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Sarah Chin | c83bce4 | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 55 | void RadioSimTest::updateSimCardStatus() { |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 56 | serial = GetRandomSerialNumber(); |
| 57 | radio_sim->getIccCardStatus(serial); |
| 58 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
Sarah Chin | c83bce4 | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 59 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 60 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 61 | EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | /* |
| 65 | * Test IRadioSim.setSimCardPower() for the response returned. |
| 66 | */ |
| 67 | TEST_P(RadioSimTest, setSimCardPower) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 68 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 69 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 70 | GTEST_SKIP() << "Skipping setSimCardPower " |
| 71 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 72 | } |
| 73 | } |
| 74 | |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 75 | /* Test setSimCardPower power down */ |
| 76 | serial = GetRandomSerialNumber(); |
| 77 | radio_sim->setSimCardPower(serial, CardPowerState::POWER_DOWN); |
| 78 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 79 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 80 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 81 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 82 | {RadioError::NONE, RadioError::INVALID_ARGUMENTS, |
| 83 | RadioError::RADIO_NOT_AVAILABLE, RadioError::SIM_ERR})); |
| 84 | |
| 85 | // setSimCardPower does not return until the request is handled, and should not trigger |
| 86 | // CardStatus::STATE_ABSENT when turning off power |
| 87 | if (radioRsp_sim->rspInfo.error == RadioError::NONE) { |
| 88 | /* Wait some time for setting sim power down and then verify it */ |
| 89 | updateSimCardStatus(); |
| 90 | // We cannot assert the consistency of CardState here due to b/203031664 |
| 91 | // EXPECT_EQ(CardStatus::STATE_PRESENT, cardStatus.cardState); |
| 92 | // applications should be an empty vector of AppStatus |
| 93 | EXPECT_EQ(0, cardStatus.applications.size()); |
| 94 | } |
| 95 | |
| 96 | // Give some time for modem to fully power down the SIM card |
| 97 | sleep(MODEM_SET_SIM_POWER_DELAY_IN_SECONDS); |
| 98 | |
| 99 | /* Test setSimCardPower power up */ |
| 100 | serial = GetRandomSerialNumber(); |
| 101 | radio_sim->setSimCardPower(serial, CardPowerState::POWER_UP); |
| 102 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 103 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 104 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 105 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 106 | {RadioError::NONE, RadioError::INVALID_ARGUMENTS, |
| 107 | RadioError::RADIO_NOT_AVAILABLE, RadioError::SIM_ERR})); |
| 108 | |
| 109 | // Give some time for modem to fully power up the SIM card |
| 110 | sleep(MODEM_SET_SIM_POWER_DELAY_IN_SECONDS); |
| 111 | |
| 112 | // setSimCardPower does not return until the request is handled. Just verify that we still |
| 113 | // have CardStatus::STATE_PRESENT after turning the power back on |
| 114 | if (radioRsp_sim->rspInfo.error == RadioError::NONE) { |
| 115 | updateSimCardStatus(); |
Tim Lin | 8a6a1d3 | 2022-03-31 21:06:57 +0800 | [diff] [blame] | 116 | updateSimSlotStatus(cardStatus.slotMap.physicalSlotId); |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 117 | EXPECT_EQ(CardStatus::STATE_PRESENT, cardStatus.cardState); |
sandeepjs | 5561b4b | 2022-02-15 11:41:28 +0000 | [diff] [blame] | 118 | EXPECT_EQ(CardStatus::STATE_PRESENT, slotStatus.cardState); |
| 119 | if (CardStatus::STATE_PRESENT == slotStatus.cardState) { |
| 120 | ASSERT_TRUE(slotStatus.portInfo[0].portActive); |
| 121 | EXPECT_EQ(0, cardStatus.slotMap.portId); |
| 122 | } |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 123 | } |
| 124 | } |
| 125 | |
| 126 | /* |
| 127 | * Test IRadioSim.setCarrierInfoForImsiEncryption() for the response returned. |
| 128 | */ |
| 129 | TEST_P(RadioSimTest, setCarrierInfoForImsiEncryption) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 130 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 131 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 132 | GTEST_SKIP() << "Skipping setCarrierInfoForImsiEncryption " |
| 133 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 134 | } |
| 135 | } |
| 136 | |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 137 | serial = GetRandomSerialNumber(); |
| 138 | ImsiEncryptionInfo imsiInfo; |
| 139 | imsiInfo.mcc = "310"; |
| 140 | imsiInfo.mnc = "004"; |
| 141 | imsiInfo.carrierKey = (std::vector<uint8_t>){1, 2, 3, 4, 5, 6}; |
| 142 | imsiInfo.keyIdentifier = "Test"; |
| 143 | imsiInfo.expirationTime = 20180101; |
| 144 | imsiInfo.keyType = ImsiEncryptionInfo::PUBLIC_KEY_TYPE_EPDG; |
| 145 | |
| 146 | radio_sim->setCarrierInfoForImsiEncryption(serial, imsiInfo); |
| 147 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 148 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 149 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 150 | |
| 151 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 152 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 153 | {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | /* |
| 158 | * Test IRadioSim.getSimPhonebookRecords() for the response returned. |
| 159 | */ |
| 160 | TEST_P(RadioSimTest, getSimPhonebookRecords) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 161 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 162 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 163 | GTEST_SKIP() << "Skipping getSimPhonebookRecords " |
| 164 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 165 | } |
| 166 | } |
| 167 | |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 168 | serial = GetRandomSerialNumber(); |
| 169 | radio_sim->getSimPhonebookRecords(serial); |
| 170 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 171 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 172 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 173 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 174 | ASSERT_TRUE( |
| 175 | CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 176 | {RadioError::INVALID_SIM_STATE, RadioError::RADIO_NOT_AVAILABLE, |
| 177 | RadioError::MODEM_ERR, RadioError::INVALID_ARGUMENTS, |
| 178 | RadioError::REQUEST_NOT_SUPPORTED}, |
| 179 | CHECK_GENERAL_ERROR)); |
| 180 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 181 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 182 | {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}, |
| 183 | CHECK_GENERAL_ERROR)); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | /* |
| 188 | * Test IRadioSim.getSimPhonebookCapacity for the response returned. |
| 189 | */ |
| 190 | TEST_P(RadioSimTest, getSimPhonebookCapacity) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 191 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 192 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 193 | GTEST_SKIP() << "Skipping getSimPhonebookCapacity " |
| 194 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 195 | } |
| 196 | } |
| 197 | |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 198 | serial = GetRandomSerialNumber(); |
| 199 | radio_sim->getSimPhonebookCapacity(serial); |
| 200 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 201 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 202 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 203 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 204 | ASSERT_TRUE( |
| 205 | CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 206 | {RadioError::INVALID_SIM_STATE, RadioError::RADIO_NOT_AVAILABLE, |
| 207 | RadioError::MODEM_ERR, RadioError::INVALID_ARGUMENTS, |
| 208 | RadioError::REQUEST_NOT_SUPPORTED}, |
| 209 | CHECK_GENERAL_ERROR)); |
| 210 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 211 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 212 | {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}, |
| 213 | CHECK_GENERAL_ERROR)); |
| 214 | |
| 215 | PhonebookCapacity pbCapacity = radioRsp_sim->capacity; |
| 216 | if (pbCapacity.maxAdnRecords > 0) { |
| 217 | EXPECT_TRUE(pbCapacity.maxNameLen > 0 && pbCapacity.maxNumberLen > 0); |
| 218 | EXPECT_TRUE(pbCapacity.usedAdnRecords <= pbCapacity.maxAdnRecords); |
| 219 | } |
| 220 | |
| 221 | if (pbCapacity.maxEmailRecords > 0) { |
| 222 | EXPECT_TRUE(pbCapacity.maxEmailLen > 0); |
| 223 | EXPECT_TRUE(pbCapacity.usedEmailRecords <= pbCapacity.maxEmailRecords); |
| 224 | } |
| 225 | |
| 226 | if (pbCapacity.maxAdditionalNumberRecords > 0) { |
| 227 | EXPECT_TRUE(pbCapacity.maxAdditionalNumberLen > 0); |
| 228 | EXPECT_TRUE(pbCapacity.usedAdditionalNumberRecords <= |
| 229 | pbCapacity.maxAdditionalNumberRecords); |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | /* |
| 235 | * Test IRadioSim.updateSimPhonebookRecords() for the response returned. |
| 236 | */ |
| 237 | TEST_P(RadioSimTest, updateSimPhonebookRecords) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 238 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 239 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 240 | GTEST_SKIP() << "Skipping updateSimPhonebookRecords " |
| 241 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 242 | } |
| 243 | } |
| 244 | |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 245 | serial = GetRandomSerialNumber(); |
| 246 | radio_sim->getSimPhonebookCapacity(serial); |
| 247 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 248 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 249 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 250 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 251 | ASSERT_TRUE( |
| 252 | CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 253 | {RadioError::INVALID_SIM_STATE, RadioError::RADIO_NOT_AVAILABLE, |
| 254 | RadioError::MODEM_ERR, RadioError::INVALID_ARGUMENTS, |
| 255 | RadioError::REQUEST_NOT_SUPPORTED}, |
| 256 | CHECK_GENERAL_ERROR)); |
| 257 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 258 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 259 | {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}, |
| 260 | CHECK_GENERAL_ERROR)); |
| 261 | PhonebookCapacity pbCapacity = radioRsp_sim->capacity; |
| 262 | |
| 263 | serial = GetRandomSerialNumber(); |
| 264 | radio_sim->getSimPhonebookRecords(serial); |
| 265 | |
| 266 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 267 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 268 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 269 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 270 | {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}, |
| 271 | CHECK_GENERAL_ERROR)); |
| 272 | |
| 273 | if (pbCapacity.maxAdnRecords > 0 && pbCapacity.usedAdnRecords < pbCapacity.maxAdnRecords) { |
| 274 | // Add a phonebook record |
| 275 | PhonebookRecordInfo recordInfo; |
| 276 | recordInfo.recordId = 0; |
| 277 | recordInfo.name = "ABC"; |
| 278 | recordInfo.number = "1234567890"; |
| 279 | serial = GetRandomSerialNumber(); |
| 280 | radio_sim->updateSimPhonebookRecords(serial, recordInfo); |
| 281 | |
| 282 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 283 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 284 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 285 | EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); |
| 286 | int index = radioRsp_sim->updatedRecordIndex; |
| 287 | EXPECT_TRUE(index > 0); |
| 288 | |
| 289 | // Deleted a phonebook record |
| 290 | recordInfo.recordId = index; |
| 291 | recordInfo.name = ""; |
| 292 | recordInfo.number = ""; |
| 293 | serial = GetRandomSerialNumber(); |
| 294 | radio_sim->updateSimPhonebookRecords(serial, recordInfo); |
| 295 | |
| 296 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 297 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 298 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 299 | EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); |
| 300 | } |
| 301 | } |
| 302 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 303 | |
| 304 | /* |
| 305 | * Test IRadioSim.enableUiccApplications() for the response returned. |
| 306 | * For SIM ABSENT case. |
| 307 | */ |
| 308 | TEST_P(RadioSimTest, togglingUiccApplicationsSimAbsent) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 309 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 310 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 311 | GTEST_SKIP() << "Skipping togglingUiccApplicationsSimAbsent " |
| 312 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 313 | } |
| 314 | } |
| 315 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 316 | // This test case only test SIM ABSENT case. |
| 317 | if (cardStatus.cardState != CardStatus::STATE_ABSENT) return; |
| 318 | |
| 319 | // Disable Uicc applications. |
| 320 | serial = GetRandomSerialNumber(); |
| 321 | radio_sim->enableUiccApplications(serial, false); |
| 322 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 323 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 324 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 325 | // As SIM is absent, RadioError::SIM_ABSENT should be thrown. |
| 326 | EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_sim->rspInfo.error); |
| 327 | |
| 328 | // Query Uicc application enablement. |
| 329 | serial = GetRandomSerialNumber(); |
| 330 | radio_sim->areUiccApplicationsEnabled(serial); |
| 331 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 332 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 333 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 334 | // As SIM is absent, RadioError::SIM_ABSENT should be thrown. |
| 335 | EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_sim->rspInfo.error); |
| 336 | } |
| 337 | |
| 338 | /* |
| 339 | * Test IRadioSim.enableUiccApplications() for the response returned. |
| 340 | * For SIM PRESENT case. |
| 341 | */ |
| 342 | TEST_P(RadioSimTest, togglingUiccApplicationsSimPresent) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 343 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 344 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 345 | GTEST_SKIP() << "Skipping togglingUiccApplicationsSimPresent " |
| 346 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 347 | } |
| 348 | } |
| 349 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 350 | // This test case only test SIM ABSENT case. |
| 351 | if (cardStatus.cardState != CardStatus::STATE_PRESENT) return; |
| 352 | if (cardStatus.applications.size() == 0) return; |
| 353 | |
| 354 | // Disable Uicc applications. |
| 355 | serial = GetRandomSerialNumber(); |
| 356 | radio_sim->enableUiccApplications(serial, false); |
| 357 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 358 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 359 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 360 | // As SIM is present, there shouldn't be error. |
| 361 | EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); |
| 362 | |
| 363 | // Query Uicc application enablement. |
| 364 | serial = GetRandomSerialNumber(); |
| 365 | radio_sim->areUiccApplicationsEnabled(serial); |
| 366 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 367 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 368 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 369 | // As SIM is present, there shouldn't be error. |
| 370 | EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); |
| 371 | ASSERT_FALSE(radioRsp_sim->areUiccApplicationsEnabled); |
| 372 | |
| 373 | // Enable Uicc applications. |
| 374 | serial = GetRandomSerialNumber(); |
| 375 | radio_sim->enableUiccApplications(serial, true); |
| 376 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 377 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 378 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 379 | // As SIM is present, there shouldn't be error. |
| 380 | EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); |
| 381 | |
| 382 | // Query Uicc application enablement. |
| 383 | serial = GetRandomSerialNumber(); |
| 384 | radio_sim->areUiccApplicationsEnabled(serial); |
| 385 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 386 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 387 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 388 | // As SIM is present, there shouldn't be error. |
| 389 | EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); |
| 390 | ASSERT_TRUE(radioRsp_sim->areUiccApplicationsEnabled); |
| 391 | } |
| 392 | |
| 393 | /* |
| 394 | * Test IRadioSim.areUiccApplicationsEnabled() for the response returned. |
| 395 | */ |
| 396 | TEST_P(RadioSimTest, areUiccApplicationsEnabled) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 397 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 398 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 399 | GTEST_SKIP() << "Skipping areUiccApplicationsEnabled " |
| 400 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 401 | } |
| 402 | } |
| 403 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 404 | // Disable Uicc applications. |
| 405 | serial = GetRandomSerialNumber(); |
| 406 | radio_sim->areUiccApplicationsEnabled(serial); |
| 407 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 408 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 409 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 410 | |
| 411 | // If SIM is absent, RadioError::SIM_ABSENT should be thrown. Otherwise there shouldn't be any |
| 412 | // error. |
| 413 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 414 | EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_sim->rspInfo.error); |
| 415 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 416 | EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | /* |
| 421 | * Test IRadioSim.getAllowedCarriers() for the response returned. |
| 422 | */ |
| 423 | TEST_P(RadioSimTest, getAllowedCarriers) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 424 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 425 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 426 | GTEST_SKIP() << "Skipping getAllowedCarriers " |
| 427 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 428 | } |
| 429 | } |
| 430 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 431 | serial = GetRandomSerialNumber(); |
| 432 | |
| 433 | radio_sim->getAllowedCarriers(serial); |
| 434 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 435 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 436 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 437 | |
| 438 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 439 | {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); |
| 440 | } |
| 441 | |
| 442 | /** |
| 443 | * Test IRadioSim.setAllowedCarriers() for the response returned. |
| 444 | */ |
| 445 | TEST_P(RadioSimTest, setAllowedCarriers) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 446 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 447 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 448 | GTEST_SKIP() << "Skipping setAllowedCarriers " |
| 449 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 450 | } |
| 451 | } |
| 452 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 453 | serial = GetRandomSerialNumber(); |
| 454 | CarrierRestrictions carrierRestrictions; |
| 455 | memset(&carrierRestrictions, 0, sizeof(carrierRestrictions)); |
arunvoddu | 902ca98 | 2024-07-25 07:40:37 +0000 | [diff] [blame^] | 456 | int32_t aidl_version; |
| 457 | ndk::ScopedAStatus aidl_status = radio_sim->getInterfaceVersion(&aidl_version); |
| 458 | ASSERT_OK(aidl_status); |
| 459 | |
| 460 | // Changes start |
| 461 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 462 | SimLockMultiSimPolicy multisimPolicy = SimLockMultiSimPolicy::NO_MULTISIM_POLICY; |
arunvoddu | 902ca98 | 2024-07-25 07:40:37 +0000 | [diff] [blame^] | 463 | ALOGI("VTSAllowedCarriers Current AIDL version is %d ", aidl_version); |
| 464 | if (aidl_version <= 2) { |
| 465 | ALOGI("VTSAllowedCarriers If aidl_version is below 3 then , it will consider old AIDLs"); |
| 466 | carrierRestrictions.allowedCarrierInfoList.resize(1); |
| 467 | if ((carrierRestrictions.allowedCarrierInfoList.size() > 0)) { |
| 468 | ALOGI("VTSAllowedCarriers If size of allowedCarrierInfoList is greater than 0"); |
| 469 | } |
| 470 | carrierRestrictions.allowedCarriers.resize(1); |
| 471 | carrierRestrictions.excludedCarriers.resize(0); |
| 472 | carrierRestrictions.allowedCarriers[0].mcc = std::string("123"); |
| 473 | carrierRestrictions.allowedCarriers[0].mnc = std::string("456"); |
| 474 | carrierRestrictions.allowedCarriers[0].matchType = Carrier::MATCH_TYPE_ALL; |
| 475 | carrierRestrictions.allowedCarriers[0].matchData = std::string(); |
| 476 | carrierRestrictions.allowedCarriersPrioritized = true; |
| 477 | multisimPolicy = SimLockMultiSimPolicy::NO_MULTISIM_POLICY; |
| 478 | } else { |
| 479 | carrierRestrictions.allowedCarrierInfoList.resize(1); |
| 480 | carrierRestrictions.excludedCarrierInfoList.resize(0); |
| 481 | carrierRestrictions.allowedCarrierInfoList[0].mcc = std::string("321"); |
| 482 | carrierRestrictions.allowedCarrierInfoList[0].mnc = std::string("654"); |
| 483 | carrierRestrictions.allowedCarrierInfoList[0].spn = std::string("TestNetwork"); |
| 484 | carrierRestrictions.allowedCarrierInfoList[0].gid1 = std::string("BAE000000000000"); |
| 485 | carrierRestrictions.allowedCarrierInfoList[0].gid2 = std::string("AE0000000000000"); |
| 486 | carrierRestrictions.allowedCarrierInfoList[0].imsiPrefix = std::string("9987"); |
| 487 | carrierRestrictions.allowedCarriersPrioritized = true; |
| 488 | carrierRestrictions.status = CarrierRestrictions::CarrierRestrictionStatus::RESTRICTED; |
| 489 | multisimPolicy = SimLockMultiSimPolicy::NO_MULTISIM_POLICY; |
| 490 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 491 | |
| 492 | radio_sim->setAllowedCarriers(serial, carrierRestrictions, multisimPolicy); |
| 493 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 494 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 495 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 496 | |
| 497 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 498 | {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); |
| 499 | |
| 500 | if (radioRsp_sim->rspInfo.error == RadioError::NONE) { |
| 501 | /* Verify the update of the SIM status. This might need some time */ |
| 502 | if (cardStatus.cardState != CardStatus::STATE_ABSENT) { |
| 503 | updateSimCardStatus(); |
| 504 | auto startTime = std::chrono::system_clock::now(); |
| 505 | while (cardStatus.cardState != CardStatus::STATE_RESTRICTED && |
| 506 | std::chrono::duration_cast<std::chrono::seconds>( |
| 507 | std::chrono::system_clock::now() - startTime) |
| 508 | .count() < 30) { |
| 509 | /* Set 2 seconds as interval to check card status */ |
| 510 | sleep(2); |
| 511 | updateSimCardStatus(); |
| 512 | } |
Sarah Chin | 0623bdd | 2022-02-16 11:09:26 -0800 | [diff] [blame] | 513 | // TODO: uncomment once CF fully supports setAllowedCarriers |
| 514 | // EXPECT_EQ(CardStatus::STATE_RESTRICTED, cardStatus.cardState); |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | /* Verify that configuration was set correctly, retrieving it from the modem */ |
| 518 | serial = GetRandomSerialNumber(); |
| 519 | |
| 520 | radio_sim->getAllowedCarriers(serial); |
| 521 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 522 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 523 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 524 | EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); |
| 525 | |
arunvoddu | 902ca98 | 2024-07-25 07:40:37 +0000 | [diff] [blame^] | 526 | if (aidl_version <= 2) { |
| 527 | EXPECT_EQ(1, radioRsp_sim->carrierRestrictionsResp.allowedCarriers.size()); |
| 528 | EXPECT_EQ(0, radioRsp_sim->carrierRestrictionsResp.excludedCarriers.size()); |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 529 | |
arunvoddu | 902ca98 | 2024-07-25 07:40:37 +0000 | [diff] [blame^] | 530 | ASSERT_TRUE(std::string("123") == |
| 531 | radioRsp_sim->carrierRestrictionsResp.allowedCarriers[0].mcc); |
| 532 | ASSERT_TRUE(std::string("456") == |
| 533 | radioRsp_sim->carrierRestrictionsResp.allowedCarriers[0].mnc); |
| 534 | EXPECT_EQ(Carrier::MATCH_TYPE_ALL, |
| 535 | radioRsp_sim->carrierRestrictionsResp.allowedCarriers[0].matchType); |
| 536 | ASSERT_TRUE(radioRsp_sim->carrierRestrictionsResp.allowedCarriersPrioritized); |
| 537 | EXPECT_EQ(SimLockMultiSimPolicy::NO_MULTISIM_POLICY, radioRsp_sim->multiSimPolicyResp); |
| 538 | } else { |
| 539 | EXPECT_EQ(1, radioRsp_sim->carrierRestrictionsResp.allowedCarrierInfoList.size()); |
| 540 | EXPECT_EQ(0, radioRsp_sim->carrierRestrictionsResp.excludedCarrierInfoList.size()); |
| 541 | ASSERT_TRUE(std::string("321") == |
| 542 | radioRsp_sim->carrierRestrictionsResp.allowedCarrierInfoList[0].mcc); |
| 543 | ASSERT_TRUE(std::string("654") == |
| 544 | radioRsp_sim->carrierRestrictionsResp.allowedCarrierInfoList[0].mnc); |
| 545 | ASSERT_TRUE(std::string("BAE000000000000") == |
| 546 | radioRsp_sim->carrierRestrictionsResp.allowedCarrierInfoList[0].gid1); |
| 547 | ASSERT_TRUE(std::string("AE0000000000000") == |
| 548 | radioRsp_sim->carrierRestrictionsResp.allowedCarrierInfoList[0].gid2); |
| 549 | ASSERT_TRUE(std::string("9987") == |
| 550 | radioRsp_sim->carrierRestrictionsResp.allowedCarrierInfoList[0].imsiPrefix); |
| 551 | ASSERT_TRUE(radioRsp_sim->carrierRestrictionsResp.allowedCarriersPrioritized); |
| 552 | EXPECT_EQ(CarrierRestrictions::CarrierRestrictionStatus::RESTRICTED, |
| 553 | radioRsp_sim->carrierRestrictionsResp.status); |
| 554 | EXPECT_EQ(SimLockMultiSimPolicy::NO_MULTISIM_POLICY, radioRsp_sim->multiSimPolicyResp); |
| 555 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 556 | sleep(10); |
| 557 | |
| 558 | /** |
| 559 | * Another test case of the API to cover to allow carrier. |
| 560 | * If the API is supported, this is also used to reset to no carrier restriction |
| 561 | * status for cardStatus. |
| 562 | */ |
| 563 | memset(&carrierRestrictions, 0, sizeof(carrierRestrictions)); |
arunvoddu | 902ca98 | 2024-07-25 07:40:37 +0000 | [diff] [blame^] | 564 | if (aidl_version <= 2) { |
| 565 | carrierRestrictions.allowedCarriers.resize(0); |
| 566 | carrierRestrictions.excludedCarriers.resize(0); |
| 567 | carrierRestrictions.allowedCarriersPrioritized = false; |
| 568 | } else { |
| 569 | carrierRestrictions.allowedCarrierInfoList.resize(0); |
| 570 | carrierRestrictions.excludedCarrierInfoList.resize(0); |
| 571 | carrierRestrictions.allowedCarriersPrioritized = false; |
| 572 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 573 | |
| 574 | serial = GetRandomSerialNumber(); |
| 575 | radio_sim->setAllowedCarriers(serial, carrierRestrictions, multisimPolicy); |
| 576 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 577 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 578 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 579 | |
| 580 | EXPECT_EQ(RadioError::NONE, radioRsp_sim->rspInfo.error); |
| 581 | |
| 582 | if (cardStatus.cardState != CardStatus::STATE_ABSENT) { |
| 583 | /* Resetting back to no carrier restriction needs some time */ |
| 584 | updateSimCardStatus(); |
| 585 | auto startTime = std::chrono::system_clock::now(); |
| 586 | while (cardStatus.cardState == CardStatus::STATE_RESTRICTED && |
| 587 | std::chrono::duration_cast<std::chrono::seconds>( |
| 588 | std::chrono::system_clock::now() - startTime) |
| 589 | .count() < 10) { |
| 590 | /* Set 2 seconds as interval to check card status */ |
| 591 | sleep(2); |
| 592 | updateSimCardStatus(); |
| 593 | } |
| 594 | EXPECT_NE(CardStatus::STATE_RESTRICTED, cardStatus.cardState); |
| 595 | sleep(10); |
| 596 | } |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | /* |
| 601 | * Test IRadioSim.getIccCardStatus() for the response returned. |
| 602 | */ |
| 603 | TEST_P(RadioSimTest, getIccCardStatus) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 604 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 605 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 606 | GTEST_SKIP() << "Skipping getIccCardStatus " |
| 607 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 608 | } |
| 609 | } |
| 610 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 611 | EXPECT_LE(cardStatus.applications.size(), RadioConst::CARD_MAX_APPS); |
| 612 | EXPECT_LT(cardStatus.gsmUmtsSubscriptionAppIndex, RadioConst::CARD_MAX_APPS); |
| 613 | EXPECT_LT(cardStatus.cdmaSubscriptionAppIndex, RadioConst::CARD_MAX_APPS); |
| 614 | EXPECT_LT(cardStatus.imsSubscriptionAppIndex, RadioConst::CARD_MAX_APPS); |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | /* |
| 618 | * Test IRadioSim.supplyIccPinForApp() for the response returned |
| 619 | */ |
| 620 | TEST_P(RadioSimTest, supplyIccPinForApp) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 621 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 622 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 623 | GTEST_SKIP() << "Skipping supplyIccPinForApp " |
| 624 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 625 | } |
| 626 | } |
| 627 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 628 | serial = GetRandomSerialNumber(); |
| 629 | |
| 630 | // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and |
| 631 | // 3GPP2 apps only |
| 632 | for (int i = 0; i < (int)cardStatus.applications.size(); i++) { |
| 633 | if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || |
| 634 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || |
| 635 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || |
| 636 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { |
| 637 | radio_sim->supplyIccPinForApp(serial, std::string("test1"), |
| 638 | cardStatus.applications[i].aidPtr); |
| 639 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 640 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 641 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 642 | ASSERT_TRUE(CheckAnyOfErrors( |
| 643 | radioRsp_sim->rspInfo.error, |
| 644 | {RadioError::PASSWORD_INCORRECT, RadioError::REQUEST_NOT_SUPPORTED})); |
| 645 | } |
| 646 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | /* |
| 650 | * Test IRadioSim.supplyIccPukForApp() for the response returned. |
| 651 | */ |
| 652 | TEST_P(RadioSimTest, supplyIccPukForApp) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 653 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 654 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 655 | GTEST_SKIP() << "Skipping supplyIccPukForApp " |
| 656 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 657 | } |
| 658 | } |
| 659 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 660 | serial = GetRandomSerialNumber(); |
| 661 | |
| 662 | // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and |
| 663 | // 3GPP2 apps only |
| 664 | for (int i = 0; i < (int)cardStatus.applications.size(); i++) { |
| 665 | if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || |
| 666 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || |
| 667 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || |
| 668 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { |
| 669 | radio_sim->supplyIccPukForApp(serial, std::string("test1"), std::string("test2"), |
| 670 | cardStatus.applications[i].aidPtr); |
| 671 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 672 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 673 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 674 | ASSERT_TRUE(CheckAnyOfErrors( |
| 675 | radioRsp_sim->rspInfo.error, |
| 676 | {RadioError::PASSWORD_INCORRECT, RadioError::INVALID_SIM_STATE})); |
| 677 | } |
| 678 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | /* |
| 682 | * Test IRadioSim.supplyIccPin2ForApp() for the response returned. |
| 683 | */ |
| 684 | TEST_P(RadioSimTest, supplyIccPin2ForApp) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 685 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 686 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 687 | GTEST_SKIP() << "Skipping supplyIccPin2ForApp " |
| 688 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 689 | } |
| 690 | } |
| 691 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 692 | serial = GetRandomSerialNumber(); |
| 693 | |
| 694 | // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and |
| 695 | // 3GPP2 apps only |
| 696 | for (int i = 0; i < (int)cardStatus.applications.size(); i++) { |
| 697 | if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || |
| 698 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || |
| 699 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || |
| 700 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { |
| 701 | radio_sim->supplyIccPin2ForApp(serial, std::string("test1"), |
| 702 | cardStatus.applications[i].aidPtr); |
| 703 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 704 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 705 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 706 | ASSERT_TRUE( |
| 707 | CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 708 | {RadioError::PASSWORD_INCORRECT, |
| 709 | RadioError::REQUEST_NOT_SUPPORTED, RadioError::SIM_PUK2})); |
| 710 | } |
| 711 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | /* |
| 715 | * Test IRadioSim.supplyIccPuk2ForApp() for the response returned. |
| 716 | */ |
| 717 | TEST_P(RadioSimTest, supplyIccPuk2ForApp) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 718 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 719 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 720 | GTEST_SKIP() << "Skipping supplyIccPuk2ForApp " |
| 721 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 722 | } |
| 723 | } |
| 724 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 725 | serial = GetRandomSerialNumber(); |
| 726 | |
| 727 | // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and |
| 728 | // 3GPP2 apps only |
| 729 | for (int i = 0; i < (int)cardStatus.applications.size(); i++) { |
| 730 | if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || |
| 731 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || |
| 732 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || |
| 733 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { |
| 734 | radio_sim->supplyIccPuk2ForApp(serial, std::string("test1"), std::string("test2"), |
| 735 | cardStatus.applications[i].aidPtr); |
| 736 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 737 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 738 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 739 | ASSERT_TRUE(CheckAnyOfErrors( |
| 740 | radioRsp_sim->rspInfo.error, |
| 741 | {RadioError::PASSWORD_INCORRECT, RadioError::INVALID_SIM_STATE})); |
| 742 | } |
| 743 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | /* |
| 747 | * Test IRadioSim.changeIccPinForApp() for the response returned. |
| 748 | */ |
| 749 | TEST_P(RadioSimTest, changeIccPinForApp) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 750 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 751 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 752 | GTEST_SKIP() << "Skipping changeIccPinForApp " |
| 753 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 754 | } |
| 755 | } |
| 756 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 757 | serial = GetRandomSerialNumber(); |
| 758 | |
| 759 | // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and |
| 760 | // 3GPP2 apps only |
| 761 | for (int i = 0; i < (int)cardStatus.applications.size(); i++) { |
| 762 | if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || |
| 763 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || |
| 764 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || |
| 765 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { |
| 766 | radio_sim->changeIccPinForApp(serial, std::string("test1"), std::string("test2"), |
| 767 | cardStatus.applications[i].aidPtr); |
| 768 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 769 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 770 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 771 | ASSERT_TRUE(CheckAnyOfErrors( |
| 772 | radioRsp_sim->rspInfo.error, |
| 773 | {RadioError::PASSWORD_INCORRECT, RadioError::REQUEST_NOT_SUPPORTED})); |
| 774 | } |
| 775 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 776 | } |
| 777 | |
| 778 | /* |
| 779 | * Test IRadioSim.changeIccPin2ForApp() for the response returned. |
| 780 | */ |
| 781 | TEST_P(RadioSimTest, changeIccPin2ForApp) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 782 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 783 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 784 | GTEST_SKIP() << "Skipping changeIccPin2ForApp " |
| 785 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 786 | } |
| 787 | } |
| 788 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 789 | serial = GetRandomSerialNumber(); |
| 790 | |
| 791 | // Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and |
| 792 | // 3GPP2 apps only |
| 793 | for (int i = 0; i < (int)cardStatus.applications.size(); i++) { |
| 794 | if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || |
| 795 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || |
| 796 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || |
| 797 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { |
| 798 | radio_sim->changeIccPin2ForApp(serial, std::string("test1"), std::string("test2"), |
| 799 | cardStatus.applications[i].aidPtr); |
| 800 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 801 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 802 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 803 | ASSERT_TRUE( |
| 804 | CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 805 | {RadioError::PASSWORD_INCORRECT, |
| 806 | RadioError::REQUEST_NOT_SUPPORTED, RadioError::SIM_PUK2})); |
| 807 | } |
| 808 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | /* |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 812 | * Test IRadioSim.getImsiForApp() for the response returned. |
| 813 | */ |
Sarah Chin | ca421a6 | 2022-01-28 15:54:36 -0800 | [diff] [blame] | 814 | TEST_P(RadioSimTest, getImsiForApp) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 815 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 816 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 817 | GTEST_SKIP() << "Skipping getImsiForApp " |
| 818 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 819 | } |
| 820 | } |
| 821 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 822 | serial = GetRandomSerialNumber(); |
| 823 | |
| 824 | // Check success returned while getting imsi for 3GPP and 3GPP2 apps only |
| 825 | for (int i = 0; i < (int)cardStatus.applications.size(); i++) { |
| 826 | if (cardStatus.applications[i].appType == AppStatus::APP_TYPE_SIM || |
| 827 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_USIM || |
| 828 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_RUIM || |
| 829 | cardStatus.applications[i].appType == AppStatus::APP_TYPE_CSIM) { |
| 830 | radio_sim->getImsiForApp(serial, cardStatus.applications[i].aidPtr); |
| 831 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 832 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 833 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 834 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, {RadioError::NONE}, |
| 835 | CHECK_GENERAL_ERROR)); |
| 836 | |
| 837 | // IMSI (MCC+MNC+MSIN) is at least 6 digits, but not more than 15 |
| 838 | if (radioRsp_sim->rspInfo.error == RadioError::NONE) { |
| 839 | EXPECT_NE(radioRsp_sim->imsi, std::string()); |
| 840 | EXPECT_GE((int)(radioRsp_sim->imsi).size(), 6); |
| 841 | EXPECT_LE((int)(radioRsp_sim->imsi).size(), 15); |
| 842 | } |
| 843 | } |
| 844 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | /* |
| 848 | * Test IRadioSim.iccIoForApp() for the response returned. |
| 849 | */ |
| 850 | TEST_P(RadioSimTest, iccIoForApp) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 851 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 852 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 853 | GTEST_SKIP() << "Skipping iccIoForApp " |
| 854 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 855 | } |
| 856 | } |
| 857 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 858 | serial = GetRandomSerialNumber(); |
| 859 | |
| 860 | for (int i = 0; i < (int)cardStatus.applications.size(); i++) { |
| 861 | IccIo iccIo; |
| 862 | iccIo.command = 0xc0; |
| 863 | iccIo.fileId = 0x6f11; |
| 864 | iccIo.path = std::string("3F007FFF"); |
| 865 | iccIo.p1 = 0; |
| 866 | iccIo.p2 = 0; |
| 867 | iccIo.p3 = 0; |
| 868 | iccIo.data = std::string(); |
| 869 | iccIo.pin2 = std::string(); |
| 870 | iccIo.aid = cardStatus.applications[i].aidPtr; |
| 871 | |
| 872 | radio_sim->iccIoForApp(serial, iccIo); |
| 873 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 874 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 875 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 876 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 877 | } |
| 878 | |
| 879 | /* |
| 880 | * Test IRadioSim.iccTransmitApduBasicChannel() for the response returned. |
| 881 | */ |
| 882 | TEST_P(RadioSimTest, iccTransmitApduBasicChannel) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 883 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 884 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 885 | GTEST_SKIP() << "Skipping iccTransmitApduBasicChannel " |
| 886 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 887 | } |
| 888 | } |
| 889 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 890 | serial = GetRandomSerialNumber(); |
| 891 | SimApdu msg; |
| 892 | memset(&msg, 0, sizeof(msg)); |
| 893 | msg.data = std::string(); |
| 894 | |
| 895 | radio_sim->iccTransmitApduBasicChannel(serial, msg); |
| 896 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 897 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 898 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 899 | } |
| 900 | |
| 901 | /* |
| 902 | * Test IRadioSim.iccOpenLogicalChannel() for the response returned. |
| 903 | */ |
| 904 | TEST_P(RadioSimTest, iccOpenLogicalChannel) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 905 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 906 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 907 | GTEST_SKIP() << "Skipping iccOpenLogicalChannel " |
| 908 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 909 | } |
| 910 | } |
| 911 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 912 | serial = GetRandomSerialNumber(); |
| 913 | int p2 = 0x04; |
| 914 | // Specified in ISO 7816-4 clause 7.1.1 0x04 means that FCP template is requested. |
| 915 | for (int i = 0; i < (int)cardStatus.applications.size(); i++) { |
| 916 | radio_sim->iccOpenLogicalChannel(serial, cardStatus.applications[i].aidPtr, p2); |
| 917 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 918 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 919 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 920 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 921 | } |
| 922 | |
| 923 | /* |
| 924 | * Test IRadioSim.iccCloseLogicalChannel() for the response returned. |
| 925 | */ |
| 926 | TEST_P(RadioSimTest, iccCloseLogicalChannel) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 927 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 928 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 929 | GTEST_SKIP() << "Skipping iccCloseLogicalChannel " |
| 930 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 931 | } |
| 932 | } |
| 933 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 934 | serial = GetRandomSerialNumber(); |
| 935 | // Try closing invalid channel and check INVALID_ARGUMENTS returned as error |
| 936 | radio_sim->iccCloseLogicalChannel(serial, 0); |
| 937 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 938 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 939 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 940 | |
| 941 | EXPECT_EQ(RadioError::INVALID_ARGUMENTS, radioRsp_sim->rspInfo.error); |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | /* |
Muralidhar Reddy | c13d0d6 | 2023-01-18 18:45:14 +0000 | [diff] [blame] | 945 | * Test IRadioSim.iccCloseLogicalChannelWithSessionInfo() for the response returned. |
| 946 | */ |
| 947 | TEST_P(RadioSimTest, iccCloseLogicalChannelWithSessionInfo) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 948 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 949 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 950 | GTEST_SKIP() << "Skipping iccCloseLogicalChannelWithSessionInfo " |
| 951 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 952 | } |
| 953 | } |
| 954 | |
Muralidhar Reddy | eb1c617 | 2023-04-12 12:55:19 +0000 | [diff] [blame] | 955 | int32_t aidl_version; |
| 956 | ndk::ScopedAStatus aidl_status = radio_sim->getInterfaceVersion(&aidl_version); |
| 957 | ASSERT_OK(aidl_status); |
| 958 | if (aidl_version < 2) { |
| 959 | ALOGI("Skipped the test since" |
| 960 | " iccCloseLogicalChannelWithSessionInfo is not supported on version < 2"); |
| 961 | GTEST_SKIP(); |
| 962 | } |
Muralidhar Reddy | c13d0d6 | 2023-01-18 18:45:14 +0000 | [diff] [blame] | 963 | serial = GetRandomSerialNumber(); |
| 964 | SessionInfo info; |
| 965 | memset(&info, 0, sizeof(info)); |
| 966 | info.sessionId = 0; |
| 967 | info.isEs10 = false; |
| 968 | |
| 969 | // Try closing invalid channel and check INVALID_ARGUMENTS returned as error |
| 970 | radio_sim->iccCloseLogicalChannelWithSessionInfo(serial, info); |
| 971 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 972 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 973 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 974 | |
| 975 | EXPECT_EQ(RadioError::INVALID_ARGUMENTS, radioRsp_sim->rspInfo.error); |
Muralidhar Reddy | c13d0d6 | 2023-01-18 18:45:14 +0000 | [diff] [blame] | 976 | } |
| 977 | |
| 978 | /* |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 979 | * Test IRadioSim.iccTransmitApduLogicalChannel() for the response returned. |
| 980 | */ |
| 981 | TEST_P(RadioSimTest, iccTransmitApduLogicalChannel) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 982 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 983 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 984 | GTEST_SKIP() << "Skipping iccTransmitApduLogicalChannel " |
| 985 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 986 | } |
| 987 | } |
| 988 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 989 | serial = GetRandomSerialNumber(); |
| 990 | SimApdu msg; |
| 991 | memset(&msg, 0, sizeof(msg)); |
| 992 | msg.data = std::string(); |
| 993 | |
| 994 | radio_sim->iccTransmitApduLogicalChannel(serial, msg); |
| 995 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 996 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 997 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | /* |
| 1001 | * Test IRadioSim.requestIccSimAuthentication() for the response returned. |
| 1002 | */ |
| 1003 | TEST_P(RadioSimTest, requestIccSimAuthentication) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 1004 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 1005 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 1006 | GTEST_SKIP() << "Skipping requestIccSimAuthentication " |
| 1007 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 1008 | } |
| 1009 | } |
| 1010 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1011 | serial = GetRandomSerialNumber(); |
| 1012 | |
| 1013 | // Pass wrong challenge string and check RadioError::INVALID_ARGUMENTS |
| 1014 | // or REQUEST_NOT_SUPPORTED returned as error. |
| 1015 | for (int i = 0; i < (int)cardStatus.applications.size(); i++) { |
| 1016 | radio_sim->requestIccSimAuthentication(serial, 0, std::string("test"), |
| 1017 | cardStatus.applications[i].aidPtr); |
| 1018 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 1019 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 1020 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 1021 | ASSERT_TRUE(CheckAnyOfErrors( |
| 1022 | radioRsp_sim->rspInfo.error, |
| 1023 | {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); |
| 1024 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | /* |
| 1028 | * Test IRadioSim.getFacilityLockForApp() for the response returned. |
| 1029 | */ |
| 1030 | TEST_P(RadioSimTest, getFacilityLockForApp) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 1031 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 1032 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 1033 | GTEST_SKIP() << "Skipping getFacilityLockForApp " |
| 1034 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 1035 | } |
| 1036 | } |
| 1037 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1038 | serial = GetRandomSerialNumber(); |
| 1039 | std::string facility = ""; |
| 1040 | std::string password = ""; |
| 1041 | int32_t serviceClass = 1; |
| 1042 | std::string appId = ""; |
| 1043 | |
| 1044 | radio_sim->getFacilityLockForApp(serial, facility, password, serviceClass, appId); |
| 1045 | |
| 1046 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 1047 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 1048 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 1049 | |
| 1050 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 1051 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 1052 | {RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR}, |
| 1053 | CHECK_GENERAL_ERROR)); |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | /* |
| 1058 | * Test IRadioSim.setFacilityLockForApp() for the response returned. |
| 1059 | */ |
| 1060 | TEST_P(RadioSimTest, setFacilityLockForApp) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 1061 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 1062 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 1063 | GTEST_SKIP() << "Skipping setFacilityLockForApp " |
| 1064 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 1065 | } |
| 1066 | } |
| 1067 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1068 | serial = GetRandomSerialNumber(); |
| 1069 | std::string facility = ""; |
| 1070 | bool lockState = false; |
| 1071 | std::string password = ""; |
| 1072 | int32_t serviceClass = 1; |
| 1073 | std::string appId = ""; |
| 1074 | |
| 1075 | radio_sim->setFacilityLockForApp(serial, facility, lockState, password, serviceClass, appId); |
| 1076 | |
| 1077 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 1078 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 1079 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 1080 | |
| 1081 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 1082 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 1083 | {RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR}, |
| 1084 | CHECK_GENERAL_ERROR)); |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | /* |
| 1089 | * Test IRadioSim.getCdmaSubscription() for the response returned. |
| 1090 | */ |
| 1091 | TEST_P(RadioSimTest, getCdmaSubscription) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 1092 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 1093 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) { |
| 1094 | GTEST_SKIP() << "Skipping getCdmaSubscription " |
| 1095 | "due to undefined FEATURE_TELEPHONY_CDMA"; |
| 1096 | } |
| 1097 | } |
| 1098 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1099 | serial = GetRandomSerialNumber(); |
| 1100 | |
| 1101 | radio_sim->getCdmaSubscription(serial); |
| 1102 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 1103 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 1104 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 1105 | |
| 1106 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 1107 | ASSERT_TRUE(CheckAnyOfErrors( |
| 1108 | radioRsp_sim->rspInfo.error, |
| 1109 | {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED, RadioError::SIM_ABSENT})); |
| 1110 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1111 | } |
| 1112 | |
| 1113 | /* |
| 1114 | * Test IRadioSim.getCdmaSubscriptionSource() for the response returned. |
| 1115 | */ |
| 1116 | TEST_P(RadioSimTest, getCdmaSubscriptionSource) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 1117 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 1118 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) { |
| 1119 | GTEST_SKIP() << "Skipping getCdmaSubscriptionSource " |
| 1120 | "due to undefined FEATURE_TELEPHONY_CDMA"; |
| 1121 | } |
| 1122 | } |
| 1123 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1124 | serial = GetRandomSerialNumber(); |
| 1125 | |
| 1126 | radio_sim->getCdmaSubscriptionSource(serial); |
| 1127 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 1128 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 1129 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 1130 | |
| 1131 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 1132 | ASSERT_TRUE(CheckAnyOfErrors( |
| 1133 | radioRsp_sim->rspInfo.error, |
| 1134 | {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED, RadioError::SIM_ABSENT})); |
| 1135 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1136 | } |
| 1137 | |
| 1138 | /* |
| 1139 | * Test IRadioSim.setCdmaSubscriptionSource() for the response returned. |
| 1140 | */ |
| 1141 | TEST_P(RadioSimTest, setCdmaSubscriptionSource) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 1142 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 1143 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) { |
| 1144 | GTEST_SKIP() << "Skipping setCdmaSubscriptionSource " |
| 1145 | "due to undefined FEATURE_TELEPHONY_CDMA"; |
| 1146 | } |
| 1147 | } |
| 1148 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1149 | serial = GetRandomSerialNumber(); |
| 1150 | |
| 1151 | radio_sim->setCdmaSubscriptionSource(serial, CdmaSubscriptionSource::RUIM_SIM); |
| 1152 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 1153 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 1154 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 1155 | |
| 1156 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 1157 | ASSERT_TRUE(CheckAnyOfErrors( |
| 1158 | radioRsp_sim->rspInfo.error, |
| 1159 | {RadioError::NONE, RadioError::SIM_ABSENT, RadioError::SUBSCRIPTION_NOT_AVAILABLE}, |
| 1160 | CHECK_GENERAL_ERROR)); |
| 1161 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | /* |
| 1165 | * Test IRadioSim.setUiccSubscription() for the response returned. |
| 1166 | */ |
| 1167 | TEST_P(RadioSimTest, setUiccSubscription) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 1168 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 1169 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 1170 | GTEST_SKIP() << "Skipping setUiccSubscription " |
| 1171 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 1172 | } |
| 1173 | } |
| 1174 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1175 | serial = GetRandomSerialNumber(); |
| 1176 | SelectUiccSub item; |
| 1177 | memset(&item, 0, sizeof(item)); |
| 1178 | |
| 1179 | radio_sim->setUiccSubscription(serial, item); |
| 1180 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 1181 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 1182 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 1183 | |
| 1184 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 1185 | ASSERT_TRUE( |
| 1186 | CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 1187 | {RadioError::NONE, RadioError::INVALID_ARGUMENTS, |
| 1188 | RadioError::MODEM_ERR, RadioError::SUBSCRIPTION_NOT_SUPPORTED}, |
| 1189 | CHECK_GENERAL_ERROR)); |
| 1190 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1191 | } |
| 1192 | |
| 1193 | /* |
| 1194 | * Test IRadioSim.sendEnvelope() for the response returned. |
| 1195 | */ |
| 1196 | TEST_P(RadioSimTest, sendEnvelope) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 1197 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 1198 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 1199 | GTEST_SKIP() << "Skipping sendEnvelope " |
| 1200 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 1201 | } |
| 1202 | } |
| 1203 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1204 | serial = GetRandomSerialNumber(); |
| 1205 | |
| 1206 | // Test with sending empty string |
| 1207 | std::string content = ""; |
| 1208 | |
| 1209 | radio_sim->sendEnvelope(serial, content); |
| 1210 | |
| 1211 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 1212 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 1213 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 1214 | |
| 1215 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 1216 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, |
| 1217 | {RadioError::NONE, RadioError::INVALID_ARGUMENTS, |
| 1218 | RadioError::MODEM_ERR, RadioError::SIM_ABSENT}, |
| 1219 | CHECK_GENERAL_ERROR)); |
| 1220 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1221 | } |
| 1222 | |
| 1223 | /* |
| 1224 | * Test IRadioSim.sendTerminalResponseToSim() for the response returned. |
| 1225 | */ |
| 1226 | TEST_P(RadioSimTest, sendTerminalResponseToSim) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 1227 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 1228 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 1229 | GTEST_SKIP() << "Skipping sendTerminalResponseToSim " |
| 1230 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 1231 | } |
| 1232 | } |
| 1233 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1234 | serial = GetRandomSerialNumber(); |
| 1235 | |
| 1236 | // Test with sending empty string |
| 1237 | std::string commandResponse = ""; |
| 1238 | |
| 1239 | radio_sim->sendTerminalResponseToSim(serial, commandResponse); |
| 1240 | |
| 1241 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 1242 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 1243 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 1244 | |
| 1245 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 1246 | ASSERT_TRUE(CheckAnyOfErrors( |
| 1247 | radioRsp_sim->rspInfo.error, |
| 1248 | {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::SIM_ABSENT}, |
| 1249 | CHECK_GENERAL_ERROR)); |
| 1250 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1251 | } |
| 1252 | |
| 1253 | /* |
| 1254 | * Test IRadioSim.reportStkServiceIsRunning() for the response returned. |
| 1255 | */ |
| 1256 | TEST_P(RadioSimTest, reportStkServiceIsRunning) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 1257 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 1258 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 1259 | GTEST_SKIP() << "Skipping reportStkServiceIsRunning " |
| 1260 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 1261 | } |
| 1262 | } |
| 1263 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1264 | serial = GetRandomSerialNumber(); |
| 1265 | |
| 1266 | radio_sim->reportStkServiceIsRunning(serial); |
| 1267 | |
| 1268 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 1269 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 1270 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 1271 | |
| 1272 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 1273 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_sim->rspInfo.error, {RadioError::NONE}, |
| 1274 | CHECK_GENERAL_ERROR)); |
| 1275 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1276 | } |
| 1277 | |
| 1278 | /* |
| 1279 | * Test IRadioSim.sendEnvelopeWithStatus() for the response returned with empty |
| 1280 | * string. |
| 1281 | */ |
| 1282 | TEST_P(RadioSimTest, sendEnvelopeWithStatus) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame] | 1283 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 1284 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_SUBSCRIPTION)) { |
| 1285 | GTEST_SKIP() << "Skipping sendEnvelopeWithStatus " |
| 1286 | "due to undefined FEATURE_TELEPHONY_SUBSCRIPTION"; |
| 1287 | } |
| 1288 | } |
| 1289 | |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1290 | serial = GetRandomSerialNumber(); |
| 1291 | |
| 1292 | // Test with sending empty string |
| 1293 | std::string contents = ""; |
| 1294 | |
| 1295 | radio_sim->sendEnvelopeWithStatus(serial, contents); |
| 1296 | |
| 1297 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 1298 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_sim->rspInfo.type); |
| 1299 | EXPECT_EQ(serial, radioRsp_sim->rspInfo.serial); |
| 1300 | |
| 1301 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 1302 | ASSERT_TRUE(CheckAnyOfErrors( |
| 1303 | radioRsp_sim->rspInfo.error, |
| 1304 | {RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR, RadioError::SIM_ABSENT}, |
| 1305 | CHECK_GENERAL_ERROR)); |
| 1306 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 1307 | } |