Home | History | Annotate | Download | only in functional
      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 <VtsHalHidlTargetTestBase.h>
     20 #include <chrono>
     21 #include <condition_variable>
     22 #include <mutex>
     23 
     24 #include <android/hardware/radio/1.0/IRadio.h>
     25 #include <android/hardware/radio/1.0/IRadioIndication.h>
     26 #include <android/hardware/radio/1.0/IRadioResponse.h>
     27 #include <android/hardware/radio/1.0/types.h>
     28 
     29 #include <vts_test_util.h>
     30 
     31 using ::android::hardware::radio::V1_0::ActivityStatsInfo;
     32 using ::android::hardware::radio::V1_0::AppType;
     33 using ::android::hardware::radio::V1_0::CardStatus;
     34 using ::android::hardware::radio::V1_0::CardState;
     35 using ::android::hardware::radio::V1_0::Call;
     36 using ::android::hardware::radio::V1_0::CallForwardInfo;
     37 using ::android::hardware::radio::V1_0::CarrierMatchType;
     38 using ::android::hardware::radio::V1_0::CarrierRestrictions;
     39 using ::android::hardware::radio::V1_0::CdmaRoamingType;
     40 using ::android::hardware::radio::V1_0::CdmaBroadcastSmsConfigInfo;
     41 using ::android::hardware::radio::V1_0::CdmaSubscriptionSource;
     42 using ::android::hardware::radio::V1_0::CellInfo;
     43 using ::android::hardware::radio::V1_0::ClipStatus;
     44 using ::android::hardware::radio::V1_0::DataRegStateResult;
     45 using ::android::hardware::radio::V1_0::DeviceStateType;
     46 using ::android::hardware::radio::V1_0::Dial;
     47 using ::android::hardware::radio::V1_0::GsmBroadcastSmsConfigInfo;
     48 using ::android::hardware::radio::V1_0::HardwareConfig;
     49 using ::android::hardware::radio::V1_0::IccIo;
     50 using ::android::hardware::radio::V1_0::IccIoResult;
     51 using ::android::hardware::radio::V1_0::IRadio;
     52 using ::android::hardware::radio::V1_0::IRadioResponse;
     53 using ::android::hardware::radio::V1_0::IRadioIndication;
     54 using ::android::hardware::radio::V1_0::RadioConst;
     55 using ::android::hardware::radio::V1_0::RadioError;
     56 using ::android::hardware::radio::V1_0::RadioResponseInfo;
     57 using ::android::hardware::radio::V1_0::LastCallFailCauseInfo;
     58 using ::android::hardware::radio::V1_0::LceDataInfo;
     59 using ::android::hardware::radio::V1_0::LceStatusInfo;
     60 using ::android::hardware::radio::V1_0::NeighboringCell;
     61 using ::android::hardware::radio::V1_0::NvItem;
     62 using ::android::hardware::radio::V1_0::NvWriteItem;
     63 using ::android::hardware::radio::V1_0::OperatorInfo;
     64 using ::android::hardware::radio::V1_0::PreferredNetworkType;
     65 using ::android::hardware::radio::V1_0::RadioBandMode;
     66 using ::android::hardware::radio::V1_0::RadioCapability;
     67 using ::android::hardware::radio::V1_0::RadioResponseType;
     68 using ::android::hardware::radio::V1_0::RadioTechnology;
     69 using ::android::hardware::radio::V1_0::RadioTechnologyFamily;
     70 using ::android::hardware::radio::V1_0::ResetNvType;
     71 using ::android::hardware::radio::V1_0::SelectUiccSub;
     72 using ::android::hardware::radio::V1_0::SendSmsResult;
     73 using ::android::hardware::radio::V1_0::SetupDataCallResult;
     74 using ::android::hardware::radio::V1_0::SignalStrength;
     75 using ::android::hardware::radio::V1_0::SimApdu;
     76 using ::android::hardware::radio::V1_0::TtyMode;
     77 using ::android::hardware::radio::V1_0::VoiceRegStateResult;
     78 
     79 using ::android::hardware::hidl_string;
     80 using ::android::hardware::hidl_vec;
     81 using ::android::hardware::Return;
     82 using ::android::hardware::Void;
     83 using ::android::sp;
     84 
     85 #define TIMEOUT_PERIOD 75
     86 #define RADIO_SERVICE_NAME "slot1"
     87 
     88 class RadioHidlTest;
     89 extern CardStatus cardStatus;
     90 
     91 /* Callback class for radio response */
     92 class RadioResponse : public IRadioResponse {
     93    private:
     94     RadioHidlTest& parent;
     95 
     96    public:
     97     RadioResponseInfo rspInfo;
     98     hidl_string imsi;
     99     IccIoResult iccIoResult;
    100     int channelId;
    101 
    102     // Sms
    103     SendSmsResult sendSmsResult;
    104     hidl_string smscAddress;
    105     uint32_t writeSmsToSimIndex;
    106     uint32_t writeSmsToRuimIndex;
    107 
    108     RadioResponse(RadioHidlTest& parent);
    109 
    110     virtual ~RadioResponse() = default;
    111 
    112     Return<void> getIccCardStatusResponse(const RadioResponseInfo& info,
    113                                           const CardStatus& cardStatus);
    114 
    115     Return<void> supplyIccPinForAppResponse(const RadioResponseInfo& info,
    116                                             int32_t remainingRetries);
    117 
    118     Return<void> supplyIccPukForAppResponse(const RadioResponseInfo& info,
    119                                             int32_t remainingRetries);
    120 
    121     Return<void> supplyIccPin2ForAppResponse(const RadioResponseInfo& info,
    122                                              int32_t remainingRetries);
    123 
    124     Return<void> supplyIccPuk2ForAppResponse(const RadioResponseInfo& info,
    125                                              int32_t remainingRetries);
    126 
    127     Return<void> changeIccPinForAppResponse(const RadioResponseInfo& info,
    128                                             int32_t remainingRetries);
    129 
    130     Return<void> changeIccPin2ForAppResponse(const RadioResponseInfo& info,
    131                                              int32_t remainingRetries);
    132 
    133     Return<void> supplyNetworkDepersonalizationResponse(const RadioResponseInfo& info,
    134                                                         int32_t remainingRetries);
    135 
    136     Return<void> getCurrentCallsResponse(const RadioResponseInfo& info,
    137                                          const ::android::hardware::hidl_vec<Call>& calls);
    138 
    139     Return<void> dialResponse(const RadioResponseInfo& info);
    140 
    141     Return<void> getIMSIForAppResponse(const RadioResponseInfo& info,
    142                                        const ::android::hardware::hidl_string& imsi);
    143 
    144     Return<void> hangupConnectionResponse(const RadioResponseInfo& info);
    145 
    146     Return<void> hangupWaitingOrBackgroundResponse(const RadioResponseInfo& info);
    147 
    148     Return<void> hangupForegroundResumeBackgroundResponse(const RadioResponseInfo& info);
    149 
    150     Return<void> switchWaitingOrHoldingAndActiveResponse(const RadioResponseInfo& info);
    151 
    152     Return<void> conferenceResponse(const RadioResponseInfo& info);
    153 
    154     Return<void> rejectCallResponse(const RadioResponseInfo& info);
    155 
    156     Return<void> getLastCallFailCauseResponse(const RadioResponseInfo& info,
    157                                               const LastCallFailCauseInfo& failCauseInfo);
    158 
    159     Return<void> getSignalStrengthResponse(const RadioResponseInfo& info,
    160                                            const SignalStrength& sigStrength);
    161 
    162     Return<void> getVoiceRegistrationStateResponse(const RadioResponseInfo& info,
    163                                                    const VoiceRegStateResult& voiceRegResponse);
    164 
    165     Return<void> getDataRegistrationStateResponse(const RadioResponseInfo& info,
    166                                                   const DataRegStateResult& dataRegResponse);
    167 
    168     Return<void> getOperatorResponse(const RadioResponseInfo& info,
    169                                      const ::android::hardware::hidl_string& longName,
    170                                      const ::android::hardware::hidl_string& shortName,
    171                                      const ::android::hardware::hidl_string& numeric);
    172 
    173     Return<void> setRadioPowerResponse(const RadioResponseInfo& info);
    174 
    175     Return<void> sendDtmfResponse(const RadioResponseInfo& info);
    176 
    177     Return<void> sendSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
    178 
    179     Return<void> sendSMSExpectMoreResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
    180 
    181     Return<void> setupDataCallResponse(const RadioResponseInfo& info,
    182                                        const SetupDataCallResult& dcResponse);
    183 
    184     Return<void> iccIOForAppResponse(const RadioResponseInfo& info, const IccIoResult& iccIo);
    185 
    186     Return<void> sendUssdResponse(const RadioResponseInfo& info);
    187 
    188     Return<void> cancelPendingUssdResponse(const RadioResponseInfo& info);
    189 
    190     Return<void> getClirResponse(const RadioResponseInfo& info, int32_t n, int32_t m);
    191 
    192     Return<void> setClirResponse(const RadioResponseInfo& info);
    193 
    194     Return<void> getCallForwardStatusResponse(
    195         const RadioResponseInfo& info,
    196         const ::android::hardware::hidl_vec<CallForwardInfo>& call_forwardInfos);
    197 
    198     Return<void> setCallForwardResponse(const RadioResponseInfo& info);
    199 
    200     Return<void> getCallWaitingResponse(const RadioResponseInfo& info, bool enable,
    201                                         int32_t serviceClass);
    202 
    203     Return<void> setCallWaitingResponse(const RadioResponseInfo& info);
    204 
    205     Return<void> acknowledgeLastIncomingGsmSmsResponse(const RadioResponseInfo& info);
    206 
    207     Return<void> acceptCallResponse(const RadioResponseInfo& info);
    208 
    209     Return<void> deactivateDataCallResponse(const RadioResponseInfo& info);
    210 
    211     Return<void> getFacilityLockForAppResponse(const RadioResponseInfo& info, int32_t response);
    212 
    213     Return<void> setFacilityLockForAppResponse(const RadioResponseInfo& info, int32_t retry);
    214 
    215     Return<void> setBarringPasswordResponse(const RadioResponseInfo& info);
    216 
    217     Return<void> getNetworkSelectionModeResponse(const RadioResponseInfo& info, bool manual);
    218 
    219     Return<void> setNetworkSelectionModeAutomaticResponse(const RadioResponseInfo& info);
    220 
    221     Return<void> setNetworkSelectionModeManualResponse(const RadioResponseInfo& info);
    222 
    223     Return<void> getAvailableNetworksResponse(
    224         const RadioResponseInfo& info,
    225         const ::android::hardware::hidl_vec<OperatorInfo>& networkInfos);
    226 
    227     Return<void> startDtmfResponse(const RadioResponseInfo& info);
    228 
    229     Return<void> stopDtmfResponse(const RadioResponseInfo& info);
    230 
    231     Return<void> getBasebandVersionResponse(const RadioResponseInfo& info,
    232                                             const ::android::hardware::hidl_string& version);
    233 
    234     Return<void> separateConnectionResponse(const RadioResponseInfo& info);
    235 
    236     Return<void> setMuteResponse(const RadioResponseInfo& info);
    237 
    238     Return<void> getMuteResponse(const RadioResponseInfo& info, bool enable);
    239 
    240     Return<void> getClipResponse(const RadioResponseInfo& info, ClipStatus status);
    241 
    242     Return<void> getDataCallListResponse(
    243         const RadioResponseInfo& info,
    244         const ::android::hardware::hidl_vec<SetupDataCallResult>& dcResponse);
    245 
    246     Return<void> sendOemRilRequestRawResponse(const RadioResponseInfo& info,
    247                                               const ::android::hardware::hidl_vec<uint8_t>& data);
    248 
    249     Return<void> sendOemRilRequestStringsResponse(
    250         const RadioResponseInfo& info,
    251         const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
    252 
    253     Return<void> setSuppServiceNotificationsResponse(const RadioResponseInfo& info);
    254 
    255     Return<void> writeSmsToSimResponse(const RadioResponseInfo& info, int32_t index);
    256 
    257     Return<void> deleteSmsOnSimResponse(const RadioResponseInfo& info);
    258 
    259     Return<void> setBandModeResponse(const RadioResponseInfo& info);
    260 
    261     Return<void> getAvailableBandModesResponse(
    262         const RadioResponseInfo& info,
    263         const ::android::hardware::hidl_vec<RadioBandMode>& bandModes);
    264 
    265     Return<void> sendEnvelopeResponse(const RadioResponseInfo& info,
    266                                       const ::android::hardware::hidl_string& commandResponse);
    267 
    268     Return<void> sendTerminalResponseToSimResponse(const RadioResponseInfo& info);
    269 
    270     Return<void> handleStkCallSetupRequestFromSimResponse(const RadioResponseInfo& info);
    271 
    272     Return<void> explicitCallTransferResponse(const RadioResponseInfo& info);
    273 
    274     Return<void> setPreferredNetworkTypeResponse(const RadioResponseInfo& info);
    275 
    276     Return<void> getPreferredNetworkTypeResponse(const RadioResponseInfo& info,
    277                                                  PreferredNetworkType nwType);
    278 
    279     Return<void> getNeighboringCidsResponse(
    280         const RadioResponseInfo& info, const ::android::hardware::hidl_vec<NeighboringCell>& cells);
    281 
    282     Return<void> setLocationUpdatesResponse(const RadioResponseInfo& info);
    283 
    284     Return<void> setCdmaSubscriptionSourceResponse(const RadioResponseInfo& info);
    285 
    286     Return<void> setCdmaRoamingPreferenceResponse(const RadioResponseInfo& info);
    287 
    288     Return<void> getCdmaRoamingPreferenceResponse(const RadioResponseInfo& info,
    289                                                   CdmaRoamingType type);
    290 
    291     Return<void> setTTYModeResponse(const RadioResponseInfo& info);
    292 
    293     Return<void> getTTYModeResponse(const RadioResponseInfo& info, TtyMode mode);
    294 
    295     Return<void> setPreferredVoicePrivacyResponse(const RadioResponseInfo& info);
    296 
    297     Return<void> getPreferredVoicePrivacyResponse(const RadioResponseInfo& info, bool enable);
    298 
    299     Return<void> sendCDMAFeatureCodeResponse(const RadioResponseInfo& info);
    300 
    301     Return<void> sendBurstDtmfResponse(const RadioResponseInfo& info);
    302 
    303     Return<void> sendCdmaSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
    304 
    305     Return<void> acknowledgeLastIncomingCdmaSmsResponse(const RadioResponseInfo& info);
    306 
    307     Return<void> getGsmBroadcastConfigResponse(
    308         const RadioResponseInfo& info,
    309         const ::android::hardware::hidl_vec<GsmBroadcastSmsConfigInfo>& configs);
    310 
    311     Return<void> setGsmBroadcastConfigResponse(const RadioResponseInfo& info);
    312 
    313     Return<void> setGsmBroadcastActivationResponse(const RadioResponseInfo& info);
    314 
    315     Return<void> getCdmaBroadcastConfigResponse(
    316         const RadioResponseInfo& info,
    317         const ::android::hardware::hidl_vec<CdmaBroadcastSmsConfigInfo>& configs);
    318 
    319     Return<void> setCdmaBroadcastConfigResponse(const RadioResponseInfo& info);
    320 
    321     Return<void> setCdmaBroadcastActivationResponse(const RadioResponseInfo& info);
    322 
    323     Return<void> getCDMASubscriptionResponse(const RadioResponseInfo& info,
    324                                              const ::android::hardware::hidl_string& mdn,
    325                                              const ::android::hardware::hidl_string& hSid,
    326                                              const ::android::hardware::hidl_string& hNid,
    327                                              const ::android::hardware::hidl_string& min,
    328                                              const ::android::hardware::hidl_string& prl);
    329 
    330     Return<void> writeSmsToRuimResponse(const RadioResponseInfo& info, uint32_t index);
    331 
    332     Return<void> deleteSmsOnRuimResponse(const RadioResponseInfo& info);
    333 
    334     Return<void> getDeviceIdentityResponse(const RadioResponseInfo& info,
    335                                            const ::android::hardware::hidl_string& imei,
    336                                            const ::android::hardware::hidl_string& imeisv,
    337                                            const ::android::hardware::hidl_string& esn,
    338                                            const ::android::hardware::hidl_string& meid);
    339 
    340     Return<void> exitEmergencyCallbackModeResponse(const RadioResponseInfo& info);
    341 
    342     Return<void> getSmscAddressResponse(const RadioResponseInfo& info,
    343                                         const ::android::hardware::hidl_string& smsc);
    344 
    345     Return<void> setSmscAddressResponse(const RadioResponseInfo& info);
    346 
    347     Return<void> reportSmsMemoryStatusResponse(const RadioResponseInfo& info);
    348 
    349     Return<void> reportStkServiceIsRunningResponse(const RadioResponseInfo& info);
    350 
    351     Return<void> getCdmaSubscriptionSourceResponse(const RadioResponseInfo& info,
    352                                                    CdmaSubscriptionSource source);
    353 
    354     Return<void> requestIsimAuthenticationResponse(
    355         const RadioResponseInfo& info, const ::android::hardware::hidl_string& response);
    356 
    357     Return<void> acknowledgeIncomingGsmSmsWithPduResponse(const RadioResponseInfo& info);
    358 
    359     Return<void> sendEnvelopeWithStatusResponse(const RadioResponseInfo& info,
    360                                                 const IccIoResult& iccIo);
    361 
    362     Return<void> getVoiceRadioTechnologyResponse(const RadioResponseInfo& info,
    363                                                  RadioTechnology rat);
    364 
    365     Return<void> getCellInfoListResponse(const RadioResponseInfo& info,
    366                                          const ::android::hardware::hidl_vec<CellInfo>& cellInfo);
    367 
    368     Return<void> setCellInfoListRateResponse(const RadioResponseInfo& info);
    369 
    370     Return<void> setInitialAttachApnResponse(const RadioResponseInfo& info);
    371 
    372     Return<void> getImsRegistrationStateResponse(const RadioResponseInfo& info, bool isRegistered,
    373                                                  RadioTechnologyFamily ratFamily);
    374 
    375     Return<void> sendImsSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
    376 
    377     Return<void> iccTransmitApduBasicChannelResponse(const RadioResponseInfo& info,
    378                                                      const IccIoResult& result);
    379 
    380     Return<void> iccOpenLogicalChannelResponse(
    381         const RadioResponseInfo& info, int32_t channelId,
    382         const ::android::hardware::hidl_vec<int8_t>& selectResponse);
    383 
    384     Return<void> iccCloseLogicalChannelResponse(const RadioResponseInfo& info);
    385 
    386     Return<void> iccTransmitApduLogicalChannelResponse(const RadioResponseInfo& info,
    387                                                        const IccIoResult& result);
    388 
    389     Return<void> nvReadItemResponse(const RadioResponseInfo& info,
    390                                     const ::android::hardware::hidl_string& result);
    391 
    392     Return<void> nvWriteItemResponse(const RadioResponseInfo& info);
    393 
    394     Return<void> nvWriteCdmaPrlResponse(const RadioResponseInfo& info);
    395 
    396     Return<void> nvResetConfigResponse(const RadioResponseInfo& info);
    397 
    398     Return<void> setUiccSubscriptionResponse(const RadioResponseInfo& info);
    399 
    400     Return<void> setDataAllowedResponse(const RadioResponseInfo& info);
    401 
    402     Return<void> getHardwareConfigResponse(
    403         const RadioResponseInfo& info, const ::android::hardware::hidl_vec<HardwareConfig>& config);
    404 
    405     Return<void> requestIccSimAuthenticationResponse(const RadioResponseInfo& info,
    406                                                      const IccIoResult& result);
    407 
    408     Return<void> setDataProfileResponse(const RadioResponseInfo& info);
    409 
    410     Return<void> requestShutdownResponse(const RadioResponseInfo& info);
    411 
    412     Return<void> getRadioCapabilityResponse(const RadioResponseInfo& info,
    413                                             const RadioCapability& rc);
    414 
    415     Return<void> setRadioCapabilityResponse(const RadioResponseInfo& info,
    416                                             const RadioCapability& rc);
    417 
    418     Return<void> startLceServiceResponse(const RadioResponseInfo& info,
    419                                          const LceStatusInfo& statusInfo);
    420 
    421     Return<void> stopLceServiceResponse(const RadioResponseInfo& info,
    422                                         const LceStatusInfo& statusInfo);
    423 
    424     Return<void> pullLceDataResponse(const RadioResponseInfo& info, const LceDataInfo& lceInfo);
    425 
    426     Return<void> getModemActivityInfoResponse(const RadioResponseInfo& info,
    427                                               const ActivityStatsInfo& activityInfo);
    428 
    429     Return<void> setAllowedCarriersResponse(const RadioResponseInfo& info, int32_t numAllowed);
    430 
    431     Return<void> getAllowedCarriersResponse(const RadioResponseInfo& info, bool allAllowed,
    432                                             const CarrierRestrictions& carriers);
    433 
    434     Return<void> sendDeviceStateResponse(const RadioResponseInfo& info);
    435 
    436     Return<void> setIndicationFilterResponse(const RadioResponseInfo& info);
    437 
    438     Return<void> setSimCardPowerResponse(const RadioResponseInfo& info);
    439 
    440     Return<void> acknowledgeRequest(int32_t serial);
    441 };
    442 
    443 // The main test class for Radio HIDL.
    444 class RadioHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    445    private:
    446     std::mutex mtx;
    447     std::condition_variable cv;
    448     int count;
    449 
    450    public:
    451     virtual void SetUp() override;
    452 
    453     virtual void TearDown() override;
    454 
    455     /* Used as a mechanism to inform the test about data/event callback */
    456     void notify();
    457 
    458     /* Test code calls this function to wait for response */
    459     std::cv_status wait();
    460 
    461     /* Used for checking General Errors */
    462     bool CheckGeneralError();
    463 
    464     /* Used for checking OEM Errors */
    465     bool CheckOEMError();
    466 
    467     sp<IRadio> radio;
    468     sp<RadioResponse> radioRsp;
    469     sp<IRadioIndication> radioInd;
    470 };
    471 
    472 // A class for test environment setup
    473 class RadioHidlEnvironment : public ::testing::Environment {
    474    public:
    475     virtual void SetUp() {}
    476     virtual void TearDown() {}
    477 };