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