Merge "Automatic mk -> bp."
[android/platform-hardware-interfaces.git] / radio / 1.2 / vts / functional / radio_hidl_hal_utils_v1_2.h
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  */
17 #include <android-base/logging.h>
19 #include <VtsHalHidlTargetTestBase.h>
20 #include <chrono>
21 #include <condition_variable>
22 #include <mutex>
24 #include <android/hardware/radio/1.1/IRadioIndication.h>
25 #include <android/hardware/radio/1.1/IRadioResponse.h>
26 #include <android/hardware/radio/1.2/IRadio.h>
27 #include <android/hardware/radio/1.2/types.h>
29 #include "vts_test_util.h"
31 using namespace ::android::hardware::radio;
32 using namespace ::android::hardware::radio::V1_1;
33 using namespace ::android::hardware::radio::V1_0;
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;
41 #define TIMEOUT_PERIOD 75
42 #define RADIO_SERVICE_NAME "slot1"
44 class RadioHidlTest_v1_2;
45 extern CardStatus cardStatus;
47 /* Callback class for radio response v1_2*/
48 class RadioResponse_v1_2 : public V1_1::IRadioResponse {
49    protected:
50     RadioHidlTest_v1_2& parent_v1_2;
52    public:
53     RadioResponseInfo rspInfo;
55     RadioResponse_v1_2(RadioHidlTest_v1_2& parent_v1_2);
56     virtual ~RadioResponse_v1_2() = default;
58     Return<void> getIccCardStatusResponse(const RadioResponseInfo& info,
59                                           const CardStatus& cardStatus);
61     Return<void> supplyIccPinForAppResponse(const RadioResponseInfo& info,
62                                             int32_t remainingRetries);
64     Return<void> supplyIccPukForAppResponse(const RadioResponseInfo& info,
65                                             int32_t remainingRetries);
67     Return<void> supplyIccPin2ForAppResponse(const RadioResponseInfo& info,
68                                              int32_t remainingRetries);
70     Return<void> supplyIccPuk2ForAppResponse(const RadioResponseInfo& info,
71                                              int32_t remainingRetries);
73     Return<void> changeIccPinForAppResponse(const RadioResponseInfo& info,
74                                             int32_t remainingRetries);
76     Return<void> changeIccPin2ForAppResponse(const RadioResponseInfo& info,
77                                              int32_t remainingRetries);
79     Return<void> supplyNetworkDepersonalizationResponse(const RadioResponseInfo& info,
80                                                         int32_t remainingRetries);
82     Return<void> getCurrentCallsResponse(const RadioResponseInfo& info,
83                                          const ::android::hardware::hidl_vec<Call>& calls);
85     Return<void> dialResponse(const RadioResponseInfo& info);
87     Return<void> getIMSIForAppResponse(const RadioResponseInfo& info,
88                                        const ::android::hardware::hidl_string& imsi);
90     Return<void> hangupConnectionResponse(const RadioResponseInfo& info);
92     Return<void> hangupWaitingOrBackgroundResponse(const RadioResponseInfo& info);
94     Return<void> hangupForegroundResumeBackgroundResponse(const RadioResponseInfo& info);
96     Return<void> switchWaitingOrHoldingAndActiveResponse(const RadioResponseInfo& info);
98     Return<void> conferenceResponse(const RadioResponseInfo& info);
100     Return<void> rejectCallResponse(const RadioResponseInfo& info);
102     Return<void> getLastCallFailCauseResponse(const RadioResponseInfo& info,
103                                               const LastCallFailCauseInfo& failCauseInfo);
105     Return<void> getSignalStrengthResponse(const RadioResponseInfo& info,
106                                            const SignalStrength& sigStrength);
108     Return<void> getVoiceRegistrationStateResponse(const RadioResponseInfo& info,
109                                                    const VoiceRegStateResult& voiceRegResponse);
111     Return<void> getDataRegistrationStateResponse(const RadioResponseInfo& info,
112                                                   const DataRegStateResult& dataRegResponse);
114     Return<void> getOperatorResponse(const RadioResponseInfo& info,
115                                      const ::android::hardware::hidl_string& longName,
116                                      const ::android::hardware::hidl_string& shortName,
117                                      const ::android::hardware::hidl_string& numeric);
119     Return<void> setRadioPowerResponse(const RadioResponseInfo& info);
121     Return<void> sendDtmfResponse(const RadioResponseInfo& info);
123     Return<void> sendSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
125     Return<void> sendSMSExpectMoreResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
127     Return<void> setupDataCallResponse(const RadioResponseInfo& info,
128                                        const SetupDataCallResult& dcResponse);
130     Return<void> iccIOForAppResponse(const RadioResponseInfo& info, const IccIoResult& iccIo);
132     Return<void> sendUssdResponse(const RadioResponseInfo& info);
134     Return<void> cancelPendingUssdResponse(const RadioResponseInfo& info);
136     Return<void> getClirResponse(const RadioResponseInfo& info, int32_t n, int32_t m);
138     Return<void> setClirResponse(const RadioResponseInfo& info);
140     Return<void> getCallForwardStatusResponse(
141         const RadioResponseInfo& info,
142         const ::android::hardware::hidl_vec<CallForwardInfo>& call_forwardInfos);
144     Return<void> setCallForwardResponse(const RadioResponseInfo& info);
146     Return<void> getCallWaitingResponse(const RadioResponseInfo& info, bool enable,
147                                         int32_t serviceClass);
149     Return<void> setCallWaitingResponse(const RadioResponseInfo& info);
151     Return<void> acknowledgeLastIncomingGsmSmsResponse(const RadioResponseInfo& info);
153     Return<void> acceptCallResponse(const RadioResponseInfo& info);
155     Return<void> deactivateDataCallResponse(const RadioResponseInfo& info);
157     Return<void> getFacilityLockForAppResponse(const RadioResponseInfo& info, int32_t response);
159     Return<void> setFacilityLockForAppResponse(const RadioResponseInfo& info, int32_t retry);
161     Return<void> setBarringPasswordResponse(const RadioResponseInfo& info);
163     Return<void> getNetworkSelectionModeResponse(const RadioResponseInfo& info, bool manual);
165     Return<void> setNetworkSelectionModeAutomaticResponse(const RadioResponseInfo& info);
167     Return<void> setNetworkSelectionModeManualResponse(const RadioResponseInfo& info);
169     Return<void> getAvailableNetworksResponse(
170         const RadioResponseInfo& info,
171         const ::android::hardware::hidl_vec<OperatorInfo>& networkInfos);
173     Return<void> startDtmfResponse(const RadioResponseInfo& info);
175     Return<void> stopDtmfResponse(const RadioResponseInfo& info);
177     Return<void> getBasebandVersionResponse(const RadioResponseInfo& info,
178                                             const ::android::hardware::hidl_string& version);
180     Return<void> separateConnectionResponse(const RadioResponseInfo& info);
182     Return<void> setMuteResponse(const RadioResponseInfo& info);
184     Return<void> getMuteResponse(const RadioResponseInfo& info, bool enable);
186     Return<void> getClipResponse(const RadioResponseInfo& info, ClipStatus status);
188     Return<void> getDataCallListResponse(
189         const RadioResponseInfo& info,
190         const ::android::hardware::hidl_vec<SetupDataCallResult>& dcResponse);
192     Return<void> sendOemRilRequestRawResponse(const RadioResponseInfo& info,
193                                               const ::android::hardware::hidl_vec<uint8_t>& data);
195     Return<void> sendOemRilRequestStringsResponse(
196         const RadioResponseInfo& info,
197         const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
199     Return<void> setSuppServiceNotificationsResponse(const RadioResponseInfo& info);
201     Return<void> writeSmsToSimResponse(const RadioResponseInfo& info, int32_t index);
203     Return<void> deleteSmsOnSimResponse(const RadioResponseInfo& info);
205     Return<void> setBandModeResponse(const RadioResponseInfo& info);
207     Return<void> getAvailableBandModesResponse(
208         const RadioResponseInfo& info,
209         const ::android::hardware::hidl_vec<RadioBandMode>& bandModes);
211     Return<void> sendEnvelopeResponse(const RadioResponseInfo& info,
212                                       const ::android::hardware::hidl_string& commandResponse);
214     Return<void> sendTerminalResponseToSimResponse(const RadioResponseInfo& info);
216     Return<void> handleStkCallSetupRequestFromSimResponse(const RadioResponseInfo& info);
218     Return<void> explicitCallTransferResponse(const RadioResponseInfo& info);
220     Return<void> setPreferredNetworkTypeResponse(const RadioResponseInfo& info);
222     Return<void> getPreferredNetworkTypeResponse(const RadioResponseInfo& info,
223                                                  PreferredNetworkType nwType);
225     Return<void> getNeighboringCidsResponse(
226         const RadioResponseInfo& info, const ::android::hardware::hidl_vec<NeighboringCell>& cells);
228     Return<void> setLocationUpdatesResponse(const RadioResponseInfo& info);
230     Return<void> setCdmaSubscriptionSourceResponse(const RadioResponseInfo& info);
232     Return<void> setCdmaRoamingPreferenceResponse(const RadioResponseInfo& info);
234     Return<void> getCdmaRoamingPreferenceResponse(const RadioResponseInfo& info,
235                                                   CdmaRoamingType type);
237     Return<void> setTTYModeResponse(const RadioResponseInfo& info);
239     Return<void> getTTYModeResponse(const RadioResponseInfo& info, TtyMode mode);
241     Return<void> setPreferredVoicePrivacyResponse(const RadioResponseInfo& info);
243     Return<void> getPreferredVoicePrivacyResponse(const RadioResponseInfo& info, bool enable);
245     Return<void> sendCDMAFeatureCodeResponse(const RadioResponseInfo& info);
247     Return<void> sendBurstDtmfResponse(const RadioResponseInfo& info);
249     Return<void> sendCdmaSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
251     Return<void> acknowledgeLastIncomingCdmaSmsResponse(const RadioResponseInfo& info);
253     Return<void> getGsmBroadcastConfigResponse(
254         const RadioResponseInfo& info,
255         const ::android::hardware::hidl_vec<GsmBroadcastSmsConfigInfo>& configs);
257     Return<void> setGsmBroadcastConfigResponse(const RadioResponseInfo& info);
259     Return<void> setGsmBroadcastActivationResponse(const RadioResponseInfo& info);
261     Return<void> getCdmaBroadcastConfigResponse(
262         const RadioResponseInfo& info,
263         const ::android::hardware::hidl_vec<CdmaBroadcastSmsConfigInfo>& configs);
265     Return<void> setCdmaBroadcastConfigResponse(const RadioResponseInfo& info);
267     Return<void> setCdmaBroadcastActivationResponse(const RadioResponseInfo& info);
269     Return<void> getCDMASubscriptionResponse(const RadioResponseInfo& info,
270                                              const ::android::hardware::hidl_string& mdn,
271                                              const ::android::hardware::hidl_string& hSid,
272                                              const ::android::hardware::hidl_string& hNid,
273                                              const ::android::hardware::hidl_string& min,
274                                              const ::android::hardware::hidl_string& prl);
276     Return<void> writeSmsToRuimResponse(const RadioResponseInfo& info, uint32_t index);
278     Return<void> deleteSmsOnRuimResponse(const RadioResponseInfo& info);
280     Return<void> getDeviceIdentityResponse(const RadioResponseInfo& info,
281                                            const ::android::hardware::hidl_string& imei,
282                                            const ::android::hardware::hidl_string& imeisv,
283                                            const ::android::hardware::hidl_string& esn,
284                                            const ::android::hardware::hidl_string& meid);
286     Return<void> exitEmergencyCallbackModeResponse(const RadioResponseInfo& info);
288     Return<void> getSmscAddressResponse(const RadioResponseInfo& info,
289                                         const ::android::hardware::hidl_string& smsc);
291     Return<void> setSmscAddressResponse(const RadioResponseInfo& info);
293     Return<void> reportSmsMemoryStatusResponse(const RadioResponseInfo& info);
295     Return<void> reportStkServiceIsRunningResponse(const RadioResponseInfo& info);
297     Return<void> getCdmaSubscriptionSourceResponse(const RadioResponseInfo& info,
298                                                    CdmaSubscriptionSource source);
300     Return<void> requestIsimAuthenticationResponse(
301         const RadioResponseInfo& info, const ::android::hardware::hidl_string& response);
303     Return<void> acknowledgeIncomingGsmSmsWithPduResponse(const RadioResponseInfo& info);
305     Return<void> sendEnvelopeWithStatusResponse(const RadioResponseInfo& info,
306                                                 const IccIoResult& iccIo);
308     Return<void> getVoiceRadioTechnologyResponse(const RadioResponseInfo& info,
309                                                  RadioTechnology rat);
311     Return<void> getCellInfoListResponse(const RadioResponseInfo& info,
312                                          const ::android::hardware::hidl_vec<CellInfo>& cellInfo);
314     Return<void> setCellInfoListRateResponse(const RadioResponseInfo& info);
316     Return<void> setInitialAttachApnResponse(const RadioResponseInfo& info);
318     Return<void> getImsRegistrationStateResponse(const RadioResponseInfo& info, bool isRegistered,
319                                                  RadioTechnologyFamily ratFamily);
321     Return<void> sendImsSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
323     Return<void> iccTransmitApduBasicChannelResponse(const RadioResponseInfo& info,
324                                                      const IccIoResult& result);
326     Return<void> iccOpenLogicalChannelResponse(
327         const RadioResponseInfo& info, int32_t channelId,
328         const ::android::hardware::hidl_vec<int8_t>& selectResponse);
330     Return<void> iccCloseLogicalChannelResponse(const RadioResponseInfo& info);
332     Return<void> iccTransmitApduLogicalChannelResponse(const RadioResponseInfo& info,
333                                                        const IccIoResult& result);
335     Return<void> nvReadItemResponse(const RadioResponseInfo& info,
336                                     const ::android::hardware::hidl_string& result);
338     Return<void> nvWriteItemResponse(const RadioResponseInfo& info);
340     Return<void> nvWriteCdmaPrlResponse(const RadioResponseInfo& info);
342     Return<void> nvResetConfigResponse(const RadioResponseInfo& info);
344     Return<void> setUiccSubscriptionResponse(const RadioResponseInfo& info);
346     Return<void> setDataAllowedResponse(const RadioResponseInfo& info);
348     Return<void> getHardwareConfigResponse(
349         const RadioResponseInfo& info, const ::android::hardware::hidl_vec<HardwareConfig>& config);
351     Return<void> requestIccSimAuthenticationResponse(const RadioResponseInfo& info,
352                                                      const IccIoResult& result);
354     Return<void> setDataProfileResponse(const RadioResponseInfo& info);
356     Return<void> requestShutdownResponse(const RadioResponseInfo& info);
358     Return<void> getRadioCapabilityResponse(const RadioResponseInfo& info,
359                                             const RadioCapability& rc);
361     Return<void> setRadioCapabilityResponse(const RadioResponseInfo& info,
362                                             const RadioCapability& rc);
364     Return<void> startLceServiceResponse(const RadioResponseInfo& info,
365                                          const LceStatusInfo& statusInfo);
367     Return<void> stopLceServiceResponse(const RadioResponseInfo& info,
368                                         const LceStatusInfo& statusInfo);
370     Return<void> pullLceDataResponse(const RadioResponseInfo& info, const LceDataInfo& lceInfo);
372     Return<void> getModemActivityInfoResponse(const RadioResponseInfo& info,
373                                               const ActivityStatsInfo& activityInfo);
375     Return<void> setAllowedCarriersResponse(const RadioResponseInfo& info, int32_t numAllowed);
377     Return<void> getAllowedCarriersResponse(const RadioResponseInfo& info, bool allAllowed,
378                                             const CarrierRestrictions& carriers);
380     Return<void> sendDeviceStateResponse(const RadioResponseInfo& info);
382     Return<void> setIndicationFilterResponse(const RadioResponseInfo& info);
384     Return<void> setSimCardPowerResponse(const RadioResponseInfo& info);
386     Return<void> acknowledgeRequest(int32_t serial);
388     /* 1.1 Api */
389     Return<void> setCarrierInfoForImsiEncryptionResponse(const RadioResponseInfo& info);
391     Return<void> setSimCardPowerResponse_1_1(const RadioResponseInfo& info);
393     Return<void> startNetworkScanResponse(const RadioResponseInfo& info);
395     Return<void> stopNetworkScanResponse(const RadioResponseInfo& info);
397     Return<void> startKeepaliveResponse(const RadioResponseInfo& info,
398                                         const KeepaliveStatus& status);
400     Return<void> stopKeepaliveResponse(const RadioResponseInfo& info);
401 };
403 /* Callback class for radio indication */
404 class RadioIndication_v1_2 : public V1_1::IRadioIndication {
405    protected:
406     RadioHidlTest_v1_2& parent_v1_2;
408    public:
409     RadioIndication_v1_2(RadioHidlTest_v1_2& parent_v1_2);
410     virtual ~RadioIndication_v1_2() = default;
412     /* 1.1 Api */
413     Return<void> carrierInfoForImsiEncryption(RadioIndicationType info);
415     Return<void> networkScanResult(RadioIndicationType type, const NetworkScanResult& result);
417     Return<void> keepaliveStatus(RadioIndicationType type, const KeepaliveStatus& status);
419     /* 1.0 Api */
420     Return<void> radioStateChanged(RadioIndicationType type, RadioState radioState);
422     Return<void> callStateChanged(RadioIndicationType type);
424     Return<void> networkStateChanged(RadioIndicationType type);
426     Return<void> newSms(RadioIndicationType type,
427                         const ::android::hardware::hidl_vec<uint8_t>& pdu);
429     Return<void> newSmsStatusReport(RadioIndicationType type,
430                                     const ::android::hardware::hidl_vec<uint8_t>& pdu);
432     Return<void> newSmsOnSim(RadioIndicationType type, int32_t recordNumber);
434     Return<void> onUssd(RadioIndicationType type, UssdModeType modeType,
435                         const ::android::hardware::hidl_string& msg);
437     Return<void> nitzTimeReceived(RadioIndicationType type,
438                                   const ::android::hardware::hidl_string& nitzTime,
439                                   uint64_t receivedTime);
441     Return<void> currentSignalStrength(RadioIndicationType type,
442                                        const SignalStrength& signalStrength);
444     Return<void> dataCallListChanged(
445         RadioIndicationType type, const ::android::hardware::hidl_vec<SetupDataCallResult>& dcList);
447     Return<void> suppSvcNotify(RadioIndicationType type, const SuppSvcNotification& suppSvc);
449     Return<void> stkSessionEnd(RadioIndicationType type);
451     Return<void> stkProactiveCommand(RadioIndicationType type,
452                                      const ::android::hardware::hidl_string& cmd);
454     Return<void> stkEventNotify(RadioIndicationType type,
455                                 const ::android::hardware::hidl_string& cmd);
457     Return<void> stkCallSetup(RadioIndicationType type, int64_t timeout);
459     Return<void> simSmsStorageFull(RadioIndicationType type);
461     Return<void> simRefresh(RadioIndicationType type, const SimRefreshResult& refreshResult);
463     Return<void> callRing(RadioIndicationType type, bool isGsm, const CdmaSignalInfoRecord& record);
465     Return<void> simStatusChanged(RadioIndicationType type);
467     Return<void> cdmaNewSms(RadioIndicationType type, const CdmaSmsMessage& msg);
469     Return<void> newBroadcastSms(RadioIndicationType type,
470                                  const ::android::hardware::hidl_vec<uint8_t>& data);
472     Return<void> cdmaRuimSmsStorageFull(RadioIndicationType type);
474     Return<void> restrictedStateChanged(RadioIndicationType type, PhoneRestrictedState state);
476     Return<void> enterEmergencyCallbackMode(RadioIndicationType type);
478     Return<void> cdmaCallWaiting(RadioIndicationType type,
479                                  const CdmaCallWaiting& callWaitingRecord);
481     Return<void> cdmaOtaProvisionStatus(RadioIndicationType type, CdmaOtaProvisionStatus status);
483     Return<void> cdmaInfoRec(RadioIndicationType type, const CdmaInformationRecords& records);
485     Return<void> indicateRingbackTone(RadioIndicationType type, bool start);
487     Return<void> resendIncallMute(RadioIndicationType type);
489     Return<void> cdmaSubscriptionSourceChanged(RadioIndicationType type,
490                                                CdmaSubscriptionSource cdmaSource);
492     Return<void> cdmaPrlChanged(RadioIndicationType type, int32_t version);
494     Return<void> exitEmergencyCallbackMode(RadioIndicationType type);
496     Return<void> rilConnected(RadioIndicationType type);
498     Return<void> voiceRadioTechChanged(RadioIndicationType type, RadioTechnology rat);
500     Return<void> cellInfoList(RadioIndicationType type,
501                               const ::android::hardware::hidl_vec<CellInfo>& records);
503     Return<void> imsNetworkStateChanged(RadioIndicationType type);
505     Return<void> subscriptionStatusChanged(RadioIndicationType type, bool activate);
507     Return<void> srvccStateNotify(RadioIndicationType type, SrvccState state);
509     Return<void> hardwareConfigChanged(
510         RadioIndicationType type, const ::android::hardware::hidl_vec<HardwareConfig>& configs);
512     Return<void> radioCapabilityIndication(RadioIndicationType type, const RadioCapability& rc);
514     Return<void> onSupplementaryServiceIndication(RadioIndicationType type,
515                                                   const StkCcUnsolSsResult& ss);
517     Return<void> stkCallControlAlphaNotify(RadioIndicationType type,
518                                            const ::android::hardware::hidl_string& alpha);
520     Return<void> lceData(RadioIndicationType type, const LceDataInfo& lce);
522     Return<void> pcoData(RadioIndicationType type, const PcoDataInfo& pco);
524     Return<void> modemReset(RadioIndicationType type,
525                             const ::android::hardware::hidl_string& reason);
526 };
528 // The main test class for Radio HIDL.
529 class RadioHidlTest_v1_2 : public ::testing::VtsHalHidlTargetTestBase {
530    protected:
531     std::mutex mtx_;
532     std::condition_variable cv_;
533     int count_;
535    public:
536     virtual void SetUp() override;
538     /* Used as a mechanism to inform the test about data/event callback */
539     void notify();
541     /* Test code calls this function to wait for response */
542     std::cv_status wait();
544     /* radio service handle */
545     sp<V1_2::IRadio> radio_v1_2;
547     /* radio response handle */
548     sp<RadioResponse_v1_2> radioRsp_v1_2;
550     /* radio indication handle */
551     sp<RadioIndication_v1_2> radioInd_v1_2;
552 };