1 /* 2 * Copyright (C) 2017 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 17 #include <radio_hidl_hal_utils_v1_0.h> 18 19 /* 20 * Test IRadio.getSignalStrength() for the response returned. 21 */ 22 TEST_F(RadioHidlTest, getSignalStrength) { 23 int serial = GetRandomSerialNumber(); 24 25 radio->getSignalStrength(serial); 26 EXPECT_EQ(std::cv_status::no_timeout, wait()); 27 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 28 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 29 30 if (cardStatus.cardState == CardState::ABSENT) { 31 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 32 } 33 } 34 35 /* 36 * Test IRadio.getVoiceRegistrationState() for the response returned. 37 */ 38 TEST_F(RadioHidlTest, getVoiceRegistrationState) { 39 int serial = GetRandomSerialNumber(); 40 41 radio->getVoiceRegistrationState(serial); 42 EXPECT_EQ(std::cv_status::no_timeout, wait()); 43 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 44 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 45 46 if (cardStatus.cardState == CardState::ABSENT) { 47 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 48 } 49 } 50 51 /* 52 * Test IRadio.getOperator() for the response returned. 53 */ 54 TEST_F(RadioHidlTest, getOperator) { 55 int serial = GetRandomSerialNumber(); 56 57 radio->getOperator(serial); 58 EXPECT_EQ(std::cv_status::no_timeout, wait()); 59 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 60 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 61 62 if (cardStatus.cardState == CardState::ABSENT) { 63 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 64 } 65 } 66 67 /* 68 * Test IRadio.setRadioPower() for the response returned. 69 */ 70 TEST_F(RadioHidlTest, setRadioPower) { 71 int serial = GetRandomSerialNumber(); 72 73 radio->setRadioPower(serial, 1); 74 EXPECT_EQ(std::cv_status::no_timeout, wait()); 75 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 76 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 77 78 if (cardStatus.cardState == CardState::ABSENT) { 79 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 80 } 81 } 82 83 /* 84 * Test IRadio.getNetworkSelectionMode() for the response returned. 85 */ 86 TEST_F(RadioHidlTest, getNetworkSelectionMode) { 87 int serial = GetRandomSerialNumber(); 88 89 radio->getNetworkSelectionMode(serial); 90 EXPECT_EQ(std::cv_status::no_timeout, wait()); 91 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 92 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 93 94 if (cardStatus.cardState == CardState::ABSENT) { 95 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 96 } 97 } 98 99 /* 100 * Test IRadio.setNetworkSelectionModeAutomatic() for the response returned. 101 */ 102 TEST_F(RadioHidlTest, setNetworkSelectionModeAutomatic) { 103 int serial = GetRandomSerialNumber(); 104 105 radio->setNetworkSelectionModeAutomatic(serial); 106 EXPECT_EQ(std::cv_status::no_timeout, wait()); 107 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 108 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 109 110 if (cardStatus.cardState == CardState::ABSENT) { 111 ASSERT_TRUE(CheckGeneralError() || 112 radioRsp->rspInfo.error == RadioError::ILLEGAL_SIM_OR_ME || 113 radioRsp->rspInfo.error == RadioError::NONE || 114 radioRsp->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED); 115 } 116 } 117 118 /* 119 * Test IRadio.setNetworkSelectionModeManual() for the response returned. 120 */ 121 TEST_F(RadioHidlTest, setNetworkSelectionModeManual) { 122 int serial = GetRandomSerialNumber(); 123 124 radio->setNetworkSelectionModeManual(serial, "123456"); 125 EXPECT_EQ(std::cv_status::no_timeout, wait()); 126 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 127 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 128 129 if (cardStatus.cardState == CardState::ABSENT) { 130 ASSERT_TRUE(CheckGeneralError() || 131 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS || 132 radioRsp->rspInfo.error == RadioError::ILLEGAL_SIM_OR_ME || 133 radioRsp->rspInfo.error == RadioError::NONE || 134 radioRsp->rspInfo.error == RadioError::INVALID_STATE); 135 } 136 } 137 138 /* 139 * Test IRadio.getAvailableNetworks() for the response returned. 140 */ 141 TEST_F(RadioHidlTest, getAvailableNetworks) { 142 int serial = GetRandomSerialNumber(); 143 144 radio->getAvailableNetworks(serial); 145 EXPECT_EQ(std::cv_status::no_timeout, wait()); 146 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 147 ASSERT_TRUE(radioRsp->rspInfo.type == RadioResponseType::SOLICITED || 148 radioRsp->rspInfo.type == RadioResponseType::SOLICITED_ACK_EXP); 149 150 if (cardStatus.cardState == CardState::ABSENT) { 151 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE || 152 radioRsp->rspInfo.error == RadioError::DEVICE_IN_USE || 153 radioRsp->rspInfo.error == RadioError::CANCELLED || 154 radioRsp->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED || 155 radioRsp->rspInfo.error == RadioError::MODEM_ERR); 156 } 157 } 158 159 /* 160 * Test IRadio.getBasebandVersion() for the response returned. 161 */ 162 TEST_F(RadioHidlTest, getBasebandVersion) { 163 int serial = GetRandomSerialNumber(); 164 165 radio->getBasebandVersion(serial); 166 EXPECT_EQ(std::cv_status::no_timeout, wait()); 167 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 168 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 169 170 if (cardStatus.cardState == CardState::ABSENT) { 171 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 172 } 173 } 174 175 /* 176 * Test IRadio.setBandMode() for the response returned. 177 */ 178 TEST_F(RadioHidlTest, setBandMode) { 179 int serial = GetRandomSerialNumber(); 180 181 radio->setBandMode(serial, RadioBandMode::BAND_MODE_USA); 182 EXPECT_EQ(std::cv_status::no_timeout, wait()); 183 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 184 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 185 186 if (cardStatus.cardState == CardState::ABSENT) { 187 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE); 188 } 189 } 190 191 /* 192 * Test IRadio.getAvailableBandModes() for the response returned. 193 */ 194 TEST_F(RadioHidlTest, getAvailableBandModes) { 195 int serial = GetRandomSerialNumber(); 196 197 radio->getAvailableBandModes(serial); 198 EXPECT_EQ(std::cv_status::no_timeout, wait()); 199 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 200 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 201 202 if (cardStatus.cardState == CardState::ABSENT) { 203 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 204 } 205 } 206 207 /* 208 * Test IRadio.setPreferredNetworkType() for the response returned. 209 */ 210 TEST_F(RadioHidlTest, setPreferredNetworkType) { 211 int serial = GetRandomSerialNumber(); 212 213 radio->setPreferredNetworkType(serial, PreferredNetworkType::GSM_ONLY); 214 EXPECT_EQ(std::cv_status::no_timeout, wait()); 215 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 216 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 217 218 if (cardStatus.cardState == CardState::ABSENT) { 219 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE); 220 } 221 } 222 223 /* 224 * Test IRadio.getPreferredNetworkType() for the response returned. 225 */ 226 TEST_F(RadioHidlTest, getPreferredNetworkType) { 227 int serial = GetRandomSerialNumber(); 228 229 radio->getPreferredNetworkType(serial); 230 EXPECT_EQ(std::cv_status::no_timeout, wait()); 231 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 232 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 233 234 if (cardStatus.cardState == CardState::ABSENT) { 235 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 236 } 237 } 238 239 /* 240 * Test IRadio.getNeighboringCids() for the response returned. 241 */ 242 TEST_F(RadioHidlTest, getNeighboringCids) { 243 int serial = GetRandomSerialNumber(); 244 245 radio->getNeighboringCids(serial); 246 EXPECT_EQ(std::cv_status::no_timeout, wait()); 247 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 248 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 249 250 if (cardStatus.cardState == CardState::ABSENT) { 251 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 252 radioRsp->rspInfo.error == RadioError::SIM_ABSENT); 253 } 254 } 255 256 /* 257 * Test IRadio.setLocationUpdates() for the response returned. 258 */ 259 TEST_F(RadioHidlTest, setLocationUpdates) { 260 int serial = GetRandomSerialNumber(); 261 262 radio->setLocationUpdates(serial, true); 263 EXPECT_EQ(std::cv_status::no_timeout, wait()); 264 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 265 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 266 267 if (cardStatus.cardState == CardState::ABSENT) { 268 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 269 radioRsp->rspInfo.error == RadioError::SIM_ABSENT); 270 } 271 } 272 273 /* 274 * Test IRadio.setCdmaRoamingPreference() for the response returned. 275 */ 276 TEST_F(RadioHidlTest, setCdmaRoamingPreference) { 277 int serial = GetRandomSerialNumber(); 278 279 radio->setCdmaRoamingPreference(serial, CdmaRoamingType::HOME_NETWORK); 280 EXPECT_EQ(std::cv_status::no_timeout, wait()); 281 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 282 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 283 284 if (cardStatus.cardState == CardState::ABSENT) { 285 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 286 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED || 287 radioRsp->rspInfo.error == RadioError::SIM_ABSENT); 288 } 289 } 290 291 /* 292 * Test IRadio.getCdmaRoamingPreference() for the response returned. 293 */ 294 TEST_F(RadioHidlTest, getCdmaRoamingPreference) { 295 int serial = GetRandomSerialNumber(); 296 297 radio->getCdmaRoamingPreference(serial); 298 EXPECT_EQ(std::cv_status::no_timeout, wait()); 299 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 300 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 301 302 if (cardStatus.cardState == CardState::ABSENT) { 303 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE || 304 radioRsp->rspInfo.error == RadioError::MODEM_ERR || 305 radioRsp->rspInfo.error == RadioError::SIM_ABSENT); 306 } 307 } 308 309 /* 310 * Test IRadio.getTTYMode() for the response returned. 311 */ 312 TEST_F(RadioHidlTest, getTTYMode) { 313 int serial = GetRandomSerialNumber(); 314 315 radio->getTTYMode(serial); 316 EXPECT_EQ(std::cv_status::no_timeout, wait()); 317 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 318 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 319 320 if (cardStatus.cardState == CardState::ABSENT) { 321 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 322 } 323 } 324 325 /* 326 * Test IRadio.setTTYMode() for the response returned. 327 */ 328 TEST_F(RadioHidlTest, setTTYMode) { 329 int serial = GetRandomSerialNumber(); 330 331 radio->setTTYMode(serial, TtyMode::OFF); 332 EXPECT_EQ(std::cv_status::no_timeout, wait()); 333 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 334 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 335 336 if (cardStatus.cardState == CardState::ABSENT) { 337 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 338 } 339 } 340 341 /* 342 * Test IRadio.setPreferredVoicePrivacy() for the response returned. 343 */ 344 TEST_F(RadioHidlTest, setPreferredVoicePrivacy) { 345 int serial = GetRandomSerialNumber(); 346 347 radio->setPreferredVoicePrivacy(serial, true); 348 EXPECT_EQ(std::cv_status::no_timeout, wait()); 349 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 350 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 351 352 if (cardStatus.cardState == CardState::ABSENT) { 353 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 354 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); 355 } 356 } 357 358 /* 359 * Test IRadio.getPreferredVoicePrivacy() for the response returned. 360 */ 361 TEST_F(RadioHidlTest, getPreferredVoicePrivacy) { 362 int serial = GetRandomSerialNumber(); 363 364 radio->getPreferredVoicePrivacy(serial); 365 EXPECT_EQ(std::cv_status::no_timeout, wait()); 366 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 367 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 368 369 if (cardStatus.cardState == CardState::ABSENT) { 370 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 371 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); 372 } 373 } 374 375 /* 376 * Test IRadio.getCDMASubscription() for the response returned. 377 */ 378 TEST_F(RadioHidlTest, getCDMASubscription) { 379 int serial = GetRandomSerialNumber(); 380 381 radio->getCDMASubscription(serial); 382 EXPECT_EQ(std::cv_status::no_timeout, wait()); 383 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 384 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 385 386 if (cardStatus.cardState == CardState::ABSENT) { 387 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 388 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED || 389 radioRsp->rspInfo.error == RadioError::SIM_ABSENT); 390 } 391 } 392 393 /* 394 * Test IRadio.getDeviceIdentity() for the response returned. 395 */ 396 TEST_F(RadioHidlTest, getDeviceIdentity) { 397 int serial = GetRandomSerialNumber(); 398 399 radio->getDeviceIdentity(serial); 400 EXPECT_EQ(std::cv_status::no_timeout, wait()); 401 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 402 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 403 404 if (cardStatus.cardState == CardState::ABSENT) { 405 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 406 radioRsp->rspInfo.error == RadioError::EMPTY_RECORD); 407 } 408 } 409 410 /* 411 * Test IRadio.exitEmergencyCallbackMode() for the response returned. 412 */ 413 TEST_F(RadioHidlTest, exitEmergencyCallbackMode) { 414 int serial = GetRandomSerialNumber(); 415 416 radio->exitEmergencyCallbackMode(serial); 417 EXPECT_EQ(std::cv_status::no_timeout, wait()); 418 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 419 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 420 421 if (cardStatus.cardState == CardState::ABSENT) { 422 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 423 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED || 424 radioRsp->rspInfo.error == RadioError::SIM_ABSENT); 425 } 426 } 427 428 /* 429 * Test IRadio.getCdmaSubscriptionSource() for the response returned. 430 */ 431 TEST_F(RadioHidlTest, getCdmaSubscriptionSource) { 432 int serial = GetRandomSerialNumber(); 433 434 radio->getCdmaSubscriptionSource(serial); 435 EXPECT_EQ(std::cv_status::no_timeout, wait()); 436 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 437 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 438 439 if (cardStatus.cardState == CardState::ABSENT) { 440 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 441 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED || 442 radioRsp->rspInfo.error == RadioError::SIM_ABSENT); 443 } 444 } 445 446 /* 447 * Test IRadio.setCdmaSubscriptionSource() for the response returned. 448 */ 449 TEST_F(RadioHidlTest, setCdmaSubscriptionSource) { 450 int serial = GetRandomSerialNumber(); 451 452 radio->setCdmaSubscriptionSource(serial, CdmaSubscriptionSource::RUIM_SIM); 453 EXPECT_EQ(std::cv_status::no_timeout, wait()); 454 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 455 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 456 457 if (cardStatus.cardState == CardState::ABSENT) { 458 std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl; 459 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::SIM_ABSENT || 460 radioRsp->rspInfo.error == RadioError::SUBSCRIPTION_NOT_AVAILABLE || 461 radioRsp->rspInfo.error == RadioError::NONE); 462 } 463 } 464 465 /* 466 * Test IRadio.getVoiceRadioTechnology() for the response returned. 467 */ 468 TEST_F(RadioHidlTest, getVoiceRadioTechnology) { 469 int serial = GetRandomSerialNumber(); 470 471 radio->getVoiceRadioTechnology(serial); 472 EXPECT_EQ(std::cv_status::no_timeout, wait()); 473 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 474 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 475 476 if (cardStatus.cardState == CardState::ABSENT) { 477 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 478 } 479 } 480 481 /* 482 * Test IRadio.getCellInfoList() for the response returned. 483 */ 484 TEST_F(RadioHidlTest, getCellInfoList) { 485 int serial = GetRandomSerialNumber(); 486 487 radio->getCellInfoList(serial); 488 EXPECT_EQ(std::cv_status::no_timeout, wait()); 489 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 490 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 491 492 if (cardStatus.cardState == CardState::ABSENT) { 493 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE || 494 radioRsp->rspInfo.error == RadioError::NO_NETWORK_FOUND); 495 } 496 } 497 498 /* 499 * Test IRadio.setCellInfoListRate() for the response returned. 500 */ 501 TEST_F(RadioHidlTest, setCellInfoListRate) { 502 int serial = GetRandomSerialNumber(); 503 504 // TODO(sanketpadawe): RIL crashes with value of rate = 10 505 radio->setCellInfoListRate(serial, 10); 506 EXPECT_EQ(std::cv_status::no_timeout, wait()); 507 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 508 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 509 510 if (cardStatus.cardState == CardState::ABSENT) { 511 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 512 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); 513 } 514 } 515 516 /* 517 * Test IRadio.nvReadItem() for the response returned. 518 */ 519 TEST_F(RadioHidlTest, nvReadItem) { 520 int serial = GetRandomSerialNumber(); 521 522 radio->nvReadItem(serial, NvItem::LTE_BAND_ENABLE_25); 523 EXPECT_EQ(std::cv_status::no_timeout, wait()); 524 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 525 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 526 527 if (cardStatus.cardState == CardState::ABSENT) { 528 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE); 529 } 530 } 531 532 /* 533 * Test IRadio.nvWriteItem() for the response returned. 534 */ 535 TEST_F(RadioHidlTest, nvWriteItem) { 536 int serial = GetRandomSerialNumber(); 537 NvWriteItem item; 538 memset(&item, 0, sizeof(item)); 539 item.value = hidl_string(); 540 541 radio->nvWriteItem(serial, item); 542 EXPECT_EQ(std::cv_status::no_timeout, wait()); 543 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 544 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 545 546 if (cardStatus.cardState == CardState::ABSENT) { 547 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE); 548 } 549 } 550 551 /* 552 * Test IRadio.nvWriteCdmaPrl() for the response returned. 553 */ 554 TEST_F(RadioHidlTest, nvWriteCdmaPrl) { 555 int serial = GetRandomSerialNumber(); 556 std::vector<uint8_t> prl = {1, 2, 3, 4, 5}; 557 558 radio->nvWriteCdmaPrl(serial, hidl_vec<uint8_t>(prl)); 559 EXPECT_EQ(std::cv_status::no_timeout, wait()); 560 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 561 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 562 563 if (cardStatus.cardState == CardState::ABSENT) { 564 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE); 565 } 566 } 567 568 /* 569 * Test IRadio.nvResetConfig() for the response returned. 570 */ 571 TEST_F(RadioHidlTest, nvResetConfig) { 572 int serial = GetRandomSerialNumber(); 573 574 radio->nvResetConfig(++serial, ResetNvType::ERASE); 575 EXPECT_EQ(std::cv_status::no_timeout, wait()); 576 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 577 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 578 579 if (cardStatus.cardState == CardState::ABSENT) { 580 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 581 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); 582 } 583 } 584 585 /* 586 * Test IRadio.setUiccSubscription() for the response returned. 587 */ 588 TEST_F(RadioHidlTest, setUiccSubscription) { 589 int serial = GetRandomSerialNumber(); 590 SelectUiccSub item; 591 memset(&item, 0, sizeof(item)); 592 593 radio->setUiccSubscription(serial, item); 594 EXPECT_EQ(std::cv_status::no_timeout, wait()); 595 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 596 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 597 598 if (cardStatus.cardState == CardState::ABSENT) { 599 ASSERT_TRUE(CheckGeneralError() || 600 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS || 601 radioRsp->rspInfo.error == RadioError::NONE || 602 radioRsp->rspInfo.error == RadioError::SUBSCRIPTION_NOT_SUPPORTED || 603 radioRsp->rspInfo.error == RadioError::MODEM_ERR); 604 } 605 } 606 607 /* 608 * Test IRadio.getHardwareConfig() for the response returned. 609 */ 610 TEST_F(RadioHidlTest, getHardwareConfig) { 611 int serial = GetRandomSerialNumber(); 612 613 radio->getHardwareConfig(serial); 614 EXPECT_EQ(std::cv_status::no_timeout, wait()); 615 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 616 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 617 618 if (cardStatus.cardState == CardState::ABSENT) { 619 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE); 620 } 621 } 622 623 /* 624 * Test IRadio.requestShutdown() for the response returned. 625 */ 626 TEST_F(RadioHidlTest, requestShutdown) { 627 int serial = GetRandomSerialNumber(); 628 629 radio->requestShutdown(serial); 630 EXPECT_EQ(std::cv_status::no_timeout, wait()); 631 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 632 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 633 634 if (cardStatus.cardState == CardState::ABSENT) { 635 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE); 636 } 637 } 638 639 /* 640 * Test IRadio.getRadioCapability() for the response returned. 641 */ 642 TEST_F(RadioHidlTest, getRadioCapability) { 643 int serial = GetRandomSerialNumber(); 644 645 radio->getRadioCapability(serial); 646 EXPECT_EQ(std::cv_status::no_timeout, wait()); 647 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 648 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 649 650 if (cardStatus.cardState == CardState::ABSENT) { 651 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE); 652 } 653 } 654 655 /* 656 * Test IRadio.setRadioCapability() for the response returned. 657 */ 658 TEST_F(RadioHidlTest, setRadioCapability) { 659 int serial = GetRandomSerialNumber(); 660 RadioCapability rc; 661 memset(&rc, 0, sizeof(rc)); 662 rc.logicalModemUuid = hidl_string(); 663 664 radio->setRadioCapability(serial, rc); 665 EXPECT_EQ(std::cv_status::no_timeout, wait()); 666 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 667 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 668 669 if (cardStatus.cardState == CardState::ABSENT) { 670 ASSERT_TRUE(CheckGeneralError() || 671 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS || 672 radioRsp->rspInfo.error == RadioError::INVALID_STATE); 673 } 674 } 675 676 /* 677 * Test IRadio.startLceService() for the response returned. 678 */ 679 TEST_F(RadioHidlTest, startLceService) { 680 int serial = GetRandomSerialNumber(); 681 682 radio->startLceService(serial, 5, true); 683 EXPECT_EQ(std::cv_status::no_timeout, wait()); 684 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 685 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 686 687 if (cardStatus.cardState == CardState::ABSENT) { 688 std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl; 689 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE || 690 radioRsp->rspInfo.error == RadioError::LCE_NOT_SUPPORTED || 691 radioRsp->rspInfo.error == RadioError::INTERNAL_ERR || 692 radioRsp->rspInfo.error == RadioError::SIM_ABSENT); 693 } 694 } 695 696 /* 697 * Test IRadio.stopLceService() for the response returned. 698 */ 699 TEST_F(RadioHidlTest, stopLceService) { 700 int serial = GetRandomSerialNumber(); 701 702 radio->stopLceService(serial); 703 EXPECT_EQ(std::cv_status::no_timeout, wait()); 704 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 705 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 706 707 if (cardStatus.cardState == CardState::ABSENT) { 708 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 709 radioRsp->rspInfo.error == RadioError::LCE_NOT_SUPPORTED || 710 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED || 711 radioRsp->rspInfo.error == RadioError::SIM_ABSENT); 712 } 713 } 714 715 /* 716 * Test IRadio.pullLceData() for the response returned. 717 */ 718 TEST_F(RadioHidlTest, pullLceData) { 719 int serial = GetRandomSerialNumber(); 720 721 radio->pullLceData(serial); 722 EXPECT_EQ(std::cv_status::no_timeout, wait()); 723 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 724 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 725 726 if (cardStatus.cardState == CardState::ABSENT) { 727 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE || CheckOEMError() || 728 radioRsp->rspInfo.error == RadioError::INTERNAL_ERR || 729 radioRsp->rspInfo.error == RadioError::NONE); 730 } 731 } 732 733 /* 734 * Test IRadio.getModemActivityInfo() for the response returned. 735 */ 736 TEST_F(RadioHidlTest, getModemActivityInfo) { 737 int serial = GetRandomSerialNumber(); 738 739 radio->getModemActivityInfo(serial); 740 EXPECT_EQ(std::cv_status::no_timeout, wait()); 741 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 742 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 743 744 if (cardStatus.cardState == CardState::ABSENT) { 745 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 746 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); 747 } 748 } 749 750 /* 751 * Test IRadio.setAllowedCarriers() for the response returned. 752 */ 753 TEST_F(RadioHidlTest, setAllowedCarriers) { 754 int serial = GetRandomSerialNumber(); 755 CarrierRestrictions carriers; 756 memset(&carriers, 0, sizeof(carriers)); 757 carriers.allowedCarriers.resize(1); 758 carriers.excludedCarriers.resize(0); 759 carriers.allowedCarriers[0].mcc = hidl_string(); 760 carriers.allowedCarriers[0].mnc = hidl_string(); 761 carriers.allowedCarriers[0].matchType = CarrierMatchType::ALL; 762 carriers.allowedCarriers[0].matchData = hidl_string(); 763 764 radio->setAllowedCarriers(serial, false, carriers); 765 EXPECT_EQ(std::cv_status::no_timeout, wait()); 766 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 767 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 768 769 if (cardStatus.cardState == CardState::ABSENT) { 770 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 771 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); 772 } 773 774 /* Reset back to no carrier restriction */ 775 memset(&carriers, 0, sizeof(carriers)); 776 carriers.allowedCarriers.resize(0); 777 carriers.excludedCarriers.resize(0); 778 779 radio->setAllowedCarriers(++serial, true, carriers); 780 EXPECT_EQ(std::cv_status::no_timeout, wait()); 781 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 782 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 783 784 if (cardStatus.cardState == CardState::ABSENT) { 785 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 786 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); 787 } 788 } 789 790 /* 791 * Test IRadio.getAllowedCarriers() for the response returned. 792 */ 793 TEST_F(RadioHidlTest, getAllowedCarriers) { 794 int serial = GetRandomSerialNumber(); 795 796 radio->getAllowedCarriers(serial); 797 EXPECT_EQ(std::cv_status::no_timeout, wait()); 798 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 799 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 800 801 if (cardStatus.cardState == CardState::ABSENT) { 802 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 803 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); 804 } 805 } 806 807 /* 808 * Test IRadio.sendDeviceState() for the response returned. 809 */ 810 TEST_F(RadioHidlTest, sendDeviceState) { 811 int serial = GetRandomSerialNumber(); 812 813 radio->sendDeviceState(serial, DeviceStateType::POWER_SAVE_MODE, true); 814 EXPECT_EQ(std::cv_status::no_timeout, wait()); 815 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 816 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 817 818 std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl; 819 820 if (cardStatus.cardState == CardState::ABSENT) { 821 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 822 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); 823 } 824 } 825 826 /* 827 * Test IRadio.setIndicationFilter() for the response returned. 828 */ 829 TEST_F(RadioHidlTest, setIndicationFilter) { 830 int serial = GetRandomSerialNumber(); 831 832 radio->setIndicationFilter(serial, 1); 833 EXPECT_EQ(std::cv_status::no_timeout, wait()); 834 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 835 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 836 837 std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl; 838 839 if (cardStatus.cardState == CardState::ABSENT) { 840 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 841 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); 842 } 843 } 844 845 /* 846 * Test IRadio.setSimCardPower() for the response returned. 847 */ 848 TEST_F(RadioHidlTest, setSimCardPower) { 849 int serial = GetRandomSerialNumber(); 850 851 radio->setSimCardPower(serial, true); 852 EXPECT_EQ(std::cv_status::no_timeout, wait()); 853 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type); 854 EXPECT_EQ(serial, radioRsp->rspInfo.serial); 855 856 if (cardStatus.cardState == CardState::ABSENT) { 857 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE || 858 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); 859 } 860 } 861