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