1 /*
2  * Copyright (C) 2019 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 #pragma once
18 
19 #include <android-base/logging.h>
20 
21 #include <gtest/gtest.h>
22 #include <hidl/GtestPrinter.h>
23 #include <hidl/ServiceManagement.h>
24 #include <utils/Log.h>
25 #include <chrono>
26 #include <condition_variable>
27 #include <mutex>
28 
29 #include <android/hardware/radio/config/1.1/IRadioConfig.h>
30 
31 #include <android/hardware/radio/1.5/IRadio.h>
32 #include <android/hardware/radio/1.5/IRadioIndication.h>
33 #include <android/hardware/radio/1.5/IRadioResponse.h>
34 #include <android/hardware/radio/1.5/types.h>
35 
36 #include "vts_test_util.h"
37 
38 using namespace ::android::hardware::radio::V1_5;
39 using namespace ::android::hardware::radio::V1_4;
40 using namespace ::android::hardware::radio::V1_3;
41 using namespace ::android::hardware::radio::V1_2;
42 using namespace ::android::hardware::radio::V1_1;
43 using namespace ::android::hardware::radio::V1_0;
44 
45 using ::android::sp;
46 using ::android::hardware::hidl_string;
47 using ::android::hardware::hidl_vec;
48 using ::android::hardware::Return;
49 using ::android::hardware::Void;
50 
51 #define TIMEOUT_PERIOD 75
52 #define MODEM_EMERGENCY_CALL_ESTABLISH_TIME 3
53 #define MODEM_EMERGENCY_CALL_DISCONNECT_TIME 3
54 
55 #define RADIO_SERVICE_NAME "slot1"
56 
57 class RadioHidlTest_v1_5;
58 extern ::android::hardware::radio::V1_5::CardStatus cardStatus;
59 
60 /* Callback class for radio response v1_5 */
61 class RadioResponse_v1_5 : public ::android::hardware::radio::V1_5::IRadioResponse {
62   protected:
63     RadioHidlTest_v1_5& parent_v1_5;
64 
65   public:
66     hidl_vec<RadioBandMode> radioBandModes;
67 
68     RadioResponseInfo rspInfo;
69 
70     // Call
71     hidl_vec<::android::hardware::radio::V1_2::Call> currentCalls;
72 
73     // Modem
74     bool isModemEnabled;
75     bool enableModemResponseToggle;
76 
77     ::android::hardware::hidl_bitfield<::android::hardware::radio::V1_4::RadioAccessFamily>
78             networkTypeBitmapResponse;
79 
80     // Data
81     ::android::hardware::radio::V1_4::DataRegStateResult dataRegResp;
82 
83     // SimLock status
84     ::android::hardware::radio::V1_4::CarrierRestrictionsWithPriority carrierRestrictionsResp;
85     ::android::hardware::radio::V1_4::SimLockMultiSimPolicy multiSimPolicyResp;
86 
87     // Whether toggling uicc applications operation is supported.
88     bool canToggleUiccApplicationsEnablement;
89 
90     // Whether Uicc applications are enabled or not.
91     bool areUiccApplicationsEnabled;
92 
93     // Barring Info Response
94     ::android::hardware::radio::V1_5::CellIdentity barringCellIdentity;
95     ::android::hardware::hidl_vec<::android::hardware::radio::V1_5::BarringInfo> barringInfos;
96 
97     RadioResponse_v1_5(RadioHidlTest_v1_5& parent_v1_5);
98     virtual ~RadioResponse_v1_5() = default;
99 
100     Return<void> getIccCardStatusResponse(
101             const RadioResponseInfo& info,
102             const ::android::hardware::radio::V1_0::CardStatus& cardStatus);
103 
104     Return<void> supplyIccPinForAppResponse(const RadioResponseInfo& info,
105                                             int32_t remainingRetries);
106 
107     Return<void> supplyIccPukForAppResponse(const RadioResponseInfo& info,
108                                             int32_t remainingRetries);
109 
110     Return<void> supplyIccPin2ForAppResponse(const RadioResponseInfo& info,
111                                              int32_t remainingRetries);
112 
113     Return<void> supplyIccPuk2ForAppResponse(const RadioResponseInfo& info,
114                                              int32_t remainingRetries);
115 
116     Return<void> changeIccPinForAppResponse(const RadioResponseInfo& info,
117                                             int32_t remainingRetries);
118 
119     Return<void> changeIccPin2ForAppResponse(const RadioResponseInfo& info,
120                                              int32_t remainingRetries);
121 
122     Return<void> supplyNetworkDepersonalizationResponse(const RadioResponseInfo& info,
123                                                         int32_t remainingRetries);
124 
125     Return<void> getCurrentCallsResponse(
126             const RadioResponseInfo& info,
127             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_0::Call>& calls);
128 
129     Return<void> dialResponse(const RadioResponseInfo& info);
130 
131     Return<void> getIMSIForAppResponse(const RadioResponseInfo& info,
132                                        const ::android::hardware::hidl_string& imsi);
133 
134     Return<void> hangupConnectionResponse(const RadioResponseInfo& info);
135 
136     Return<void> hangupWaitingOrBackgroundResponse(const RadioResponseInfo& info);
137 
138     Return<void> hangupForegroundResumeBackgroundResponse(const RadioResponseInfo& info);
139 
140     Return<void> switchWaitingOrHoldingAndActiveResponse(const RadioResponseInfo& info);
141 
142     Return<void> conferenceResponse(const RadioResponseInfo& info);
143 
144     Return<void> rejectCallResponse(const RadioResponseInfo& info);
145 
146     Return<void> getLastCallFailCauseResponse(const RadioResponseInfo& info,
147                                               const LastCallFailCauseInfo& failCauseInfo);
148 
149     Return<void> getSignalStrengthResponse(
150             const RadioResponseInfo& info,
151             const ::android::hardware::radio::V1_0::SignalStrength& sigStrength);
152 
153     Return<void> getVoiceRegistrationStateResponse(
154             const RadioResponseInfo& info,
155             const ::android::hardware::radio::V1_0::VoiceRegStateResult& voiceRegResponse);
156 
157     Return<void> getDataRegistrationStateResponse(
158             const RadioResponseInfo& info,
159             const ::android::hardware::radio::V1_0::DataRegStateResult& dataRegResponse);
160 
161     Return<void> getOperatorResponse(const RadioResponseInfo& info,
162                                      const ::android::hardware::hidl_string& longName,
163                                      const ::android::hardware::hidl_string& shortName,
164                                      const ::android::hardware::hidl_string& numeric);
165 
166     Return<void> setRadioPowerResponse(const RadioResponseInfo& info);
167 
168     Return<void> sendDtmfResponse(const RadioResponseInfo& info);
169 
170     Return<void> sendSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
171 
172     Return<void> sendSMSExpectMoreResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
173 
174     Return<void> setupDataCallResponse(
175             const RadioResponseInfo& info,
176             const android::hardware::radio::V1_0::SetupDataCallResult& dcResponse);
177 
178     Return<void> iccIOForAppResponse(const RadioResponseInfo& info, const IccIoResult& iccIo);
179 
180     Return<void> sendUssdResponse(const RadioResponseInfo& info);
181 
182     Return<void> cancelPendingUssdResponse(const RadioResponseInfo& info);
183 
184     Return<void> getClirResponse(const RadioResponseInfo& info, int32_t n, int32_t m);
185 
186     Return<void> setClirResponse(const RadioResponseInfo& info);
187 
188     Return<void> getCallForwardStatusResponse(
189             const RadioResponseInfo& info,
190             const ::android::hardware::hidl_vec<CallForwardInfo>& call_forwardInfos);
191 
192     Return<void> setCallForwardResponse(const RadioResponseInfo& info);
193 
194     Return<void> getCallWaitingResponse(const RadioResponseInfo& info, bool enable,
195                                         int32_t serviceClass);
196 
197     Return<void> setCallWaitingResponse(const RadioResponseInfo& info);
198 
199     Return<void> acknowledgeLastIncomingGsmSmsResponse(const RadioResponseInfo& info);
200 
201     Return<void> acceptCallResponse(const RadioResponseInfo& info);
202 
203     Return<void> deactivateDataCallResponse(const RadioResponseInfo& info);
204 
205     Return<void> getFacilityLockForAppResponse(const RadioResponseInfo& info, int32_t response);
206 
207     Return<void> setFacilityLockForAppResponse(const RadioResponseInfo& info, int32_t retry);
208 
209     Return<void> setBarringPasswordResponse(const RadioResponseInfo& info);
210 
211     Return<void> getNetworkSelectionModeResponse(const RadioResponseInfo& info, bool manual);
212 
213     Return<void> setNetworkSelectionModeAutomaticResponse(const RadioResponseInfo& info);
214 
215     Return<void> setNetworkSelectionModeManualResponse(const RadioResponseInfo& info);
216 
217     Return<void> getAvailableNetworksResponse(
218             const RadioResponseInfo& info,
219             const ::android::hardware::hidl_vec<OperatorInfo>& networkInfos);
220 
221     Return<void> startDtmfResponse(const RadioResponseInfo& info);
222 
223     Return<void> stopDtmfResponse(const RadioResponseInfo& info);
224 
225     Return<void> getBasebandVersionResponse(const RadioResponseInfo& info,
226                                             const ::android::hardware::hidl_string& version);
227 
228     Return<void> separateConnectionResponse(const RadioResponseInfo& info);
229 
230     Return<void> setMuteResponse(const RadioResponseInfo& info);
231 
232     Return<void> getMuteResponse(const RadioResponseInfo& info, bool enable);
233 
234     Return<void> getClipResponse(const RadioResponseInfo& info, ClipStatus status);
235 
236     Return<void> getDataCallListResponse(
237             const RadioResponseInfo& info,
238             const ::android::hardware::hidl_vec<
239                     android::hardware::radio::V1_0::SetupDataCallResult>& dcResponse);
240 
241     Return<void> sendOemRilRequestRawResponse(const RadioResponseInfo& info,
242                                               const ::android::hardware::hidl_vec<uint8_t>& data);
243 
244     Return<void> sendOemRilRequestStringsResponse(
245             const RadioResponseInfo& info,
246             const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
247 
248     Return<void> setSuppServiceNotificationsResponse(const RadioResponseInfo& info);
249 
250     Return<void> writeSmsToSimResponse(const RadioResponseInfo& info, int32_t index);
251 
252     Return<void> deleteSmsOnSimResponse(const RadioResponseInfo& info);
253 
254     Return<void> setBandModeResponse(const RadioResponseInfo& info);
255 
256     Return<void> getAvailableBandModesResponse(
257             const RadioResponseInfo& info,
258             const ::android::hardware::hidl_vec<RadioBandMode>& bandModes);
259 
260     Return<void> sendEnvelopeResponse(const RadioResponseInfo& info,
261                                       const ::android::hardware::hidl_string& commandResponse);
262 
263     Return<void> sendTerminalResponseToSimResponse(const RadioResponseInfo& info);
264 
265     Return<void> handleStkCallSetupRequestFromSimResponse(const RadioResponseInfo& info);
266 
267     Return<void> explicitCallTransferResponse(const RadioResponseInfo& info);
268 
269     Return<void> setPreferredNetworkTypeResponse(const RadioResponseInfo& info);
270 
271     Return<void> getPreferredNetworkTypeResponse(const RadioResponseInfo& info,
272                                                  PreferredNetworkType nwType);
273 
274     Return<void> getNeighboringCidsResponse(
275             const RadioResponseInfo& info,
276             const ::android::hardware::hidl_vec<NeighboringCell>& cells);
277 
278     Return<void> setLocationUpdatesResponse(const RadioResponseInfo& info);
279 
280     Return<void> setCdmaSubscriptionSourceResponse(const RadioResponseInfo& info);
281 
282     Return<void> setCdmaRoamingPreferenceResponse(const RadioResponseInfo& info);
283 
284     Return<void> getCdmaRoamingPreferenceResponse(const RadioResponseInfo& info,
285                                                   CdmaRoamingType type);
286 
287     Return<void> setTTYModeResponse(const RadioResponseInfo& info);
288 
289     Return<void> getTTYModeResponse(const RadioResponseInfo& info, TtyMode mode);
290 
291     Return<void> setPreferredVoicePrivacyResponse(const RadioResponseInfo& info);
292 
293     Return<void> getPreferredVoicePrivacyResponse(const RadioResponseInfo& info, bool enable);
294 
295     Return<void> sendCDMAFeatureCodeResponse(const RadioResponseInfo& info);
296 
297     Return<void> sendBurstDtmfResponse(const RadioResponseInfo& info);
298 
299     Return<void> sendCdmaSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
300 
301     Return<void> acknowledgeLastIncomingCdmaSmsResponse(const RadioResponseInfo& info);
302 
303     Return<void> getGsmBroadcastConfigResponse(
304             const RadioResponseInfo& info,
305             const ::android::hardware::hidl_vec<GsmBroadcastSmsConfigInfo>& configs);
306 
307     Return<void> setGsmBroadcastConfigResponse(const RadioResponseInfo& info);
308 
309     Return<void> setGsmBroadcastActivationResponse(const RadioResponseInfo& info);
310 
311     Return<void> getCdmaBroadcastConfigResponse(
312             const RadioResponseInfo& info,
313             const ::android::hardware::hidl_vec<CdmaBroadcastSmsConfigInfo>& configs);
314 
315     Return<void> setCdmaBroadcastConfigResponse(const RadioResponseInfo& info);
316 
317     Return<void> setCdmaBroadcastActivationResponse(const RadioResponseInfo& info);
318 
319     Return<void> getCDMASubscriptionResponse(const RadioResponseInfo& info,
320                                              const ::android::hardware::hidl_string& mdn,
321                                              const ::android::hardware::hidl_string& hSid,
322                                              const ::android::hardware::hidl_string& hNid,
323                                              const ::android::hardware::hidl_string& min,
324                                              const ::android::hardware::hidl_string& prl);
325 
326     Return<void> writeSmsToRuimResponse(const RadioResponseInfo& info, uint32_t index);
327 
328     Return<void> deleteSmsOnRuimResponse(const RadioResponseInfo& info);
329 
330     Return<void> getDeviceIdentityResponse(const RadioResponseInfo& info,
331                                            const ::android::hardware::hidl_string& imei,
332                                            const ::android::hardware::hidl_string& imeisv,
333                                            const ::android::hardware::hidl_string& esn,
334                                            const ::android::hardware::hidl_string& meid);
335 
336     Return<void> exitEmergencyCallbackModeResponse(const RadioResponseInfo& info);
337 
338     Return<void> getSmscAddressResponse(const RadioResponseInfo& info,
339                                         const ::android::hardware::hidl_string& smsc);
340 
341     Return<void> setSmscAddressResponse(const RadioResponseInfo& info);
342 
343     Return<void> reportSmsMemoryStatusResponse(const RadioResponseInfo& info);
344 
345     Return<void> reportStkServiceIsRunningResponse(const RadioResponseInfo& info);
346 
347     Return<void> getCdmaSubscriptionSourceResponse(const RadioResponseInfo& info,
348                                                    CdmaSubscriptionSource source);
349 
350     Return<void> requestIsimAuthenticationResponse(
351             const RadioResponseInfo& info, const ::android::hardware::hidl_string& response);
352 
353     Return<void> acknowledgeIncomingGsmSmsWithPduResponse(const RadioResponseInfo& info);
354 
355     Return<void> sendEnvelopeWithStatusResponse(const RadioResponseInfo& info,
356                                                 const IccIoResult& iccIo);
357 
358     Return<void> getVoiceRadioTechnologyResponse(
359             const RadioResponseInfo& info, ::android::hardware::radio::V1_0::RadioTechnology rat);
360 
361     Return<void> getCellInfoListResponse(
362             const RadioResponseInfo& info,
363             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_0::CellInfo>&
364                     cellInfo);
365 
366     Return<void> setCellInfoListRateResponse(const RadioResponseInfo& info);
367 
368     Return<void> setInitialAttachApnResponse(const RadioResponseInfo& info);
369 
370     Return<void> getImsRegistrationStateResponse(const RadioResponseInfo& info, bool isRegistered,
371                                                  RadioTechnologyFamily ratFamily);
372 
373     Return<void> sendImsSmsResponse(const RadioResponseInfo& info, const SendSmsResult& sms);
374 
375     Return<void> iccTransmitApduBasicChannelResponse(const RadioResponseInfo& info,
376                                                      const IccIoResult& result);
377 
378     Return<void> iccOpenLogicalChannelResponse(
379             const RadioResponseInfo& info, int32_t channelId,
380             const ::android::hardware::hidl_vec<int8_t>& selectResponse);
381 
382     Return<void> iccCloseLogicalChannelResponse(const RadioResponseInfo& info);
383 
384     Return<void> iccTransmitApduLogicalChannelResponse(const RadioResponseInfo& info,
385                                                        const IccIoResult& result);
386 
387     Return<void> nvReadItemResponse(const RadioResponseInfo& info,
388                                     const ::android::hardware::hidl_string& result);
389 
390     Return<void> nvWriteItemResponse(const RadioResponseInfo& info);
391 
392     Return<void> nvWriteCdmaPrlResponse(const RadioResponseInfo& info);
393 
394     Return<void> nvResetConfigResponse(const RadioResponseInfo& info);
395 
396     Return<void> setUiccSubscriptionResponse(const RadioResponseInfo& info);
397 
398     Return<void> setDataAllowedResponse(const RadioResponseInfo& info);
399 
400     Return<void> getHardwareConfigResponse(
401             const RadioResponseInfo& info,
402             const ::android::hardware::hidl_vec<HardwareConfig>& config);
403 
404     Return<void> requestIccSimAuthenticationResponse(const RadioResponseInfo& info,
405                                                      const IccIoResult& result);
406 
407     Return<void> setDataProfileResponse(const RadioResponseInfo& info);
408 
409     Return<void> requestShutdownResponse(const RadioResponseInfo& info);
410 
411     Return<void> getRadioCapabilityResponse(
412             const RadioResponseInfo& info,
413             const android::hardware::radio::V1_0::RadioCapability& rc);
414 
415     Return<void> setRadioCapabilityResponse(
416             const RadioResponseInfo& info,
417             const android::hardware::radio::V1_0::RadioCapability& rc);
418 
419     Return<void> startLceServiceResponse(const RadioResponseInfo& info,
420                                          const LceStatusInfo& statusInfo);
421 
422     Return<void> stopLceServiceResponse(const RadioResponseInfo& info,
423                                         const LceStatusInfo& statusInfo);
424 
425     Return<void> pullLceDataResponse(const RadioResponseInfo& info, const LceDataInfo& lceInfo);
426 
427     Return<void> getModemActivityInfoResponse(const RadioResponseInfo& info,
428                                               const ActivityStatsInfo& activityInfo);
429 
430     Return<void> setAllowedCarriersResponse(const RadioResponseInfo& info, int32_t numAllowed);
431 
432     Return<void> getAllowedCarriersResponse(const RadioResponseInfo& info, bool allAllowed,
433                                             const CarrierRestrictions& carriers);
434 
435     Return<void> sendDeviceStateResponse(const RadioResponseInfo& info);
436 
437     Return<void> setIndicationFilterResponse(const RadioResponseInfo& info);
438 
439     Return<void> setSimCardPowerResponse(const RadioResponseInfo& info);
440 
441     Return<void> acknowledgeRequest(int32_t serial);
442 
443     /* 1.1 Api */
444     Return<void> setCarrierInfoForImsiEncryptionResponse(const RadioResponseInfo& info);
445 
446     Return<void> setSimCardPowerResponse_1_1(const RadioResponseInfo& info);
447 
448     Return<void> startNetworkScanResponse(const RadioResponseInfo& info);
449 
450     Return<void> stopNetworkScanResponse(const RadioResponseInfo& info);
451 
452     Return<void> startKeepaliveResponse(const RadioResponseInfo& info,
453                                         const KeepaliveStatus& status);
454 
455     Return<void> stopKeepaliveResponse(const RadioResponseInfo& info);
456 
457     /* 1.2 Api */
458     Return<void> setSignalStrengthReportingCriteriaResponse(const RadioResponseInfo& info);
459 
460     Return<void> setLinkCapacityReportingCriteriaResponse(const RadioResponseInfo& info);
461 
462     Return<void> getIccCardStatusResponse_1_2(
463             const RadioResponseInfo& info,
464             const ::android::hardware::radio::V1_2::CardStatus& card_status);
465 
466     Return<void> getCurrentCallsResponse_1_2(
467             const RadioResponseInfo& info,
468             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_2::Call>& calls);
469 
470     Return<void> getSignalStrengthResponse_1_2(
471             const RadioResponseInfo& info,
472             const ::android::hardware::radio::V1_2::SignalStrength& sig_strength);
473 
474     Return<void> getSignalStrengthResponse_1_4(
475             const RadioResponseInfo& info,
476             const ::android::hardware::radio::V1_4::SignalStrength& sig_strength);
477 
478     Return<void> getCellInfoListResponse_1_2(
479             const RadioResponseInfo& info,
480             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_2::CellInfo>&
481                     cellInfo);
482 
483     Return<void> getVoiceRegistrationStateResponse_1_2(
484             const RadioResponseInfo& info,
485             const ::android::hardware::radio::V1_2::VoiceRegStateResult& voiceRegResponse);
486 
487     Return<void> getDataRegistrationStateResponse_1_2(
488             const RadioResponseInfo& info,
489             const ::android::hardware::radio::V1_2::DataRegStateResult& dataRegResponse);
490 
491     /* 1.3 Api */
492     Return<void> setSystemSelectionChannelsResponse(const RadioResponseInfo& info);
493 
494     Return<void> enableModemResponse(const RadioResponseInfo& info);
495 
496     Return<void> getModemStackStatusResponse(const RadioResponseInfo& info, const bool enabled);
497 
498     /* 1.4 Api */
499     Return<void> emergencyDialResponse(const RadioResponseInfo& info);
500 
501     Return<void> startNetworkScanResponse_1_4(const RadioResponseInfo& info);
502 
503     Return<void> getCellInfoListResponse_1_4(
504             const RadioResponseInfo& info,
505             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_4::CellInfo>&
506                     cellInfo);
507 
508     Return<void> getDataRegistrationStateResponse_1_4(
509             const RadioResponseInfo& info,
510             const ::android::hardware::radio::V1_4::DataRegStateResult& dataRegResponse);
511 
512     Return<void> getIccCardStatusResponse_1_4(
513             const RadioResponseInfo& info,
514             const ::android::hardware::radio::V1_4::CardStatus& card_status);
515 
516     Return<void> getPreferredNetworkTypeBitmapResponse(
517             const RadioResponseInfo& info,
518             const ::android::hardware::hidl_bitfield<
519                     ::android::hardware::radio::V1_4::RadioAccessFamily>
520                     networkTypeBitmap);
521 
522     Return<void> setPreferredNetworkTypeBitmapResponse(const RadioResponseInfo& info);
523 
524     Return<void> getDataCallListResponse_1_4(
525             const RadioResponseInfo& info,
526             const ::android::hardware::hidl_vec<
527                     ::android::hardware::radio::V1_4::SetupDataCallResult>& dcResponse);
528 
529     Return<void> setupDataCallResponse_1_4(
530             const RadioResponseInfo& info,
531             const android::hardware::radio::V1_4::SetupDataCallResult& dcResponse);
532 
533     Return<void> setAllowedCarriersResponse_1_4(const RadioResponseInfo& info);
534 
535     Return<void> getAllowedCarriersResponse_1_4(const RadioResponseInfo& info,
536                                                 const CarrierRestrictionsWithPriority& carriers,
537                                                 SimLockMultiSimPolicy multiSimPolicy);
538 
539     /* 1.5 Api */
540     Return<void> setSignalStrengthReportingCriteriaResponse_1_5(const RadioResponseInfo& info);
541 
542     Return<void> setLinkCapacityReportingCriteriaResponse_1_5(const RadioResponseInfo& info);
543 
544     Return<void> enableUiccApplicationsResponse(const RadioResponseInfo& info);
545 
546     Return<void> areUiccApplicationsEnabledResponse(const RadioResponseInfo& info, bool enabled);
547 
548     Return<void> canToggleUiccApplicationsEnablementResponse(const RadioResponseInfo& info,
549                                                              bool canToggle);
550 
551     Return<void> setSystemSelectionChannelsResponse_1_5(const RadioResponseInfo& info);
552 
553     Return<void> startNetworkScanResponse_1_5(const RadioResponseInfo& info);
554 
555     Return<void> setupDataCallResponse_1_5(
556             const RadioResponseInfo& info,
557             const android::hardware::radio::V1_5::SetupDataCallResult& dcResponse);
558 
559     Return<void> getDataCallListResponse_1_5(
560             const RadioResponseInfo& info,
561             const hidl_vec<::android::hardware::radio::V1_5::SetupDataCallResult>& dcResponse);
562 
563     Return<void> setInitialAttachApnResponse_1_5(const RadioResponseInfo& info);
564 
565     Return<void> setDataProfileResponse_1_5(const RadioResponseInfo& info);
566 
567     Return<void> setRadioPowerResponse_1_5(const RadioResponseInfo& info);
568 
569     Return<void> setIndicationFilterResponse_1_5(const RadioResponseInfo& info);
570 
571     Return<void> getBarringInfoResponse(
572             const RadioResponseInfo& info,
573             const ::android::hardware::radio::V1_5::CellIdentity& cellIdentity,
574             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_5::BarringInfo>&
575                     barringInfos);
576 
577     Return<void> getVoiceRegistrationStateResponse_1_5(
578             const RadioResponseInfo& info,
579             const ::android::hardware::radio::V1_5::RegStateResult& regResponse);
580 
581     Return<void> getDataRegistrationStateResponse_1_5(
582             const RadioResponseInfo& info,
583             const ::android::hardware::radio::V1_5::RegStateResult& regResponse);
584 
585     Return<void> getCellInfoListResponse_1_5(
586             const RadioResponseInfo& info,
587             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_5::CellInfo>&
588                     cellInfo);
589 
590     Return<void> setNetworkSelectionModeManualResponse_1_5(const RadioResponseInfo& info);
591 
592     Return<void> sendCdmaSmsExpectMoreResponse(const RadioResponseInfo& info,
593                                                const SendSmsResult& sms);
594 
595     Return<void> supplySimDepersonalizationResponse(
596             const RadioResponseInfo& info,
597             ::android::hardware::radio::V1_5::PersoSubstate persoType, int32_t remainingRetries);
598 
599     Return<void> getIccCardStatusResponse_1_5(
600             const RadioResponseInfo& info,
601             const ::android::hardware::radio::V1_5::CardStatus& card_status);
602 };
603 
604 /* Callback class for radio indication */
605 class RadioIndication_v1_5 : public ::android::hardware::radio::V1_5::IRadioIndication {
606   protected:
607     RadioHidlTest_v1_5& parent_v1_5;
608 
609   public:
610     RadioIndication_v1_5(RadioHidlTest_v1_5& parent_v1_5);
611     virtual ~RadioIndication_v1_5() = default;
612 
613     /* 1.5 Api */
614     Return<void> uiccApplicationsEnablementChanged(RadioIndicationType type, bool enabled);
615 
616     Return<void> networkScanResult_1_5(
617             RadioIndicationType type,
618             const ::android::hardware::radio::V1_5::NetworkScanResult& result);
619 
620     Return<void> cellInfoList_1_5(
621             RadioIndicationType type,
622             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_5::CellInfo>&
623                     records);
624 
625     Return<void> dataCallListChanged_1_5(
626             RadioIndicationType type,
627             const hidl_vec<::android::hardware::radio::V1_5::SetupDataCallResult>& dcList);
628 
629     /* 1.4 Api */
630     Return<void> currentEmergencyNumberList(
631             RadioIndicationType type,
632             const ::android::hardware::hidl_vec<EmergencyNumber>& emergencyNumberList);
633 
634     Return<void> cellInfoList_1_4(
635             RadioIndicationType type,
636             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_4::CellInfo>&
637                     records);
638 
639     Return<void> networkScanResult_1_4(
640             RadioIndicationType type,
641             const ::android::hardware::radio::V1_4::NetworkScanResult& result);
642 
643     Return<void> currentPhysicalChannelConfigs_1_4(
644             RadioIndicationType type,
645             const ::android::hardware::hidl_vec<
646                     ::android::hardware::radio::V1_4::PhysicalChannelConfig>& configs);
647 
648     Return<void> dataCallListChanged_1_4(
649             RadioIndicationType type,
650             const ::android::hardware::hidl_vec<
651                     android::hardware::radio::V1_4::SetupDataCallResult>& dcList);
652 
653     /* 1.2 Api */
654     Return<void> networkScanResult_1_2(
655             RadioIndicationType type,
656             const ::android::hardware::radio::V1_2::NetworkScanResult& result);
657 
658     Return<void> cellInfoList_1_2(
659             RadioIndicationType type,
660             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_2::CellInfo>&
661                     records);
662 
663     Return<void> currentLinkCapacityEstimate(
664             RadioIndicationType type,
665             const ::android::hardware::radio::V1_2::LinkCapacityEstimate& lce);
666 
667     Return<void> currentPhysicalChannelConfigs(
668             RadioIndicationType type,
669             const ::android::hardware::hidl_vec<
670                     ::android::hardware::radio::V1_2::PhysicalChannelConfig>& configs);
671 
672     Return<void> currentSignalStrength_1_2(
673             RadioIndicationType type,
674             const ::android::hardware::radio::V1_2::SignalStrength& signalStrength);
675 
676     Return<void> currentSignalStrength_1_4(
677             RadioIndicationType type,
678             const ::android::hardware::radio::V1_4::SignalStrength& signalStrength);
679 
680     /* 1.1 Api */
681     Return<void> carrierInfoForImsiEncryption(RadioIndicationType info);
682 
683     Return<void> networkScanResult(
684             RadioIndicationType type,
685             const ::android::hardware::radio::V1_1::NetworkScanResult& result);
686 
687     Return<void> keepaliveStatus(RadioIndicationType type, const KeepaliveStatus& status);
688 
689     /* 1.0 Api */
690     Return<void> radioStateChanged(RadioIndicationType type, RadioState radioState);
691 
692     Return<void> callStateChanged(RadioIndicationType type);
693 
694     Return<void> networkStateChanged(RadioIndicationType type);
695 
696     Return<void> newSms(RadioIndicationType type,
697                         const ::android::hardware::hidl_vec<uint8_t>& pdu);
698 
699     Return<void> newSmsStatusReport(RadioIndicationType type,
700                                     const ::android::hardware::hidl_vec<uint8_t>& pdu);
701 
702     Return<void> newSmsOnSim(RadioIndicationType type, int32_t recordNumber);
703 
704     Return<void> onUssd(RadioIndicationType type, UssdModeType modeType,
705                         const ::android::hardware::hidl_string& msg);
706 
707     Return<void> nitzTimeReceived(RadioIndicationType type,
708                                   const ::android::hardware::hidl_string& nitzTime,
709                                   uint64_t receivedTime);
710 
711     Return<void> currentSignalStrength(
712             RadioIndicationType type,
713             const ::android::hardware::radio::V1_0::SignalStrength& signalStrength);
714 
715     Return<void> dataCallListChanged(
716             RadioIndicationType type,
717             const ::android::hardware::hidl_vec<
718                     android::hardware::radio::V1_0::SetupDataCallResult>& dcList);
719 
720     Return<void> suppSvcNotify(RadioIndicationType type, const SuppSvcNotification& suppSvc);
721 
722     Return<void> stkSessionEnd(RadioIndicationType type);
723 
724     Return<void> stkProactiveCommand(RadioIndicationType type,
725                                      const ::android::hardware::hidl_string& cmd);
726 
727     Return<void> stkEventNotify(RadioIndicationType type,
728                                 const ::android::hardware::hidl_string& cmd);
729 
730     Return<void> stkCallSetup(RadioIndicationType type, int64_t timeout);
731 
732     Return<void> simSmsStorageFull(RadioIndicationType type);
733 
734     Return<void> simRefresh(RadioIndicationType type, const SimRefreshResult& refreshResult);
735 
736     Return<void> callRing(RadioIndicationType type, bool isGsm, const CdmaSignalInfoRecord& record);
737 
738     Return<void> simStatusChanged(RadioIndicationType type);
739 
740     Return<void> cdmaNewSms(RadioIndicationType type, const CdmaSmsMessage& msg);
741 
742     Return<void> newBroadcastSms(RadioIndicationType type,
743                                  const ::android::hardware::hidl_vec<uint8_t>& data);
744 
745     Return<void> cdmaRuimSmsStorageFull(RadioIndicationType type);
746 
747     Return<void> restrictedStateChanged(RadioIndicationType type, PhoneRestrictedState state);
748 
749     Return<void> enterEmergencyCallbackMode(RadioIndicationType type);
750 
751     Return<void> cdmaCallWaiting(RadioIndicationType type,
752                                  const CdmaCallWaiting& callWaitingRecord);
753 
754     Return<void> cdmaOtaProvisionStatus(RadioIndicationType type, CdmaOtaProvisionStatus status);
755 
756     Return<void> cdmaInfoRec(RadioIndicationType type, const CdmaInformationRecords& records);
757 
758     Return<void> indicateRingbackTone(RadioIndicationType type, bool start);
759 
760     Return<void> resendIncallMute(RadioIndicationType type);
761 
762     Return<void> cdmaSubscriptionSourceChanged(RadioIndicationType type,
763                                                CdmaSubscriptionSource cdmaSource);
764 
765     Return<void> cdmaPrlChanged(RadioIndicationType type, int32_t version);
766 
767     Return<void> exitEmergencyCallbackMode(RadioIndicationType type);
768 
769     Return<void> rilConnected(RadioIndicationType type);
770 
771     Return<void> voiceRadioTechChanged(RadioIndicationType type,
772                                        ::android::hardware::radio::V1_0::RadioTechnology rat);
773 
774     Return<void> cellInfoList(
775             RadioIndicationType type,
776             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_0::CellInfo>&
777                     records);
778 
779     Return<void> imsNetworkStateChanged(RadioIndicationType type);
780 
781     Return<void> subscriptionStatusChanged(RadioIndicationType type, bool activate);
782 
783     Return<void> srvccStateNotify(RadioIndicationType type, SrvccState state);
784 
785     Return<void> hardwareConfigChanged(
786             RadioIndicationType type, const ::android::hardware::hidl_vec<HardwareConfig>& configs);
787 
788     Return<void> radioCapabilityIndication(
789             RadioIndicationType type, const android::hardware::radio::V1_0::RadioCapability& rc);
790 
791     Return<void> onSupplementaryServiceIndication(RadioIndicationType type,
792                                                   const StkCcUnsolSsResult& ss);
793 
794     Return<void> stkCallControlAlphaNotify(RadioIndicationType type,
795                                            const ::android::hardware::hidl_string& alpha);
796 
797     Return<void> lceData(RadioIndicationType type, const LceDataInfo& lce);
798 
799     Return<void> pcoData(RadioIndicationType type, const PcoDataInfo& pco);
800 
801     Return<void> modemReset(RadioIndicationType type,
802                             const ::android::hardware::hidl_string& reason);
803 
804     Return<void> registrationFailed(
805             RadioIndicationType type,
806             const ::android::hardware::radio::V1_5::CellIdentity& cellIdentity,
807             const ::android::hardware::hidl_string& chosenPlmn,
808             ::android::hardware::hidl_bitfield<::android::hardware::radio::V1_5::Domain> domain,
809             int32_t causeCode, int32_t additionalCauseCode);
810 
811     Return<void> barringInfoChanged(
812             RadioIndicationType /*type*/,
813             const ::android::hardware::radio::V1_5::CellIdentity& /*cellIdentity*/,
814             const ::android::hardware::hidl_vec<::android::hardware::radio::V1_5::BarringInfo>&
815             /*barringInfos*/);
816 };
817 
818 // The main test class for Radio HIDL.
819 class RadioHidlTest_v1_5 : public ::testing::TestWithParam<std::string> {
820   protected:
821     std::mutex mtx_;
822     std::condition_variable cv_;
823     int count_;
824 
825     /* Serial number for radio request */
826     int serial;
827 
828     /* Clear Potential Established Calls */
829     void clearPotentialEstablishedCalls();
830 
831     /* Update Sim Card Status */
832     void updateSimCardStatus();
833 
834     /* Stop Network Scan Command */
835     void stopNetworkScan();
836 
837   public:
838     virtual void SetUp() override;
839 
840     /* Used as a mechanism to inform the test about data/event callback */
841     void notify(int receivedSerial);
842 
843     /* Test code calls this function to wait for response */
844     std::cv_status wait();
845 
846     /* radio service handle */
847     sp<::android::hardware::radio::V1_5::IRadio> radio_v1_5;
848 
849     /* radio response handle */
850     sp<RadioResponse_v1_5> radioRsp_v1_5;
851 
852     /* radio indication handle */
853     sp<RadioIndication_v1_5> radioInd_v1_5;
854 };
855