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 <android-base/logging.h> 18 19 #include <log/log.h> 20 #include <chrono> 21 #include <condition_variable> 22 #include <mutex> 23 24 #include <android/hardware/radio/1.1/IRadio.h> 25 #include <android/hardware/radio/1.1/IRadioIndication.h> 26 #include <android/hardware/radio/1.1/IRadioResponse.h> 27 #include <android/hardware/radio/1.1/types.h> 28 #include <gtest/gtest.h> 29 30 #include "vts_test_util.h" 31 32 using namespace ::android::hardware::radio::V1_0; 33 using namespace ::android::hardware::radio::V1_1; 34 35 using ::android::hardware::hidl_string; 36 using ::android::hardware::hidl_vec; 37 using ::android::hardware::Return; 38 using ::android::hardware::Void; 39 using ::android::sp; 40 41 #define TIMEOUT_PERIOD 75 42 #define RADIO_SERVICE_NAME "slot1" 43 44 class RadioHidlTest_v1_1; 45 extern CardStatus cardStatus; 46 47 /* Callback class for radio response v1_1*/ 48 class RadioResponse_v1_1 : public ::android::hardware::radio::V1_1::IRadioResponse { 49 protected: 50 RadioHidlTest_v1_1& parent_v1_1; 51 52 public: 53 RadioResponseInfo rspInfo; 54 hidl_string imsi; 55 IccIoResult iccIoResult; 56 int channelId; 57 KeepaliveStatus keepaliveStatus; 58 59 // Sms 60 SendSmsResult sendSmsResult; 61 hidl_string smscAddress; 62 uint32_t writeSmsToSimIndex; 63 uint32_t writeSmsToRuimIndex; 64 65 RadioResponse_v1_1(RadioHidlTest_v1_1& parent_v1_1); 66 virtual ~RadioResponse_v1_1() = default; 67 68 Return<void> getIccCardStatusResponse(const RadioResponseInfo& info, 69 const CardStatus& cardStatus); 70 71 Return<void> supplyIccPinForAppResponse(const RadioResponseInfo& info, 72 int32_t remainingRetries); 73 74 Return<void> supplyIccPukForAppResponse(const RadioResponseInfo& info, 75 int32_t remainingRetries); 76 77 Return<void> supplyIccPin2ForAppResponse(const RadioResponseInfo& info, 78 int32_t remainingRetries); 79 80 Return<void> supplyIccPuk2ForAppResponse(const RadioResponseInfo& info, 81 int32_t remainingRetries); 82 83 Return<void> changeIccPinForAppResponse(const RadioResponseInfo& info, 84 int32_t remainingRetries); 85 86 Return<void> changeIccPin2ForAppResponse(const RadioResponseInfo& info, 87 int32_t remainingRetries); 88 89 Return<void> supplyNetworkDepersonalizationResponse(const RadioResponseInfo& info, 90 int32_t remainingRetries); 91 92 Return<void> getCurrentCallsResponse(const RadioResponseInfo& info, 93 const ::android::hardware::hidl_vec<Call>& calls); 94 95 Return<void> dialResponse(const RadioResponseInfo& info); 96 97 Return<void> getIMSIForAppResponse(const RadioResponseInfo& info, 98 const ::android::hardware::hidl_string& imsi); 99 100 Return<void> hangupConnectionResponse(const RadioResponseInfo& info); 101 102 Return<void> hangupWaitingOrBackgroundResponse(const RadioResponseInfo& info); 103 104 Return<void> hangupForegroundResumeBackgroundResponse(const RadioResponseInfo& info); 105 106 Return<void> switchWaitingOrHoldingAndActiveResponse(const RadioResponseInfo& info); 107 108 Return<void> conferenceResponse(const RadioResponseInfo& info); 109 110 Return<void> rejectCallResponse(const RadioResponseInfo& info); 111 112 Return<void> getLastCallFailCauseResponse(const RadioResponseInfo& info, 113 const LastCallFailCauseInfo& failCauseInfo); 114 115 Return<void> getSignalStrengthResponse(const RadioResponseInfo& info, 116 const SignalStrength& sigStrength); 117 118 Return<void> getVoiceRegistrationStateResponse(const RadioResponseInfo& info, 119 const VoiceRegStateResult& voiceRegResponse); 120 121 Return<void> getDataRegistrationStateResponse(const RadioResponseInfo& info, 122 const DataRegStateResult& dataRegResponse); 123 124 Return<void> getOperatorResponse(const RadioResponseInfo& info, 125 const ::android::hardware::hidl_string& longName, 126 const ::android::hardware::hidl_string& shortName, 127 const ::android::hardware::hidl_string& numeric); 128 129 Return<void> setRadioPowerResponse(const RadioResponseInfo& info); 130 131 Return<void> sendDtmfResponse(const RadioResponseInfo& info); 132 133 Return<void> sendSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms); 134 135 Return<void> sendSMSExpectMoreResponse(const RadioResponseInfo& info, const SendSmsResult& sms); 136 137 Return<void> setupDataCallResponse(const RadioResponseInfo& info, 138 const SetupDataCallResult& dcResponse); 139 140 Return<void> iccIOForAppResponse(const RadioResponseInfo& info, const IccIoResult& iccIo); 141 142 Return<void> sendUssdResponse(const RadioResponseInfo& info); 143 144 Return<void> cancelPendingUssdResponse(const RadioResponseInfo& info); 145 146 Return<void> getClirResponse(const RadioResponseInfo& info, int32_t n, int32_t m); 147 148 Return<void> setClirResponse(const RadioResponseInfo& info); 149 150 Return<void> getCallForwardStatusResponse( 151 const RadioResponseInfo& info, 152 const ::android::hardware::hidl_vec<CallForwardInfo>& call_forwardInfos); 153 154 Return<void> setCallForwardResponse(const RadioResponseInfo& info); 155 156 Return<void> getCallWaitingResponse(const RadioResponseInfo& info, bool enable, 157 int32_t serviceClass); 158 159 Return<void> setCallWaitingResponse(const RadioResponseInfo& info); 160 161 Return<void> acknowledgeLastIncomingGsmSmsResponse(const RadioResponseInfo& info); 162 163 Return<void> acceptCallResponse(const RadioResponseInfo& info); 164 165 Return<void> deactivateDataCallResponse(const RadioResponseInfo& info); 166 167 Return<void> getFacilityLockForAppResponse(const RadioResponseInfo& info, int32_t response); 168 169 Return<void> setFacilityLockForAppResponse(const RadioResponseInfo& info, int32_t retry); 170 171 Return<void> setBarringPasswordResponse(const RadioResponseInfo& info); 172 173 Return<void> getNetworkSelectionModeResponse(const RadioResponseInfo& info, bool manual); 174 175 Return<void> setNetworkSelectionModeAutomaticResponse(const RadioResponseInfo& info); 176 177 Return<void> setNetworkSelectionModeManualResponse(const RadioResponseInfo& info); 178 179 Return<void> getAvailableNetworksResponse( 180 const RadioResponseInfo& info, 181 const ::android::hardware::hidl_vec<OperatorInfo>& networkInfos); 182 183 Return<void> startDtmfResponse(const RadioResponseInfo& info); 184 185 Return<void> stopDtmfResponse(const RadioResponseInfo& info); 186 187 Return<void> getBasebandVersionResponse(const RadioResponseInfo& info, 188 const ::android::hardware::hidl_string& version); 189 190 Return<void> separateConnectionResponse(const RadioResponseInfo& info); 191 192 Return<void> setMuteResponse(const RadioResponseInfo& info); 193 194 Return<void> getMuteResponse(const RadioResponseInfo& info, bool enable); 195 196 Return<void> getClipResponse(const RadioResponseInfo& info, ClipStatus status); 197 198 Return<void> getDataCallListResponse( 199 const RadioResponseInfo& info, 200 const ::android::hardware::hidl_vec<SetupDataCallResult>& dcResponse); 201 202 Return<void> sendOemRilRequestRawResponse(const RadioResponseInfo& info, 203 const ::android::hardware::hidl_vec<uint8_t>& data); 204 205 Return<void> sendOemRilRequestStringsResponse( 206 const RadioResponseInfo& info, 207 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data); 208 209 Return<void> setSuppServiceNotificationsResponse(const RadioResponseInfo& info); 210 211 Return<void> writeSmsToSimResponse(const RadioResponseInfo& info, int32_t index); 212 213 Return<void> deleteSmsOnSimResponse(const RadioResponseInfo& info); 214 215 Return<void> setBandModeResponse(const RadioResponseInfo& info); 216 217 Return<void> getAvailableBandModesResponse( 218 const RadioResponseInfo& info, 219 const ::android::hardware::hidl_vec<RadioBandMode>& bandModes); 220 221 Return<void> sendEnvelopeResponse(const RadioResponseInfo& info, 222 const ::android::hardware::hidl_string& commandResponse); 223 224 Return<void> sendTerminalResponseToSimResponse(const RadioResponseInfo& info); 225 226 Return<void> handleStkCallSetupRequestFromSimResponse(const RadioResponseInfo& info); 227 228 Return<void> explicitCallTransferResponse(const RadioResponseInfo& info); 229 230 Return<void> setPreferredNetworkTypeResponse(const RadioResponseInfo& info); 231 232 Return<void> getPreferredNetworkTypeResponse(const RadioResponseInfo& info, 233 PreferredNetworkType nwType); 234 235 Return<void> getNeighboringCidsResponse( 236 const RadioResponseInfo& info, const ::android::hardware::hidl_vec<NeighboringCell>& cells); 237 238 Return<void> setLocationUpdatesResponse(const RadioResponseInfo& info); 239 240 Return<void> setCdmaSubscriptionSourceResponse(const RadioResponseInfo& info); 241 242 Return<void> setCdmaRoamingPreferenceResponse(const RadioResponseInfo& info); 243 244 Return<void> getCdmaRoamingPreferenceResponse(const RadioResponseInfo& info, 245 CdmaRoamingType type); 246 247 Return<void> setTTYModeResponse(const RadioResponseInfo& info); 248 249 Return<void> getTTYModeResponse(const RadioResponseInfo& info, TtyMode mode); 250 251 Return<void> setPreferredVoicePrivacyResponse(const RadioResponseInfo& info); 252 253 Return<void> getPreferredVoicePrivacyResponse(const RadioResponseInfo& info, bool enable); 254 255 Return<void> sendCDMAFeatureCodeResponse(const RadioResponseInfo& info); 256 257 Return<void> sendBurstDtmfResponse(const RadioResponseInfo& info); 258 259 Return<void> sendCdmaSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms); 260 261 Return<void> acknowledgeLastIncomingCdmaSmsResponse(const RadioResponseInfo& info); 262 263 Return<void> getGsmBroadcastConfigResponse( 264 const RadioResponseInfo& info, 265 const ::android::hardware::hidl_vec<GsmBroadcastSmsConfigInfo>& configs); 266 267 Return<void> setGsmBroadcastConfigResponse(const RadioResponseInfo& info); 268 269 Return<void> setGsmBroadcastActivationResponse(const RadioResponseInfo& info); 270 271 Return<void> getCdmaBroadcastConfigResponse( 272 const RadioResponseInfo& info, 273 const ::android::hardware::hidl_vec<CdmaBroadcastSmsConfigInfo>& configs); 274 275 Return<void> setCdmaBroadcastConfigResponse(const RadioResponseInfo& info); 276 277 Return<void> setCdmaBroadcastActivationResponse(const RadioResponseInfo& info); 278 279 Return<void> getCDMASubscriptionResponse(const RadioResponseInfo& info, 280 const ::android::hardware::hidl_string& mdn, 281 const ::android::hardware::hidl_string& hSid, 282 const ::android::hardware::hidl_string& hNid, 283 const ::android::hardware::hidl_string& min, 284 const ::android::hardware::hidl_string& prl); 285 286 Return<void> writeSmsToRuimResponse(const RadioResponseInfo& info, uint32_t index); 287 288 Return<void> deleteSmsOnRuimResponse(const RadioResponseInfo& info); 289 290 Return<void> getDeviceIdentityResponse(const RadioResponseInfo& info, 291 const ::android::hardware::hidl_string& imei, 292 const ::android::hardware::hidl_string& imeisv, 293 const ::android::hardware::hidl_string& esn, 294 const ::android::hardware::hidl_string& meid); 295 296 Return<void> exitEmergencyCallbackModeResponse(const RadioResponseInfo& info); 297 298 Return<void> getSmscAddressResponse(const RadioResponseInfo& info, 299 const ::android::hardware::hidl_string& smsc); 300 301 Return<void> setSmscAddressResponse(const RadioResponseInfo& info); 302 303 Return<void> reportSmsMemoryStatusResponse(const RadioResponseInfo& info); 304 305 Return<void> reportStkServiceIsRunningResponse(const RadioResponseInfo& info); 306 307 Return<void> getCdmaSubscriptionSourceResponse(const RadioResponseInfo& info, 308 CdmaSubscriptionSource source); 309 310 Return<void> requestIsimAuthenticationResponse( 311 const RadioResponseInfo& info, const ::android::hardware::hidl_string& response); 312 313 Return<void> acknowledgeIncomingGsmSmsWithPduResponse(const RadioResponseInfo& info); 314 315 Return<void> sendEnvelopeWithStatusResponse(const RadioResponseInfo& info, 316 const IccIoResult& iccIo); 317 318 Return<void> getVoiceRadioTechnologyResponse(const RadioResponseInfo& info, 319 RadioTechnology rat); 320 321 Return<void> getCellInfoListResponse(const RadioResponseInfo& info, 322 const ::android::hardware::hidl_vec<CellInfo>& cellInfo); 323 324 Return<void> setCellInfoListRateResponse(const RadioResponseInfo& info); 325 326 Return<void> setInitialAttachApnResponse(const RadioResponseInfo& info); 327 328 Return<void> getImsRegistrationStateResponse(const RadioResponseInfo& info, bool isRegistered, 329 RadioTechnologyFamily ratFamily); 330 331 Return<void> sendImsSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms); 332 333 Return<void> iccTransmitApduBasicChannelResponse(const RadioResponseInfo& info, 334 const IccIoResult& result); 335 336 Return<void> iccOpenLogicalChannelResponse( 337 const RadioResponseInfo& info, int32_t channelId, 338 const ::android::hardware::hidl_vec<int8_t>& selectResponse); 339 340 Return<void> iccCloseLogicalChannelResponse(const RadioResponseInfo& info); 341 342 Return<void> iccTransmitApduLogicalChannelResponse(const RadioResponseInfo& info, 343 const IccIoResult& result); 344 345 Return<void> nvReadItemResponse(const RadioResponseInfo& info, 346 const ::android::hardware::hidl_string& result); 347 348 Return<void> nvWriteItemResponse(const RadioResponseInfo& info); 349 350 Return<void> nvWriteCdmaPrlResponse(const RadioResponseInfo& info); 351 352 Return<void> nvResetConfigResponse(const RadioResponseInfo& info); 353 354 Return<void> setUiccSubscriptionResponse(const RadioResponseInfo& info); 355 356 Return<void> setDataAllowedResponse(const RadioResponseInfo& info); 357 358 Return<void> getHardwareConfigResponse( 359 const RadioResponseInfo& info, const ::android::hardware::hidl_vec<HardwareConfig>& config); 360 361 Return<void> requestIccSimAuthenticationResponse(const RadioResponseInfo& info, 362 const IccIoResult& result); 363 364 Return<void> setDataProfileResponse(const RadioResponseInfo& info); 365 366 Return<void> requestShutdownResponse(const RadioResponseInfo& info); 367 368 Return<void> getRadioCapabilityResponse(const RadioResponseInfo& info, 369 const RadioCapability& rc); 370 371 Return<void> setRadioCapabilityResponse(const RadioResponseInfo& info, 372 const RadioCapability& rc); 373 374 Return<void> startLceServiceResponse(const RadioResponseInfo& info, 375 const LceStatusInfo& statusInfo); 376 377 Return<void> stopLceServiceResponse(const RadioResponseInfo& info, 378 const LceStatusInfo& statusInfo); 379 380 Return<void> pullLceDataResponse(const RadioResponseInfo& info, const LceDataInfo& lceInfo); 381 382 Return<void> getModemActivityInfoResponse(const RadioResponseInfo& info, 383 const ActivityStatsInfo& activityInfo); 384 385 Return<void> setAllowedCarriersResponse(const RadioResponseInfo& info, int32_t numAllowed); 386 387 Return<void> getAllowedCarriersResponse(const RadioResponseInfo& info, bool allAllowed, 388 const CarrierRestrictions& carriers); 389 390 Return<void> sendDeviceStateResponse(const RadioResponseInfo& info); 391 392 Return<void> setIndicationFilterResponse(const RadioResponseInfo& info); 393 394 Return<void> setSimCardPowerResponse(const RadioResponseInfo& info); 395 396 Return<void> acknowledgeRequest(int32_t serial); 397 398 /* 1.1 Api */ 399 Return<void> setCarrierInfoForImsiEncryptionResponse(const RadioResponseInfo& info); 400 401 Return<void> setSimCardPowerResponse_1_1(const RadioResponseInfo& info); 402 403 Return<void> startNetworkScanResponse(const RadioResponseInfo& info); 404 405 Return<void> stopNetworkScanResponse(const RadioResponseInfo& info); 406 407 Return<void> startKeepaliveResponse(const RadioResponseInfo& info, 408 const KeepaliveStatus& status); 409 410 Return<void> stopKeepaliveResponse(const RadioResponseInfo& info); 411 }; 412 413 /* Callback class for radio indication */ 414 class RadioIndication_v1_1 : public ::android::hardware::radio::V1_1::IRadioIndication { 415 protected: 416 RadioHidlTest_v1_1& parent_v1_1; 417 418 public: 419 RadioIndication_v1_1(RadioHidlTest_v1_1& parent_v1_1); 420 virtual ~RadioIndication_v1_1() = default; 421 422 /* 1.1 Api */ 423 Return<void> carrierInfoForImsiEncryption(RadioIndicationType info); 424 425 Return<void> networkScanResult(RadioIndicationType type, const NetworkScanResult& result); 426 427 Return<void> keepaliveStatus(RadioIndicationType type, const KeepaliveStatus& status); 428 429 /* 1.0 Api */ 430 Return<void> radioStateChanged(RadioIndicationType type, RadioState radioState); 431 432 Return<void> callStateChanged(RadioIndicationType type); 433 434 Return<void> networkStateChanged(RadioIndicationType type); 435 436 Return<void> newSms(RadioIndicationType type, 437 const ::android::hardware::hidl_vec<uint8_t>& pdu); 438 439 Return<void> newSmsStatusReport(RadioIndicationType type, 440 const ::android::hardware::hidl_vec<uint8_t>& pdu); 441 442 Return<void> newSmsOnSim(RadioIndicationType type, int32_t recordNumber); 443 444 Return<void> onUssd(RadioIndicationType type, UssdModeType modeType, 445 const ::android::hardware::hidl_string& msg); 446 447 Return<void> nitzTimeReceived(RadioIndicationType type, 448 const ::android::hardware::hidl_string& nitzTime, 449 uint64_t receivedTime); 450 451 Return<void> currentSignalStrength(RadioIndicationType type, 452 const SignalStrength& signalStrength); 453 454 Return<void> dataCallListChanged( 455 RadioIndicationType type, const ::android::hardware::hidl_vec<SetupDataCallResult>& dcList); 456 457 Return<void> suppSvcNotify(RadioIndicationType type, const SuppSvcNotification& suppSvc); 458 459 Return<void> stkSessionEnd(RadioIndicationType type); 460 461 Return<void> stkProactiveCommand(RadioIndicationType type, 462 const ::android::hardware::hidl_string& cmd); 463 464 Return<void> stkEventNotify(RadioIndicationType type, 465 const ::android::hardware::hidl_string& cmd); 466 467 Return<void> stkCallSetup(RadioIndicationType type, int64_t timeout); 468 469 Return<void> simSmsStorageFull(RadioIndicationType type); 470 471 Return<void> simRefresh(RadioIndicationType type, const SimRefreshResult& refreshResult); 472 473 Return<void> callRing(RadioIndicationType type, bool isGsm, const CdmaSignalInfoRecord& record); 474 475 Return<void> simStatusChanged(RadioIndicationType type); 476 477 Return<void> cdmaNewSms(RadioIndicationType type, const CdmaSmsMessage& msg); 478 479 Return<void> newBroadcastSms(RadioIndicationType type, 480 const ::android::hardware::hidl_vec<uint8_t>& data); 481 482 Return<void> cdmaRuimSmsStorageFull(RadioIndicationType type); 483 484 Return<void> restrictedStateChanged(RadioIndicationType type, PhoneRestrictedState state); 485 486 Return<void> enterEmergencyCallbackMode(RadioIndicationType type); 487 488 Return<void> cdmaCallWaiting(RadioIndicationType type, 489 const CdmaCallWaiting& callWaitingRecord); 490 491 Return<void> cdmaOtaProvisionStatus(RadioIndicationType type, CdmaOtaProvisionStatus status); 492 493 Return<void> cdmaInfoRec(RadioIndicationType type, const CdmaInformationRecords& records); 494 495 Return<void> indicateRingbackTone(RadioIndicationType type, bool start); 496 497 Return<void> resendIncallMute(RadioIndicationType type); 498 499 Return<void> cdmaSubscriptionSourceChanged(RadioIndicationType type, 500 CdmaSubscriptionSource cdmaSource); 501 502 Return<void> cdmaPrlChanged(RadioIndicationType type, int32_t version); 503 504 Return<void> exitEmergencyCallbackMode(RadioIndicationType type); 505 506 Return<void> rilConnected(RadioIndicationType type); 507 508 Return<void> voiceRadioTechChanged(RadioIndicationType type, RadioTechnology rat); 509 510 Return<void> cellInfoList(RadioIndicationType type, 511 const ::android::hardware::hidl_vec<CellInfo>& records); 512 513 Return<void> imsNetworkStateChanged(RadioIndicationType type); 514 515 Return<void> subscriptionStatusChanged(RadioIndicationType type, bool activate); 516 517 Return<void> srvccStateNotify(RadioIndicationType type, SrvccState state); 518 519 Return<void> hardwareConfigChanged( 520 RadioIndicationType type, const ::android::hardware::hidl_vec<HardwareConfig>& configs); 521 522 Return<void> radioCapabilityIndication(RadioIndicationType type, const RadioCapability& rc); 523 524 Return<void> onSupplementaryServiceIndication(RadioIndicationType type, 525 const StkCcUnsolSsResult& ss); 526 527 Return<void> stkCallControlAlphaNotify(RadioIndicationType type, 528 const ::android::hardware::hidl_string& alpha); 529 530 Return<void> lceData(RadioIndicationType type, const LceDataInfo& lce); 531 532 Return<void> pcoData(RadioIndicationType type, const PcoDataInfo& pco); 533 534 Return<void> modemReset(RadioIndicationType type, 535 const ::android::hardware::hidl_string& reason); 536 }; 537 538 // The main test class for Radio HIDL. 539 class RadioHidlTest_v1_1 : public ::testing::TestWithParam<std::string> { 540 protected: 541 std::mutex mtx; 542 std::condition_variable cv; 543 int count; 544 545 /* Serial number for radio request */ 546 int serial; 547 548 /* Update Sim Card Status */ 549 void updateSimCardStatus(); 550 551 public: 552 virtual void SetUp() override; 553 554 /* Used as a mechanism to inform the test about data/event callback */ 555 void notify(int receivedSerial); 556 557 /* Test code calls this function to wait for response */ 558 std::cv_status wait(int sec = TIMEOUT_PERIOD); 559 560 sp<::android::hardware::radio::V1_1::IRadio> radio_v1_1; 561 sp<RadioResponse_v1_1> radioRsp_v1_1; 562 sp<RadioIndication_v1_1> radioInd_v1_1; 563 }; 564