1 /*
2 * Copyright (c) 2016 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 #define LOG_TAG "RILC"
18
19 #include <android/hardware/radio/1.1/IRadio.h>
20 #include <android/hardware/radio/1.1/IRadioResponse.h>
21 #include <android/hardware/radio/1.1/IRadioIndication.h>
22 #include <android/hardware/radio/1.1/types.h>
23
24 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
25
26 #include <hwbinder/IPCThreadState.h>
27 #include <hwbinder/ProcessState.h>
28 #include <ril_service.h>
29 #include <hidl/HidlTransportSupport.h>
30 #include <utils/SystemClock.h>
31 #include <inttypes.h>
32
33 #define INVALID_HEX_CHAR 16
34
35 using namespace android::hardware::radio;
36 using namespace android::hardware::radio::V1_0;
37 using namespace android::hardware::radio::deprecated::V1_0;
38 using ::android::hardware::configureRpcThreadpool;
39 using ::android::hardware::joinRpcThreadpool;
40 using ::android::hardware::Return;
41 using ::android::hardware::hidl_string;
42 using ::android::hardware::hidl_vec;
43 using ::android::hardware::hidl_array;
44 using ::android::hardware::Void;
45 using android::CommandInfo;
46 using android::RequestInfo;
47 using android::requestToString;
48 using android::sp;
49
50 #define BOOL_TO_INT(x) (x ? 1 : 0)
51 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
52 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
53
54 #if defined(ANDROID_MULTI_SIM)
55 #define CALL_ONREQUEST(a, b, c, d, e) \
56 s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e)))
57 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a))
58 #else
59 #define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d))
60 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
61 #endif
62
63 RIL_RadioFunctions *s_vendorFunctions = NULL;
64 static CommandInfo *s_commands;
65
66 struct RadioImpl;
67 struct OemHookImpl;
68
69 #if (SIM_COUNT >= 2)
70 sp<RadioImpl> radioService[SIM_COUNT];
71 sp<OemHookImpl> oemHookService[SIM_COUNT];
72 // counter used for synchronization. It is incremented every time response callbacks are updated.
73 volatile int32_t mCounterRadio[SIM_COUNT];
74 volatile int32_t mCounterOemHook[SIM_COUNT];
75 #else
76 sp<RadioImpl> radioService[1];
77 sp<OemHookImpl> oemHookService[1];
78 // counter used for synchronization. It is incremented every time response callbacks are updated.
79 volatile int32_t mCounterRadio[1];
80 volatile int32_t mCounterOemHook[1];
81 #endif
82
83 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
84
85 #if (SIM_COUNT >= 2)
86 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
87 #if (SIM_COUNT >= 3)
88 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
89 #if (SIM_COUNT >= 4)
90 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
91 #endif
92 #endif
93 #endif
94
95 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
96 hidl_vec<HardwareConfig>& records);
97
98 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
99
100 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
101
102 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
103 SignalStrength& signalStrength);
104
105 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
106 SetupDataCallResult& dcResult);
107
108 void convertRilDataCallListToHal(void *response, size_t responseLen,
109 hidl_vec<SetupDataCallResult>& dcResultList);
110
111 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
112
113 struct RadioImpl : public V1_1::IRadio {
114 int32_t mSlotId;
115 sp<IRadioResponse> mRadioResponse;
116 sp<IRadioIndication> mRadioIndication;
117 sp<V1_1::IRadioResponse> mRadioResponseV1_1;
118 sp<V1_1::IRadioIndication> mRadioIndicationV1_1;
119
120 Return<void> setResponseFunctions(
121 const ::android::sp<IRadioResponse>& radioResponse,
122 const ::android::sp<IRadioIndication>& radioIndication);
123
124 Return<void> getIccCardStatus(int32_t serial);
125
126 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
127 const hidl_string& aid);
128
129 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
130 const hidl_string& pin, const hidl_string& aid);
131
132 Return<void> supplyIccPin2ForApp(int32_t serial,
133 const hidl_string& pin2,
134 const hidl_string& aid);
135
136 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
137 const hidl_string& pin2, const hidl_string& aid);
138
139 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
140 const hidl_string& newPin, const hidl_string& aid);
141
142 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
143 const hidl_string& newPin2, const hidl_string& aid);
144
145 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
146
147 Return<void> getCurrentCalls(int32_t serial);
148
149 Return<void> dial(int32_t serial, const Dial& dialInfo);
150
151 Return<void> getImsiForApp(int32_t serial,
152 const ::android::hardware::hidl_string& aid);
153
154 Return<void> hangup(int32_t serial, int32_t gsmIndex);
155
156 Return<void> hangupWaitingOrBackground(int32_t serial);
157
158 Return<void> hangupForegroundResumeBackground(int32_t serial);
159
160 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
161
162 Return<void> conference(int32_t serial);
163
164 Return<void> rejectCall(int32_t serial);
165
166 Return<void> getLastCallFailCause(int32_t serial);
167
168 Return<void> getSignalStrength(int32_t serial);
169
170 Return<void> getVoiceRegistrationState(int32_t serial);
171
172 Return<void> getDataRegistrationState(int32_t serial);
173
174 Return<void> getOperator(int32_t serial);
175
176 Return<void> setRadioPower(int32_t serial, bool on);
177
178 Return<void> sendDtmf(int32_t serial,
179 const ::android::hardware::hidl_string& s);
180
181 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
182
183 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
184
185 Return<void> setupDataCall(int32_t serial,
186 RadioTechnology radioTechnology,
187 const DataProfileInfo& profileInfo,
188 bool modemCognitive,
189 bool roamingAllowed,
190 bool isRoaming);
191
192 Return<void> iccIOForApp(int32_t serial,
193 const IccIo& iccIo);
194
195 Return<void> sendUssd(int32_t serial,
196 const ::android::hardware::hidl_string& ussd);
197
198 Return<void> cancelPendingUssd(int32_t serial);
199
200 Return<void> getClir(int32_t serial);
201
202 Return<void> setClir(int32_t serial, int32_t status);
203
204 Return<void> getCallForwardStatus(int32_t serial,
205 const CallForwardInfo& callInfo);
206
207 Return<void> setCallForward(int32_t serial,
208 const CallForwardInfo& callInfo);
209
210 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
211
212 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
213
214 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
215 bool success, SmsAcknowledgeFailCause cause);
216
217 Return<void> acceptCall(int32_t serial);
218
219 Return<void> deactivateDataCall(int32_t serial,
220 int32_t cid, bool reasonRadioShutDown);
221
222 Return<void> getFacilityLockForApp(int32_t serial,
223 const ::android::hardware::hidl_string& facility,
224 const ::android::hardware::hidl_string& password,
225 int32_t serviceClass,
226 const ::android::hardware::hidl_string& appId);
227
228 Return<void> setFacilityLockForApp(int32_t serial,
229 const ::android::hardware::hidl_string& facility,
230 bool lockState,
231 const ::android::hardware::hidl_string& password,
232 int32_t serviceClass,
233 const ::android::hardware::hidl_string& appId);
234
235 Return<void> setBarringPassword(int32_t serial,
236 const ::android::hardware::hidl_string& facility,
237 const ::android::hardware::hidl_string& oldPassword,
238 const ::android::hardware::hidl_string& newPassword);
239
240 Return<void> getNetworkSelectionMode(int32_t serial);
241
242 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
243
244 Return<void> setNetworkSelectionModeManual(int32_t serial,
245 const ::android::hardware::hidl_string& operatorNumeric);
246
247 Return<void> getAvailableNetworks(int32_t serial);
248
249 Return<void> startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request);
250
251 Return<void> stopNetworkScan(int32_t serial);
252
253 Return<void> startDtmf(int32_t serial,
254 const ::android::hardware::hidl_string& s);
255
256 Return<void> stopDtmf(int32_t serial);
257
258 Return<void> getBasebandVersion(int32_t serial);
259
260 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
261
262 Return<void> setMute(int32_t serial, bool enable);
263
264 Return<void> getMute(int32_t serial);
265
266 Return<void> getClip(int32_t serial);
267
268 Return<void> getDataCallList(int32_t serial);
269
270 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
271
272 Return<void> writeSmsToSim(int32_t serial,
273 const SmsWriteArgs& smsWriteArgs);
274
275 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
276
277 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
278
279 Return<void> getAvailableBandModes(int32_t serial);
280
281 Return<void> sendEnvelope(int32_t serial,
282 const ::android::hardware::hidl_string& command);
283
284 Return<void> sendTerminalResponseToSim(int32_t serial,
285 const ::android::hardware::hidl_string& commandResponse);
286
287 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
288
289 Return<void> explicitCallTransfer(int32_t serial);
290
291 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
292
293 Return<void> getPreferredNetworkType(int32_t serial);
294
295 Return<void> getNeighboringCids(int32_t serial);
296
297 Return<void> setLocationUpdates(int32_t serial, bool enable);
298
299 Return<void> setCdmaSubscriptionSource(int32_t serial,
300 CdmaSubscriptionSource cdmaSub);
301
302 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
303
304 Return<void> getCdmaRoamingPreference(int32_t serial);
305
306 Return<void> setTTYMode(int32_t serial, TtyMode mode);
307
308 Return<void> getTTYMode(int32_t serial);
309
310 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
311
312 Return<void> getPreferredVoicePrivacy(int32_t serial);
313
314 Return<void> sendCDMAFeatureCode(int32_t serial,
315 const ::android::hardware::hidl_string& featureCode);
316
317 Return<void> sendBurstDtmf(int32_t serial,
318 const ::android::hardware::hidl_string& dtmf,
319 int32_t on,
320 int32_t off);
321
322 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
323
324 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
325 const CdmaSmsAck& smsAck);
326
327 Return<void> getGsmBroadcastConfig(int32_t serial);
328
329 Return<void> setGsmBroadcastConfig(int32_t serial,
330 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
331
332 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
333
334 Return<void> getCdmaBroadcastConfig(int32_t serial);
335
336 Return<void> setCdmaBroadcastConfig(int32_t serial,
337 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
338
339 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
340
341 Return<void> getCDMASubscription(int32_t serial);
342
343 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
344
345 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
346
347 Return<void> getDeviceIdentity(int32_t serial);
348
349 Return<void> exitEmergencyCallbackMode(int32_t serial);
350
351 Return<void> getSmscAddress(int32_t serial);
352
353 Return<void> setSmscAddress(int32_t serial,
354 const ::android::hardware::hidl_string& smsc);
355
356 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
357
358 Return<void> reportStkServiceIsRunning(int32_t serial);
359
360 Return<void> getCdmaSubscriptionSource(int32_t serial);
361
362 Return<void> requestIsimAuthentication(int32_t serial,
363 const ::android::hardware::hidl_string& challenge);
364
365 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
366 bool success,
367 const ::android::hardware::hidl_string& ackPdu);
368
369 Return<void> sendEnvelopeWithStatus(int32_t serial,
370 const ::android::hardware::hidl_string& contents);
371
372 Return<void> getVoiceRadioTechnology(int32_t serial);
373
374 Return<void> getCellInfoList(int32_t serial);
375
376 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
377
378 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
379 bool modemCognitive, bool isRoaming);
380
381 Return<void> getImsRegistrationState(int32_t serial);
382
383 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
384
385 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
386
387 Return<void> iccOpenLogicalChannel(int32_t serial,
388 const ::android::hardware::hidl_string& aid, int32_t p2);
389
390 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
391
392 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
393
394 Return<void> nvReadItem(int32_t serial, NvItem itemId);
395
396 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
397
398 Return<void> nvWriteCdmaPrl(int32_t serial,
399 const ::android::hardware::hidl_vec<uint8_t>& prl);
400
401 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
402
403 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
404
405 Return<void> setDataAllowed(int32_t serial, bool allow);
406
407 Return<void> getHardwareConfig(int32_t serial);
408
409 Return<void> requestIccSimAuthentication(int32_t serial,
410 int32_t authContext,
411 const ::android::hardware::hidl_string& authData,
412 const ::android::hardware::hidl_string& aid);
413
414 Return<void> setDataProfile(int32_t serial,
415 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
416
417 Return<void> requestShutdown(int32_t serial);
418
419 Return<void> getRadioCapability(int32_t serial);
420
421 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
422
423 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
424
425 Return<void> stopLceService(int32_t serial);
426
427 Return<void> pullLceData(int32_t serial);
428
429 Return<void> getModemActivityInfo(int32_t serial);
430
431 Return<void> setAllowedCarriers(int32_t serial,
432 bool allAllowed,
433 const CarrierRestrictions& carriers);
434
435 Return<void> getAllowedCarriers(int32_t serial);
436
437 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
438
439 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
440
441 Return<void> startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive);
442
443 Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
444
445 Return<void> setSimCardPower(int32_t serial, bool powerUp);
446 Return<void> setSimCardPower_1_1(int32_t serial,
447 const V1_1::CardPowerState state);
448
449 Return<void> responseAcknowledgement();
450
451 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
452 const V1_1::ImsiEncryptionInfo& message);
453
454 void checkReturnStatus(Return<void>& ret);
455 };
456
457 struct OemHookImpl : public IOemHook {
458 int32_t mSlotId;
459 sp<IOemHookResponse> mOemHookResponse;
460 sp<IOemHookIndication> mOemHookIndication;
461
462 Return<void> setResponseFunctions(
463 const ::android::sp<IOemHookResponse>& oemHookResponse,
464 const ::android::sp<IOemHookIndication>& oemHookIndication);
465
466 Return<void> sendRequestRaw(int32_t serial,
467 const ::android::hardware::hidl_vec<uint8_t>& data);
468
469 Return<void> sendRequestStrings(int32_t serial,
470 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
471 };
472
memsetAndFreeStrings(int numPointers,...)473 void memsetAndFreeStrings(int numPointers, ...) {
474 va_list ap;
475 va_start(ap, numPointers);
476 for (int i = 0; i < numPointers; i++) {
477 char *ptr = va_arg(ap, char *);
478 if (ptr) {
479 #ifdef MEMSET_FREED
480 #define MAX_STRING_LENGTH 4096
481 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
482 #endif
483 free(ptr);
484 }
485 }
486 va_end(ap);
487 }
488
sendErrorResponse(RequestInfo * pRI,RIL_Errno err)489 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
490 pRI->pCI->responseFunction((int) pRI->socket_id,
491 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
492 }
493
494 /**
495 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
496 * request with error RIL_E_NO_MEMORY.
497 * Returns true on success, and false on failure.
498 */
copyHidlStringToRil(char ** dest,const hidl_string & src,RequestInfo * pRI)499 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
500 size_t len = src.size();
501 if (len == 0) {
502 *dest = NULL;
503 return true;
504 }
505 *dest = (char *) calloc(len + 1, sizeof(char));
506 if (*dest == NULL) {
507 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
508 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
509 return false;
510 }
511 strncpy(*dest, src.c_str(), len + 1);
512 return true;
513 }
514
convertCharPtrToHidlString(const char * ptr)515 hidl_string convertCharPtrToHidlString(const char *ptr) {
516 hidl_string ret;
517 if (ptr != NULL) {
518 // TODO: replace this with strnlen
519 ret.setToExternal(ptr, strlen(ptr));
520 }
521 return ret;
522 }
523
dispatchVoid(int serial,int slotId,int request)524 bool dispatchVoid(int serial, int slotId, int request) {
525 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
526 if (pRI == NULL) {
527 return false;
528 }
529 CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
530 return true;
531 }
532
dispatchString(int serial,int slotId,int request,const char * str)533 bool dispatchString(int serial, int slotId, int request, const char * str) {
534 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
535 if (pRI == NULL) {
536 return false;
537 }
538
539 char *pString;
540 if (!copyHidlStringToRil(&pString, str, pRI)) {
541 return false;
542 }
543
544 CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
545
546 memsetAndFreeStrings(1, pString);
547 return true;
548 }
549
dispatchStrings(int serial,int slotId,int request,int countStrings,...)550 bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) {
551 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
552 if (pRI == NULL) {
553 return false;
554 }
555
556 char **pStrings;
557 pStrings = (char **)calloc(countStrings, sizeof(char *));
558 if (pStrings == NULL) {
559 RLOGE("Memory allocation failed for request %s", requestToString(request));
560 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
561 return false;
562 }
563 va_list ap;
564 va_start(ap, countStrings);
565 for (int i = 0; i < countStrings; i++) {
566 const char* str = va_arg(ap, const char *);
567 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI)) {
568 va_end(ap);
569 for (int j = 0; j < i; j++) {
570 memsetAndFreeStrings(1, pStrings[j]);
571 }
572 free(pStrings);
573 return false;
574 }
575 }
576 va_end(ap);
577
578 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
579
580 if (pStrings != NULL) {
581 for (int i = 0 ; i < countStrings ; i++) {
582 memsetAndFreeStrings(1, pStrings[i]);
583 }
584
585 #ifdef MEMSET_FREED
586 memset(pStrings, 0, countStrings * sizeof(char *));
587 #endif
588 free(pStrings);
589 }
590 return true;
591 }
592
dispatchStrings(int serial,int slotId,int request,const hidl_vec<hidl_string> & data)593 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
594 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
595 if (pRI == NULL) {
596 return false;
597 }
598
599 int countStrings = data.size();
600 char **pStrings;
601 pStrings = (char **)calloc(countStrings, sizeof(char *));
602 if (pStrings == NULL) {
603 RLOGE("Memory allocation failed for request %s", requestToString(request));
604 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
605 return false;
606 }
607
608 for (int i = 0; i < countStrings; i++) {
609 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
610 for (int j = 0; j < i; j++) {
611 memsetAndFreeStrings(1, pStrings[j]);
612 }
613 free(pStrings);
614 return false;
615 }
616 }
617
618 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
619
620 if (pStrings != NULL) {
621 for (int i = 0 ; i < countStrings ; i++) {
622 memsetAndFreeStrings(1, pStrings[i]);
623 }
624
625 #ifdef MEMSET_FREED
626 memset(pStrings, 0, countStrings * sizeof(char *));
627 #endif
628 free(pStrings);
629 }
630 return true;
631 }
632
dispatchInts(int serial,int slotId,int request,int countInts,...)633 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
634 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
635 if (pRI == NULL) {
636 return false;
637 }
638
639 int *pInts = (int *)calloc(countInts, sizeof(int));
640
641 if (pInts == NULL) {
642 RLOGE("Memory allocation failed for request %s", requestToString(request));
643 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
644 return false;
645 }
646 va_list ap;
647 va_start(ap, countInts);
648 for (int i = 0; i < countInts; i++) {
649 pInts[i] = va_arg(ap, int);
650 }
651 va_end(ap);
652
653 CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
654
655 if (pInts != NULL) {
656 #ifdef MEMSET_FREED
657 memset(pInts, 0, countInts * sizeof(int));
658 #endif
659 free(pInts);
660 }
661 return true;
662 }
663
dispatchCallForwardStatus(int serial,int slotId,int request,const CallForwardInfo & callInfo)664 bool dispatchCallForwardStatus(int serial, int slotId, int request,
665 const CallForwardInfo& callInfo) {
666 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
667 if (pRI == NULL) {
668 return false;
669 }
670
671 RIL_CallForwardInfo cf;
672 cf.status = (int) callInfo.status;
673 cf.reason = callInfo.reason;
674 cf.serviceClass = callInfo.serviceClass;
675 cf.toa = callInfo.toa;
676 cf.timeSeconds = callInfo.timeSeconds;
677
678 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
679 return false;
680 }
681
682 CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
683
684 memsetAndFreeStrings(1, cf.number);
685
686 return true;
687 }
688
dispatchRaw(int serial,int slotId,int request,const hidl_vec<uint8_t> & rawBytes)689 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
690 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
691 if (pRI == NULL) {
692 return false;
693 }
694
695 const uint8_t *uData = rawBytes.data();
696
697 CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
698
699 return true;
700 }
701
dispatchIccApdu(int serial,int slotId,int request,const SimApdu & message)702 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
703 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
704 if (pRI == NULL) {
705 return false;
706 }
707
708 RIL_SIM_APDU apdu = {};
709
710 apdu.sessionid = message.sessionId;
711 apdu.cla = message.cla;
712 apdu.instruction = message.instruction;
713 apdu.p1 = message.p1;
714 apdu.p2 = message.p2;
715 apdu.p3 = message.p3;
716
717 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
718 return false;
719 }
720
721 CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
722
723 memsetAndFreeStrings(1, apdu.data);
724
725 return true;
726 }
727
checkReturnStatus(int32_t slotId,Return<void> & ret,bool isRadioService)728 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
729 if (ret.isOk() == false) {
730 RLOGE("checkReturnStatus: unable to call response/indication callback");
731 // Remote process hosting the callbacks must be dead. Reset the callback objects;
732 // there's no other recovery to be done here. When the client process is back up, it will
733 // call setResponseFunctions()
734
735 // Caller should already hold rdlock, release that first
736 // note the current counter to avoid overwriting updates made by another thread before
737 // write lock is acquired.
738 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
739 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
740 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
741 assert(ret == 0);
742
743 // acquire wrlock
744 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
745 assert(ret == 0);
746
747 // make sure the counter value has not changed
748 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
749 if (isRadioService) {
750 radioService[slotId]->mRadioResponse = NULL;
751 radioService[slotId]->mRadioIndication = NULL;
752 radioService[slotId]->mRadioResponseV1_1 = NULL;
753 radioService[slotId]->mRadioIndicationV1_1 = NULL;
754 } else {
755 oemHookService[slotId]->mOemHookResponse = NULL;
756 oemHookService[slotId]->mOemHookIndication = NULL;
757 }
758 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
759 } else {
760 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
761 "got updated on another thread");
762 }
763
764 // release wrlock
765 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
766 assert(ret == 0);
767
768 // Reacquire rdlock
769 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
770 assert(ret == 0);
771 }
772 }
773
checkReturnStatus(Return<void> & ret)774 void RadioImpl::checkReturnStatus(Return<void>& ret) {
775 ::checkReturnStatus(mSlotId, ret, true);
776 }
777
setResponseFunctions(const::android::sp<IRadioResponse> & radioResponseParam,const::android::sp<IRadioIndication> & radioIndicationParam)778 Return<void> RadioImpl::setResponseFunctions(
779 const ::android::sp<IRadioResponse>& radioResponseParam,
780 const ::android::sp<IRadioIndication>& radioIndicationParam) {
781 RLOGD("setResponseFunctions");
782
783 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
784 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
785 assert(ret == 0);
786
787 mRadioResponse = radioResponseParam;
788 mRadioIndication = radioIndicationParam;
789 mRadioResponseV1_1 = V1_1::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
790 mRadioIndicationV1_1 = V1_1::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
791 if (mRadioResponseV1_1 == nullptr || mRadioIndicationV1_1 == nullptr) {
792 mRadioResponseV1_1 = nullptr;
793 mRadioIndicationV1_1 = nullptr;
794 }
795
796 mCounterRadio[mSlotId]++;
797
798 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
799 assert(ret == 0);
800
801 // client is connected. Send initial indications.
802 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
803
804 return Void();
805 }
806
getIccCardStatus(int32_t serial)807 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
808 #if VDBG
809 RLOGD("getIccCardStatus: serial %d", serial);
810 #endif
811 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
812 return Void();
813 }
814
supplyIccPinForApp(int32_t serial,const hidl_string & pin,const hidl_string & aid)815 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
816 const hidl_string& aid) {
817 #if VDBG
818 RLOGD("supplyIccPinForApp: serial %d", serial);
819 #endif
820 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
821 2, pin.c_str(), aid.c_str());
822 return Void();
823 }
824
supplyIccPukForApp(int32_t serial,const hidl_string & puk,const hidl_string & pin,const hidl_string & aid)825 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
826 const hidl_string& pin, const hidl_string& aid) {
827 #if VDBG
828 RLOGD("supplyIccPukForApp: serial %d", serial);
829 #endif
830 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
831 3, puk.c_str(), pin.c_str(), aid.c_str());
832 return Void();
833 }
834
supplyIccPin2ForApp(int32_t serial,const hidl_string & pin2,const hidl_string & aid)835 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
836 const hidl_string& aid) {
837 #if VDBG
838 RLOGD("supplyIccPin2ForApp: serial %d", serial);
839 #endif
840 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
841 2, pin2.c_str(), aid.c_str());
842 return Void();
843 }
844
supplyIccPuk2ForApp(int32_t serial,const hidl_string & puk2,const hidl_string & pin2,const hidl_string & aid)845 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
846 const hidl_string& pin2, const hidl_string& aid) {
847 #if VDBG
848 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
849 #endif
850 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
851 3, puk2.c_str(), pin2.c_str(), aid.c_str());
852 return Void();
853 }
854
changeIccPinForApp(int32_t serial,const hidl_string & oldPin,const hidl_string & newPin,const hidl_string & aid)855 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
856 const hidl_string& newPin, const hidl_string& aid) {
857 #if VDBG
858 RLOGD("changeIccPinForApp: serial %d", serial);
859 #endif
860 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
861 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
862 return Void();
863 }
864
changeIccPin2ForApp(int32_t serial,const hidl_string & oldPin2,const hidl_string & newPin2,const hidl_string & aid)865 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
866 const hidl_string& newPin2, const hidl_string& aid) {
867 #if VDBG
868 RLOGD("changeIccPin2ForApp: serial %d", serial);
869 #endif
870 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
871 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
872 return Void();
873 }
874
supplyNetworkDepersonalization(int32_t serial,const hidl_string & netPin)875 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
876 const hidl_string& netPin) {
877 #if VDBG
878 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
879 #endif
880 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
881 1, netPin.c_str());
882 return Void();
883 }
884
getCurrentCalls(int32_t serial)885 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
886 #if VDBG
887 RLOGD("getCurrentCalls: serial %d", serial);
888 #endif
889 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
890 return Void();
891 }
892
dial(int32_t serial,const Dial & dialInfo)893 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
894 #if VDBG
895 RLOGD("dial: serial %d", serial);
896 #endif
897 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
898 if (pRI == NULL) {
899 return Void();
900 }
901 RIL_Dial dial = {};
902 RIL_UUS_Info uusInfo = {};
903 int32_t sizeOfDial = sizeof(dial);
904
905 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
906 return Void();
907 }
908 dial.clir = (int) dialInfo.clir;
909
910 if (dialInfo.uusInfo.size() != 0) {
911 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
912 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
913
914 if (dialInfo.uusInfo[0].uusData.size() == 0) {
915 uusInfo.uusData = NULL;
916 uusInfo.uusLength = 0;
917 } else {
918 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
919 memsetAndFreeStrings(1, dial.address);
920 return Void();
921 }
922 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
923 }
924
925 dial.uusInfo = &uusInfo;
926 }
927
928 CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
929
930 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
931
932 return Void();
933 }
934
getImsiForApp(int32_t serial,const hidl_string & aid)935 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
936 #if VDBG
937 RLOGD("getImsiForApp: serial %d", serial);
938 #endif
939 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
940 1, aid.c_str());
941 return Void();
942 }
943
hangup(int32_t serial,int32_t gsmIndex)944 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
945 #if VDBG
946 RLOGD("hangup: serial %d", serial);
947 #endif
948 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
949 return Void();
950 }
951
hangupWaitingOrBackground(int32_t serial)952 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
953 #if VDBG
954 RLOGD("hangupWaitingOrBackground: serial %d", serial);
955 #endif
956 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
957 return Void();
958 }
959
hangupForegroundResumeBackground(int32_t serial)960 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
961 #if VDBG
962 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
963 #endif
964 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
965 return Void();
966 }
967
switchWaitingOrHoldingAndActive(int32_t serial)968 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
969 #if VDBG
970 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
971 #endif
972 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
973 return Void();
974 }
975
conference(int32_t serial)976 Return<void> RadioImpl::conference(int32_t serial) {
977 #if VDBG
978 RLOGD("conference: serial %d", serial);
979 #endif
980 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
981 return Void();
982 }
983
rejectCall(int32_t serial)984 Return<void> RadioImpl::rejectCall(int32_t serial) {
985 #if VDBG
986 RLOGD("rejectCall: serial %d", serial);
987 #endif
988 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
989 return Void();
990 }
991
getLastCallFailCause(int32_t serial)992 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
993 #if VDBG
994 RLOGD("getLastCallFailCause: serial %d", serial);
995 #endif
996 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
997 return Void();
998 }
999
getSignalStrength(int32_t serial)1000 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
1001 #if VDBG
1002 RLOGD("getSignalStrength: serial %d", serial);
1003 #endif
1004 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
1005 return Void();
1006 }
1007
getVoiceRegistrationState(int32_t serial)1008 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
1009 #if VDBG
1010 RLOGD("getVoiceRegistrationState: serial %d", serial);
1011 #endif
1012 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
1013 return Void();
1014 }
1015
getDataRegistrationState(int32_t serial)1016 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
1017 #if VDBG
1018 RLOGD("getDataRegistrationState: serial %d", serial);
1019 #endif
1020 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1021 return Void();
1022 }
1023
getOperator(int32_t serial)1024 Return<void> RadioImpl::getOperator(int32_t serial) {
1025 #if VDBG
1026 RLOGD("getOperator: serial %d", serial);
1027 #endif
1028 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1029 return Void();
1030 }
1031
setRadioPower(int32_t serial,bool on)1032 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
1033 RLOGD("setRadioPower: serial %d on %d", serial, on);
1034 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1035 return Void();
1036 }
1037
sendDtmf(int32_t serial,const hidl_string & s)1038 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1039 #if VDBG
1040 RLOGD("sendDtmf: serial %d", serial);
1041 #endif
1042 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1043 return Void();
1044 }
1045
sendSms(int32_t serial,const GsmSmsMessage & message)1046 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1047 #if VDBG
1048 RLOGD("sendSms: serial %d", serial);
1049 #endif
1050 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
1051 2, message.smscPdu.c_str(), message.pdu.c_str());
1052 return Void();
1053 }
1054
sendSMSExpectMore(int32_t serial,const GsmSmsMessage & message)1055 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1056 #if VDBG
1057 RLOGD("sendSMSExpectMore: serial %d", serial);
1058 #endif
1059 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
1060 2, message.smscPdu.c_str(), message.pdu.c_str());
1061 return Void();
1062 }
1063
convertMvnoTypeToString(MvnoType type,char * & str)1064 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1065 switch (type) {
1066 case MvnoType::IMSI:
1067 str = (char *)"imsi";
1068 return true;
1069 case MvnoType::GID:
1070 str = (char *)"gid";
1071 return true;
1072 case MvnoType::SPN:
1073 str = (char *)"spn";
1074 return true;
1075 case MvnoType::NONE:
1076 str = (char *)"";
1077 return true;
1078 }
1079 return false;
1080 }
1081
setupDataCall(int32_t serial,RadioTechnology radioTechnology,const DataProfileInfo & dataProfileInfo,bool modemCognitive,bool roamingAllowed,bool isRoaming)1082 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1083 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1084 bool roamingAllowed, bool isRoaming) {
1085
1086 #if VDBG
1087 RLOGD("setupDataCall: serial %d", serial);
1088 #endif
1089
1090 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1091 const hidl_string &protocol =
1092 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1093 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
1094 std::to_string((int) radioTechnology + 2).c_str(),
1095 std::to_string((int) dataProfileInfo.profileId).c_str(),
1096 dataProfileInfo.apn.c_str(),
1097 dataProfileInfo.user.c_str(),
1098 dataProfileInfo.password.c_str(),
1099 std::to_string((int) dataProfileInfo.authType).c_str(),
1100 protocol.c_str());
1101 } else if (s_vendorFunctions->version >= 15) {
1102 char *mvnoTypeStr = NULL;
1103 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1104 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1105 RIL_REQUEST_SETUP_DATA_CALL);
1106 if (pRI != NULL) {
1107 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1108 }
1109 return Void();
1110 }
1111 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1112 std::to_string((int) radioTechnology + 2).c_str(),
1113 std::to_string((int) dataProfileInfo.profileId).c_str(),
1114 dataProfileInfo.apn.c_str(),
1115 dataProfileInfo.user.c_str(),
1116 dataProfileInfo.password.c_str(),
1117 std::to_string((int) dataProfileInfo.authType).c_str(),
1118 dataProfileInfo.protocol.c_str(),
1119 dataProfileInfo.roamingProtocol.c_str(),
1120 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1121 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1122 modemCognitive ? "1" : "0",
1123 std::to_string(dataProfileInfo.mtu).c_str(),
1124 mvnoTypeStr,
1125 dataProfileInfo.mvnoMatchData.c_str(),
1126 roamingAllowed ? "1" : "0");
1127 } else {
1128 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1129 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1130 RIL_REQUEST_SETUP_DATA_CALL);
1131 if (pRI != NULL) {
1132 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1133 }
1134 }
1135 return Void();
1136 }
1137
iccIOForApp(int32_t serial,const IccIo & iccIo)1138 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1139 #if VDBG
1140 RLOGD("iccIOForApp: serial %d", serial);
1141 #endif
1142 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1143 if (pRI == NULL) {
1144 return Void();
1145 }
1146
1147 RIL_SIM_IO_v6 rilIccIo = {};
1148 rilIccIo.command = iccIo.command;
1149 rilIccIo.fileid = iccIo.fileId;
1150 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1151 return Void();
1152 }
1153
1154 rilIccIo.p1 = iccIo.p1;
1155 rilIccIo.p2 = iccIo.p2;
1156 rilIccIo.p3 = iccIo.p3;
1157
1158 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1159 memsetAndFreeStrings(1, rilIccIo.path);
1160 return Void();
1161 }
1162
1163 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1164 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1165 return Void();
1166 }
1167
1168 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1169 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1170 return Void();
1171 }
1172
1173 CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1174
1175 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1176
1177 return Void();
1178 }
1179
sendUssd(int32_t serial,const hidl_string & ussd)1180 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1181 #if VDBG
1182 RLOGD("sendUssd: serial %d", serial);
1183 #endif
1184 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1185 return Void();
1186 }
1187
cancelPendingUssd(int32_t serial)1188 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1189 #if VDBG
1190 RLOGD("cancelPendingUssd: serial %d", serial);
1191 #endif
1192 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1193 return Void();
1194 }
1195
getClir(int32_t serial)1196 Return<void> RadioImpl::getClir(int32_t serial) {
1197 #if VDBG
1198 RLOGD("getClir: serial %d", serial);
1199 #endif
1200 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1201 return Void();
1202 }
1203
setClir(int32_t serial,int32_t status)1204 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1205 #if VDBG
1206 RLOGD("setClir: serial %d", serial);
1207 #endif
1208 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1209 return Void();
1210 }
1211
getCallForwardStatus(int32_t serial,const CallForwardInfo & callInfo)1212 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1213 #if VDBG
1214 RLOGD("getCallForwardStatus: serial %d", serial);
1215 #endif
1216 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1217 callInfo);
1218 return Void();
1219 }
1220
setCallForward(int32_t serial,const CallForwardInfo & callInfo)1221 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1222 #if VDBG
1223 RLOGD("setCallForward: serial %d", serial);
1224 #endif
1225 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1226 callInfo);
1227 return Void();
1228 }
1229
getCallWaiting(int32_t serial,int32_t serviceClass)1230 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1231 #if VDBG
1232 RLOGD("getCallWaiting: serial %d", serial);
1233 #endif
1234 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1235 return Void();
1236 }
1237
setCallWaiting(int32_t serial,bool enable,int32_t serviceClass)1238 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1239 #if VDBG
1240 RLOGD("setCallWaiting: serial %d", serial);
1241 #endif
1242 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1243 serviceClass);
1244 return Void();
1245 }
1246
acknowledgeLastIncomingGsmSms(int32_t serial,bool success,SmsAcknowledgeFailCause cause)1247 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1248 bool success, SmsAcknowledgeFailCause cause) {
1249 #if VDBG
1250 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1251 #endif
1252 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1253 cause);
1254 return Void();
1255 }
1256
acceptCall(int32_t serial)1257 Return<void> RadioImpl::acceptCall(int32_t serial) {
1258 #if VDBG
1259 RLOGD("acceptCall: serial %d", serial);
1260 #endif
1261 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1262 return Void();
1263 }
1264
deactivateDataCall(int32_t serial,int32_t cid,bool reasonRadioShutDown)1265 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1266 int32_t cid, bool reasonRadioShutDown) {
1267 #if VDBG
1268 RLOGD("deactivateDataCall: serial %d", serial);
1269 #endif
1270 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1271 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1272 return Void();
1273 }
1274
getFacilityLockForApp(int32_t serial,const hidl_string & facility,const hidl_string & password,int32_t serviceClass,const hidl_string & appId)1275 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1276 const hidl_string& password, int32_t serviceClass,
1277 const hidl_string& appId) {
1278 #if VDBG
1279 RLOGD("getFacilityLockForApp: serial %d", serial);
1280 #endif
1281 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1282 4, facility.c_str(), password.c_str(),
1283 (std::to_string(serviceClass)).c_str(), appId.c_str());
1284 return Void();
1285 }
1286
setFacilityLockForApp(int32_t serial,const hidl_string & facility,bool lockState,const hidl_string & password,int32_t serviceClass,const hidl_string & appId)1287 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1288 bool lockState, const hidl_string& password,
1289 int32_t serviceClass, const hidl_string& appId) {
1290 #if VDBG
1291 RLOGD("setFacilityLockForApp: serial %d", serial);
1292 #endif
1293 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1294 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1295 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1296 return Void();
1297 }
1298
setBarringPassword(int32_t serial,const hidl_string & facility,const hidl_string & oldPassword,const hidl_string & newPassword)1299 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1300 const hidl_string& oldPassword,
1301 const hidl_string& newPassword) {
1302 #if VDBG
1303 RLOGD("setBarringPassword: serial %d", serial);
1304 #endif
1305 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1306 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1307 return Void();
1308 }
1309
getNetworkSelectionMode(int32_t serial)1310 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1311 #if VDBG
1312 RLOGD("getNetworkSelectionMode: serial %d", serial);
1313 #endif
1314 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1315 return Void();
1316 }
1317
setNetworkSelectionModeAutomatic(int32_t serial)1318 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1319 #if VDBG
1320 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1321 #endif
1322 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1323 return Void();
1324 }
1325
setNetworkSelectionModeManual(int32_t serial,const hidl_string & operatorNumeric)1326 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1327 const hidl_string& operatorNumeric) {
1328 #if VDBG
1329 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1330 #endif
1331 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1332 operatorNumeric.c_str());
1333 return Void();
1334 }
1335
getAvailableNetworks(int32_t serial)1336 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1337 #if VDBG
1338 RLOGD("getAvailableNetworks: serial %d", serial);
1339 #endif
1340 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1341 return Void();
1342 }
1343
startNetworkScan(int32_t serial,const V1_1::NetworkScanRequest & request)1344 Return<void> RadioImpl::startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request) {
1345 #if VDBG
1346 RLOGD("startNetworkScan: serial %d", serial);
1347 #endif
1348
1349 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1350 if (pRI == NULL) {
1351 return Void();
1352 }
1353
1354 if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
1355 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1356 return Void();
1357 }
1358
1359 RIL_NetworkScanRequest scan_request = {};
1360
1361 scan_request.type = (RIL_ScanType) request.type;
1362 scan_request.interval = request.interval;
1363 scan_request.specifiers_length = request.specifiers.size();
1364 for (size_t i = 0; i < request.specifiers.size(); ++i) {
1365 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
1366 request.specifiers[i].utranBands.size() > MAX_BANDS ||
1367 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
1368 request.specifiers[i].channels.size() > MAX_CHANNELS) {
1369 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1370 return Void();
1371 }
1372 const V1_1::RadioAccessSpecifier& ras_from =
1373 request.specifiers[i];
1374 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
1375
1376 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
1377 ras_to.channels_length = ras_from.channels.size();
1378
1379 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
1380 const std::vector<uint32_t> * bands = nullptr;
1381 switch (request.specifiers[i].radioAccessNetwork) {
1382 case V1_1::RadioAccessNetworks::GERAN:
1383 ras_to.bands_length = ras_from.geranBands.size();
1384 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
1385 break;
1386 case V1_1::RadioAccessNetworks::UTRAN:
1387 ras_to.bands_length = ras_from.utranBands.size();
1388 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
1389 break;
1390 case V1_1::RadioAccessNetworks::EUTRAN:
1391 ras_to.bands_length = ras_from.eutranBands.size();
1392 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
1393 break;
1394 default:
1395 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1396 return Void();
1397 }
1398 // safe to copy to geran_bands because it's a union member
1399 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
1400 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
1401 }
1402 }
1403
1404 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
1405 mSlotId);
1406
1407 return Void();
1408 }
1409
stopNetworkScan(int32_t serial)1410 Return<void> RadioImpl::stopNetworkScan(int32_t serial) {
1411 #if VDBG
1412 RLOGD("stopNetworkScan: serial %d", serial);
1413 #endif
1414 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1415 return Void();
1416 }
1417
startDtmf(int32_t serial,const hidl_string & s)1418 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1419 #if VDBG
1420 RLOGD("startDtmf: serial %d", serial);
1421 #endif
1422 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1423 s.c_str());
1424 return Void();
1425 }
1426
stopDtmf(int32_t serial)1427 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1428 #if VDBG
1429 RLOGD("stopDtmf: serial %d", serial);
1430 #endif
1431 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1432 return Void();
1433 }
1434
getBasebandVersion(int32_t serial)1435 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1436 #if VDBG
1437 RLOGD("getBasebandVersion: serial %d", serial);
1438 #endif
1439 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1440 return Void();
1441 }
1442
separateConnection(int32_t serial,int32_t gsmIndex)1443 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1444 #if VDBG
1445 RLOGD("separateConnection: serial %d", serial);
1446 #endif
1447 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1448 return Void();
1449 }
1450
setMute(int32_t serial,bool enable)1451 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1452 #if VDBG
1453 RLOGD("setMute: serial %d", serial);
1454 #endif
1455 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1456 return Void();
1457 }
1458
getMute(int32_t serial)1459 Return<void> RadioImpl::getMute(int32_t serial) {
1460 #if VDBG
1461 RLOGD("getMute: serial %d", serial);
1462 #endif
1463 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1464 return Void();
1465 }
1466
getClip(int32_t serial)1467 Return<void> RadioImpl::getClip(int32_t serial) {
1468 #if VDBG
1469 RLOGD("getClip: serial %d", serial);
1470 #endif
1471 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1472 return Void();
1473 }
1474
getDataCallList(int32_t serial)1475 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1476 #if VDBG
1477 RLOGD("getDataCallList: serial %d", serial);
1478 #endif
1479 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1480 return Void();
1481 }
1482
setSuppServiceNotifications(int32_t serial,bool enable)1483 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1484 #if VDBG
1485 RLOGD("setSuppServiceNotifications: serial %d", serial);
1486 #endif
1487 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1488 BOOL_TO_INT(enable));
1489 return Void();
1490 }
1491
writeSmsToSim(int32_t serial,const SmsWriteArgs & smsWriteArgs)1492 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1493 #if VDBG
1494 RLOGD("writeSmsToSim: serial %d", serial);
1495 #endif
1496 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1497 if (pRI == NULL) {
1498 return Void();
1499 }
1500
1501 RIL_SMS_WriteArgs args;
1502 args.status = (int) smsWriteArgs.status;
1503
1504 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1505 return Void();
1506 }
1507
1508 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1509 memsetAndFreeStrings(1, args.pdu);
1510 return Void();
1511 }
1512
1513 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
1514
1515 memsetAndFreeStrings(2, args.smsc, args.pdu);
1516
1517 return Void();
1518 }
1519
deleteSmsOnSim(int32_t serial,int32_t index)1520 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1521 #if VDBG
1522 RLOGD("deleteSmsOnSim: serial %d", serial);
1523 #endif
1524 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1525 return Void();
1526 }
1527
setBandMode(int32_t serial,RadioBandMode mode)1528 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1529 #if VDBG
1530 RLOGD("setBandMode: serial %d", serial);
1531 #endif
1532 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1533 return Void();
1534 }
1535
getAvailableBandModes(int32_t serial)1536 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1537 #if VDBG
1538 RLOGD("getAvailableBandModes: serial %d", serial);
1539 #endif
1540 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1541 return Void();
1542 }
1543
sendEnvelope(int32_t serial,const hidl_string & command)1544 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1545 #if VDBG
1546 RLOGD("sendEnvelope: serial %d", serial);
1547 #endif
1548 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1549 command.c_str());
1550 return Void();
1551 }
1552
sendTerminalResponseToSim(int32_t serial,const hidl_string & commandResponse)1553 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1554 const hidl_string& commandResponse) {
1555 #if VDBG
1556 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1557 #endif
1558 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1559 commandResponse.c_str());
1560 return Void();
1561 }
1562
handleStkCallSetupRequestFromSim(int32_t serial,bool accept)1563 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1564 #if VDBG
1565 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1566 #endif
1567 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1568 1, BOOL_TO_INT(accept));
1569 return Void();
1570 }
1571
explicitCallTransfer(int32_t serial)1572 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1573 #if VDBG
1574 RLOGD("explicitCallTransfer: serial %d", serial);
1575 #endif
1576 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1577 return Void();
1578 }
1579
setPreferredNetworkType(int32_t serial,PreferredNetworkType nwType)1580 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1581 #if VDBG
1582 RLOGD("setPreferredNetworkType: serial %d", serial);
1583 #endif
1584 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1585 return Void();
1586 }
1587
getPreferredNetworkType(int32_t serial)1588 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1589 #if VDBG
1590 RLOGD("getPreferredNetworkType: serial %d", serial);
1591 #endif
1592 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1593 return Void();
1594 }
1595
getNeighboringCids(int32_t serial)1596 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1597 #if VDBG
1598 RLOGD("getNeighboringCids: serial %d", serial);
1599 #endif
1600 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1601 return Void();
1602 }
1603
setLocationUpdates(int32_t serial,bool enable)1604 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1605 #if VDBG
1606 RLOGD("setLocationUpdates: serial %d", serial);
1607 #endif
1608 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1609 return Void();
1610 }
1611
setCdmaSubscriptionSource(int32_t serial,CdmaSubscriptionSource cdmaSub)1612 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1613 #if VDBG
1614 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1615 #endif
1616 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1617 return Void();
1618 }
1619
setCdmaRoamingPreference(int32_t serial,CdmaRoamingType type)1620 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1621 #if VDBG
1622 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1623 #endif
1624 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1625 return Void();
1626 }
1627
getCdmaRoamingPreference(int32_t serial)1628 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1629 #if VDBG
1630 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1631 #endif
1632 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1633 return Void();
1634 }
1635
setTTYMode(int32_t serial,TtyMode mode)1636 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1637 #if VDBG
1638 RLOGD("setTTYMode: serial %d", serial);
1639 #endif
1640 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1641 return Void();
1642 }
1643
getTTYMode(int32_t serial)1644 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1645 #if VDBG
1646 RLOGD("getTTYMode: serial %d", serial);
1647 #endif
1648 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1649 return Void();
1650 }
1651
setPreferredVoicePrivacy(int32_t serial,bool enable)1652 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1653 #if VDBG
1654 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1655 #endif
1656 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1657 1, BOOL_TO_INT(enable));
1658 return Void();
1659 }
1660
getPreferredVoicePrivacy(int32_t serial)1661 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1662 #if VDBG
1663 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1664 #endif
1665 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1666 return Void();
1667 }
1668
sendCDMAFeatureCode(int32_t serial,const hidl_string & featureCode)1669 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1670 #if VDBG
1671 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1672 #endif
1673 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1674 featureCode.c_str());
1675 return Void();
1676 }
1677
sendBurstDtmf(int32_t serial,const hidl_string & dtmf,int32_t on,int32_t off)1678 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1679 int32_t off) {
1680 #if VDBG
1681 RLOGD("sendBurstDtmf: serial %d", serial);
1682 #endif
1683 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1684 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1685 (std::to_string(off)).c_str());
1686 return Void();
1687 }
1688
constructCdmaSms(RIL_CDMA_SMS_Message & rcsm,const CdmaSmsMessage & sms)1689 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1690 rcsm.uTeleserviceID = sms.teleserviceId;
1691 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1692 rcsm.uServicecategory = sms.serviceCategory;
1693 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1694 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1695 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1696 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1697
1698 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1699 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1700 for (int i = 0; i < digitLimit; i++) {
1701 rcsm.sAddress.digits[i] = sms.address.digits[i];
1702 }
1703
1704 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1705 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1706
1707 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1708 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1709 for (int i = 0; i < digitLimit; i++) {
1710 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1711 }
1712
1713 rcsm.uBearerDataLen = sms.bearerData.size();
1714 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1715 for (int i = 0; i < digitLimit; i++) {
1716 rcsm.aBearerData[i] = sms.bearerData[i];
1717 }
1718 }
1719
sendCdmaSms(int32_t serial,const CdmaSmsMessage & sms)1720 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1721 #if VDBG
1722 RLOGD("sendCdmaSms: serial %d", serial);
1723 #endif
1724 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1725 if (pRI == NULL) {
1726 return Void();
1727 }
1728
1729 RIL_CDMA_SMS_Message rcsm = {};
1730 constructCdmaSms(rcsm, sms);
1731
1732 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
1733 return Void();
1734 }
1735
acknowledgeLastIncomingCdmaSms(int32_t serial,const CdmaSmsAck & smsAck)1736 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1737 #if VDBG
1738 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1739 #endif
1740 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1741 if (pRI == NULL) {
1742 return Void();
1743 }
1744
1745 RIL_CDMA_SMS_Ack rcsa = {};
1746
1747 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1748 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1749
1750 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
1751 return Void();
1752 }
1753
getGsmBroadcastConfig(int32_t serial)1754 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1755 #if VDBG
1756 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1757 #endif
1758 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1759 return Void();
1760 }
1761
setGsmBroadcastConfig(int32_t serial,const hidl_vec<GsmBroadcastSmsConfigInfo> & configInfo)1762 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1763 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1764 configInfo) {
1765 #if VDBG
1766 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1767 #endif
1768 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1769 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1770 if (pRI == NULL) {
1771 return Void();
1772 }
1773
1774 int num = configInfo.size();
1775 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1776 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1777
1778 for (int i = 0 ; i < num ; i++ ) {
1779 gsmBciPtrs[i] = &gsmBci[i];
1780 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1781 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1782 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1783 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1784 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1785 }
1786
1787 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs,
1788 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
1789 return Void();
1790 }
1791
setGsmBroadcastActivation(int32_t serial,bool activate)1792 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1793 #if VDBG
1794 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1795 #endif
1796 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1797 1, BOOL_TO_INT(!activate));
1798 return Void();
1799 }
1800
getCdmaBroadcastConfig(int32_t serial)1801 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1802 #if VDBG
1803 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1804 #endif
1805 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1806 return Void();
1807 }
1808
setCdmaBroadcastConfig(int32_t serial,const hidl_vec<CdmaBroadcastSmsConfigInfo> & configInfo)1809 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1810 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1811 configInfo) {
1812 #if VDBG
1813 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1814 #endif
1815 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1816 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1817 if (pRI == NULL) {
1818 return Void();
1819 }
1820
1821 int num = configInfo.size();
1822 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1823 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1824
1825 for (int i = 0 ; i < num ; i++ ) {
1826 cdmaBciPtrs[i] = &cdmaBci[i];
1827 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1828 cdmaBci[i].language = configInfo[i].language;
1829 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1830 }
1831
1832 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs,
1833 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
1834 return Void();
1835 }
1836
setCdmaBroadcastActivation(int32_t serial,bool activate)1837 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1838 #if VDBG
1839 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1840 #endif
1841 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1842 1, BOOL_TO_INT(!activate));
1843 return Void();
1844 }
1845
getCDMASubscription(int32_t serial)1846 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1847 #if VDBG
1848 RLOGD("getCDMASubscription: serial %d", serial);
1849 #endif
1850 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1851 return Void();
1852 }
1853
writeSmsToRuim(int32_t serial,const CdmaSmsWriteArgs & cdmaSms)1854 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1855 #if VDBG
1856 RLOGD("writeSmsToRuim: serial %d", serial);
1857 #endif
1858 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1859 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1860 if (pRI == NULL) {
1861 return Void();
1862 }
1863
1864 RIL_CDMA_SMS_WriteArgs rcsw = {};
1865 rcsw.status = (int) cdmaSms.status;
1866 constructCdmaSms(rcsw.message, cdmaSms.message);
1867
1868 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
1869 return Void();
1870 }
1871
deleteSmsOnRuim(int32_t serial,int32_t index)1872 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1873 #if VDBG
1874 RLOGD("deleteSmsOnRuim: serial %d", serial);
1875 #endif
1876 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1877 return Void();
1878 }
1879
getDeviceIdentity(int32_t serial)1880 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1881 #if VDBG
1882 RLOGD("getDeviceIdentity: serial %d", serial);
1883 #endif
1884 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1885 return Void();
1886 }
1887
exitEmergencyCallbackMode(int32_t serial)1888 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1889 #if VDBG
1890 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1891 #endif
1892 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1893 return Void();
1894 }
1895
getSmscAddress(int32_t serial)1896 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1897 #if VDBG
1898 RLOGD("getSmscAddress: serial %d", serial);
1899 #endif
1900 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1901 return Void();
1902 }
1903
setSmscAddress(int32_t serial,const hidl_string & smsc)1904 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1905 #if VDBG
1906 RLOGD("setSmscAddress: serial %d", serial);
1907 #endif
1908 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1909 smsc.c_str());
1910 return Void();
1911 }
1912
reportSmsMemoryStatus(int32_t serial,bool available)1913 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1914 #if VDBG
1915 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1916 #endif
1917 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1918 BOOL_TO_INT(available));
1919 return Void();
1920 }
1921
reportStkServiceIsRunning(int32_t serial)1922 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1923 #if VDBG
1924 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1925 #endif
1926 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1927 return Void();
1928 }
1929
getCdmaSubscriptionSource(int32_t serial)1930 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1931 #if VDBG
1932 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1933 #endif
1934 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1935 return Void();
1936 }
1937
requestIsimAuthentication(int32_t serial,const hidl_string & challenge)1938 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1939 #if VDBG
1940 RLOGD("requestIsimAuthentication: serial %d", serial);
1941 #endif
1942 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1943 challenge.c_str());
1944 return Void();
1945 }
1946
acknowledgeIncomingGsmSmsWithPdu(int32_t serial,bool success,const hidl_string & ackPdu)1947 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1948 const hidl_string& ackPdu) {
1949 #if VDBG
1950 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1951 #endif
1952 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1953 2, success ? "1" : "0", ackPdu.c_str());
1954 return Void();
1955 }
1956
sendEnvelopeWithStatus(int32_t serial,const hidl_string & contents)1957 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1958 #if VDBG
1959 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1960 #endif
1961 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1962 contents.c_str());
1963 return Void();
1964 }
1965
getVoiceRadioTechnology(int32_t serial)1966 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1967 #if VDBG
1968 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1969 #endif
1970 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1971 return Void();
1972 }
1973
getCellInfoList(int32_t serial)1974 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1975 #if VDBG
1976 RLOGD("getCellInfoList: serial %d", serial);
1977 #endif
1978 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1979 return Void();
1980 }
1981
setCellInfoListRate(int32_t serial,int32_t rate)1982 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1983 #if VDBG
1984 RLOGD("setCellInfoListRate: serial %d", serial);
1985 #endif
1986 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1987 return Void();
1988 }
1989
setInitialAttachApn(int32_t serial,const DataProfileInfo & dataProfileInfo,bool modemCognitive,bool isRoaming)1990 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1991 bool modemCognitive, bool isRoaming) {
1992 #if VDBG
1993 RLOGD("setInitialAttachApn: serial %d", serial);
1994 #endif
1995 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1996 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
1997 if (pRI == NULL) {
1998 return Void();
1999 }
2000
2001 if (s_vendorFunctions->version <= 14) {
2002 RIL_InitialAttachApn iaa = {};
2003
2004 if (dataProfileInfo.apn.size() == 0) {
2005 iaa.apn = (char *) calloc(1, sizeof(char));
2006 if (iaa.apn == NULL) {
2007 RLOGE("Memory allocation failed for request %s",
2008 requestToString(pRI->pCI->requestNumber));
2009 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2010 return Void();
2011 }
2012 iaa.apn[0] = '\0';
2013 } else {
2014 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
2015 return Void();
2016 }
2017 }
2018
2019 const hidl_string &protocol =
2020 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
2021
2022 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
2023 memsetAndFreeStrings(1, iaa.apn);
2024 return Void();
2025 }
2026 iaa.authtype = (int) dataProfileInfo.authType;
2027 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2028 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2029 return Void();
2030 }
2031 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2032 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
2033 return Void();
2034 }
2035
2036 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2037
2038 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
2039 } else {
2040 RIL_InitialAttachApn_v15 iaa = {};
2041
2042 if (dataProfileInfo.apn.size() == 0) {
2043 iaa.apn = (char *) calloc(1, sizeof(char));
2044 if (iaa.apn == NULL) {
2045 RLOGE("Memory allocation failed for request %s",
2046 requestToString(pRI->pCI->requestNumber));
2047 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2048 return Void();
2049 }
2050 iaa.apn[0] = '\0';
2051 } else {
2052 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
2053 return Void();
2054 }
2055 }
2056
2057 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
2058 memsetAndFreeStrings(1, iaa.apn);
2059 return Void();
2060 }
2061 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
2062 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2063 return Void();
2064 }
2065 iaa.authtype = (int) dataProfileInfo.authType;
2066 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2067 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
2068 return Void();
2069 }
2070 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2071 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
2072 return Void();
2073 }
2074 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
2075 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
2076 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
2077 iaa.mtu = dataProfileInfo.mtu;
2078
2079 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
2080 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2081 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2082 iaa.password);
2083 return Void();
2084 }
2085
2086 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
2087 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2088 iaa.password);
2089 return Void();
2090 }
2091
2092 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2093
2094 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2095 iaa.password, iaa.mvnoMatchData);
2096 }
2097
2098 return Void();
2099 }
2100
getImsRegistrationState(int32_t serial)2101 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
2102 #if VDBG
2103 RLOGD("getImsRegistrationState: serial %d", serial);
2104 #endif
2105 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2106 return Void();
2107 }
2108
dispatchImsGsmSms(const ImsSmsMessage & message,RequestInfo * pRI)2109 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2110 RIL_IMS_SMS_Message rism = {};
2111 char **pStrings;
2112 int countStrings = 2;
2113 int dataLen = sizeof(char *) * countStrings;
2114
2115 rism.tech = RADIO_TECH_3GPP;
2116 rism.retry = BOOL_TO_INT(message.retry);
2117 rism.messageRef = message.messageRef;
2118
2119 if (message.gsmMessage.size() != 1) {
2120 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2121 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2122 return false;
2123 }
2124
2125 pStrings = (char **)calloc(countStrings, sizeof(char *));
2126 if (pStrings == NULL) {
2127 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2128 requestToString(pRI->pCI->requestNumber));
2129 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2130 return false;
2131 }
2132
2133 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2134 #ifdef MEMSET_FREED
2135 memset(pStrings, 0, dataLen);
2136 #endif
2137 free(pStrings);
2138 return false;
2139 }
2140
2141 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2142 memsetAndFreeStrings(1, pStrings[0]);
2143 #ifdef MEMSET_FREED
2144 memset(pStrings, 0, dataLen);
2145 #endif
2146 free(pStrings);
2147 return false;
2148 }
2149
2150 rism.message.gsmMessage = pStrings;
2151 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2152 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2153
2154 for (int i = 0 ; i < countStrings ; i++) {
2155 memsetAndFreeStrings(1, pStrings[i]);
2156 }
2157
2158 #ifdef MEMSET_FREED
2159 memset(pStrings, 0, dataLen);
2160 #endif
2161 free(pStrings);
2162
2163 return true;
2164 }
2165
2166 struct ImsCdmaSms {
2167 RIL_IMS_SMS_Message imsSms;
2168 RIL_CDMA_SMS_Message cdmaSms;
2169 };
2170
dispatchImsCdmaSms(const ImsSmsMessage & message,RequestInfo * pRI)2171 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2172 ImsCdmaSms temp = {};
2173
2174 if (message.cdmaMessage.size() != 1) {
2175 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2176 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2177 return false;
2178 }
2179
2180 temp.imsSms.tech = RADIO_TECH_3GPP2;
2181 temp.imsSms.retry = BOOL_TO_INT(message.retry);
2182 temp.imsSms.messageRef = message.messageRef;
2183 temp.imsSms.message.cdmaMessage = &temp.cdmaSms;
2184
2185 constructCdmaSms(temp.cdmaSms, message.cdmaMessage[0]);
2186
2187 // Vendor code expects payload length to include actual msg payload
2188 // (sizeof(RIL_CDMA_SMS_Message)) instead of (RIL_CDMA_SMS_Message *) + size of other fields in
2189 // RIL_IMS_SMS_Message
2190 int payloadLen = sizeof(RIL_RadioTechnologyFamily) + sizeof(uint8_t) + sizeof(int32_t)
2191 + sizeof(RIL_CDMA_SMS_Message);
2192
2193 CALL_ONREQUEST(pRI->pCI->requestNumber, &temp.imsSms, payloadLen, pRI, pRI->socket_id);
2194
2195 return true;
2196 }
2197
sendImsSms(int32_t serial,const ImsSmsMessage & message)2198 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2199 #if VDBG
2200 RLOGD("sendImsSms: serial %d", serial);
2201 #endif
2202 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2203 if (pRI == NULL) {
2204 return Void();
2205 }
2206
2207 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2208
2209 if (RADIO_TECH_3GPP == format) {
2210 dispatchImsGsmSms(message, pRI);
2211 } else if (RADIO_TECH_3GPP2 == format) {
2212 dispatchImsCdmaSms(message, pRI);
2213 } else {
2214 RLOGE("sendImsSms: Invalid radio tech %s",
2215 requestToString(pRI->pCI->requestNumber));
2216 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2217 }
2218 return Void();
2219 }
2220
iccTransmitApduBasicChannel(int32_t serial,const SimApdu & message)2221 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2222 #if VDBG
2223 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2224 #endif
2225 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2226 return Void();
2227 }
2228
iccOpenLogicalChannel(int32_t serial,const hidl_string & aid,int32_t p2)2229 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2230 #if VDBG
2231 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2232 #endif
2233 if (s_vendorFunctions->version < 15) {
2234 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2235 } else {
2236 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2237 if (pRI == NULL) {
2238 return Void();
2239 }
2240
2241 RIL_OpenChannelParams params = {};
2242
2243 params.p2 = p2;
2244
2245 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2246 return Void();
2247 }
2248
2249 CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId);
2250
2251 memsetAndFreeStrings(1, params.aidPtr);
2252 }
2253 return Void();
2254 }
2255
iccCloseLogicalChannel(int32_t serial,int32_t channelId)2256 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2257 #if VDBG
2258 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2259 #endif
2260 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2261 return Void();
2262 }
2263
iccTransmitApduLogicalChannel(int32_t serial,const SimApdu & message)2264 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2265 #if VDBG
2266 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2267 #endif
2268 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2269 return Void();
2270 }
2271
nvReadItem(int32_t serial,NvItem itemId)2272 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2273 #if VDBG
2274 RLOGD("nvReadItem: serial %d", serial);
2275 #endif
2276 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2277 if (pRI == NULL) {
2278 return Void();
2279 }
2280
2281 RIL_NV_ReadItem nvri = {};
2282 nvri.itemID = (RIL_NV_Item) itemId;
2283
2284 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2285 return Void();
2286 }
2287
nvWriteItem(int32_t serial,const NvWriteItem & item)2288 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2289 #if VDBG
2290 RLOGD("nvWriteItem: serial %d", serial);
2291 #endif
2292 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2293 if (pRI == NULL) {
2294 return Void();
2295 }
2296
2297 RIL_NV_WriteItem nvwi = {};
2298
2299 nvwi.itemID = (RIL_NV_Item) item.itemId;
2300
2301 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2302 return Void();
2303 }
2304
2305 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2306
2307 memsetAndFreeStrings(1, nvwi.value);
2308 return Void();
2309 }
2310
nvWriteCdmaPrl(int32_t serial,const hidl_vec<uint8_t> & prl)2311 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2312 #if VDBG
2313 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2314 #endif
2315 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2316 return Void();
2317 }
2318
nvResetConfig(int32_t serial,ResetNvType resetType)2319 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2320 int rilResetType = -1;
2321 #if VDBG
2322 RLOGD("nvResetConfig: serial %d", serial);
2323 #endif
2324 /* Convert ResetNvType to RIL.h values
2325 * RIL_REQUEST_NV_RESET_CONFIG
2326 * 1 - reload all NV items
2327 * 2 - erase NV reset (SCRTN)
2328 * 3 - factory reset (RTN)
2329 */
2330 switch(resetType) {
2331 case ResetNvType::RELOAD:
2332 rilResetType = 1;
2333 break;
2334 case ResetNvType::ERASE:
2335 rilResetType = 2;
2336 break;
2337 case ResetNvType::FACTORY_RESET:
2338 rilResetType = 3;
2339 break;
2340 }
2341 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2342 return Void();
2343 }
2344
setUiccSubscription(int32_t serial,const SelectUiccSub & uiccSub)2345 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2346 #if VDBG
2347 RLOGD("setUiccSubscription: serial %d", serial);
2348 #endif
2349 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2350 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2351 if (pRI == NULL) {
2352 return Void();
2353 }
2354
2355 RIL_SelectUiccSub rilUiccSub = {};
2356
2357 rilUiccSub.slot = uiccSub.slot;
2358 rilUiccSub.app_index = uiccSub.appIndex;
2359 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2360 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2361
2362 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2363 return Void();
2364 }
2365
setDataAllowed(int32_t serial,bool allow)2366 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2367 #if VDBG
2368 RLOGD("setDataAllowed: serial %d", serial);
2369 #endif
2370 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2371 return Void();
2372 }
2373
getHardwareConfig(int32_t serial)2374 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2375 #if VDBG
2376 RLOGD("getHardwareConfig: serial %d", serial);
2377 #endif
2378 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2379 return Void();
2380 }
2381
requestIccSimAuthentication(int32_t serial,int32_t authContext,const hidl_string & authData,const hidl_string & aid)2382 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2383 const hidl_string& authData, const hidl_string& aid) {
2384 #if VDBG
2385 RLOGD("requestIccSimAuthentication: serial %d", serial);
2386 #endif
2387 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2388 if (pRI == NULL) {
2389 return Void();
2390 }
2391
2392 RIL_SimAuthentication pf = {};
2393
2394 pf.authContext = authContext;
2395
2396 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2397 return Void();
2398 }
2399
2400 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2401 memsetAndFreeStrings(1, pf.authData);
2402 return Void();
2403 }
2404
2405 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2406
2407 memsetAndFreeStrings(2, pf.authData, pf.aid);
2408 return Void();
2409 }
2410
2411 /**
2412 * @param numProfiles number of data profile
2413 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2414 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2415 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2416 * @param numfields number of string-type member in the data profile structure
2417 * @param ... the variadic parameters are pointers to each string-type member
2418 **/
2419 template <typename T>
freeSetDataProfileData(int numProfiles,T * dataProfiles,T ** dataProfilePtrs,int numfields,...)2420 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2421 int numfields, ...) {
2422 va_list args;
2423 va_start(args, numfields);
2424
2425 // Iterate through each string-type field that need to be free.
2426 for (int i = 0; i < numfields; i++) {
2427 // Iterate through each data profile and free that specific string-type field.
2428 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2429 char *T::*ptr = va_arg(args, char *T::*);
2430 for (int j = 0; j < numProfiles; j++) {
2431 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2432 }
2433 }
2434
2435 va_end(args);
2436
2437 #ifdef MEMSET_FREED
2438 memset(dataProfiles, 0, numProfiles * sizeof(T));
2439 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2440 #endif
2441 free(dataProfiles);
2442 free(dataProfilePtrs);
2443 }
2444
setDataProfile(int32_t serial,const hidl_vec<DataProfileInfo> & profiles,bool isRoaming)2445 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2446 bool isRoaming) {
2447 #if VDBG
2448 RLOGD("setDataProfile: serial %d", serial);
2449 #endif
2450 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2451 if (pRI == NULL) {
2452 return Void();
2453 }
2454
2455 size_t num = profiles.size();
2456 bool success = false;
2457
2458 if (s_vendorFunctions->version <= 14) {
2459
2460 RIL_DataProfileInfo *dataProfiles =
2461 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2462
2463 if (dataProfiles == NULL) {
2464 RLOGE("Memory allocation failed for request %s",
2465 requestToString(pRI->pCI->requestNumber));
2466 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2467 return Void();
2468 }
2469
2470 RIL_DataProfileInfo **dataProfilePtrs =
2471 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2472 if (dataProfilePtrs == NULL) {
2473 RLOGE("Memory allocation failed for request %s",
2474 requestToString(pRI->pCI->requestNumber));
2475 free(dataProfiles);
2476 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2477 return Void();
2478 }
2479
2480 for (size_t i = 0; i < num; i++) {
2481 dataProfilePtrs[i] = &dataProfiles[i];
2482
2483 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2484
2485 const hidl_string &protocol =
2486 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2487
2488 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2489 success = false;
2490 }
2491
2492 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2493 success = false;
2494 }
2495 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2496 pRI)) {
2497 success = false;
2498 }
2499
2500 if (!success) {
2501 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2502 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2503 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2504 return Void();
2505 }
2506
2507 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2508 dataProfiles[i].authType = (int) profiles[i].authType;
2509 dataProfiles[i].type = (int) profiles[i].type;
2510 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2511 dataProfiles[i].maxConns = profiles[i].maxConns;
2512 dataProfiles[i].waitTime = profiles[i].waitTime;
2513 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2514 }
2515
2516 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2517 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2518
2519 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2520 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2521 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2522 } else {
2523 RIL_DataProfileInfo_v15 *dataProfiles =
2524 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2525
2526 if (dataProfiles == NULL) {
2527 RLOGE("Memory allocation failed for request %s",
2528 requestToString(pRI->pCI->requestNumber));
2529 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2530 return Void();
2531 }
2532
2533 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2534 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2535 if (dataProfilePtrs == NULL) {
2536 RLOGE("Memory allocation failed for request %s",
2537 requestToString(pRI->pCI->requestNumber));
2538 free(dataProfiles);
2539 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2540 return Void();
2541 }
2542
2543 for (size_t i = 0; i < num; i++) {
2544 dataProfilePtrs[i] = &dataProfiles[i];
2545
2546 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2547 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2548 pRI)) {
2549 success = false;
2550 }
2551 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2552 profiles[i].roamingProtocol, pRI)) {
2553 success = false;
2554 }
2555 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2556 success = false;
2557 }
2558 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2559 pRI)) {
2560 success = false;
2561 }
2562 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2563 profiles[i].mvnoMatchData, pRI)) {
2564 success = false;
2565 }
2566
2567 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2568 dataProfiles[i].mvnoType)) {
2569 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2570 success = false;
2571 }
2572
2573 if (!success) {
2574 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2575 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2576 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2577 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2578 return Void();
2579 }
2580
2581 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2582 dataProfiles[i].authType = (int) profiles[i].authType;
2583 dataProfiles[i].type = (int) profiles[i].type;
2584 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2585 dataProfiles[i].maxConns = profiles[i].maxConns;
2586 dataProfiles[i].waitTime = profiles[i].waitTime;
2587 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2588 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2589 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2590 dataProfiles[i].mtu = profiles[i].mtu;
2591 }
2592
2593 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2594 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
2595
2596 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2597 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2598 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2599 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2600 }
2601
2602 return Void();
2603 }
2604
requestShutdown(int32_t serial)2605 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2606 #if VDBG
2607 RLOGD("requestShutdown: serial %d", serial);
2608 #endif
2609 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2610 return Void();
2611 }
2612
getRadioCapability(int32_t serial)2613 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2614 #if VDBG
2615 RLOGD("getRadioCapability: serial %d", serial);
2616 #endif
2617 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2618 return Void();
2619 }
2620
setRadioCapability(int32_t serial,const RadioCapability & rc)2621 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2622 #if VDBG
2623 RLOGD("setRadioCapability: serial %d", serial);
2624 #endif
2625 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2626 if (pRI == NULL) {
2627 return Void();
2628 }
2629
2630 RIL_RadioCapability rilRc = {};
2631
2632 // TODO : set rilRc.version using HIDL version ?
2633 rilRc.session = rc.session;
2634 rilRc.phase = (int) rc.phase;
2635 rilRc.rat = (int) rc.raf;
2636 rilRc.status = (int) rc.status;
2637 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2638
2639 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
2640
2641 return Void();
2642 }
2643
startLceService(int32_t serial,int32_t reportInterval,bool pullMode)2644 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2645 #if VDBG
2646 RLOGD("startLceService: serial %d", serial);
2647 #endif
2648 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2649 BOOL_TO_INT(pullMode));
2650 return Void();
2651 }
2652
stopLceService(int32_t serial)2653 Return<void> RadioImpl::stopLceService(int32_t serial) {
2654 #if VDBG
2655 RLOGD("stopLceService: serial %d", serial);
2656 #endif
2657 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2658 return Void();
2659 }
2660
pullLceData(int32_t serial)2661 Return<void> RadioImpl::pullLceData(int32_t serial) {
2662 #if VDBG
2663 RLOGD("pullLceData: serial %d", serial);
2664 #endif
2665 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2666 return Void();
2667 }
2668
getModemActivityInfo(int32_t serial)2669 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2670 #if VDBG
2671 RLOGD("getModemActivityInfo: serial %d", serial);
2672 #endif
2673 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2674 return Void();
2675 }
2676
setAllowedCarriers(int32_t serial,bool allAllowed,const CarrierRestrictions & carriers)2677 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2678 const CarrierRestrictions& carriers) {
2679 #if VDBG
2680 RLOGD("setAllowedCarriers: serial %d", serial);
2681 #endif
2682 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2683 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2684 if (pRI == NULL) {
2685 return Void();
2686 }
2687
2688 RIL_CarrierRestrictions cr = {};
2689 RIL_Carrier *allowedCarriers = NULL;
2690 RIL_Carrier *excludedCarriers = NULL;
2691
2692 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2693 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2694 if (allowedCarriers == NULL) {
2695 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2696 requestToString(pRI->pCI->requestNumber));
2697 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2698 return Void();
2699 }
2700 cr.allowed_carriers = allowedCarriers;
2701
2702 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2703 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2704 if (excludedCarriers == NULL) {
2705 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2706 requestToString(pRI->pCI->requestNumber));
2707 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2708 #ifdef MEMSET_FREED
2709 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2710 #endif
2711 free(allowedCarriers);
2712 return Void();
2713 }
2714 cr.excluded_carriers = excludedCarriers;
2715
2716 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2717 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2718 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2719 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2720 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2721 }
2722
2723 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2724 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2725 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2726 excludedCarriers[i].match_type =
2727 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2728 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2729 }
2730
2731 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
2732
2733 #ifdef MEMSET_FREED
2734 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2735 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2736 #endif
2737 free(allowedCarriers);
2738 free(excludedCarriers);
2739 return Void();
2740 }
2741
getAllowedCarriers(int32_t serial)2742 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2743 #if VDBG
2744 RLOGD("getAllowedCarriers: serial %d", serial);
2745 #endif
2746 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2747 return Void();
2748 }
2749
sendDeviceState(int32_t serial,DeviceStateType deviceStateType,bool state)2750 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2751 bool state) {
2752 #if VDBG
2753 RLOGD("sendDeviceState: serial %d", serial);
2754 #endif
2755 if (s_vendorFunctions->version < 15) {
2756 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2757 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2758 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2759 } else {
2760 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2761 RIL_REQUEST_SEND_DEVICE_STATE);
2762 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2763 }
2764 return Void();
2765 }
2766 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2767 BOOL_TO_INT(state));
2768 return Void();
2769 }
2770
setIndicationFilter(int32_t serial,int32_t indicationFilter)2771 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2772 #if VDBG
2773 RLOGD("setIndicationFilter: serial %d", serial);
2774 #endif
2775 if (s_vendorFunctions->version < 15) {
2776 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2777 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2778 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2779 return Void();
2780 }
2781 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2782 return Void();
2783 }
2784
setSimCardPower(int32_t serial,bool powerUp)2785 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2786 #if VDBG
2787 RLOGD("setSimCardPower: serial %d", serial);
2788 #endif
2789 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2790 return Void();
2791 }
2792
setSimCardPower_1_1(int32_t serial,const V1_1::CardPowerState state)2793 Return<void> RadioImpl::setSimCardPower_1_1(int32_t serial, const V1_1::CardPowerState state) {
2794 #if VDBG
2795 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
2796 #endif
2797 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
2798 return Void();
2799 }
2800
setCarrierInfoForImsiEncryption(int32_t serial,const V1_1::ImsiEncryptionInfo & data)2801 Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial,
2802 const V1_1::ImsiEncryptionInfo& data) {
2803 #if VDBG
2804 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
2805 #endif
2806 RequestInfo *pRI = android::addRequestToList(
2807 serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
2808 if (pRI == NULL) {
2809 return Void();
2810 }
2811
2812 RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
2813
2814 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
2815 return Void();
2816 }
2817 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
2818 memsetAndFreeStrings(1, imsiEncryption.mnc);
2819 return Void();
2820 }
2821 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
2822 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
2823 return Void();
2824 }
2825 int32_t lSize = data.carrierKey.size();
2826 imsiEncryption.carrierKey = new uint8_t[lSize];
2827 memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), lSize);
2828 imsiEncryption.expirationTime = data.expirationTime;
2829 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
2830 sizeof(RIL_CarrierInfoForImsiEncryption), pRI, mSlotId);
2831 delete(imsiEncryption.carrierKey);
2832 return Void();
2833 }
2834
startKeepalive(int32_t serial,const V1_1::KeepaliveRequest & keepalive)2835 Return<void> RadioImpl::startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive) {
2836 #if VDBG
2837 RLOGD("%s(): %d", __FUNCTION__, serial);
2838 #endif
2839 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_KEEPALIVE);
2840 if (pRI == NULL) {
2841 return Void();
2842 }
2843
2844 RIL_KeepaliveRequest kaReq = {};
2845
2846 kaReq.type = static_cast<RIL_KeepaliveType>(keepalive.type);
2847 switch(kaReq.type) {
2848 case NATT_IPV4:
2849 if (keepalive.sourceAddress.size() != 4 ||
2850 keepalive.destinationAddress.size() != 4) {
2851 RLOGE("Invalid address for keepalive!");
2852 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2853 return Void();
2854 }
2855 break;
2856 case NATT_IPV6:
2857 if (keepalive.sourceAddress.size() != 16 ||
2858 keepalive.destinationAddress.size() != 16) {
2859 RLOGE("Invalid address for keepalive!");
2860 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2861 return Void();
2862 }
2863 break;
2864 default:
2865 RLOGE("Unknown packet keepalive type!");
2866 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2867 return Void();
2868 }
2869
2870 ::memcpy(kaReq.sourceAddress, keepalive.sourceAddress.data(), keepalive.sourceAddress.size());
2871 kaReq.sourcePort = keepalive.sourcePort;
2872
2873 ::memcpy(kaReq.destinationAddress,
2874 keepalive.destinationAddress.data(), keepalive.destinationAddress.size());
2875 kaReq.destinationPort = keepalive.destinationPort;
2876
2877 kaReq.maxKeepaliveIntervalMillis = keepalive.maxKeepaliveIntervalMillis;
2878 kaReq.cid = keepalive.cid; // This is the context ID of the data call
2879
2880 CALL_ONREQUEST(pRI->pCI->requestNumber, &kaReq, sizeof(RIL_KeepaliveRequest), pRI, mSlotId);
2881 return Void();
2882 }
2883
stopKeepalive(int32_t serial,int32_t sessionHandle)2884 Return<void> RadioImpl::stopKeepalive(int32_t serial, int32_t sessionHandle) {
2885 #if VDBG
2886 RLOGD("%s(): %d", __FUNCTION__, serial);
2887 #endif
2888 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_STOP_KEEPALIVE);
2889 if (pRI == NULL) {
2890 return Void();
2891 }
2892
2893 CALL_ONREQUEST(pRI->pCI->requestNumber, &sessionHandle, sizeof(uint32_t), pRI, mSlotId);
2894 return Void();
2895 }
2896
responseAcknowledgement()2897 Return<void> RadioImpl::responseAcknowledgement() {
2898 android::releaseWakeLock();
2899 return Void();
2900 }
2901
setResponseFunctions(const::android::sp<IOemHookResponse> & oemHookResponseParam,const::android::sp<IOemHookIndication> & oemHookIndicationParam)2902 Return<void> OemHookImpl::setResponseFunctions(
2903 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2904 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2905 #if VDBG
2906 RLOGD("OemHookImpl::setResponseFunctions");
2907 #endif
2908
2909 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2910 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2911 assert(ret == 0);
2912
2913 mOemHookResponse = oemHookResponseParam;
2914 mOemHookIndication = oemHookIndicationParam;
2915 mCounterOemHook[mSlotId]++;
2916
2917 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2918 assert(ret == 0);
2919
2920 return Void();
2921 }
2922
sendRequestRaw(int32_t serial,const hidl_vec<uint8_t> & data)2923 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2924 #if VDBG
2925 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2926 #endif
2927 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2928 return Void();
2929 }
2930
sendRequestStrings(int32_t serial,const hidl_vec<hidl_string> & data)2931 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2932 const hidl_vec<hidl_string>& data) {
2933 #if VDBG
2934 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2935 #endif
2936 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2937 return Void();
2938 }
2939
2940 /***************************************************************************************************
2941 * RESPONSE FUNCTIONS
2942 * Functions above are used for requests going from framework to vendor code. The ones below are
2943 * responses for those requests coming back from the vendor code.
2944 **************************************************************************************************/
2945
acknowledgeRequest(int slotId,int serial)2946 void radio::acknowledgeRequest(int slotId, int serial) {
2947 if (radioService[slotId]->mRadioResponse != NULL) {
2948 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2949 radioService[slotId]->checkReturnStatus(retStatus);
2950 } else {
2951 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2952 }
2953 }
2954
populateResponseInfo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e)2955 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2956 RIL_Errno e) {
2957 responseInfo.serial = serial;
2958 switch (responseType) {
2959 case RESPONSE_SOLICITED:
2960 responseInfo.type = RadioResponseType::SOLICITED;
2961 break;
2962 case RESPONSE_SOLICITED_ACK_EXP:
2963 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2964 break;
2965 }
2966 responseInfo.error = (RadioError) e;
2967 }
2968
responseIntOrEmpty(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)2969 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2970 void *response, size_t responseLen) {
2971 populateResponseInfo(responseInfo, serial, responseType, e);
2972 int ret = -1;
2973
2974 if (response == NULL && responseLen == 0) {
2975 // Earlier RILs did not send a response for some cases although the interface
2976 // expected an integer as response. Do not return error if response is empty. Instead
2977 // Return -1 in those cases to maintain backward compatibility.
2978 } else if (response == NULL || responseLen != sizeof(int)) {
2979 RLOGE("responseIntOrEmpty: Invalid response");
2980 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2981 } else {
2982 int *p_int = (int *) response;
2983 ret = p_int[0];
2984 }
2985 return ret;
2986 }
2987
responseInt(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)2988 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2989 void *response, size_t responseLen) {
2990 populateResponseInfo(responseInfo, serial, responseType, e);
2991 int ret = -1;
2992
2993 if (response == NULL || responseLen != sizeof(int)) {
2994 RLOGE("responseInt: Invalid response");
2995 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2996 } else {
2997 int *p_int = (int *) response;
2998 ret = p_int[0];
2999 }
3000 return ret;
3001 }
3002
getIccCardStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3003 int radio::getIccCardStatusResponse(int slotId,
3004 int responseType, int serial, RIL_Errno e,
3005 void *response, size_t responseLen) {
3006 if (radioService[slotId]->mRadioResponse != NULL) {
3007 RadioResponseInfo responseInfo = {};
3008 populateResponseInfo(responseInfo, serial, responseType, e);
3009 CardStatus cardStatus = {};
3010 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
3011 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)
3012 || p_cur->gsm_umts_subscription_app_index >= p_cur->num_applications
3013 || p_cur->cdma_subscription_app_index >= p_cur->num_applications
3014 || p_cur->ims_subscription_app_index >= p_cur->num_applications) {
3015 RLOGE("getIccCardStatusResponse: Invalid response");
3016 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3017 } else {
3018 cardStatus.cardState = (CardState) p_cur->card_state;
3019 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
3020 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
3021 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
3022 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
3023
3024 RIL_AppStatus *rilAppStatus = p_cur->applications;
3025 cardStatus.applications.resize(p_cur->num_applications);
3026 AppStatus *appStatus = cardStatus.applications.data();
3027 #if VDBG
3028 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
3029 #endif
3030 for (int i = 0; i < p_cur->num_applications; i++) {
3031 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
3032 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
3033 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
3034 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
3035 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
3036 rilAppStatus[i].app_label_ptr);
3037 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
3038 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
3039 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
3040 }
3041 }
3042
3043 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3044 getIccCardStatusResponse(responseInfo, cardStatus);
3045 radioService[slotId]->checkReturnStatus(retStatus);
3046 } else {
3047 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3048 }
3049
3050 return 0;
3051 }
3052
supplyIccPinForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3053 int radio::supplyIccPinForAppResponse(int slotId,
3054 int responseType, int serial, RIL_Errno e,
3055 void *response, size_t responseLen) {
3056 #if VDBG
3057 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
3058 #endif
3059
3060 if (radioService[slotId]->mRadioResponse != NULL) {
3061 RadioResponseInfo responseInfo = {};
3062 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3063 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3064 supplyIccPinForAppResponse(responseInfo, ret);
3065 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
3066 radioService[slotId]->checkReturnStatus(retStatus);
3067 } else {
3068 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3069 slotId);
3070 }
3071
3072 return 0;
3073 }
3074
supplyIccPukForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3075 int radio::supplyIccPukForAppResponse(int slotId,
3076 int responseType, int serial, RIL_Errno e,
3077 void *response, size_t responseLen) {
3078 #if VDBG
3079 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
3080 #endif
3081
3082 if (radioService[slotId]->mRadioResponse != NULL) {
3083 RadioResponseInfo responseInfo = {};
3084 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3085 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
3086 responseInfo, ret);
3087 radioService[slotId]->checkReturnStatus(retStatus);
3088 } else {
3089 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
3090 slotId);
3091 }
3092
3093 return 0;
3094 }
3095
supplyIccPin2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3096 int radio::supplyIccPin2ForAppResponse(int slotId,
3097 int responseType, int serial, RIL_Errno e,
3098 void *response, size_t responseLen) {
3099 #if VDBG
3100 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
3101 #endif
3102
3103 if (radioService[slotId]->mRadioResponse != NULL) {
3104 RadioResponseInfo responseInfo = {};
3105 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3106 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3107 supplyIccPin2ForAppResponse(responseInfo, ret);
3108 radioService[slotId]->checkReturnStatus(retStatus);
3109 } else {
3110 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3111 slotId);
3112 }
3113
3114 return 0;
3115 }
3116
supplyIccPuk2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3117 int radio::supplyIccPuk2ForAppResponse(int slotId,
3118 int responseType, int serial, RIL_Errno e,
3119 void *response, size_t responseLen) {
3120 #if VDBG
3121 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
3122 #endif
3123
3124 if (radioService[slotId]->mRadioResponse != NULL) {
3125 RadioResponseInfo responseInfo = {};
3126 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3127 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3128 supplyIccPuk2ForAppResponse(responseInfo, ret);
3129 radioService[slotId]->checkReturnStatus(retStatus);
3130 } else {
3131 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3132 slotId);
3133 }
3134
3135 return 0;
3136 }
3137
changeIccPinForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3138 int radio::changeIccPinForAppResponse(int slotId,
3139 int responseType, int serial, RIL_Errno e,
3140 void *response, size_t responseLen) {
3141 #if VDBG
3142 RLOGD("changeIccPinForAppResponse: serial %d", serial);
3143 #endif
3144
3145 if (radioService[slotId]->mRadioResponse != NULL) {
3146 RadioResponseInfo responseInfo = {};
3147 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3148 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3149 changeIccPinForAppResponse(responseInfo, ret);
3150 radioService[slotId]->checkReturnStatus(retStatus);
3151 } else {
3152 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3153 slotId);
3154 }
3155
3156 return 0;
3157 }
3158
changeIccPin2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3159 int radio::changeIccPin2ForAppResponse(int slotId,
3160 int responseType, int serial, RIL_Errno e,
3161 void *response, size_t responseLen) {
3162 #if VDBG
3163 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
3164 #endif
3165
3166 if (radioService[slotId]->mRadioResponse != NULL) {
3167 RadioResponseInfo responseInfo = {};
3168 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3169 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3170 changeIccPin2ForAppResponse(responseInfo, ret);
3171 radioService[slotId]->checkReturnStatus(retStatus);
3172 } else {
3173 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3174 slotId);
3175 }
3176
3177 return 0;
3178 }
3179
supplyNetworkDepersonalizationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3180 int radio::supplyNetworkDepersonalizationResponse(int slotId,
3181 int responseType, int serial, RIL_Errno e,
3182 void *response, size_t responseLen) {
3183 #if VDBG
3184 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
3185 #endif
3186
3187 if (radioService[slotId]->mRadioResponse != NULL) {
3188 RadioResponseInfo responseInfo = {};
3189 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3190 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3191 supplyNetworkDepersonalizationResponse(responseInfo, ret);
3192 radioService[slotId]->checkReturnStatus(retStatus);
3193 } else {
3194 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
3195 "NULL", slotId);
3196 }
3197
3198 return 0;
3199 }
3200
getCurrentCallsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3201 int radio::getCurrentCallsResponse(int slotId,
3202 int responseType, int serial, RIL_Errno e,
3203 void *response, size_t responseLen) {
3204 #if VDBG
3205 RLOGD("getCurrentCallsResponse: serial %d", serial);
3206 #endif
3207
3208 if (radioService[slotId]->mRadioResponse != NULL) {
3209 RadioResponseInfo responseInfo = {};
3210 populateResponseInfo(responseInfo, serial, responseType, e);
3211
3212 hidl_vec<Call> calls;
3213 if ((response == NULL && responseLen != 0)
3214 || (responseLen % sizeof(RIL_Call *)) != 0) {
3215 RLOGE("getCurrentCallsResponse: Invalid response");
3216 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3217 } else {
3218 int num = responseLen / sizeof(RIL_Call *);
3219 calls.resize(num);
3220
3221 for (int i = 0 ; i < num ; i++) {
3222 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3223 /* each call info */
3224 calls[i].state = (CallState) p_cur->state;
3225 calls[i].index = p_cur->index;
3226 calls[i].toa = p_cur->toa;
3227 calls[i].isMpty = p_cur->isMpty;
3228 calls[i].isMT = p_cur->isMT;
3229 calls[i].als = p_cur->als;
3230 calls[i].isVoice = p_cur->isVoice;
3231 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3232 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3233 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3234 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3235 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3236 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3237 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3238 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3239 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3240 // convert uusInfo->uusData to a null-terminated string
3241 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3242 calls[i].uusInfo[0].uusData = nullTermStr;
3243 free(nullTermStr);
3244 }
3245 }
3246 }
3247
3248 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3249 getCurrentCallsResponse(responseInfo, calls);
3250 radioService[slotId]->checkReturnStatus(retStatus);
3251 } else {
3252 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3253 }
3254
3255 return 0;
3256 }
3257
dialResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3258 int radio::dialResponse(int slotId,
3259 int responseType, int serial, RIL_Errno e, void *response,
3260 size_t responseLen) {
3261 #if VDBG
3262 RLOGD("dialResponse: serial %d", serial);
3263 #endif
3264
3265 if (radioService[slotId]->mRadioResponse != NULL) {
3266 RadioResponseInfo responseInfo = {};
3267 populateResponseInfo(responseInfo, serial, responseType, e);
3268 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3269 radioService[slotId]->checkReturnStatus(retStatus);
3270 } else {
3271 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3272 }
3273
3274 return 0;
3275 }
3276
getIMSIForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3277 int radio::getIMSIForAppResponse(int slotId,
3278 int responseType, int serial, RIL_Errno e, void *response,
3279 size_t responseLen) {
3280 #if VDBG
3281 RLOGD("getIMSIForAppResponse: serial %d", serial);
3282 #endif
3283
3284 if (radioService[slotId]->mRadioResponse != NULL) {
3285 RadioResponseInfo responseInfo = {};
3286 populateResponseInfo(responseInfo, serial, responseType, e);
3287 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3288 responseInfo, convertCharPtrToHidlString((char *) response));
3289 radioService[slotId]->checkReturnStatus(retStatus);
3290 } else {
3291 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3292 slotId);
3293 }
3294
3295 return 0;
3296 }
3297
hangupConnectionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3298 int radio::hangupConnectionResponse(int slotId,
3299 int responseType, int serial, RIL_Errno e,
3300 void *response, size_t responseLen) {
3301 #if VDBG
3302 RLOGD("hangupConnectionResponse: serial %d", serial);
3303 #endif
3304
3305 if (radioService[slotId]->mRadioResponse != NULL) {
3306 RadioResponseInfo responseInfo = {};
3307 populateResponseInfo(responseInfo, serial, responseType, e);
3308 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3309 responseInfo);
3310 radioService[slotId]->checkReturnStatus(retStatus);
3311 } else {
3312 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3313 slotId);
3314 }
3315
3316 return 0;
3317 }
3318
hangupWaitingOrBackgroundResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3319 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3320 int responseType, int serial, RIL_Errno e,
3321 void *response, size_t responseLen) {
3322 #if VDBG
3323 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3324 #endif
3325
3326 if (radioService[slotId]->mRadioResponse != NULL) {
3327 RadioResponseInfo responseInfo = {};
3328 populateResponseInfo(responseInfo, serial, responseType, e);
3329 Return<void> retStatus =
3330 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3331 responseInfo);
3332 radioService[slotId]->checkReturnStatus(retStatus);
3333 } else {
3334 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3335 slotId);
3336 }
3337
3338 return 0;
3339 }
3340
hangupForegroundResumeBackgroundResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3341 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3342 RIL_Errno e, void *response,
3343 size_t responseLen) {
3344 #if VDBG
3345 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3346 #endif
3347
3348 if (radioService[slotId]->mRadioResponse != NULL) {
3349 RadioResponseInfo responseInfo = {};
3350 populateResponseInfo(responseInfo, serial, responseType, e);
3351 Return<void> retStatus =
3352 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3353 responseInfo);
3354 radioService[slotId]->checkReturnStatus(retStatus);
3355 } else {
3356 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3357 slotId);
3358 }
3359
3360 return 0;
3361 }
3362
switchWaitingOrHoldingAndActiveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3363 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3364 RIL_Errno e, void *response,
3365 size_t responseLen) {
3366 #if VDBG
3367 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3368 #endif
3369
3370 if (radioService[slotId]->mRadioResponse != NULL) {
3371 RadioResponseInfo responseInfo = {};
3372 populateResponseInfo(responseInfo, serial, responseType, e);
3373 Return<void> retStatus =
3374 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3375 responseInfo);
3376 radioService[slotId]->checkReturnStatus(retStatus);
3377 } else {
3378 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3379 "== NULL", slotId);
3380 }
3381
3382 return 0;
3383 }
3384
conferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3385 int radio::conferenceResponse(int slotId, int responseType,
3386 int serial, RIL_Errno e, void *response, size_t responseLen) {
3387 #if VDBG
3388 RLOGD("conferenceResponse: serial %d", serial);
3389 #endif
3390
3391 if (radioService[slotId]->mRadioResponse != NULL) {
3392 RadioResponseInfo responseInfo = {};
3393 populateResponseInfo(responseInfo, serial, responseType, e);
3394 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3395 responseInfo);
3396 radioService[slotId]->checkReturnStatus(retStatus);
3397 } else {
3398 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3399 slotId);
3400 }
3401
3402 return 0;
3403 }
3404
rejectCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3405 int radio::rejectCallResponse(int slotId, int responseType,
3406 int serial, RIL_Errno e, void *response, size_t responseLen) {
3407 #if VDBG
3408 RLOGD("rejectCallResponse: serial %d", serial);
3409 #endif
3410
3411 if (radioService[slotId]->mRadioResponse != NULL) {
3412 RadioResponseInfo responseInfo = {};
3413 populateResponseInfo(responseInfo, serial, responseType, e);
3414 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3415 responseInfo);
3416 radioService[slotId]->checkReturnStatus(retStatus);
3417 } else {
3418 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3419 slotId);
3420 }
3421
3422 return 0;
3423 }
3424
getLastCallFailCauseResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3425 int radio::getLastCallFailCauseResponse(int slotId,
3426 int responseType, int serial, RIL_Errno e, void *response,
3427 size_t responseLen) {
3428 #if VDBG
3429 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3430 #endif
3431
3432 if (radioService[slotId]->mRadioResponse != NULL) {
3433 RadioResponseInfo responseInfo = {};
3434 populateResponseInfo(responseInfo, serial, responseType, e);
3435
3436 LastCallFailCauseInfo info = {};
3437 info.vendorCause = hidl_string();
3438 if (response == NULL) {
3439 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3440 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3441 } else if (responseLen == sizeof(int)) {
3442 int *pInt = (int *) response;
3443 info.causeCode = (LastCallFailCause) pInt[0];
3444 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3445 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3446 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3447 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3448 } else {
3449 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3450 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3451 }
3452
3453 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3454 responseInfo, info);
3455 radioService[slotId]->checkReturnStatus(retStatus);
3456 } else {
3457 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3458 slotId);
3459 }
3460
3461 return 0;
3462 }
3463
getSignalStrengthResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3464 int radio::getSignalStrengthResponse(int slotId,
3465 int responseType, int serial, RIL_Errno e,
3466 void *response, size_t responseLen) {
3467 #if VDBG
3468 RLOGD("getSignalStrengthResponse: serial %d", serial);
3469 #endif
3470
3471 if (radioService[slotId]->mRadioResponse != NULL) {
3472 RadioResponseInfo responseInfo = {};
3473 populateResponseInfo(responseInfo, serial, responseType, e);
3474 SignalStrength signalStrength = {};
3475 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3476 RLOGE("getSignalStrengthResponse: Invalid response");
3477 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3478 } else {
3479 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3480 }
3481
3482 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3483 responseInfo, signalStrength);
3484 radioService[slotId]->checkReturnStatus(retStatus);
3485 } else {
3486 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3487 slotId);
3488 }
3489
3490 return 0;
3491 }
3492
getCellInfoTypeRadioTechnology(char * rat)3493 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3494 if (rat == NULL) {
3495 return RIL_CELL_INFO_TYPE_NONE;
3496 }
3497
3498 int radioTech = atoi(rat);
3499
3500 switch(radioTech) {
3501
3502 case RADIO_TECH_GPRS:
3503 case RADIO_TECH_EDGE:
3504 case RADIO_TECH_GSM: {
3505 return RIL_CELL_INFO_TYPE_GSM;
3506 }
3507
3508 case RADIO_TECH_UMTS:
3509 case RADIO_TECH_HSDPA:
3510 case RADIO_TECH_HSUPA:
3511 case RADIO_TECH_HSPA:
3512 case RADIO_TECH_HSPAP: {
3513 return RIL_CELL_INFO_TYPE_WCDMA;
3514 }
3515
3516 case RADIO_TECH_IS95A:
3517 case RADIO_TECH_IS95B:
3518 case RADIO_TECH_1xRTT:
3519 case RADIO_TECH_EVDO_0:
3520 case RADIO_TECH_EVDO_A:
3521 case RADIO_TECH_EVDO_B:
3522 case RADIO_TECH_EHRPD: {
3523 return RIL_CELL_INFO_TYPE_CDMA;
3524 }
3525
3526 case RADIO_TECH_LTE:
3527 case RADIO_TECH_LTE_CA: {
3528 return RIL_CELL_INFO_TYPE_LTE;
3529 }
3530
3531 case RADIO_TECH_TD_SCDMA: {
3532 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3533 }
3534
3535 default: {
3536 break;
3537 }
3538 }
3539
3540 return RIL_CELL_INFO_TYPE_NONE;
3541
3542 }
3543
fillCellIdentityResponse(CellIdentity & cellIdentity,RIL_CellIdentity_v16 & rilCellIdentity)3544 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3545
3546 cellIdentity.cellIdentityGsm.resize(0);
3547 cellIdentity.cellIdentityWcdma.resize(0);
3548 cellIdentity.cellIdentityCdma.resize(0);
3549 cellIdentity.cellIdentityTdscdma.resize(0);
3550 cellIdentity.cellIdentityLte.resize(0);
3551 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3552 switch(rilCellIdentity.cellInfoType) {
3553
3554 case RIL_CELL_INFO_TYPE_GSM: {
3555 cellIdentity.cellIdentityGsm.resize(1);
3556 cellIdentity.cellIdentityGsm[0].mcc =
3557 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3558 cellIdentity.cellIdentityGsm[0].mnc =
3559 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3560 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3561 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3562 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3563 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3564 break;
3565 }
3566
3567 case RIL_CELL_INFO_TYPE_WCDMA: {
3568 cellIdentity.cellIdentityWcdma.resize(1);
3569 cellIdentity.cellIdentityWcdma[0].mcc =
3570 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3571 cellIdentity.cellIdentityWcdma[0].mnc =
3572 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3573 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3574 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3575 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3576 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3577 break;
3578 }
3579
3580 case RIL_CELL_INFO_TYPE_CDMA: {
3581 cellIdentity.cellIdentityCdma.resize(1);
3582 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3583 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3584 cellIdentity.cellIdentityCdma[0].baseStationId =
3585 rilCellIdentity.cellIdentityCdma.basestationId;
3586 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3587 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3588 break;
3589 }
3590
3591 case RIL_CELL_INFO_TYPE_LTE: {
3592 cellIdentity.cellIdentityLte.resize(1);
3593 cellIdentity.cellIdentityLte[0].mcc =
3594 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3595 cellIdentity.cellIdentityLte[0].mnc =
3596 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3597 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3598 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3599 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3600 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3601 break;
3602 }
3603
3604 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3605 cellIdentity.cellIdentityTdscdma.resize(1);
3606 cellIdentity.cellIdentityTdscdma[0].mcc =
3607 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3608 cellIdentity.cellIdentityTdscdma[0].mnc =
3609 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3610 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3611 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3612 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3613 break;
3614 }
3615
3616 default: {
3617 break;
3618 }
3619 }
3620 }
3621
convertResponseStringEntryToInt(char ** response,int index,int numStrings)3622 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3623 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3624 return atoi(response[index]);
3625 }
3626
3627 return -1;
3628 }
3629
convertResponseHexStringEntryToInt(char ** response,int index,int numStrings)3630 int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
3631 const int hexBase = 16;
3632 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3633 return strtol(response[index], NULL, hexBase);
3634 }
3635
3636 return -1;
3637 }
3638
3639 /* Fill Cell Identity info from Voice Registration State Response.
3640 * This fucntion is applicable only for RIL Version < 15.
3641 * Response is a "char **".
3642 * First and Second entries are in hex string format
3643 * and rest are integers represented in ascii format. */
fillCellIdentityFromVoiceRegStateResponseString(CellIdentity & cellIdentity,int numStrings,char ** response)3644 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3645 int numStrings, char** response) {
3646
3647 RIL_CellIdentity_v16 rilCellIdentity;
3648 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3649
3650 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3651 switch(rilCellIdentity.cellInfoType) {
3652
3653 case RIL_CELL_INFO_TYPE_GSM: {
3654 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3655 rilCellIdentity.cellIdentityGsm.lac =
3656 convertResponseHexStringEntryToInt(response, 1, numStrings);
3657
3658 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3659 rilCellIdentity.cellIdentityGsm.cid =
3660 convertResponseHexStringEntryToInt(response, 2, numStrings);
3661 break;
3662 }
3663
3664 case RIL_CELL_INFO_TYPE_WCDMA: {
3665 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3666 rilCellIdentity.cellIdentityWcdma.lac =
3667 convertResponseHexStringEntryToInt(response, 1, numStrings);
3668
3669 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3670 rilCellIdentity.cellIdentityWcdma.cid =
3671 convertResponseHexStringEntryToInt(response, 2, numStrings);
3672 rilCellIdentity.cellIdentityWcdma.psc =
3673 convertResponseStringEntryToInt(response, 14, numStrings);
3674 break;
3675 }
3676
3677 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3678 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3679 rilCellIdentity.cellIdentityTdscdma.lac =
3680 convertResponseHexStringEntryToInt(response, 1, numStrings);
3681
3682 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3683 rilCellIdentity.cellIdentityTdscdma.cid =
3684 convertResponseHexStringEntryToInt(response, 2, numStrings);
3685 break;
3686 }
3687
3688 case RIL_CELL_INFO_TYPE_CDMA:{
3689 rilCellIdentity.cellIdentityCdma.basestationId =
3690 convertResponseStringEntryToInt(response, 4, numStrings);
3691 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
3692 rilCellIdentity.cellIdentityCdma.latitude =
3693 convertResponseStringEntryToInt(response, 5, numStrings);
3694 rilCellIdentity.cellIdentityCdma.longitude =
3695 convertResponseStringEntryToInt(response, 6, numStrings);
3696 rilCellIdentity.cellIdentityCdma.systemId =
3697 convertResponseStringEntryToInt(response, 8, numStrings);
3698 rilCellIdentity.cellIdentityCdma.networkId =
3699 convertResponseStringEntryToInt(response, 9, numStrings);
3700 break;
3701 }
3702
3703 case RIL_CELL_INFO_TYPE_LTE:{
3704 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
3705 rilCellIdentity.cellIdentityLte.tac =
3706 convertResponseHexStringEntryToInt(response, 1, numStrings);
3707
3708 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3709 rilCellIdentity.cellIdentityLte.ci =
3710 convertResponseHexStringEntryToInt(response, 2, numStrings);
3711 break;
3712 }
3713
3714 default: {
3715 break;
3716 }
3717 }
3718
3719 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3720 }
3721
3722 /* Fill Cell Identity info from Data Registration State Response.
3723 * This fucntion is applicable only for RIL Version < 15.
3724 * Response is a "char **".
3725 * First and Second entries are in hex string format
3726 * and rest are integers represented in ascii format. */
fillCellIdentityFromDataRegStateResponseString(CellIdentity & cellIdentity,int numStrings,char ** response)3727 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3728 int numStrings, char** response) {
3729
3730 RIL_CellIdentity_v16 rilCellIdentity;
3731 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3732
3733 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3734 switch(rilCellIdentity.cellInfoType) {
3735 case RIL_CELL_INFO_TYPE_GSM: {
3736 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3737 rilCellIdentity.cellIdentityGsm.lac =
3738 convertResponseHexStringEntryToInt(response, 1, numStrings);
3739
3740 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3741 rilCellIdentity.cellIdentityGsm.cid =
3742 convertResponseHexStringEntryToInt(response, 2, numStrings);
3743 break;
3744 }
3745 case RIL_CELL_INFO_TYPE_WCDMA: {
3746 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3747 rilCellIdentity.cellIdentityWcdma.lac =
3748 convertResponseHexStringEntryToInt(response, 1, numStrings);
3749
3750 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3751 rilCellIdentity.cellIdentityWcdma.cid =
3752 convertResponseHexStringEntryToInt(response, 2, numStrings);
3753 break;
3754 }
3755 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3756 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3757 rilCellIdentity.cellIdentityTdscdma.lac =
3758 convertResponseHexStringEntryToInt(response, 1, numStrings);
3759
3760 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3761 rilCellIdentity.cellIdentityTdscdma.cid =
3762 convertResponseHexStringEntryToInt(response, 2, numStrings);
3763 break;
3764 }
3765 case RIL_CELL_INFO_TYPE_LTE: {
3766 rilCellIdentity.cellIdentityLte.tac =
3767 convertResponseStringEntryToInt(response, 6, numStrings);
3768 rilCellIdentity.cellIdentityLte.pci =
3769 convertResponseStringEntryToInt(response, 7, numStrings);
3770 rilCellIdentity.cellIdentityLte.ci =
3771 convertResponseStringEntryToInt(response, 8, numStrings);
3772 break;
3773 }
3774 default: {
3775 break;
3776 }
3777 }
3778
3779 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3780 }
3781
getVoiceRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3782 int radio::getVoiceRegistrationStateResponse(int slotId,
3783 int responseType, int serial, RIL_Errno e,
3784 void *response, size_t responseLen) {
3785 #if VDBG
3786 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3787 #endif
3788
3789 if (radioService[slotId]->mRadioResponse != NULL) {
3790 RadioResponseInfo responseInfo = {};
3791 populateResponseInfo(responseInfo, serial, responseType, e);
3792
3793 VoiceRegStateResult voiceRegResponse = {};
3794 int numStrings = responseLen / sizeof(char *);
3795 if (response == NULL) {
3796 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3797 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3798 } else if (s_vendorFunctions->version <= 14) {
3799 if (numStrings != 15) {
3800 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3801 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3802 } else {
3803 char **resp = (char **) response;
3804 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3805 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3806 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3807 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3808 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3809 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3810 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3811 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3812 numStrings, resp);
3813 }
3814 } else {
3815 RIL_VoiceRegistrationStateResponse *voiceRegState =
3816 (RIL_VoiceRegistrationStateResponse *)response;
3817
3818 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3819 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3820 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3821 } else {
3822 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3823 voiceRegResponse.rat = voiceRegState->rat;;
3824 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3825 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3826 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3827 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3828 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3829 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3830 voiceRegState->cellIdentity);
3831 }
3832 }
3833
3834 Return<void> retStatus =
3835 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3836 responseInfo, voiceRegResponse);
3837 radioService[slotId]->checkReturnStatus(retStatus);
3838 } else {
3839 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3840 slotId);
3841 }
3842
3843 return 0;
3844 }
3845
getDataRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3846 int radio::getDataRegistrationStateResponse(int slotId,
3847 int responseType, int serial, RIL_Errno e,
3848 void *response, size_t responseLen) {
3849 #if VDBG
3850 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3851 #endif
3852
3853 if (radioService[slotId]->mRadioResponse != NULL) {
3854 RadioResponseInfo responseInfo = {};
3855 populateResponseInfo(responseInfo, serial, responseType, e);
3856 DataRegStateResult dataRegResponse = {};
3857 if (response == NULL) {
3858 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3859 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3860 } else if (s_vendorFunctions->version <= 14) {
3861 int numStrings = responseLen / sizeof(char *);
3862 if ((numStrings != 6) && (numStrings != 11)) {
3863 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3864 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3865 } else {
3866 char **resp = (char **) response;
3867 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3868 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3869 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3870 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3871 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3872 numStrings, resp);
3873 }
3874 } else {
3875 RIL_DataRegistrationStateResponse *dataRegState =
3876 (RIL_DataRegistrationStateResponse *)response;
3877
3878 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3879 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3880 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3881 } else {
3882 dataRegResponse.regState = (RegState) dataRegState->regState;
3883 dataRegResponse.rat = dataRegState->rat;;
3884 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3885 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3886 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3887 }
3888 }
3889
3890 Return<void> retStatus =
3891 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3892 dataRegResponse);
3893 radioService[slotId]->checkReturnStatus(retStatus);
3894 } else {
3895 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3896 slotId);
3897 }
3898
3899 return 0;
3900 }
3901
getOperatorResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3902 int radio::getOperatorResponse(int slotId,
3903 int responseType, int serial, RIL_Errno e, void *response,
3904 size_t responseLen) {
3905 #if VDBG
3906 RLOGD("getOperatorResponse: serial %d", serial);
3907 #endif
3908
3909 if (radioService[slotId]->mRadioResponse != NULL) {
3910 RadioResponseInfo responseInfo = {};
3911 populateResponseInfo(responseInfo, serial, responseType, e);
3912 hidl_string longName;
3913 hidl_string shortName;
3914 hidl_string numeric;
3915 int numStrings = responseLen / sizeof(char *);
3916 if (response == NULL || numStrings != 3) {
3917 RLOGE("getOperatorResponse Invalid response: NULL");
3918 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3919
3920 } else {
3921 char **resp = (char **) response;
3922 longName = convertCharPtrToHidlString(resp[0]);
3923 shortName = convertCharPtrToHidlString(resp[1]);
3924 numeric = convertCharPtrToHidlString(resp[2]);
3925 }
3926 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3927 responseInfo, longName, shortName, numeric);
3928 radioService[slotId]->checkReturnStatus(retStatus);
3929 } else {
3930 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3931 slotId);
3932 }
3933
3934 return 0;
3935 }
3936
setRadioPowerResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3937 int radio::setRadioPowerResponse(int slotId,
3938 int responseType, int serial, RIL_Errno e, void *response,
3939 size_t responseLen) {
3940 RLOGD("setRadioPowerResponse: serial %d", serial);
3941
3942 if (radioService[slotId]->mRadioResponse != NULL) {
3943 RadioResponseInfo responseInfo = {};
3944 populateResponseInfo(responseInfo, serial, responseType, e);
3945 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3946 responseInfo);
3947 radioService[slotId]->checkReturnStatus(retStatus);
3948 } else {
3949 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3950 slotId);
3951 }
3952
3953 return 0;
3954 }
3955
sendDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3956 int radio::sendDtmfResponse(int slotId,
3957 int responseType, int serial, RIL_Errno e, void *response,
3958 size_t responseLen) {
3959 #if VDBG
3960 RLOGD("sendDtmfResponse: serial %d", serial);
3961 #endif
3962
3963 if (radioService[slotId]->mRadioResponse != NULL) {
3964 RadioResponseInfo responseInfo = {};
3965 populateResponseInfo(responseInfo, serial, responseType, e);
3966 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3967 responseInfo);
3968 radioService[slotId]->checkReturnStatus(retStatus);
3969 } else {
3970 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3971 slotId);
3972 }
3973
3974 return 0;
3975 }
3976
makeSendSmsResult(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)3977 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3978 RIL_Errno e, void *response, size_t responseLen) {
3979 populateResponseInfo(responseInfo, serial, responseType, e);
3980 SendSmsResult result = {};
3981
3982 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3983 RLOGE("Invalid response: NULL");
3984 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3985 result.ackPDU = hidl_string();
3986 } else {
3987 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3988 result.messageRef = resp->messageRef;
3989 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3990 result.errorCode = resp->errorCode;
3991 }
3992 return result;
3993 }
3994
sendSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3995 int radio::sendSmsResponse(int slotId,
3996 int responseType, int serial, RIL_Errno e, void *response,
3997 size_t responseLen) {
3998 #if VDBG
3999 RLOGD("sendSmsResponse: serial %d", serial);
4000 #endif
4001
4002 if (radioService[slotId]->mRadioResponse != NULL) {
4003 RadioResponseInfo responseInfo = {};
4004 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4005 responseLen);
4006
4007 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
4008 result);
4009 radioService[slotId]->checkReturnStatus(retStatus);
4010 } else {
4011 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4012 }
4013
4014 return 0;
4015 }
4016
sendSMSExpectMoreResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4017 int radio::sendSMSExpectMoreResponse(int slotId,
4018 int responseType, int serial, RIL_Errno e, void *response,
4019 size_t responseLen) {
4020 #if VDBG
4021 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
4022 #endif
4023
4024 if (radioService[slotId]->mRadioResponse != NULL) {
4025 RadioResponseInfo responseInfo = {};
4026 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4027 responseLen);
4028
4029 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
4030 responseInfo, result);
4031 radioService[slotId]->checkReturnStatus(retStatus);
4032 } else {
4033 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4034 }
4035
4036 return 0;
4037 }
4038
setupDataCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4039 int radio::setupDataCallResponse(int slotId,
4040 int responseType, int serial, RIL_Errno e, void *response,
4041 size_t responseLen) {
4042 #if VDBG
4043 RLOGD("setupDataCallResponse: serial %d", serial);
4044 #endif
4045
4046 if (radioService[slotId]->mRadioResponse != NULL) {
4047 RadioResponseInfo responseInfo = {};
4048 populateResponseInfo(responseInfo, serial, responseType, e);
4049
4050 SetupDataCallResult result = {};
4051 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
4052 if (response != NULL) {
4053 RLOGE("setupDataCallResponse: Invalid response");
4054 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4055 }
4056 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
4057 result.type = hidl_string();
4058 result.ifname = hidl_string();
4059 result.addresses = hidl_string();
4060 result.dnses = hidl_string();
4061 result.gateways = hidl_string();
4062 result.pcscf = hidl_string();
4063 } else {
4064 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
4065 }
4066
4067 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
4068 responseInfo, result);
4069 radioService[slotId]->checkReturnStatus(retStatus);
4070 } else {
4071 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4072 }
4073
4074 return 0;
4075 }
4076
responseIccIo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)4077 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
4078 RIL_Errno e, void *response, size_t responseLen) {
4079 populateResponseInfo(responseInfo, serial, responseType, e);
4080 IccIoResult result = {};
4081
4082 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
4083 RLOGE("Invalid response: NULL");
4084 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4085 result.simResponse = hidl_string();
4086 } else {
4087 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
4088 result.sw1 = resp->sw1;
4089 result.sw2 = resp->sw2;
4090 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
4091 }
4092 return result;
4093 }
4094
iccIOForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4095 int radio::iccIOForAppResponse(int slotId,
4096 int responseType, int serial, RIL_Errno e, void *response,
4097 size_t responseLen) {
4098 #if VDBG
4099 RLOGD("iccIOForAppResponse: serial %d", serial);
4100 #endif
4101
4102 if (radioService[slotId]->mRadioResponse != NULL) {
4103 RadioResponseInfo responseInfo = {};
4104 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
4105 responseLen);
4106
4107 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
4108 responseInfo, result);
4109 radioService[slotId]->checkReturnStatus(retStatus);
4110 } else {
4111 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4112 }
4113
4114 return 0;
4115 }
4116
sendUssdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4117 int radio::sendUssdResponse(int slotId,
4118 int responseType, int serial, RIL_Errno e, void *response,
4119 size_t responseLen) {
4120 #if VDBG
4121 RLOGD("sendUssdResponse: serial %d", serial);
4122 #endif
4123
4124 if (radioService[slotId]->mRadioResponse != NULL) {
4125 RadioResponseInfo responseInfo = {};
4126 populateResponseInfo(responseInfo, serial, responseType, e);
4127 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
4128 responseInfo);
4129 radioService[slotId]->checkReturnStatus(retStatus);
4130 } else {
4131 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
4132 slotId);
4133 }
4134
4135 return 0;
4136 }
4137
cancelPendingUssdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4138 int radio::cancelPendingUssdResponse(int slotId,
4139 int responseType, int serial, RIL_Errno e, void *response,
4140 size_t responseLen) {
4141 #if VDBG
4142 RLOGD("cancelPendingUssdResponse: serial %d", serial);
4143 #endif
4144
4145 if (radioService[slotId]->mRadioResponse != NULL) {
4146 RadioResponseInfo responseInfo = {};
4147 populateResponseInfo(responseInfo, serial, responseType, e);
4148 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
4149 responseInfo);
4150 radioService[slotId]->checkReturnStatus(retStatus);
4151 } else {
4152 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
4153 slotId);
4154 }
4155
4156 return 0;
4157 }
4158
getClirResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4159 int radio::getClirResponse(int slotId,
4160 int responseType, int serial, RIL_Errno e, void *response,
4161 size_t responseLen) {
4162 #if VDBG
4163 RLOGD("getClirResponse: serial %d", serial);
4164 #endif
4165
4166 if (radioService[slotId]->mRadioResponse != NULL) {
4167 RadioResponseInfo responseInfo = {};
4168 populateResponseInfo(responseInfo, serial, responseType, e);
4169 int n = -1, m = -1;
4170 int numInts = responseLen / sizeof(int);
4171 if (response == NULL || numInts != 2) {
4172 RLOGE("getClirResponse Invalid response: NULL");
4173 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4174 } else {
4175 int *pInt = (int *) response;
4176 n = pInt[0];
4177 m = pInt[1];
4178 }
4179 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
4180 n, m);
4181 radioService[slotId]->checkReturnStatus(retStatus);
4182 } else {
4183 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4184 }
4185
4186 return 0;
4187 }
4188
setClirResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4189 int radio::setClirResponse(int slotId,
4190 int responseType, int serial, RIL_Errno e, void *response,
4191 size_t responseLen) {
4192 #if VDBG
4193 RLOGD("setClirResponse: serial %d", serial);
4194 #endif
4195
4196 if (radioService[slotId]->mRadioResponse != NULL) {
4197 RadioResponseInfo responseInfo = {};
4198 populateResponseInfo(responseInfo, serial, responseType, e);
4199 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
4200 responseInfo);
4201 radioService[slotId]->checkReturnStatus(retStatus);
4202 } else {
4203 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4204 }
4205
4206 return 0;
4207 }
4208
getCallForwardStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4209 int radio::getCallForwardStatusResponse(int slotId,
4210 int responseType, int serial, RIL_Errno e,
4211 void *response, size_t responseLen) {
4212 #if VDBG
4213 RLOGD("getCallForwardStatusResponse: serial %d", serial);
4214 #endif
4215
4216 if (radioService[slotId]->mRadioResponse != NULL) {
4217 RadioResponseInfo responseInfo = {};
4218 populateResponseInfo(responseInfo, serial, responseType, e);
4219 hidl_vec<CallForwardInfo> callForwardInfos;
4220
4221 if ((response == NULL && responseLen != 0)
4222 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4223 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4224 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4225 } else {
4226 int num = responseLen / sizeof(RIL_CallForwardInfo *);
4227 callForwardInfos.resize(num);
4228 for (int i = 0 ; i < num; i++) {
4229 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4230 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4231 callForwardInfos[i].reason = resp->reason;
4232 callForwardInfos[i].serviceClass = resp->serviceClass;
4233 callForwardInfos[i].toa = resp->toa;
4234 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4235 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4236 }
4237 }
4238
4239 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4240 responseInfo, callForwardInfos);
4241 radioService[slotId]->checkReturnStatus(retStatus);
4242 } else {
4243 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4244 slotId);
4245 }
4246
4247 return 0;
4248 }
4249
setCallForwardResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4250 int radio::setCallForwardResponse(int slotId,
4251 int responseType, int serial, RIL_Errno e, void *response,
4252 size_t responseLen) {
4253 #if VDBG
4254 RLOGD("setCallForwardResponse: serial %d", serial);
4255 #endif
4256
4257 if (radioService[slotId]->mRadioResponse != NULL) {
4258 RadioResponseInfo responseInfo = {};
4259 populateResponseInfo(responseInfo, serial, responseType, e);
4260 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4261 responseInfo);
4262 radioService[slotId]->checkReturnStatus(retStatus);
4263 } else {
4264 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4265 }
4266
4267 return 0;
4268 }
4269
getCallWaitingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4270 int radio::getCallWaitingResponse(int slotId,
4271 int responseType, int serial, RIL_Errno e, void *response,
4272 size_t responseLen) {
4273 #if VDBG
4274 RLOGD("getCallWaitingResponse: serial %d", serial);
4275 #endif
4276
4277 if (radioService[slotId]->mRadioResponse != NULL) {
4278 RadioResponseInfo responseInfo = {};
4279 populateResponseInfo(responseInfo, serial, responseType, e);
4280 bool enable = false;
4281 int serviceClass = -1;
4282 int numInts = responseLen / sizeof(int);
4283 if (response == NULL || numInts != 2) {
4284 RLOGE("getCallWaitingResponse Invalid response: NULL");
4285 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4286 } else {
4287 int *pInt = (int *) response;
4288 enable = pInt[0] == 1 ? true : false;
4289 serviceClass = pInt[1];
4290 }
4291 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4292 responseInfo, enable, serviceClass);
4293 radioService[slotId]->checkReturnStatus(retStatus);
4294 } else {
4295 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4296 }
4297
4298 return 0;
4299 }
4300
setCallWaitingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4301 int radio::setCallWaitingResponse(int slotId,
4302 int responseType, int serial, RIL_Errno e, void *response,
4303 size_t responseLen) {
4304 #if VDBG
4305 RLOGD("setCallWaitingResponse: serial %d", serial);
4306 #endif
4307
4308 if (radioService[slotId]->mRadioResponse != NULL) {
4309 RadioResponseInfo responseInfo = {};
4310 populateResponseInfo(responseInfo, serial, responseType, e);
4311 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4312 responseInfo);
4313 radioService[slotId]->checkReturnStatus(retStatus);
4314 } else {
4315 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4316 }
4317
4318 return 0;
4319 }
4320
acknowledgeLastIncomingGsmSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4321 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4322 int responseType, int serial, RIL_Errno e,
4323 void *response, size_t responseLen) {
4324 #if VDBG
4325 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4326 #endif
4327
4328 if (radioService[slotId]->mRadioResponse != NULL) {
4329 RadioResponseInfo responseInfo = {};
4330 populateResponseInfo(responseInfo, serial, responseType, e);
4331 Return<void> retStatus =
4332 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4333 responseInfo);
4334 radioService[slotId]->checkReturnStatus(retStatus);
4335 } else {
4336 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4337 "== NULL", slotId);
4338 }
4339
4340 return 0;
4341 }
4342
acceptCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4343 int radio::acceptCallResponse(int slotId,
4344 int responseType, int serial, RIL_Errno e,
4345 void *response, size_t responseLen) {
4346 #if VDBG
4347 RLOGD("acceptCallResponse: serial %d", serial);
4348 #endif
4349
4350 if (radioService[slotId]->mRadioResponse != NULL) {
4351 RadioResponseInfo responseInfo = {};
4352 populateResponseInfo(responseInfo, serial, responseType, e);
4353 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4354 responseInfo);
4355 radioService[slotId]->checkReturnStatus(retStatus);
4356 } else {
4357 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4358 slotId);
4359 }
4360
4361 return 0;
4362 }
4363
deactivateDataCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4364 int radio::deactivateDataCallResponse(int slotId,
4365 int responseType, int serial, RIL_Errno e,
4366 void *response, size_t responseLen) {
4367 #if VDBG
4368 RLOGD("deactivateDataCallResponse: serial %d", serial);
4369 #endif
4370
4371 if (radioService[slotId]->mRadioResponse != NULL) {
4372 RadioResponseInfo responseInfo = {};
4373 populateResponseInfo(responseInfo, serial, responseType, e);
4374 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4375 responseInfo);
4376 radioService[slotId]->checkReturnStatus(retStatus);
4377 } else {
4378 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4379 slotId);
4380 }
4381
4382 return 0;
4383 }
4384
getFacilityLockForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4385 int radio::getFacilityLockForAppResponse(int slotId,
4386 int responseType, int serial, RIL_Errno e,
4387 void *response, size_t responseLen) {
4388 #if VDBG
4389 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4390 #endif
4391
4392 if (radioService[slotId]->mRadioResponse != NULL) {
4393 RadioResponseInfo responseInfo = {};
4394 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4395 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4396 getFacilityLockForAppResponse(responseInfo, ret);
4397 radioService[slotId]->checkReturnStatus(retStatus);
4398 } else {
4399 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4400 slotId);
4401 }
4402
4403 return 0;
4404 }
4405
setFacilityLockForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4406 int radio::setFacilityLockForAppResponse(int slotId,
4407 int responseType, int serial, RIL_Errno e,
4408 void *response, size_t responseLen) {
4409 #if VDBG
4410 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4411 #endif
4412
4413 if (radioService[slotId]->mRadioResponse != NULL) {
4414 RadioResponseInfo responseInfo = {};
4415 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4416 Return<void> retStatus
4417 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4418 ret);
4419 radioService[slotId]->checkReturnStatus(retStatus);
4420 } else {
4421 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4422 slotId);
4423 }
4424
4425 return 0;
4426 }
4427
setBarringPasswordResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4428 int radio::setBarringPasswordResponse(int slotId,
4429 int responseType, int serial, RIL_Errno e,
4430 void *response, size_t responseLen) {
4431 #if VDBG
4432 RLOGD("acceptCallResponse: serial %d", serial);
4433 #endif
4434
4435 if (radioService[slotId]->mRadioResponse != NULL) {
4436 RadioResponseInfo responseInfo = {};
4437 populateResponseInfo(responseInfo, serial, responseType, e);
4438 Return<void> retStatus
4439 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4440 radioService[slotId]->checkReturnStatus(retStatus);
4441 } else {
4442 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4443 slotId);
4444 }
4445
4446 return 0;
4447 }
4448
getNetworkSelectionModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4449 int radio::getNetworkSelectionModeResponse(int slotId,
4450 int responseType, int serial, RIL_Errno e, void *response,
4451 size_t responseLen) {
4452 #if VDBG
4453 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4454 #endif
4455
4456 if (radioService[slotId]->mRadioResponse != NULL) {
4457 RadioResponseInfo responseInfo = {};
4458 populateResponseInfo(responseInfo, serial, responseType, e);
4459 bool manual = false;
4460 if (response == NULL || responseLen != sizeof(int)) {
4461 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4462 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4463 } else {
4464 int *pInt = (int *) response;
4465 manual = pInt[0] == 1 ? true : false;
4466 }
4467 Return<void> retStatus
4468 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4469 responseInfo,
4470 manual);
4471 radioService[slotId]->checkReturnStatus(retStatus);
4472 } else {
4473 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4474 slotId);
4475 }
4476
4477 return 0;
4478 }
4479
setNetworkSelectionModeAutomaticResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4480 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4481 RIL_Errno e, void *response,
4482 size_t responseLen) {
4483 #if VDBG
4484 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4485 #endif
4486
4487 if (radioService[slotId]->mRadioResponse != NULL) {
4488 RadioResponseInfo responseInfo = {};
4489 populateResponseInfo(responseInfo, serial, responseType, e);
4490 Return<void> retStatus
4491 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4492 responseInfo);
4493 radioService[slotId]->checkReturnStatus(retStatus);
4494 } else {
4495 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4496 "== NULL", slotId);
4497 }
4498
4499 return 0;
4500 }
4501
setNetworkSelectionModeManualResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4502 int radio::setNetworkSelectionModeManualResponse(int slotId,
4503 int responseType, int serial, RIL_Errno e,
4504 void *response, size_t responseLen) {
4505 #if VDBG
4506 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4507 #endif
4508
4509 if (radioService[slotId]->mRadioResponse != NULL) {
4510 RadioResponseInfo responseInfo = {};
4511 populateResponseInfo(responseInfo, serial, responseType, e);
4512 Return<void> retStatus
4513 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4514 responseInfo);
4515 radioService[slotId]->checkReturnStatus(retStatus);
4516 } else {
4517 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4518 "== NULL", slotId);
4519 }
4520
4521 return 0;
4522 }
4523
convertOperatorStatusToInt(const char * str)4524 int convertOperatorStatusToInt(const char *str) {
4525 if (strncmp("unknown", str, 9) == 0) {
4526 return (int) OperatorStatus::UNKNOWN;
4527 } else if (strncmp("available", str, 9) == 0) {
4528 return (int) OperatorStatus::AVAILABLE;
4529 } else if (strncmp("current", str, 9) == 0) {
4530 return (int) OperatorStatus::CURRENT;
4531 } else if (strncmp("forbidden", str, 9) == 0) {
4532 return (int) OperatorStatus::FORBIDDEN;
4533 } else {
4534 return -1;
4535 }
4536 }
4537
getAvailableNetworksResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4538 int radio::getAvailableNetworksResponse(int slotId,
4539 int responseType, int serial, RIL_Errno e, void *response,
4540 size_t responseLen) {
4541 #if VDBG
4542 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4543 #endif
4544
4545 if (radioService[slotId]->mRadioResponse != NULL) {
4546 RadioResponseInfo responseInfo = {};
4547 populateResponseInfo(responseInfo, serial, responseType, e);
4548 hidl_vec<OperatorInfo> networks;
4549 if ((response == NULL && responseLen != 0)
4550 || responseLen % (4 * sizeof(char *))!= 0) {
4551 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4552 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4553 } else {
4554 char **resp = (char **) response;
4555 int numStrings = responseLen / sizeof(char *);
4556 networks.resize(numStrings/4);
4557 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4558 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4559 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4560 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4561 int status = convertOperatorStatusToInt(resp[i + 3]);
4562 if (status == -1) {
4563 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4564 } else {
4565 networks[j].status = (OperatorStatus) status;
4566 }
4567 }
4568 }
4569 Return<void> retStatus
4570 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4571 networks);
4572 radioService[slotId]->checkReturnStatus(retStatus);
4573 } else {
4574 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4575 slotId);
4576 }
4577
4578 return 0;
4579 }
4580
startDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4581 int radio::startDtmfResponse(int slotId,
4582 int responseType, int serial, RIL_Errno e,
4583 void *response, size_t responseLen) {
4584 #if VDBG
4585 RLOGD("startDtmfResponse: serial %d", serial);
4586 #endif
4587
4588 if (radioService[slotId]->mRadioResponse != NULL) {
4589 RadioResponseInfo responseInfo = {};
4590 populateResponseInfo(responseInfo, serial, responseType, e);
4591 Return<void> retStatus
4592 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4593 radioService[slotId]->checkReturnStatus(retStatus);
4594 } else {
4595 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4596 }
4597
4598 return 0;
4599 }
4600
stopDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4601 int radio::stopDtmfResponse(int slotId,
4602 int responseType, int serial, RIL_Errno e,
4603 void *response, size_t responseLen) {
4604 #if VDBG
4605 RLOGD("stopDtmfResponse: serial %d", serial);
4606 #endif
4607
4608 if (radioService[slotId]->mRadioResponse != NULL) {
4609 RadioResponseInfo responseInfo = {};
4610 populateResponseInfo(responseInfo, serial, responseType, e);
4611 Return<void> retStatus
4612 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4613 radioService[slotId]->checkReturnStatus(retStatus);
4614 } else {
4615 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4616 }
4617
4618 return 0;
4619 }
4620
getBasebandVersionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4621 int radio::getBasebandVersionResponse(int slotId,
4622 int responseType, int serial, RIL_Errno e,
4623 void *response, size_t responseLen) {
4624 #if VDBG
4625 RLOGD("getBasebandVersionResponse: serial %d", serial);
4626 #endif
4627
4628 if (radioService[slotId]->mRadioResponse != NULL) {
4629 RadioResponseInfo responseInfo = {};
4630 populateResponseInfo(responseInfo, serial, responseType, e);
4631 Return<void> retStatus
4632 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4633 convertCharPtrToHidlString((char *) response));
4634 radioService[slotId]->checkReturnStatus(retStatus);
4635 } else {
4636 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4637 }
4638
4639 return 0;
4640 }
4641
separateConnectionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4642 int radio::separateConnectionResponse(int slotId,
4643 int responseType, int serial, RIL_Errno e,
4644 void *response, size_t responseLen) {
4645 #if VDBG
4646 RLOGD("separateConnectionResponse: serial %d", serial);
4647 #endif
4648
4649 if (radioService[slotId]->mRadioResponse != NULL) {
4650 RadioResponseInfo responseInfo = {};
4651 populateResponseInfo(responseInfo, serial, responseType, e);
4652 Return<void> retStatus
4653 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4654 radioService[slotId]->checkReturnStatus(retStatus);
4655 } else {
4656 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4657 slotId);
4658 }
4659
4660 return 0;
4661 }
4662
setMuteResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4663 int radio::setMuteResponse(int slotId,
4664 int responseType, int serial, RIL_Errno e,
4665 void *response, size_t responseLen) {
4666 #if VDBG
4667 RLOGD("setMuteResponse: serial %d", serial);
4668 #endif
4669
4670 if (radioService[slotId]->mRadioResponse != NULL) {
4671 RadioResponseInfo responseInfo = {};
4672 populateResponseInfo(responseInfo, serial, responseType, e);
4673 Return<void> retStatus
4674 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4675 radioService[slotId]->checkReturnStatus(retStatus);
4676 } else {
4677 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4678 }
4679
4680 return 0;
4681 }
4682
getMuteResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4683 int radio::getMuteResponse(int slotId,
4684 int responseType, int serial, RIL_Errno e, void *response,
4685 size_t responseLen) {
4686 #if VDBG
4687 RLOGD("getMuteResponse: serial %d", serial);
4688 #endif
4689
4690 if (radioService[slotId]->mRadioResponse != NULL) {
4691 RadioResponseInfo responseInfo = {};
4692 populateResponseInfo(responseInfo, serial, responseType, e);
4693 bool enable = false;
4694 if (response == NULL || responseLen != sizeof(int)) {
4695 RLOGE("getMuteResponse Invalid response: NULL");
4696 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4697 } else {
4698 int *pInt = (int *) response;
4699 enable = pInt[0] == 1 ? true : false;
4700 }
4701 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4702 enable);
4703 radioService[slotId]->checkReturnStatus(retStatus);
4704 } else {
4705 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4706 }
4707
4708 return 0;
4709 }
4710
getClipResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4711 int radio::getClipResponse(int slotId,
4712 int responseType, int serial, RIL_Errno e,
4713 void *response, size_t responseLen) {
4714 #if VDBG
4715 RLOGD("getClipResponse: serial %d", serial);
4716 #endif
4717
4718 if (radioService[slotId]->mRadioResponse != NULL) {
4719 RadioResponseInfo responseInfo = {};
4720 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4721 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4722 (ClipStatus) ret);
4723 radioService[slotId]->checkReturnStatus(retStatus);
4724 } else {
4725 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4726 }
4727
4728 return 0;
4729 }
4730
getDataCallListResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4731 int radio::getDataCallListResponse(int slotId,
4732 int responseType, int serial, RIL_Errno e,
4733 void *response, size_t responseLen) {
4734 #if VDBG
4735 RLOGD("getDataCallListResponse: serial %d", serial);
4736 #endif
4737
4738 if (radioService[slotId]->mRadioResponse != NULL) {
4739 RadioResponseInfo responseInfo = {};
4740 populateResponseInfo(responseInfo, serial, responseType, e);
4741
4742 hidl_vec<SetupDataCallResult> ret;
4743 if ((response == NULL && responseLen != 0)
4744 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4745 RLOGE("getDataCallListResponse: invalid response");
4746 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4747 } else {
4748 convertRilDataCallListToHal(response, responseLen, ret);
4749 }
4750
4751 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4752 responseInfo, ret);
4753 radioService[slotId]->checkReturnStatus(retStatus);
4754 } else {
4755 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4756 }
4757
4758 return 0;
4759 }
4760
setSuppServiceNotificationsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4761 int radio::setSuppServiceNotificationsResponse(int slotId,
4762 int responseType, int serial, RIL_Errno e,
4763 void *response, size_t responseLen) {
4764 #if VDBG
4765 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4766 #endif
4767
4768 if (radioService[slotId]->mRadioResponse != NULL) {
4769 RadioResponseInfo responseInfo = {};
4770 populateResponseInfo(responseInfo, serial, responseType, e);
4771 Return<void> retStatus
4772 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4773 responseInfo);
4774 radioService[slotId]->checkReturnStatus(retStatus);
4775 } else {
4776 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4777 "== NULL", slotId);
4778 }
4779
4780 return 0;
4781 }
4782
deleteSmsOnSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4783 int radio::deleteSmsOnSimResponse(int slotId,
4784 int responseType, int serial, RIL_Errno e,
4785 void *response, size_t responseLen) {
4786 #if VDBG
4787 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4788 #endif
4789
4790 if (radioService[slotId]->mRadioResponse != NULL) {
4791 RadioResponseInfo responseInfo = {};
4792 populateResponseInfo(responseInfo, serial, responseType, e);
4793 Return<void> retStatus
4794 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4795 radioService[slotId]->checkReturnStatus(retStatus);
4796 } else {
4797 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4798 }
4799
4800 return 0;
4801 }
4802
setBandModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4803 int radio::setBandModeResponse(int slotId,
4804 int responseType, int serial, RIL_Errno e,
4805 void *response, size_t responseLen) {
4806 #if VDBG
4807 RLOGD("setBandModeResponse: serial %d", serial);
4808 #endif
4809
4810 if (radioService[slotId]->mRadioResponse != NULL) {
4811 RadioResponseInfo responseInfo = {};
4812 populateResponseInfo(responseInfo, serial, responseType, e);
4813 Return<void> retStatus
4814 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4815 radioService[slotId]->checkReturnStatus(retStatus);
4816 } else {
4817 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4818 }
4819
4820 return 0;
4821 }
4822
writeSmsToSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4823 int radio::writeSmsToSimResponse(int slotId,
4824 int responseType, int serial, RIL_Errno e,
4825 void *response, size_t responseLen) {
4826 #if VDBG
4827 RLOGD("writeSmsToSimResponse: serial %d", serial);
4828 #endif
4829
4830 if (radioService[slotId]->mRadioResponse != NULL) {
4831 RadioResponseInfo responseInfo = {};
4832 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4833 Return<void> retStatus
4834 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4835 radioService[slotId]->checkReturnStatus(retStatus);
4836 } else {
4837 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4838 }
4839
4840 return 0;
4841 }
4842
getAvailableBandModesResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4843 int radio::getAvailableBandModesResponse(int slotId,
4844 int responseType, int serial, RIL_Errno e, void *response,
4845 size_t responseLen) {
4846 #if VDBG
4847 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4848 #endif
4849
4850 if (radioService[slotId]->mRadioResponse != NULL) {
4851 RadioResponseInfo responseInfo = {};
4852 populateResponseInfo(responseInfo, serial, responseType, e);
4853 hidl_vec<RadioBandMode> modes;
4854 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
4855 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4856 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4857 } else {
4858 int *pInt = (int *) response;
4859 int numInts = responseLen / sizeof(int);
4860 modes.resize(numInts);
4861 for (int i = 0; i < numInts; i++) {
4862 modes[i] = (RadioBandMode) pInt[i];
4863 }
4864 }
4865 Return<void> retStatus
4866 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4867 modes);
4868 radioService[slotId]->checkReturnStatus(retStatus);
4869 } else {
4870 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4871 slotId);
4872 }
4873
4874 return 0;
4875 }
4876
sendEnvelopeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4877 int radio::sendEnvelopeResponse(int slotId,
4878 int responseType, int serial, RIL_Errno e,
4879 void *response, size_t responseLen) {
4880 #if VDBG
4881 RLOGD("sendEnvelopeResponse: serial %d", serial);
4882 #endif
4883
4884 if (radioService[slotId]->mRadioResponse != NULL) {
4885 RadioResponseInfo responseInfo = {};
4886 populateResponseInfo(responseInfo, serial, responseType, e);
4887 Return<void> retStatus
4888 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4889 convertCharPtrToHidlString((char *) response));
4890 radioService[slotId]->checkReturnStatus(retStatus);
4891 } else {
4892 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4893 }
4894
4895 return 0;
4896 }
4897
sendTerminalResponseToSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4898 int radio::sendTerminalResponseToSimResponse(int slotId,
4899 int responseType, int serial, RIL_Errno e,
4900 void *response, size_t responseLen) {
4901 #if VDBG
4902 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4903 #endif
4904
4905 if (radioService[slotId]->mRadioResponse != NULL) {
4906 RadioResponseInfo responseInfo = {};
4907 populateResponseInfo(responseInfo, serial, responseType, e);
4908 Return<void> retStatus
4909 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4910 responseInfo);
4911 radioService[slotId]->checkReturnStatus(retStatus);
4912 } else {
4913 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4914 slotId);
4915 }
4916
4917 return 0;
4918 }
4919
handleStkCallSetupRequestFromSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4920 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4921 int responseType, int serial,
4922 RIL_Errno e, void *response,
4923 size_t responseLen) {
4924 #if VDBG
4925 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4926 #endif
4927
4928 if (radioService[slotId]->mRadioResponse != NULL) {
4929 RadioResponseInfo responseInfo = {};
4930 populateResponseInfo(responseInfo, serial, responseType, e);
4931 Return<void> retStatus
4932 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4933 responseInfo);
4934 radioService[slotId]->checkReturnStatus(retStatus);
4935 } else {
4936 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4937 "== NULL", slotId);
4938 }
4939
4940 return 0;
4941 }
4942
explicitCallTransferResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4943 int radio::explicitCallTransferResponse(int slotId,
4944 int responseType, int serial, RIL_Errno e,
4945 void *response, size_t responseLen) {
4946 #if VDBG
4947 RLOGD("explicitCallTransferResponse: serial %d", serial);
4948 #endif
4949
4950 if (radioService[slotId]->mRadioResponse != NULL) {
4951 RadioResponseInfo responseInfo = {};
4952 populateResponseInfo(responseInfo, serial, responseType, e);
4953 Return<void> retStatus
4954 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4955 radioService[slotId]->checkReturnStatus(retStatus);
4956 } else {
4957 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4958 slotId);
4959 }
4960
4961 return 0;
4962 }
4963
setPreferredNetworkTypeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4964 int radio::setPreferredNetworkTypeResponse(int slotId,
4965 int responseType, int serial, RIL_Errno e,
4966 void *response, size_t responseLen) {
4967 #if VDBG
4968 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4969 #endif
4970
4971 if (radioService[slotId]->mRadioResponse != NULL) {
4972 RadioResponseInfo responseInfo = {};
4973 populateResponseInfo(responseInfo, serial, responseType, e);
4974 Return<void> retStatus
4975 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4976 responseInfo);
4977 radioService[slotId]->checkReturnStatus(retStatus);
4978 } else {
4979 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4980 slotId);
4981 }
4982
4983 return 0;
4984 }
4985
4986
getPreferredNetworkTypeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4987 int radio::getPreferredNetworkTypeResponse(int slotId,
4988 int responseType, int serial, RIL_Errno e,
4989 void *response, size_t responseLen) {
4990 #if VDBG
4991 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4992 #endif
4993
4994 if (radioService[slotId]->mRadioResponse != NULL) {
4995 RadioResponseInfo responseInfo = {};
4996 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4997 Return<void> retStatus
4998 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4999 responseInfo, (PreferredNetworkType) ret);
5000 radioService[slotId]->checkReturnStatus(retStatus);
5001 } else {
5002 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
5003 slotId);
5004 }
5005
5006 return 0;
5007 }
5008
getNeighboringCidsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5009 int radio::getNeighboringCidsResponse(int slotId,
5010 int responseType, int serial, RIL_Errno e,
5011 void *response, size_t responseLen) {
5012 #if VDBG
5013 RLOGD("getNeighboringCidsResponse: serial %d", serial);
5014 #endif
5015
5016 if (radioService[slotId]->mRadioResponse != NULL) {
5017 RadioResponseInfo responseInfo = {};
5018 populateResponseInfo(responseInfo, serial, responseType, e);
5019 hidl_vec<NeighboringCell> cells;
5020
5021 if ((response == NULL && responseLen != 0)
5022 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
5023 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
5024 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5025 } else {
5026 int num = responseLen / sizeof(RIL_NeighboringCell *);
5027 cells.resize(num);
5028 for (int i = 0 ; i < num; i++) {
5029 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
5030 cells[i].cid = convertCharPtrToHidlString(resp->cid);
5031 cells[i].rssi = resp->rssi;
5032 }
5033 }
5034
5035 Return<void> retStatus
5036 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
5037 cells);
5038 radioService[slotId]->checkReturnStatus(retStatus);
5039 } else {
5040 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
5041 slotId);
5042 }
5043
5044 return 0;
5045 }
5046
setLocationUpdatesResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5047 int radio::setLocationUpdatesResponse(int slotId,
5048 int responseType, int serial, RIL_Errno e,
5049 void *response, size_t responseLen) {
5050 #if VDBG
5051 RLOGD("setLocationUpdatesResponse: serial %d", serial);
5052 #endif
5053
5054 if (radioService[slotId]->mRadioResponse != NULL) {
5055 RadioResponseInfo responseInfo = {};
5056 populateResponseInfo(responseInfo, serial, responseType, e);
5057 Return<void> retStatus
5058 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
5059 radioService[slotId]->checkReturnStatus(retStatus);
5060 } else {
5061 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
5062 slotId);
5063 }
5064
5065 return 0;
5066 }
5067
setCdmaSubscriptionSourceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5068 int radio::setCdmaSubscriptionSourceResponse(int slotId,
5069 int responseType, int serial, RIL_Errno e,
5070 void *response, size_t responseLen) {
5071 #if VDBG
5072 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
5073 #endif
5074
5075 if (radioService[slotId]->mRadioResponse != NULL) {
5076 RadioResponseInfo responseInfo = {};
5077 populateResponseInfo(responseInfo, serial, responseType, e);
5078 Return<void> retStatus
5079 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
5080 responseInfo);
5081 radioService[slotId]->checkReturnStatus(retStatus);
5082 } else {
5083 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5084 slotId);
5085 }
5086
5087 return 0;
5088 }
5089
setCdmaRoamingPreferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5090 int radio::setCdmaRoamingPreferenceResponse(int slotId,
5091 int responseType, int serial, RIL_Errno e,
5092 void *response, size_t responseLen) {
5093 #if VDBG
5094 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
5095 #endif
5096
5097 if (radioService[slotId]->mRadioResponse != NULL) {
5098 RadioResponseInfo responseInfo = {};
5099 populateResponseInfo(responseInfo, serial, responseType, e);
5100 Return<void> retStatus
5101 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
5102 responseInfo);
5103 radioService[slotId]->checkReturnStatus(retStatus);
5104 } else {
5105 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5106 slotId);
5107 }
5108
5109 return 0;
5110 }
5111
getCdmaRoamingPreferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5112 int radio::getCdmaRoamingPreferenceResponse(int slotId,
5113 int responseType, int serial, RIL_Errno e,
5114 void *response, size_t responseLen) {
5115 #if VDBG
5116 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
5117 #endif
5118
5119 if (radioService[slotId]->mRadioResponse != NULL) {
5120 RadioResponseInfo responseInfo = {};
5121 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5122 Return<void> retStatus
5123 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
5124 responseInfo, (CdmaRoamingType) ret);
5125 radioService[slotId]->checkReturnStatus(retStatus);
5126 } else {
5127 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5128 slotId);
5129 }
5130
5131 return 0;
5132 }
5133
setTTYModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5134 int radio::setTTYModeResponse(int slotId,
5135 int responseType, int serial, RIL_Errno e,
5136 void *response, size_t responseLen) {
5137 #if VDBG
5138 RLOGD("setTTYModeResponse: serial %d", serial);
5139 #endif
5140
5141 if (radioService[slotId]->mRadioResponse != NULL) {
5142 RadioResponseInfo responseInfo = {};
5143 populateResponseInfo(responseInfo, serial, responseType, e);
5144 Return<void> retStatus
5145 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
5146 radioService[slotId]->checkReturnStatus(retStatus);
5147 } else {
5148 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5149 }
5150
5151 return 0;
5152 }
5153
getTTYModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5154 int radio::getTTYModeResponse(int slotId,
5155 int responseType, int serial, RIL_Errno e,
5156 void *response, size_t responseLen) {
5157 #if VDBG
5158 RLOGD("getTTYModeResponse: serial %d", serial);
5159 #endif
5160
5161 if (radioService[slotId]->mRadioResponse != NULL) {
5162 RadioResponseInfo responseInfo = {};
5163 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5164 Return<void> retStatus
5165 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
5166 (TtyMode) ret);
5167 radioService[slotId]->checkReturnStatus(retStatus);
5168 } else {
5169 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5170 }
5171
5172 return 0;
5173 }
5174
setPreferredVoicePrivacyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5175 int radio::setPreferredVoicePrivacyResponse(int slotId,
5176 int responseType, int serial, RIL_Errno e,
5177 void *response, size_t responseLen) {
5178 #if VDBG
5179 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
5180 #endif
5181
5182 if (radioService[slotId]->mRadioResponse != NULL) {
5183 RadioResponseInfo responseInfo = {};
5184 populateResponseInfo(responseInfo, serial, responseType, e);
5185 Return<void> retStatus
5186 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
5187 responseInfo);
5188 radioService[slotId]->checkReturnStatus(retStatus);
5189 } else {
5190 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5191 slotId);
5192 }
5193
5194 return 0;
5195 }
5196
getPreferredVoicePrivacyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5197 int radio::getPreferredVoicePrivacyResponse(int slotId,
5198 int responseType, int serial, RIL_Errno e,
5199 void *response, size_t responseLen) {
5200 #if VDBG
5201 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
5202 #endif
5203
5204 if (radioService[slotId]->mRadioResponse != NULL) {
5205 RadioResponseInfo responseInfo = {};
5206 populateResponseInfo(responseInfo, serial, responseType, e);
5207 bool enable = false;
5208 int numInts = responseLen / sizeof(int);
5209 if (response == NULL || numInts != 1) {
5210 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
5211 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5212 } else {
5213 int *pInt = (int *) response;
5214 enable = pInt[0] == 1 ? true : false;
5215 }
5216 Return<void> retStatus
5217 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5218 responseInfo, enable);
5219 radioService[slotId]->checkReturnStatus(retStatus);
5220 } else {
5221 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5222 slotId);
5223 }
5224
5225 return 0;
5226 }
5227
sendCDMAFeatureCodeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5228 int radio::sendCDMAFeatureCodeResponse(int slotId,
5229 int responseType, int serial, RIL_Errno e,
5230 void *response, size_t responseLen) {
5231 #if VDBG
5232 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5233 #endif
5234
5235 if (radioService[slotId]->mRadioResponse != NULL) {
5236 RadioResponseInfo responseInfo = {};
5237 populateResponseInfo(responseInfo, serial, responseType, e);
5238 Return<void> retStatus
5239 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5240 radioService[slotId]->checkReturnStatus(retStatus);
5241 } else {
5242 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5243 slotId);
5244 }
5245
5246 return 0;
5247 }
5248
sendBurstDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5249 int radio::sendBurstDtmfResponse(int slotId,
5250 int responseType, int serial, RIL_Errno e,
5251 void *response, size_t responseLen) {
5252 #if VDBG
5253 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5254 #endif
5255
5256 if (radioService[slotId]->mRadioResponse != NULL) {
5257 RadioResponseInfo responseInfo = {};
5258 populateResponseInfo(responseInfo, serial, responseType, e);
5259 Return<void> retStatus
5260 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5261 radioService[slotId]->checkReturnStatus(retStatus);
5262 } else {
5263 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5264 }
5265
5266 return 0;
5267 }
5268
sendCdmaSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5269 int radio::sendCdmaSmsResponse(int slotId,
5270 int responseType, int serial, RIL_Errno e, void *response,
5271 size_t responseLen) {
5272 #if VDBG
5273 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5274 #endif
5275
5276 if (radioService[slotId]->mRadioResponse != NULL) {
5277 RadioResponseInfo responseInfo = {};
5278 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5279 responseLen);
5280
5281 Return<void> retStatus
5282 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5283 radioService[slotId]->checkReturnStatus(retStatus);
5284 } else {
5285 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5286 }
5287
5288 return 0;
5289 }
5290
acknowledgeLastIncomingCdmaSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5291 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5292 int responseType, int serial, RIL_Errno e,
5293 void *response, size_t responseLen) {
5294 #if VDBG
5295 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5296 #endif
5297
5298 if (radioService[slotId]->mRadioResponse != NULL) {
5299 RadioResponseInfo responseInfo = {};
5300 populateResponseInfo(responseInfo, serial, responseType, e);
5301 Return<void> retStatus
5302 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5303 responseInfo);
5304 radioService[slotId]->checkReturnStatus(retStatus);
5305 } else {
5306 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5307 "== NULL", slotId);
5308 }
5309
5310 return 0;
5311 }
5312
getGsmBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5313 int radio::getGsmBroadcastConfigResponse(int slotId,
5314 int responseType, int serial, RIL_Errno e,
5315 void *response, size_t responseLen) {
5316 #if VDBG
5317 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5318 #endif
5319
5320 if (radioService[slotId]->mRadioResponse != NULL) {
5321 RadioResponseInfo responseInfo = {};
5322 populateResponseInfo(responseInfo, serial, responseType, e);
5323 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5324
5325 if ((response == NULL && responseLen != 0)
5326 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5327 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5328 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5329 } else {
5330 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5331 configs.resize(num);
5332 for (int i = 0 ; i < num; i++) {
5333 RIL_GSM_BroadcastSmsConfigInfo *resp =
5334 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5335 configs[i].fromServiceId = resp->fromServiceId;
5336 configs[i].toServiceId = resp->toServiceId;
5337 configs[i].fromCodeScheme = resp->fromCodeScheme;
5338 configs[i].toCodeScheme = resp->toCodeScheme;
5339 configs[i].selected = resp->selected == 1 ? true : false;
5340 }
5341 }
5342
5343 Return<void> retStatus
5344 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5345 configs);
5346 radioService[slotId]->checkReturnStatus(retStatus);
5347 } else {
5348 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5349 slotId);
5350 }
5351
5352 return 0;
5353 }
5354
setGsmBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5355 int radio::setGsmBroadcastConfigResponse(int slotId,
5356 int responseType, int serial, RIL_Errno e,
5357 void *response, size_t responseLen) {
5358 #if VDBG
5359 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5360 #endif
5361
5362 if (radioService[slotId]->mRadioResponse != NULL) {
5363 RadioResponseInfo responseInfo = {};
5364 populateResponseInfo(responseInfo, serial, responseType, e);
5365 Return<void> retStatus
5366 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5367 radioService[slotId]->checkReturnStatus(retStatus);
5368 } else {
5369 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5370 slotId);
5371 }
5372
5373 return 0;
5374 }
5375
setGsmBroadcastActivationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5376 int radio::setGsmBroadcastActivationResponse(int slotId,
5377 int responseType, int serial, RIL_Errno e,
5378 void *response, size_t responseLen) {
5379 #if VDBG
5380 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5381 #endif
5382
5383 if (radioService[slotId]->mRadioResponse != NULL) {
5384 RadioResponseInfo responseInfo = {};
5385 populateResponseInfo(responseInfo, serial, responseType, e);
5386 Return<void> retStatus
5387 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5388 responseInfo);
5389 radioService[slotId]->checkReturnStatus(retStatus);
5390 } else {
5391 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5392 slotId);
5393 }
5394
5395 return 0;
5396 }
5397
getCdmaBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5398 int radio::getCdmaBroadcastConfigResponse(int slotId,
5399 int responseType, int serial, RIL_Errno e,
5400 void *response, size_t responseLen) {
5401 #if VDBG
5402 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5403 #endif
5404
5405 if (radioService[slotId]->mRadioResponse != NULL) {
5406 RadioResponseInfo responseInfo = {};
5407 populateResponseInfo(responseInfo, serial, responseType, e);
5408 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5409
5410 if ((response == NULL && responseLen != 0)
5411 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5412 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5413 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5414 } else {
5415 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5416 configs.resize(num);
5417 for (int i = 0 ; i < num; i++) {
5418 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5419 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5420 configs[i].serviceCategory = resp->service_category;
5421 configs[i].language = resp->language;
5422 configs[i].selected = resp->selected == 1 ? true : false;
5423 }
5424 }
5425
5426 Return<void> retStatus
5427 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5428 configs);
5429 radioService[slotId]->checkReturnStatus(retStatus);
5430 } else {
5431 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5432 slotId);
5433 }
5434
5435 return 0;
5436 }
5437
setCdmaBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5438 int radio::setCdmaBroadcastConfigResponse(int slotId,
5439 int responseType, int serial, RIL_Errno e,
5440 void *response, size_t responseLen) {
5441 #if VDBG
5442 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5443 #endif
5444
5445 if (radioService[slotId]->mRadioResponse != NULL) {
5446 RadioResponseInfo responseInfo = {};
5447 populateResponseInfo(responseInfo, serial, responseType, e);
5448 Return<void> retStatus
5449 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5450 responseInfo);
5451 radioService[slotId]->checkReturnStatus(retStatus);
5452 } else {
5453 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5454 slotId);
5455 }
5456
5457 return 0;
5458 }
5459
setCdmaBroadcastActivationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5460 int radio::setCdmaBroadcastActivationResponse(int slotId,
5461 int responseType, int serial, RIL_Errno e,
5462 void *response, size_t responseLen) {
5463 #if VDBG
5464 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5465 #endif
5466
5467 if (radioService[slotId]->mRadioResponse != NULL) {
5468 RadioResponseInfo responseInfo = {};
5469 populateResponseInfo(responseInfo, serial, responseType, e);
5470 Return<void> retStatus
5471 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5472 responseInfo);
5473 radioService[slotId]->checkReturnStatus(retStatus);
5474 } else {
5475 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5476 slotId);
5477 }
5478
5479 return 0;
5480 }
5481
getCDMASubscriptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5482 int radio::getCDMASubscriptionResponse(int slotId,
5483 int responseType, int serial, RIL_Errno e, void *response,
5484 size_t responseLen) {
5485 #if VDBG
5486 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5487 #endif
5488
5489 if (radioService[slotId]->mRadioResponse != NULL) {
5490 RadioResponseInfo responseInfo = {};
5491 populateResponseInfo(responseInfo, serial, responseType, e);
5492
5493 int numStrings = responseLen / sizeof(char *);
5494 hidl_string emptyString;
5495 if (response == NULL || numStrings != 5) {
5496 RLOGE("getOperatorResponse Invalid response: NULL");
5497 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5498 Return<void> retStatus
5499 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5500 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5501 radioService[slotId]->checkReturnStatus(retStatus);
5502 } else {
5503 char **resp = (char **) response;
5504 Return<void> retStatus
5505 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5506 responseInfo,
5507 convertCharPtrToHidlString(resp[0]),
5508 convertCharPtrToHidlString(resp[1]),
5509 convertCharPtrToHidlString(resp[2]),
5510 convertCharPtrToHidlString(resp[3]),
5511 convertCharPtrToHidlString(resp[4]));
5512 radioService[slotId]->checkReturnStatus(retStatus);
5513 }
5514 } else {
5515 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5516 slotId);
5517 }
5518
5519 return 0;
5520 }
5521
writeSmsToRuimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5522 int radio::writeSmsToRuimResponse(int slotId,
5523 int responseType, int serial, RIL_Errno e,
5524 void *response, size_t responseLen) {
5525 #if VDBG
5526 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5527 #endif
5528
5529 if (radioService[slotId]->mRadioResponse != NULL) {
5530 RadioResponseInfo responseInfo = {};
5531 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5532 Return<void> retStatus
5533 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5534 radioService[slotId]->checkReturnStatus(retStatus);
5535 } else {
5536 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5537 }
5538
5539 return 0;
5540 }
5541
deleteSmsOnRuimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5542 int radio::deleteSmsOnRuimResponse(int slotId,
5543 int responseType, int serial, RIL_Errno e,
5544 void *response, size_t responseLen) {
5545 #if VDBG
5546 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5547 #endif
5548
5549 if (radioService[slotId]->mRadioResponse != NULL) {
5550 RadioResponseInfo responseInfo = {};
5551 populateResponseInfo(responseInfo, serial, responseType, e);
5552 Return<void> retStatus
5553 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5554 radioService[slotId]->checkReturnStatus(retStatus);
5555 } else {
5556 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5557 }
5558
5559 return 0;
5560 }
5561
getDeviceIdentityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5562 int radio::getDeviceIdentityResponse(int slotId,
5563 int responseType, int serial, RIL_Errno e, void *response,
5564 size_t responseLen) {
5565 #if VDBG
5566 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5567 #endif
5568
5569 if (radioService[slotId]->mRadioResponse != NULL) {
5570 RadioResponseInfo responseInfo = {};
5571 populateResponseInfo(responseInfo, serial, responseType, e);
5572
5573 int numStrings = responseLen / sizeof(char *);
5574 hidl_string emptyString;
5575 if (response == NULL || numStrings != 4) {
5576 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5577 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5578 Return<void> retStatus
5579 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5580 emptyString, emptyString, emptyString, emptyString);
5581 radioService[slotId]->checkReturnStatus(retStatus);
5582 } else {
5583 char **resp = (char **) response;
5584 Return<void> retStatus
5585 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5586 convertCharPtrToHidlString(resp[0]),
5587 convertCharPtrToHidlString(resp[1]),
5588 convertCharPtrToHidlString(resp[2]),
5589 convertCharPtrToHidlString(resp[3]));
5590 radioService[slotId]->checkReturnStatus(retStatus);
5591 }
5592 } else {
5593 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5594 slotId);
5595 }
5596
5597 return 0;
5598 }
5599
exitEmergencyCallbackModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5600 int radio::exitEmergencyCallbackModeResponse(int slotId,
5601 int responseType, int serial, RIL_Errno e,
5602 void *response, size_t responseLen) {
5603 #if VDBG
5604 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5605 #endif
5606
5607 if (radioService[slotId]->mRadioResponse != NULL) {
5608 RadioResponseInfo responseInfo = {};
5609 populateResponseInfo(responseInfo, serial, responseType, e);
5610 Return<void> retStatus
5611 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5612 responseInfo);
5613 radioService[slotId]->checkReturnStatus(retStatus);
5614 } else {
5615 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5616 slotId);
5617 }
5618
5619 return 0;
5620 }
5621
getSmscAddressResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5622 int radio::getSmscAddressResponse(int slotId,
5623 int responseType, int serial, RIL_Errno e,
5624 void *response, size_t responseLen) {
5625 #if VDBG
5626 RLOGD("getSmscAddressResponse: serial %d", serial);
5627 #endif
5628
5629 if (radioService[slotId]->mRadioResponse != NULL) {
5630 RadioResponseInfo responseInfo = {};
5631 populateResponseInfo(responseInfo, serial, responseType, e);
5632 Return<void> retStatus
5633 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5634 convertCharPtrToHidlString((char *) response));
5635 radioService[slotId]->checkReturnStatus(retStatus);
5636 } else {
5637 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5638 }
5639
5640 return 0;
5641 }
5642
setSmscAddressResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5643 int radio::setSmscAddressResponse(int slotId,
5644 int responseType, int serial, RIL_Errno e,
5645 void *response, size_t responseLen) {
5646 #if VDBG
5647 RLOGD("setSmscAddressResponse: serial %d", serial);
5648 #endif
5649
5650 if (radioService[slotId]->mRadioResponse != NULL) {
5651 RadioResponseInfo responseInfo = {};
5652 populateResponseInfo(responseInfo, serial, responseType, e);
5653 Return<void> retStatus
5654 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5655 radioService[slotId]->checkReturnStatus(retStatus);
5656 } else {
5657 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5658 }
5659
5660 return 0;
5661 }
5662
reportSmsMemoryStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5663 int radio::reportSmsMemoryStatusResponse(int slotId,
5664 int responseType, int serial, RIL_Errno e,
5665 void *response, size_t responseLen) {
5666 #if VDBG
5667 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5668 #endif
5669
5670 if (radioService[slotId]->mRadioResponse != NULL) {
5671 RadioResponseInfo responseInfo = {};
5672 populateResponseInfo(responseInfo, serial, responseType, e);
5673 Return<void> retStatus
5674 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5675 radioService[slotId]->checkReturnStatus(retStatus);
5676 } else {
5677 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5678 slotId);
5679 }
5680
5681 return 0;
5682 }
5683
reportStkServiceIsRunningResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5684 int radio::reportStkServiceIsRunningResponse(int slotId,
5685 int responseType, int serial, RIL_Errno e,
5686 void *response, size_t responseLen) {
5687 #if VDBG
5688 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5689 #endif
5690
5691 if (radioService[slotId]->mRadioResponse != NULL) {
5692 RadioResponseInfo responseInfo = {};
5693 populateResponseInfo(responseInfo, serial, responseType, e);
5694 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5695 reportStkServiceIsRunningResponse(responseInfo);
5696 radioService[slotId]->checkReturnStatus(retStatus);
5697 } else {
5698 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5699 slotId);
5700 }
5701
5702 return 0;
5703 }
5704
getCdmaSubscriptionSourceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5705 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5706 int responseType, int serial, RIL_Errno e,
5707 void *response, size_t responseLen) {
5708 #if VDBG
5709 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5710 #endif
5711
5712 if (radioService[slotId]->mRadioResponse != NULL) {
5713 RadioResponseInfo responseInfo = {};
5714 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5715 Return<void> retStatus
5716 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5717 responseInfo, (CdmaSubscriptionSource) ret);
5718 radioService[slotId]->checkReturnStatus(retStatus);
5719 } else {
5720 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5721 slotId);
5722 }
5723
5724 return 0;
5725 }
5726
requestIsimAuthenticationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5727 int radio::requestIsimAuthenticationResponse(int slotId,
5728 int responseType, int serial, RIL_Errno e,
5729 void *response, size_t responseLen) {
5730 #if VDBG
5731 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5732 #endif
5733
5734 if (radioService[slotId]->mRadioResponse != NULL) {
5735 RadioResponseInfo responseInfo = {};
5736 populateResponseInfo(responseInfo, serial, responseType, e);
5737 Return<void> retStatus
5738 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5739 responseInfo,
5740 convertCharPtrToHidlString((char *) response));
5741 radioService[slotId]->checkReturnStatus(retStatus);
5742 } else {
5743 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5744 slotId);
5745 }
5746
5747 return 0;
5748 }
5749
acknowledgeIncomingGsmSmsWithPduResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5750 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5751 int responseType,
5752 int serial, RIL_Errno e, void *response,
5753 size_t responseLen) {
5754 #if VDBG
5755 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5756 #endif
5757
5758 if (radioService[slotId]->mRadioResponse != NULL) {
5759 RadioResponseInfo responseInfo = {};
5760 populateResponseInfo(responseInfo, serial, responseType, e);
5761 Return<void> retStatus
5762 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5763 responseInfo);
5764 radioService[slotId]->checkReturnStatus(retStatus);
5765 } else {
5766 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5767 "== NULL", slotId);
5768 }
5769
5770 return 0;
5771 }
5772
sendEnvelopeWithStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5773 int radio::sendEnvelopeWithStatusResponse(int slotId,
5774 int responseType, int serial, RIL_Errno e, void *response,
5775 size_t responseLen) {
5776 #if VDBG
5777 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5778 #endif
5779
5780 if (radioService[slotId]->mRadioResponse != NULL) {
5781 RadioResponseInfo responseInfo = {};
5782 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5783 response, responseLen);
5784
5785 Return<void> retStatus
5786 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5787 result);
5788 radioService[slotId]->checkReturnStatus(retStatus);
5789 } else {
5790 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5791 slotId);
5792 }
5793
5794 return 0;
5795 }
5796
getVoiceRadioTechnologyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5797 int radio::getVoiceRadioTechnologyResponse(int slotId,
5798 int responseType, int serial, RIL_Errno e,
5799 void *response, size_t responseLen) {
5800 #if VDBG
5801 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5802 #endif
5803
5804 if (radioService[slotId]->mRadioResponse != NULL) {
5805 RadioResponseInfo responseInfo = {};
5806 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5807 Return<void> retStatus
5808 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5809 responseInfo, (RadioTechnology) ret);
5810 radioService[slotId]->checkReturnStatus(retStatus);
5811 } else {
5812 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5813 slotId);
5814 }
5815
5816 return 0;
5817 }
5818
getCellInfoListResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5819 int radio::getCellInfoListResponse(int slotId,
5820 int responseType,
5821 int serial, RIL_Errno e, void *response,
5822 size_t responseLen) {
5823 #if VDBG
5824 RLOGD("getCellInfoListResponse: serial %d", serial);
5825 #endif
5826
5827 if (radioService[slotId]->mRadioResponse != NULL) {
5828 RadioResponseInfo responseInfo = {};
5829 populateResponseInfo(responseInfo, serial, responseType, e);
5830
5831 hidl_vec<CellInfo> ret;
5832 if ((response == NULL && responseLen != 0)
5833 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5834 RLOGE("getCellInfoListResponse: Invalid response");
5835 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5836 } else {
5837 convertRilCellInfoListToHal(response, responseLen, ret);
5838 }
5839
5840 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5841 responseInfo, ret);
5842 radioService[slotId]->checkReturnStatus(retStatus);
5843 } else {
5844 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5845 }
5846
5847 return 0;
5848 }
5849
setCellInfoListRateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5850 int radio::setCellInfoListRateResponse(int slotId,
5851 int responseType,
5852 int serial, RIL_Errno e, void *response,
5853 size_t responseLen) {
5854 #if VDBG
5855 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5856 #endif
5857
5858 if (radioService[slotId]->mRadioResponse != NULL) {
5859 RadioResponseInfo responseInfo = {};
5860 populateResponseInfo(responseInfo, serial, responseType, e);
5861 Return<void> retStatus
5862 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5863 radioService[slotId]->checkReturnStatus(retStatus);
5864 } else {
5865 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5866 slotId);
5867 }
5868
5869 return 0;
5870 }
5871
setInitialAttachApnResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5872 int radio::setInitialAttachApnResponse(int slotId,
5873 int responseType, int serial, RIL_Errno e,
5874 void *response, size_t responseLen) {
5875 #if VDBG
5876 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5877 #endif
5878
5879 if (radioService[slotId]->mRadioResponse != NULL) {
5880 RadioResponseInfo responseInfo = {};
5881 populateResponseInfo(responseInfo, serial, responseType, e);
5882 Return<void> retStatus
5883 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5884 radioService[slotId]->checkReturnStatus(retStatus);
5885 } else {
5886 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5887 slotId);
5888 }
5889
5890 return 0;
5891 }
5892
getImsRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5893 int radio::getImsRegistrationStateResponse(int slotId,
5894 int responseType, int serial, RIL_Errno e,
5895 void *response, size_t responseLen) {
5896 #if VDBG
5897 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5898 #endif
5899
5900 if (radioService[slotId]->mRadioResponse != NULL) {
5901 RadioResponseInfo responseInfo = {};
5902 populateResponseInfo(responseInfo, serial, responseType, e);
5903 bool isRegistered = false;
5904 int ratFamily = 0;
5905 int numInts = responseLen / sizeof(int);
5906 if (response == NULL || numInts != 2) {
5907 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5908 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5909 } else {
5910 int *pInt = (int *) response;
5911 isRegistered = pInt[0] == 1 ? true : false;
5912 ratFamily = pInt[1];
5913 }
5914 Return<void> retStatus
5915 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5916 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5917 radioService[slotId]->checkReturnStatus(retStatus);
5918 } else {
5919 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5920 slotId);
5921 }
5922
5923 return 0;
5924 }
5925
sendImsSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5926 int radio::sendImsSmsResponse(int slotId,
5927 int responseType, int serial, RIL_Errno e, void *response,
5928 size_t responseLen) {
5929 #if VDBG
5930 RLOGD("sendImsSmsResponse: serial %d", serial);
5931 #endif
5932
5933 if (radioService[slotId]->mRadioResponse != NULL) {
5934 RadioResponseInfo responseInfo = {};
5935 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5936 responseLen);
5937
5938 Return<void> retStatus
5939 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5940 radioService[slotId]->checkReturnStatus(retStatus);
5941 } else {
5942 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5943 }
5944
5945 return 0;
5946 }
5947
iccTransmitApduBasicChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5948 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5949 int responseType, int serial, RIL_Errno e,
5950 void *response, size_t responseLen) {
5951 #if VDBG
5952 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5953 #endif
5954
5955 if (radioService[slotId]->mRadioResponse != NULL) {
5956 RadioResponseInfo responseInfo = {};
5957 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5958 responseLen);
5959
5960 Return<void> retStatus
5961 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5962 responseInfo, result);
5963 radioService[slotId]->checkReturnStatus(retStatus);
5964 } else {
5965 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5966 "== NULL", slotId);
5967 }
5968
5969 return 0;
5970 }
5971
iccOpenLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5972 int radio::iccOpenLogicalChannelResponse(int slotId,
5973 int responseType, int serial, RIL_Errno e, void *response,
5974 size_t responseLen) {
5975 #if VDBG
5976 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5977 #endif
5978
5979 if (radioService[slotId]->mRadioResponse != NULL) {
5980 RadioResponseInfo responseInfo = {};
5981 populateResponseInfo(responseInfo, serial, responseType, e);
5982 int channelId = -1;
5983 hidl_vec<int8_t> selectResponse;
5984 int numInts = responseLen / sizeof(int);
5985 if (response == NULL || responseLen % sizeof(int) != 0) {
5986 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5987 if (response != NULL) {
5988 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5989 }
5990 } else {
5991 int *pInt = (int *) response;
5992 channelId = pInt[0];
5993 selectResponse.resize(numInts - 1);
5994 for (int i = 1; i < numInts; i++) {
5995 selectResponse[i - 1] = (int8_t) pInt[i];
5996 }
5997 }
5998 Return<void> retStatus
5999 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
6000 channelId, selectResponse);
6001 radioService[slotId]->checkReturnStatus(retStatus);
6002 } else {
6003 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
6004 slotId);
6005 }
6006
6007 return 0;
6008 }
6009
iccCloseLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6010 int radio::iccCloseLogicalChannelResponse(int slotId,
6011 int responseType, int serial, RIL_Errno e,
6012 void *response, size_t responseLen) {
6013 #if VDBG
6014 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
6015 #endif
6016
6017 if (radioService[slotId]->mRadioResponse != NULL) {
6018 RadioResponseInfo responseInfo = {};
6019 populateResponseInfo(responseInfo, serial, responseType, e);
6020 Return<void> retStatus
6021 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
6022 responseInfo);
6023 radioService[slotId]->checkReturnStatus(retStatus);
6024 } else {
6025 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
6026 slotId);
6027 }
6028
6029 return 0;
6030 }
6031
iccTransmitApduLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6032 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
6033 int responseType, int serial, RIL_Errno e,
6034 void *response, size_t responseLen) {
6035 #if VDBG
6036 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
6037 #endif
6038
6039 if (radioService[slotId]->mRadioResponse != NULL) {
6040 RadioResponseInfo responseInfo = {};
6041 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6042 responseLen);
6043
6044 Return<void> retStatus
6045 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
6046 responseInfo, result);
6047 radioService[slotId]->checkReturnStatus(retStatus);
6048 } else {
6049 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
6050 "== NULL", slotId);
6051 }
6052
6053 return 0;
6054 }
6055
nvReadItemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6056 int radio::nvReadItemResponse(int slotId,
6057 int responseType, int serial, RIL_Errno e,
6058 void *response, size_t responseLen) {
6059 #if VDBG
6060 RLOGD("nvReadItemResponse: serial %d", serial);
6061 #endif
6062
6063 if (radioService[slotId]->mRadioResponse != NULL) {
6064 RadioResponseInfo responseInfo = {};
6065 populateResponseInfo(responseInfo, serial, responseType, e);
6066 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
6067 responseInfo,
6068 convertCharPtrToHidlString((char *) response));
6069 radioService[slotId]->checkReturnStatus(retStatus);
6070 } else {
6071 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6072 }
6073
6074 return 0;
6075 }
6076
nvWriteItemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6077 int radio::nvWriteItemResponse(int slotId,
6078 int responseType, int serial, RIL_Errno e,
6079 void *response, size_t responseLen) {
6080 #if VDBG
6081 RLOGD("nvWriteItemResponse: serial %d", serial);
6082 #endif
6083
6084 if (radioService[slotId]->mRadioResponse != NULL) {
6085 RadioResponseInfo responseInfo = {};
6086 populateResponseInfo(responseInfo, serial, responseType, e);
6087 Return<void> retStatus
6088 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
6089 radioService[slotId]->checkReturnStatus(retStatus);
6090 } else {
6091 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6092 }
6093
6094 return 0;
6095 }
6096
nvWriteCdmaPrlResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6097 int radio::nvWriteCdmaPrlResponse(int slotId,
6098 int responseType, int serial, RIL_Errno e,
6099 void *response, size_t responseLen) {
6100 #if VDBG
6101 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
6102 #endif
6103
6104 if (radioService[slotId]->mRadioResponse != NULL) {
6105 RadioResponseInfo responseInfo = {};
6106 populateResponseInfo(responseInfo, serial, responseType, e);
6107 Return<void> retStatus
6108 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
6109 radioService[slotId]->checkReturnStatus(retStatus);
6110 } else {
6111 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6112 }
6113
6114 return 0;
6115 }
6116
nvResetConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6117 int radio::nvResetConfigResponse(int slotId,
6118 int responseType, int serial, RIL_Errno e,
6119 void *response, size_t responseLen) {
6120 #if VDBG
6121 RLOGD("nvResetConfigResponse: serial %d", serial);
6122 #endif
6123
6124 if (radioService[slotId]->mRadioResponse != NULL) {
6125 RadioResponseInfo responseInfo = {};
6126 populateResponseInfo(responseInfo, serial, responseType, e);
6127 Return<void> retStatus
6128 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
6129 radioService[slotId]->checkReturnStatus(retStatus);
6130 } else {
6131 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6132 }
6133
6134 return 0;
6135 }
6136
setUiccSubscriptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6137 int radio::setUiccSubscriptionResponse(int slotId,
6138 int responseType, int serial, RIL_Errno e,
6139 void *response, size_t responseLen) {
6140 #if VDBG
6141 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
6142 #endif
6143
6144 if (radioService[slotId]->mRadioResponse != NULL) {
6145 RadioResponseInfo responseInfo = {};
6146 populateResponseInfo(responseInfo, serial, responseType, e);
6147 Return<void> retStatus
6148 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
6149 radioService[slotId]->checkReturnStatus(retStatus);
6150 } else {
6151 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
6152 slotId);
6153 }
6154
6155 return 0;
6156 }
6157
setDataAllowedResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6158 int radio::setDataAllowedResponse(int slotId,
6159 int responseType, int serial, RIL_Errno e,
6160 void *response, size_t responseLen) {
6161 #if VDBG
6162 RLOGD("setDataAllowedResponse: serial %d", serial);
6163 #endif
6164
6165 if (radioService[slotId]->mRadioResponse != NULL) {
6166 RadioResponseInfo responseInfo = {};
6167 populateResponseInfo(responseInfo, serial, responseType, e);
6168 Return<void> retStatus
6169 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
6170 radioService[slotId]->checkReturnStatus(retStatus);
6171 } else {
6172 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6173 }
6174
6175 return 0;
6176 }
6177
getHardwareConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6178 int radio::getHardwareConfigResponse(int slotId,
6179 int responseType, int serial, RIL_Errno e,
6180 void *response, size_t responseLen) {
6181 #if VDBG
6182 RLOGD("getHardwareConfigResponse: serial %d", serial);
6183 #endif
6184
6185 if (radioService[slotId]->mRadioResponse != NULL) {
6186 RadioResponseInfo responseInfo = {};
6187 populateResponseInfo(responseInfo, serial, responseType, e);
6188
6189 hidl_vec<HardwareConfig> result;
6190 if ((response == NULL && responseLen != 0)
6191 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
6192 RLOGE("hardwareConfigChangedInd: invalid response");
6193 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6194 } else {
6195 convertRilHardwareConfigListToHal(response, responseLen, result);
6196 }
6197
6198 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
6199 responseInfo, result);
6200 radioService[slotId]->checkReturnStatus(retStatus);
6201 } else {
6202 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6203 }
6204
6205 return 0;
6206 }
6207
requestIccSimAuthenticationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6208 int radio::requestIccSimAuthenticationResponse(int slotId,
6209 int responseType, int serial, RIL_Errno e,
6210 void *response, size_t responseLen) {
6211 #if VDBG
6212 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6213 #endif
6214
6215 if (radioService[slotId]->mRadioResponse != NULL) {
6216 RadioResponseInfo responseInfo = {};
6217 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6218 responseLen);
6219
6220 Return<void> retStatus
6221 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6222 responseInfo, result);
6223 radioService[slotId]->checkReturnStatus(retStatus);
6224 } else {
6225 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6226 "== NULL", slotId);
6227 }
6228
6229 return 0;
6230 }
6231
setDataProfileResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6232 int radio::setDataProfileResponse(int slotId,
6233 int responseType, int serial, RIL_Errno e,
6234 void *response, size_t responseLen) {
6235 #if VDBG
6236 RLOGD("setDataProfileResponse: serial %d", serial);
6237 #endif
6238
6239 if (radioService[slotId]->mRadioResponse != NULL) {
6240 RadioResponseInfo responseInfo = {};
6241 populateResponseInfo(responseInfo, serial, responseType, e);
6242 Return<void> retStatus
6243 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6244 radioService[slotId]->checkReturnStatus(retStatus);
6245 } else {
6246 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6247 }
6248
6249 return 0;
6250 }
6251
requestShutdownResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6252 int radio::requestShutdownResponse(int slotId,
6253 int responseType, int serial, RIL_Errno e,
6254 void *response, size_t responseLen) {
6255 #if VDBG
6256 RLOGD("requestShutdownResponse: serial %d", serial);
6257 #endif
6258
6259 if (radioService[slotId]->mRadioResponse != NULL) {
6260 RadioResponseInfo responseInfo = {};
6261 populateResponseInfo(responseInfo, serial, responseType, e);
6262 Return<void> retStatus
6263 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6264 radioService[slotId]->checkReturnStatus(retStatus);
6265 } else {
6266 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6267 }
6268
6269 return 0;
6270 }
6271
responseRadioCapability(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen,RadioCapability & rc)6272 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6273 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6274 populateResponseInfo(responseInfo, serial, responseType, e);
6275
6276 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6277 RLOGE("responseRadioCapability: Invalid response");
6278 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6279 rc.logicalModemUuid = hidl_string();
6280 } else {
6281 convertRilRadioCapabilityToHal(response, responseLen, rc);
6282 }
6283 }
6284
getRadioCapabilityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6285 int radio::getRadioCapabilityResponse(int slotId,
6286 int responseType, int serial, RIL_Errno e,
6287 void *response, size_t responseLen) {
6288 #if VDBG
6289 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6290 #endif
6291
6292 if (radioService[slotId]->mRadioResponse != NULL) {
6293 RadioResponseInfo responseInfo = {};
6294 RadioCapability result = {};
6295 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6296 result);
6297 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6298 responseInfo, result);
6299 radioService[slotId]->checkReturnStatus(retStatus);
6300 } else {
6301 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6302 }
6303
6304 return 0;
6305 }
6306
setRadioCapabilityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6307 int radio::setRadioCapabilityResponse(int slotId,
6308 int responseType, int serial, RIL_Errno e,
6309 void *response, size_t responseLen) {
6310 #if VDBG
6311 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6312 #endif
6313
6314 if (radioService[slotId]->mRadioResponse != NULL) {
6315 RadioResponseInfo responseInfo = {};
6316 RadioCapability result = {};
6317 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6318 result);
6319 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6320 responseInfo, result);
6321 radioService[slotId]->checkReturnStatus(retStatus);
6322 } else {
6323 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6324 }
6325
6326 return 0;
6327 }
6328
responseLceStatusInfo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)6329 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6330 RIL_Errno e, void *response, size_t responseLen) {
6331 populateResponseInfo(responseInfo, serial, responseType, e);
6332 LceStatusInfo result = {};
6333
6334 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6335 RLOGE("Invalid response: NULL");
6336 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6337 } else {
6338 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6339 result.lceStatus = (LceStatus) resp->lce_status;
6340 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6341 }
6342 return result;
6343 }
6344
startLceServiceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6345 int radio::startLceServiceResponse(int slotId,
6346 int responseType, int serial, RIL_Errno e,
6347 void *response, size_t responseLen) {
6348 #if VDBG
6349 RLOGD("startLceServiceResponse: serial %d", serial);
6350 #endif
6351
6352 if (radioService[slotId]->mRadioResponse != NULL) {
6353 RadioResponseInfo responseInfo = {};
6354 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6355 response, responseLen);
6356
6357 Return<void> retStatus
6358 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6359 result);
6360 radioService[slotId]->checkReturnStatus(retStatus);
6361 } else {
6362 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6363 }
6364
6365 return 0;
6366 }
6367
stopLceServiceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6368 int radio::stopLceServiceResponse(int slotId,
6369 int responseType, int serial, RIL_Errno e,
6370 void *response, size_t responseLen) {
6371 #if VDBG
6372 RLOGD("stopLceServiceResponse: serial %d", serial);
6373 #endif
6374
6375 if (radioService[slotId]->mRadioResponse != NULL) {
6376 RadioResponseInfo responseInfo = {};
6377 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6378 response, responseLen);
6379
6380 Return<void> retStatus
6381 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6382 result);
6383 radioService[slotId]->checkReturnStatus(retStatus);
6384 } else {
6385 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6386 }
6387
6388 return 0;
6389 }
6390
pullLceDataResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6391 int radio::pullLceDataResponse(int slotId,
6392 int responseType, int serial, RIL_Errno e,
6393 void *response, size_t responseLen) {
6394 #if VDBG
6395 RLOGD("pullLceDataResponse: serial %d", serial);
6396 #endif
6397
6398 if (radioService[slotId]->mRadioResponse != NULL) {
6399 RadioResponseInfo responseInfo = {};
6400 populateResponseInfo(responseInfo, serial, responseType, e);
6401
6402 LceDataInfo result = {};
6403 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6404 RLOGE("pullLceDataResponse: Invalid response");
6405 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6406 } else {
6407 convertRilLceDataInfoToHal(response, responseLen, result);
6408 }
6409
6410 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6411 responseInfo, result);
6412 radioService[slotId]->checkReturnStatus(retStatus);
6413 } else {
6414 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6415 }
6416
6417 return 0;
6418 }
6419
getModemActivityInfoResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6420 int radio::getModemActivityInfoResponse(int slotId,
6421 int responseType, int serial, RIL_Errno e,
6422 void *response, size_t responseLen) {
6423 #if VDBG
6424 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6425 #endif
6426
6427 if (radioService[slotId]->mRadioResponse != NULL) {
6428 RadioResponseInfo responseInfo = {};
6429 populateResponseInfo(responseInfo, serial, responseType, e);
6430 ActivityStatsInfo info;
6431 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6432 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6433 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6434 } else {
6435 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6436 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6437 info.idleModeTimeMs = resp->idle_mode_time_ms;
6438 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6439 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6440 }
6441 info.rxModeTimeMs = resp->rx_mode_time_ms;
6442 }
6443
6444 Return<void> retStatus
6445 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6446 info);
6447 radioService[slotId]->checkReturnStatus(retStatus);
6448 } else {
6449 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6450 slotId);
6451 }
6452
6453 return 0;
6454 }
6455
setAllowedCarriersResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6456 int radio::setAllowedCarriersResponse(int slotId,
6457 int responseType, int serial, RIL_Errno e,
6458 void *response, size_t responseLen) {
6459 #if VDBG
6460 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6461 #endif
6462
6463 if (radioService[slotId]->mRadioResponse != NULL) {
6464 RadioResponseInfo responseInfo = {};
6465 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6466 Return<void> retStatus
6467 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6468 ret);
6469 radioService[slotId]->checkReturnStatus(retStatus);
6470 } else {
6471 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6472 slotId);
6473 }
6474
6475 return 0;
6476 }
6477
getAllowedCarriersResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6478 int radio::getAllowedCarriersResponse(int slotId,
6479 int responseType, int serial, RIL_Errno e,
6480 void *response, size_t responseLen) {
6481 #if VDBG
6482 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6483 #endif
6484
6485 if (radioService[slotId]->mRadioResponse != NULL) {
6486 RadioResponseInfo responseInfo = {};
6487 populateResponseInfo(responseInfo, serial, responseType, e);
6488 CarrierRestrictions carrierInfo = {};
6489 bool allAllowed = true;
6490 if (response == NULL) {
6491 #if VDBG
6492 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6493 #endif
6494 carrierInfo.allowedCarriers.resize(0);
6495 carrierInfo.excludedCarriers.resize(0);
6496 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6497 RLOGE("getAllowedCarriersResponse Invalid response");
6498 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6499 } else {
6500 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6501 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6502 allAllowed = false;
6503 }
6504
6505 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6506 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6507 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6508 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6509 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6510 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6511 carrierInfo.allowedCarriers[i].matchData =
6512 convertCharPtrToHidlString(carrier->match_data);
6513 }
6514
6515 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6516 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6517 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6518 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6519 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6520 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6521 carrierInfo.excludedCarriers[i].matchData =
6522 convertCharPtrToHidlString(carrier->match_data);
6523 }
6524 }
6525
6526 Return<void> retStatus
6527 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6528 allAllowed, carrierInfo);
6529 radioService[slotId]->checkReturnStatus(retStatus);
6530 } else {
6531 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6532 slotId);
6533 }
6534
6535 return 0;
6536 }
6537
sendDeviceStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)6538 int radio::sendDeviceStateResponse(int slotId,
6539 int responseType, int serial, RIL_Errno e,
6540 void *response, size_t responselen) {
6541 #if VDBG
6542 RLOGD("sendDeviceStateResponse: serial %d", serial);
6543 #endif
6544
6545 if (radioService[slotId]->mRadioResponse != NULL) {
6546 RadioResponseInfo responseInfo = {};
6547 populateResponseInfo(responseInfo, serial, responseType, e);
6548 Return<void> retStatus
6549 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6550 radioService[slotId]->checkReturnStatus(retStatus);
6551 } else {
6552 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6553 }
6554
6555 return 0;
6556 }
6557
setCarrierInfoForImsiEncryptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6558 int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
6559 int responseType, int serial, RIL_Errno e,
6560 void *response, size_t responseLen) {
6561 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
6562 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6563 RadioResponseInfo responseInfo = {};
6564 populateResponseInfo(responseInfo, serial, responseType, e);
6565 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6566 setCarrierInfoForImsiEncryptionResponse(responseInfo);
6567 radioService[slotId]->checkReturnStatus(retStatus);
6568 } else {
6569 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponseV1_1 == "
6570 "NULL", slotId);
6571 }
6572 return 0;
6573 }
6574
setIndicationFilterResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)6575 int radio::setIndicationFilterResponse(int slotId,
6576 int responseType, int serial, RIL_Errno e,
6577 void *response, size_t responselen) {
6578 #if VDBG
6579 RLOGD("setIndicationFilterResponse: serial %d", serial);
6580 #endif
6581
6582 if (radioService[slotId]->mRadioResponse != NULL) {
6583 RadioResponseInfo responseInfo = {};
6584 populateResponseInfo(responseInfo, serial, responseType, e);
6585 Return<void> retStatus
6586 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6587 radioService[slotId]->checkReturnStatus(retStatus);
6588 } else {
6589 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6590 slotId);
6591 }
6592
6593 return 0;
6594 }
6595
setSimCardPowerResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6596 int radio::setSimCardPowerResponse(int slotId,
6597 int responseType, int serial, RIL_Errno e,
6598 void *response, size_t responseLen) {
6599 #if VDBG
6600 RLOGD("setSimCardPowerResponse: serial %d", serial);
6601 #endif
6602
6603 if (radioService[slotId]->mRadioResponse != NULL
6604 || radioService[slotId]->mRadioResponseV1_1 != NULL) {
6605 RadioResponseInfo responseInfo = {};
6606 populateResponseInfo(responseInfo, serial, responseType, e);
6607 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6608 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6609 setSimCardPowerResponse_1_1(responseInfo);
6610 radioService[slotId]->checkReturnStatus(retStatus);
6611 } else {
6612 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_1 == NULL",
6613 slotId);
6614 Return<void> retStatus
6615 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6616 radioService[slotId]->checkReturnStatus(retStatus);
6617 }
6618 } else {
6619 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL && "
6620 "radioService[%d]->mRadioResponseV1_1 == NULL", slotId, slotId);
6621 }
6622 return 0;
6623 }
6624
startNetworkScanResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6625 int radio::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6626 void *response, size_t responseLen) {
6627 #if VDBG
6628 RLOGD("startNetworkScanResponse: serial %d", serial);
6629 #endif
6630
6631 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6632 RadioResponseInfo responseInfo = {};
6633 populateResponseInfo(responseInfo, serial, responseType, e);
6634 Return<void> retStatus
6635 = radioService[slotId]->mRadioResponseV1_1->startNetworkScanResponse(responseInfo);
6636 radioService[slotId]->checkReturnStatus(retStatus);
6637 } else {
6638 RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6639 }
6640
6641 return 0;
6642 }
6643
stopNetworkScanResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6644 int radio::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6645 void *response, size_t responseLen) {
6646 #if VDBG
6647 RLOGD("stopNetworkScanResponse: serial %d", serial);
6648 #endif
6649
6650 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6651 RadioResponseInfo responseInfo = {};
6652 populateResponseInfo(responseInfo, serial, responseType, e);
6653 Return<void> retStatus
6654 = radioService[slotId]->mRadioResponseV1_1->stopNetworkScanResponse(responseInfo);
6655 radioService[slotId]->checkReturnStatus(retStatus);
6656 } else {
6657 RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6658 }
6659
6660 return 0;
6661 }
6662
convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus * rilStatus,V1_1::KeepaliveStatus & halStatus)6663 void convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus *rilStatus,
6664 V1_1::KeepaliveStatus& halStatus) {
6665 halStatus.sessionHandle = rilStatus->sessionHandle;
6666 halStatus.code = static_cast<V1_1::KeepaliveStatusCode>(rilStatus->code);
6667 }
6668
startKeepaliveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6669 int radio::startKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
6670 void *response, size_t responseLen) {
6671 #if VDBG
6672 RLOGD("%s(): %d", __FUNCTION__, serial);
6673 #endif
6674 RadioResponseInfo responseInfo = {};
6675 populateResponseInfo(responseInfo, serial, responseType, e);
6676
6677 // If we don't have a radio service, there's nothing we can do
6678 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
6679 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
6680 return 0;
6681 }
6682
6683 V1_1::KeepaliveStatus ks = {};
6684 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
6685 RLOGE("%s: invalid response - %d", __FUNCTION__, static_cast<int>(e));
6686 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6687 } else {
6688 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
6689 }
6690
6691 Return<void> retStatus =
6692 radioService[slotId]->mRadioResponseV1_1->startKeepaliveResponse(responseInfo, ks);
6693 radioService[slotId]->checkReturnStatus(retStatus);
6694 return 0;
6695 }
6696
stopKeepaliveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6697 int radio::stopKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
6698 void *response, size_t responseLen) {
6699 #if VDBG
6700 RLOGD("%s(): %d", __FUNCTION__, serial);
6701 #endif
6702 RadioResponseInfo responseInfo = {};
6703 populateResponseInfo(responseInfo, serial, responseType, e);
6704
6705 // If we don't have a radio service, there's nothing we can do
6706 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
6707 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
6708 return 0;
6709 }
6710
6711 Return<void> retStatus =
6712 radioService[slotId]->mRadioResponseV1_1->stopKeepaliveResponse(responseInfo);
6713 radioService[slotId]->checkReturnStatus(retStatus);
6714 return 0;
6715 }
6716
sendRequestRawResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6717 int radio::sendRequestRawResponse(int slotId,
6718 int responseType, int serial, RIL_Errno e,
6719 void *response, size_t responseLen) {
6720 #if VDBG
6721 RLOGD("sendRequestRawResponse: serial %d", serial);
6722 #endif
6723
6724 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6725 RadioResponseInfo responseInfo = {};
6726 populateResponseInfo(responseInfo, serial, responseType, e);
6727 hidl_vec<uint8_t> data;
6728
6729 if (response == NULL) {
6730 RLOGE("sendRequestRawResponse: Invalid response");
6731 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6732 } else {
6733 data.setToExternal((uint8_t *) response, responseLen);
6734 }
6735 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6736 sendRequestRawResponse(responseInfo, data);
6737 checkReturnStatus(slotId, retStatus, false);
6738 } else {
6739 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6740 slotId);
6741 }
6742
6743 return 0;
6744 }
6745
sendRequestStringsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6746 int radio::sendRequestStringsResponse(int slotId,
6747 int responseType, int serial, RIL_Errno e,
6748 void *response, size_t responseLen) {
6749 #if VDBG
6750 RLOGD("sendRequestStringsResponse: serial %d", serial);
6751 #endif
6752
6753 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6754 RadioResponseInfo responseInfo = {};
6755 populateResponseInfo(responseInfo, serial, responseType, e);
6756 hidl_vec<hidl_string> data;
6757
6758 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
6759 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6760 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6761 } else {
6762 char **resp = (char **) response;
6763 int numStrings = responseLen / sizeof(char *);
6764 data.resize(numStrings);
6765 for (int i = 0; i < numStrings; i++) {
6766 data[i] = convertCharPtrToHidlString(resp[i]);
6767 }
6768 }
6769 Return<void> retStatus
6770 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6771 responseInfo, data);
6772 checkReturnStatus(slotId, retStatus, false);
6773 } else {
6774 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6775 "NULL", slotId);
6776 }
6777
6778 return 0;
6779 }
6780
6781 /***************************************************************************************************
6782 * INDICATION FUNCTIONS
6783 * The below function handle unsolicited messages coming from the Radio
6784 * (messages for which there is no pending request)
6785 **************************************************************************************************/
6786
convertIntToRadioIndicationType(int indicationType)6787 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6788 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6789 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6790 }
6791
radioStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6792 int radio::radioStateChangedInd(int slotId,
6793 int indicationType, int token, RIL_Errno e, void *response,
6794 size_t responseLen) {
6795 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6796 RadioState radioState =
6797 (RadioState) CALL_ONSTATEREQUEST(slotId);
6798 RLOGD("radioStateChangedInd: radioState %d", radioState);
6799 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6800 convertIntToRadioIndicationType(indicationType), radioState);
6801 radioService[slotId]->checkReturnStatus(retStatus);
6802 } else {
6803 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6804 }
6805
6806 return 0;
6807 }
6808
callStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6809 int radio::callStateChangedInd(int slotId,
6810 int indicationType, int token, RIL_Errno e, void *response,
6811 size_t responseLen) {
6812 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6813 #if VDBG
6814 RLOGD("callStateChangedInd");
6815 #endif
6816 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6817 convertIntToRadioIndicationType(indicationType));
6818 radioService[slotId]->checkReturnStatus(retStatus);
6819 } else {
6820 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6821 }
6822
6823 return 0;
6824 }
6825
networkStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6826 int radio::networkStateChangedInd(int slotId,
6827 int indicationType, int token, RIL_Errno e, void *response,
6828 size_t responseLen) {
6829 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6830 #if VDBG
6831 RLOGD("networkStateChangedInd");
6832 #endif
6833 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6834 convertIntToRadioIndicationType(indicationType));
6835 radioService[slotId]->checkReturnStatus(retStatus);
6836 } else {
6837 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6838 slotId);
6839 }
6840
6841 return 0;
6842 }
6843
hexCharToInt(uint8_t c)6844 uint8_t hexCharToInt(uint8_t c) {
6845 if (c >= '0' && c <= '9') return (c - '0');
6846 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6847 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6848
6849 return INVALID_HEX_CHAR;
6850 }
6851
convertHexStringToBytes(void * response,size_t responseLen)6852 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6853 if (responseLen % 2 != 0) {
6854 return NULL;
6855 }
6856
6857 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6858 if (bytes == NULL) {
6859 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6860 return NULL;
6861 }
6862 uint8_t *hexString = (uint8_t *)response;
6863
6864 for (size_t i = 0; i < responseLen; i += 2) {
6865 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6866 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6867
6868 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6869 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6870 hexString[i], hexString[i + 1]);
6871 free(bytes);
6872 return NULL;
6873 }
6874 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6875 }
6876
6877 return bytes;
6878 }
6879
newSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6880 int radio::newSmsInd(int slotId, int indicationType,
6881 int token, RIL_Errno e, void *response, size_t responseLen) {
6882 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6883 if (response == NULL || responseLen == 0) {
6884 RLOGE("newSmsInd: invalid response");
6885 return 0;
6886 }
6887
6888 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6889 if (bytes == NULL) {
6890 RLOGE("newSmsInd: convertHexStringToBytes failed");
6891 return 0;
6892 }
6893
6894 hidl_vec<uint8_t> pdu;
6895 pdu.setToExternal(bytes, responseLen/2);
6896 #if VDBG
6897 RLOGD("newSmsInd");
6898 #endif
6899 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6900 convertIntToRadioIndicationType(indicationType), pdu);
6901 radioService[slotId]->checkReturnStatus(retStatus);
6902 free(bytes);
6903 } else {
6904 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6905 }
6906
6907 return 0;
6908 }
6909
newSmsStatusReportInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6910 int radio::newSmsStatusReportInd(int slotId,
6911 int indicationType, int token, RIL_Errno e, void *response,
6912 size_t responseLen) {
6913 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6914 if (response == NULL || responseLen == 0) {
6915 RLOGE("newSmsStatusReportInd: invalid response");
6916 return 0;
6917 }
6918
6919 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6920 if (bytes == NULL) {
6921 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6922 return 0;
6923 }
6924
6925 hidl_vec<uint8_t> pdu;
6926 pdu.setToExternal(bytes, responseLen/2);
6927 #if VDBG
6928 RLOGD("newSmsStatusReportInd");
6929 #endif
6930 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6931 convertIntToRadioIndicationType(indicationType), pdu);
6932 radioService[slotId]->checkReturnStatus(retStatus);
6933 free(bytes);
6934 } else {
6935 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6936 }
6937
6938 return 0;
6939 }
6940
newSmsOnSimInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6941 int radio::newSmsOnSimInd(int slotId, int indicationType,
6942 int token, RIL_Errno e, void *response, size_t responseLen) {
6943 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6944 if (response == NULL || responseLen != sizeof(int)) {
6945 RLOGE("newSmsOnSimInd: invalid response");
6946 return 0;
6947 }
6948 int32_t recordNumber = ((int32_t *) response)[0];
6949 #if VDBG
6950 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6951 #endif
6952 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6953 convertIntToRadioIndicationType(indicationType), recordNumber);
6954 radioService[slotId]->checkReturnStatus(retStatus);
6955 } else {
6956 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6957 }
6958
6959 return 0;
6960 }
6961
onUssdInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6962 int radio::onUssdInd(int slotId, int indicationType,
6963 int token, RIL_Errno e, void *response, size_t responseLen) {
6964 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6965 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6966 RLOGE("onUssdInd: invalid response");
6967 return 0;
6968 }
6969 char **strings = (char **) response;
6970 char *mode = strings[0];
6971 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6972 UssdModeType modeType = (UssdModeType) atoi(mode);
6973 #if VDBG
6974 RLOGD("onUssdInd: mode %s", mode);
6975 #endif
6976 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6977 convertIntToRadioIndicationType(indicationType), modeType, msg);
6978 radioService[slotId]->checkReturnStatus(retStatus);
6979 } else {
6980 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6981 }
6982
6983 return 0;
6984 }
6985
nitzTimeReceivedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6986 int radio::nitzTimeReceivedInd(int slotId,
6987 int indicationType, int token, RIL_Errno e, void *response,
6988 size_t responseLen) {
6989 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6990 if (response == NULL || responseLen == 0) {
6991 RLOGE("nitzTimeReceivedInd: invalid response");
6992 return 0;
6993 }
6994 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6995 int64_t timeReceived = android::elapsedRealtime();
6996 #if VDBG
6997 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6998 timeReceived);
6999 #endif
7000 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
7001 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
7002 radioService[slotId]->checkReturnStatus(retStatus);
7003 } else {
7004 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7005 return -1;
7006 }
7007
7008 return 0;
7009 }
7010
convertRilSignalStrengthToHal(void * response,size_t responseLen,SignalStrength & signalStrength)7011 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
7012 SignalStrength& signalStrength) {
7013 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
7014
7015 // Fixup LTE for backwards compatibility
7016 // signalStrength: -1 -> 99
7017 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
7018 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
7019 }
7020 // rsrp: -1 -> INT_MAX all other negative value to positive.
7021 // So remap here
7022 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
7023 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
7024 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
7025 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
7026 }
7027 // rsrq: -1 -> INT_MAX
7028 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
7029 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
7030 }
7031 // Not remapping rssnr is already using INT_MAX
7032 // cqi: -1 -> INT_MAX
7033 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
7034 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
7035 }
7036
7037 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
7038 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
7039 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
7040 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
7041 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
7042 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
7043 signalStrength.evdo.signalNoiseRatio =
7044 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
7045 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
7046 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
7047 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
7048 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
7049 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
7050 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
7051 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
7052 }
7053
currentSignalStrengthInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7054 int radio::currentSignalStrengthInd(int slotId,
7055 int indicationType, int token, RIL_Errno e,
7056 void *response, size_t responseLen) {
7057 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7058 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
7059 RLOGE("currentSignalStrengthInd: invalid response");
7060 return 0;
7061 }
7062
7063 SignalStrength signalStrength = {};
7064 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
7065
7066 #if VDBG
7067 RLOGD("currentSignalStrengthInd");
7068 #endif
7069 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
7070 convertIntToRadioIndicationType(indicationType), signalStrength);
7071 radioService[slotId]->checkReturnStatus(retStatus);
7072 } else {
7073 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
7074 slotId);
7075 }
7076
7077 return 0;
7078 }
7079
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,SetupDataCallResult & dcResult)7080 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
7081 SetupDataCallResult& dcResult) {
7082 dcResult.status = (DataCallFailCause) dcResponse->status;
7083 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
7084 dcResult.cid = dcResponse->cid;
7085 dcResult.active = dcResponse->active;
7086 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
7087 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
7088 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
7089 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
7090 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
7091 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
7092 dcResult.mtu = dcResponse->mtu;
7093 }
7094
convertRilDataCallListToHal(void * response,size_t responseLen,hidl_vec<SetupDataCallResult> & dcResultList)7095 void convertRilDataCallListToHal(void *response, size_t responseLen,
7096 hidl_vec<SetupDataCallResult>& dcResultList) {
7097 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
7098
7099 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
7100 dcResultList.resize(num);
7101 for (int i = 0; i < num; i++) {
7102 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
7103 }
7104 }
7105
dataCallListChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7106 int radio::dataCallListChangedInd(int slotId,
7107 int indicationType, int token, RIL_Errno e, void *response,
7108 size_t responseLen) {
7109 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7110 if ((response == NULL && responseLen != 0)
7111 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
7112 RLOGE("dataCallListChangedInd: invalid response");
7113 return 0;
7114 }
7115 hidl_vec<SetupDataCallResult> dcList;
7116 convertRilDataCallListToHal(response, responseLen, dcList);
7117 #if VDBG
7118 RLOGD("dataCallListChangedInd");
7119 #endif
7120 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
7121 convertIntToRadioIndicationType(indicationType), dcList);
7122 radioService[slotId]->checkReturnStatus(retStatus);
7123 } else {
7124 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7125 }
7126
7127 return 0;
7128 }
7129
suppSvcNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7130 int radio::suppSvcNotifyInd(int slotId, int indicationType,
7131 int token, RIL_Errno e, void *response, size_t responseLen) {
7132 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7133 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
7134 RLOGE("suppSvcNotifyInd: invalid response");
7135 return 0;
7136 }
7137
7138 SuppSvcNotification suppSvc = {};
7139 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
7140 suppSvc.isMT = ssn->notificationType;
7141 suppSvc.code = ssn->code;
7142 suppSvc.index = ssn->index;
7143 suppSvc.type = ssn->type;
7144 suppSvc.number = convertCharPtrToHidlString(ssn->number);
7145
7146 #if VDBG
7147 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
7148 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
7149 #endif
7150 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
7151 convertIntToRadioIndicationType(indicationType), suppSvc);
7152 radioService[slotId]->checkReturnStatus(retStatus);
7153 } else {
7154 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7155 }
7156
7157 return 0;
7158 }
7159
stkSessionEndInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7160 int radio::stkSessionEndInd(int slotId, int indicationType,
7161 int token, RIL_Errno e, void *response, size_t responseLen) {
7162 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7163 #if VDBG
7164 RLOGD("stkSessionEndInd");
7165 #endif
7166 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
7167 convertIntToRadioIndicationType(indicationType));
7168 radioService[slotId]->checkReturnStatus(retStatus);
7169 } else {
7170 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
7171 }
7172
7173 return 0;
7174 }
7175
stkProactiveCommandInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7176 int radio::stkProactiveCommandInd(int slotId,
7177 int indicationType, int token, RIL_Errno e, void *response,
7178 size_t responseLen) {
7179 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7180 if (response == NULL || responseLen == 0) {
7181 RLOGE("stkProactiveCommandInd: invalid response");
7182 return 0;
7183 }
7184 #if VDBG
7185 RLOGD("stkProactiveCommandInd");
7186 #endif
7187 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
7188 convertIntToRadioIndicationType(indicationType),
7189 convertCharPtrToHidlString((char *) response));
7190 radioService[slotId]->checkReturnStatus(retStatus);
7191 } else {
7192 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
7193 }
7194
7195 return 0;
7196 }
7197
stkEventNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7198 int radio::stkEventNotifyInd(int slotId, int indicationType,
7199 int token, RIL_Errno e, void *response, size_t responseLen) {
7200 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7201 if (response == NULL || responseLen == 0) {
7202 RLOGE("stkEventNotifyInd: invalid response");
7203 return 0;
7204 }
7205 #if VDBG
7206 RLOGD("stkEventNotifyInd");
7207 #endif
7208 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
7209 convertIntToRadioIndicationType(indicationType),
7210 convertCharPtrToHidlString((char *) response));
7211 radioService[slotId]->checkReturnStatus(retStatus);
7212 } else {
7213 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7214 }
7215
7216 return 0;
7217 }
7218
stkCallSetupInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7219 int radio::stkCallSetupInd(int slotId, int indicationType,
7220 int token, RIL_Errno e, void *response, size_t responseLen) {
7221 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7222 if (response == NULL || responseLen != sizeof(int)) {
7223 RLOGE("stkCallSetupInd: invalid response");
7224 return 0;
7225 }
7226 int32_t timeout = ((int32_t *) response)[0];
7227 #if VDBG
7228 RLOGD("stkCallSetupInd: timeout %d", timeout);
7229 #endif
7230 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
7231 convertIntToRadioIndicationType(indicationType), timeout);
7232 radioService[slotId]->checkReturnStatus(retStatus);
7233 } else {
7234 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
7235 }
7236
7237 return 0;
7238 }
7239
simSmsStorageFullInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7240 int radio::simSmsStorageFullInd(int slotId,
7241 int indicationType, int token, RIL_Errno e, void *response,
7242 size_t responseLen) {
7243 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7244 #if VDBG
7245 RLOGD("simSmsStorageFullInd");
7246 #endif
7247 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
7248 convertIntToRadioIndicationType(indicationType));
7249 radioService[slotId]->checkReturnStatus(retStatus);
7250 } else {
7251 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
7252 }
7253
7254 return 0;
7255 }
7256
simRefreshInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7257 int radio::simRefreshInd(int slotId, int indicationType,
7258 int token, RIL_Errno e, void *response, size_t responseLen) {
7259 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7260 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
7261 RLOGE("simRefreshInd: invalid response");
7262 return 0;
7263 }
7264
7265 SimRefreshResult refreshResult = {};
7266 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
7267 refreshResult.type =
7268 (V1_0::SimRefreshType) simRefreshResponse->result;
7269 refreshResult.efId = simRefreshResponse->ef_id;
7270 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
7271
7272 #if VDBG
7273 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
7274 #endif
7275 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
7276 convertIntToRadioIndicationType(indicationType), refreshResult);
7277 radioService[slotId]->checkReturnStatus(retStatus);
7278 } else {
7279 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
7280 }
7281
7282 return 0;
7283 }
7284
convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord * signalInfoRecord,CdmaSignalInfoRecord & record)7285 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
7286 CdmaSignalInfoRecord& record) {
7287 record.isPresent = signalInfoRecord->isPresent;
7288 record.signalType = signalInfoRecord->signalType;
7289 record.alertPitch = signalInfoRecord->alertPitch;
7290 record.signal = signalInfoRecord->signal;
7291 }
7292
callRingInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7293 int radio::callRingInd(int slotId, int indicationType,
7294 int token, RIL_Errno e, void *response, size_t responseLen) {
7295 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7296 bool isGsm;
7297 CdmaSignalInfoRecord record = {};
7298 if (response == NULL || responseLen == 0) {
7299 isGsm = true;
7300 } else {
7301 isGsm = false;
7302 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
7303 RLOGE("callRingInd: invalid response");
7304 return 0;
7305 }
7306 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
7307 }
7308
7309 #if VDBG
7310 RLOGD("callRingInd: isGsm %d", isGsm);
7311 #endif
7312 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
7313 convertIntToRadioIndicationType(indicationType), isGsm, record);
7314 radioService[slotId]->checkReturnStatus(retStatus);
7315 } else {
7316 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7317 }
7318
7319 return 0;
7320 }
7321
simStatusChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7322 int radio::simStatusChangedInd(int slotId,
7323 int indicationType, int token, RIL_Errno e, void *response,
7324 size_t responseLen) {
7325 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7326 #if VDBG
7327 RLOGD("simStatusChangedInd");
7328 #endif
7329 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7330 convertIntToRadioIndicationType(indicationType));
7331 radioService[slotId]->checkReturnStatus(retStatus);
7332 } else {
7333 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7334 }
7335
7336 return 0;
7337 }
7338
cdmaNewSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7339 int radio::cdmaNewSmsInd(int slotId, int indicationType,
7340 int token, RIL_Errno e, void *response, size_t responseLen) {
7341 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7342 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7343 RLOGE("cdmaNewSmsInd: invalid response");
7344 return 0;
7345 }
7346
7347 CdmaSmsMessage msg = {};
7348 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7349 msg.teleserviceId = rilMsg->uTeleserviceID;
7350 msg.isServicePresent = rilMsg->bIsServicePresent;
7351 msg.serviceCategory = rilMsg->uServicecategory;
7352 msg.address.digitMode =
7353 (V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7354 msg.address.numberMode =
7355 (V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7356 msg.address.numberType =
7357 (V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7358 msg.address.numberPlan =
7359 (V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7360
7361 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7362 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7363
7364 msg.subAddress.subaddressType = (V1_0::CdmaSmsSubaddressType)
7365 rilMsg->sSubAddress.subaddressType;
7366 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7367
7368 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7369 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7370
7371 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7372 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7373
7374 #if VDBG
7375 RLOGD("cdmaNewSmsInd");
7376 #endif
7377 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7378 convertIntToRadioIndicationType(indicationType), msg);
7379 radioService[slotId]->checkReturnStatus(retStatus);
7380 } else {
7381 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7382 }
7383
7384 return 0;
7385 }
7386
newBroadcastSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7387 int radio::newBroadcastSmsInd(int slotId,
7388 int indicationType, int token, RIL_Errno e, void *response,
7389 size_t responseLen) {
7390 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7391 if (response == NULL || responseLen == 0) {
7392 RLOGE("newBroadcastSmsInd: invalid response");
7393 return 0;
7394 }
7395
7396 hidl_vec<uint8_t> data;
7397 data.setToExternal((uint8_t *) response, responseLen);
7398 #if VDBG
7399 RLOGD("newBroadcastSmsInd");
7400 #endif
7401 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7402 convertIntToRadioIndicationType(indicationType), data);
7403 radioService[slotId]->checkReturnStatus(retStatus);
7404 } else {
7405 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7406 }
7407
7408 return 0;
7409 }
7410
cdmaRuimSmsStorageFullInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7411 int radio::cdmaRuimSmsStorageFullInd(int slotId,
7412 int indicationType, int token, RIL_Errno e, void *response,
7413 size_t responseLen) {
7414 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7415 #if VDBG
7416 RLOGD("cdmaRuimSmsStorageFullInd");
7417 #endif
7418 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7419 convertIntToRadioIndicationType(indicationType));
7420 radioService[slotId]->checkReturnStatus(retStatus);
7421 } else {
7422 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7423 slotId);
7424 }
7425
7426 return 0;
7427 }
7428
restrictedStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7429 int radio::restrictedStateChangedInd(int slotId,
7430 int indicationType, int token, RIL_Errno e, void *response,
7431 size_t responseLen) {
7432 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7433 if (response == NULL || responseLen != sizeof(int)) {
7434 RLOGE("restrictedStateChangedInd: invalid response");
7435 return 0;
7436 }
7437 int32_t state = ((int32_t *) response)[0];
7438 #if VDBG
7439 RLOGD("restrictedStateChangedInd: state %d", state);
7440 #endif
7441 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7442 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7443 radioService[slotId]->checkReturnStatus(retStatus);
7444 } else {
7445 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7446 slotId);
7447 }
7448
7449 return 0;
7450 }
7451
enterEmergencyCallbackModeInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7452 int radio::enterEmergencyCallbackModeInd(int slotId,
7453 int indicationType, int token, RIL_Errno e, void *response,
7454 size_t responseLen) {
7455 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7456 #if VDBG
7457 RLOGD("enterEmergencyCallbackModeInd");
7458 #endif
7459 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7460 convertIntToRadioIndicationType(indicationType));
7461 radioService[slotId]->checkReturnStatus(retStatus);
7462 } else {
7463 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7464 slotId);
7465 }
7466
7467 return 0;
7468 }
7469
cdmaCallWaitingInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7470 int radio::cdmaCallWaitingInd(int slotId,
7471 int indicationType, int token, RIL_Errno e, void *response,
7472 size_t responseLen) {
7473 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7474 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7475 RLOGE("cdmaCallWaitingInd: invalid response");
7476 return 0;
7477 }
7478
7479 CdmaCallWaiting callWaitingRecord = {};
7480 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7481 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7482 callWaitingRecord.numberPresentation =
7483 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7484 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7485 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7486 callWaitingRecord.signalInfoRecord);
7487 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7488 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7489
7490 #if VDBG
7491 RLOGD("cdmaCallWaitingInd");
7492 #endif
7493 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7494 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7495 radioService[slotId]->checkReturnStatus(retStatus);
7496 } else {
7497 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7498 }
7499
7500 return 0;
7501 }
7502
cdmaOtaProvisionStatusInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7503 int radio::cdmaOtaProvisionStatusInd(int slotId,
7504 int indicationType, int token, RIL_Errno e, void *response,
7505 size_t responseLen) {
7506 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7507 if (response == NULL || responseLen != sizeof(int)) {
7508 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7509 return 0;
7510 }
7511 int32_t status = ((int32_t *) response)[0];
7512 #if VDBG
7513 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7514 #endif
7515 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7516 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7517 radioService[slotId]->checkReturnStatus(retStatus);
7518 } else {
7519 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7520 slotId);
7521 }
7522
7523 return 0;
7524 }
7525
cdmaInfoRecInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7526 int radio::cdmaInfoRecInd(int slotId,
7527 int indicationType, int token, RIL_Errno e, void *response,
7528 size_t responseLen) {
7529 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7530 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7531 RLOGE("cdmaInfoRecInd: invalid response");
7532 return 0;
7533 }
7534
7535 CdmaInformationRecords records = {};
7536 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7537
7538 char* string8 = NULL;
7539 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7540 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7541 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7542 "additional ones", recordsRil->numberOfInfoRecs,
7543 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7544 }
7545 records.infoRec.resize(num);
7546 for (int i = 0 ; i < num ; i++) {
7547 CdmaInformationRecord *record = &records.infoRec[i];
7548 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7549 record->name = (CdmaInfoRecName) infoRec->name;
7550 // All vectors should be size 0 except one which will be size 1. Set everything to
7551 // size 0 initially.
7552 record->display.resize(0);
7553 record->number.resize(0);
7554 record->signal.resize(0);
7555 record->redir.resize(0);
7556 record->lineCtrl.resize(0);
7557 record->clir.resize(0);
7558 record->audioCtrl.resize(0);
7559 switch (infoRec->name) {
7560 case RIL_CDMA_DISPLAY_INFO_REC:
7561 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7562 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7563 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7564 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7565 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7566 return 0;
7567 }
7568 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7569 if (string8 == NULL) {
7570 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7571 "responseCdmaInformationRecords");
7572 return 0;
7573 }
7574 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7575 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7576
7577 record->display.resize(1);
7578 record->display[0].alphaBuf = string8;
7579 free(string8);
7580 string8 = NULL;
7581 break;
7582 }
7583
7584 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7585 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7586 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7587 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7588 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7589 "expected not more than %d", (int) infoRec->rec.number.len,
7590 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7591 return 0;
7592 }
7593 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7594 if (string8 == NULL) {
7595 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7596 "responseCdmaInformationRecords");
7597 return 0;
7598 }
7599 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7600 string8[(int)infoRec->rec.number.len] = '\0';
7601
7602 record->number.resize(1);
7603 record->number[0].number = string8;
7604 free(string8);
7605 string8 = NULL;
7606 record->number[0].numberType = infoRec->rec.number.number_type;
7607 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7608 record->number[0].pi = infoRec->rec.number.pi;
7609 record->number[0].si = infoRec->rec.number.si;
7610 break;
7611 }
7612
7613 case RIL_CDMA_SIGNAL_INFO_REC: {
7614 record->signal.resize(1);
7615 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7616 record->signal[0].signalType = infoRec->rec.signal.signalType;
7617 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7618 record->signal[0].signal = infoRec->rec.signal.signal;
7619 break;
7620 }
7621
7622 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7623 if (infoRec->rec.redir.redirectingNumber.len >
7624 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7625 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7626 "expected not more than %d\n",
7627 (int)infoRec->rec.redir.redirectingNumber.len,
7628 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7629 return 0;
7630 }
7631 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7632 sizeof(char));
7633 if (string8 == NULL) {
7634 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7635 "responseCdmaInformationRecords");
7636 return 0;
7637 }
7638 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7639 infoRec->rec.redir.redirectingNumber.len);
7640 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7641
7642 record->redir.resize(1);
7643 record->redir[0].redirectingNumber.number = string8;
7644 free(string8);
7645 string8 = NULL;
7646 record->redir[0].redirectingNumber.numberType =
7647 infoRec->rec.redir.redirectingNumber.number_type;
7648 record->redir[0].redirectingNumber.numberPlan =
7649 infoRec->rec.redir.redirectingNumber.number_plan;
7650 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7651 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7652 record->redir[0].redirectingReason =
7653 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7654 break;
7655 }
7656
7657 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7658 record->lineCtrl.resize(1);
7659 record->lineCtrl[0].lineCtrlPolarityIncluded =
7660 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7661 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7662 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7663 record->lineCtrl[0].lineCtrlPowerDenial =
7664 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7665 break;
7666 }
7667
7668 case RIL_CDMA_T53_CLIR_INFO_REC: {
7669 record->clir.resize(1);
7670 record->clir[0].cause = infoRec->rec.clir.cause;
7671 break;
7672 }
7673
7674 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7675 record->audioCtrl.resize(1);
7676 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7677 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7678 break;
7679 }
7680
7681 case RIL_CDMA_T53_RELEASE_INFO_REC:
7682 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7683 return 0;
7684
7685 default:
7686 RLOGE("cdmaInfoRecInd: Incorrect name value");
7687 return 0;
7688 }
7689 }
7690
7691 #if VDBG
7692 RLOGD("cdmaInfoRecInd");
7693 #endif
7694 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7695 convertIntToRadioIndicationType(indicationType), records);
7696 radioService[slotId]->checkReturnStatus(retStatus);
7697 } else {
7698 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7699 }
7700
7701 return 0;
7702 }
7703
indicateRingbackToneInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7704 int radio::indicateRingbackToneInd(int slotId,
7705 int indicationType, int token, RIL_Errno e, void *response,
7706 size_t responseLen) {
7707 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7708 if (response == NULL || responseLen != sizeof(int)) {
7709 RLOGE("indicateRingbackToneInd: invalid response");
7710 return 0;
7711 }
7712 bool start = ((int32_t *) response)[0];
7713 #if VDBG
7714 RLOGD("indicateRingbackToneInd: start %d", start);
7715 #endif
7716 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7717 convertIntToRadioIndicationType(indicationType), start);
7718 radioService[slotId]->checkReturnStatus(retStatus);
7719 } else {
7720 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7721 }
7722
7723 return 0;
7724 }
7725
resendIncallMuteInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7726 int radio::resendIncallMuteInd(int slotId,
7727 int indicationType, int token, RIL_Errno e, void *response,
7728 size_t responseLen) {
7729 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7730 #if VDBG
7731 RLOGD("resendIncallMuteInd");
7732 #endif
7733 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7734 convertIntToRadioIndicationType(indicationType));
7735 radioService[slotId]->checkReturnStatus(retStatus);
7736 } else {
7737 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7738 }
7739
7740 return 0;
7741 }
7742
cdmaSubscriptionSourceChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7743 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7744 int indicationType, int token, RIL_Errno e,
7745 void *response, size_t responseLen) {
7746 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7747 if (response == NULL || responseLen != sizeof(int)) {
7748 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7749 return 0;
7750 }
7751 int32_t cdmaSource = ((int32_t *) response)[0];
7752 #if VDBG
7753 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7754 #endif
7755 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7756 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7757 (CdmaSubscriptionSource) cdmaSource);
7758 radioService[slotId]->checkReturnStatus(retStatus);
7759 } else {
7760 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7761 slotId);
7762 }
7763
7764 return 0;
7765 }
7766
cdmaPrlChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7767 int radio::cdmaPrlChangedInd(int slotId,
7768 int indicationType, int token, RIL_Errno e, void *response,
7769 size_t responseLen) {
7770 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7771 if (response == NULL || responseLen != sizeof(int)) {
7772 RLOGE("cdmaPrlChangedInd: invalid response");
7773 return 0;
7774 }
7775 int32_t version = ((int32_t *) response)[0];
7776 #if VDBG
7777 RLOGD("cdmaPrlChangedInd: version %d", version);
7778 #endif
7779 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7780 convertIntToRadioIndicationType(indicationType), version);
7781 radioService[slotId]->checkReturnStatus(retStatus);
7782 } else {
7783 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7784 }
7785
7786 return 0;
7787 }
7788
exitEmergencyCallbackModeInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7789 int radio::exitEmergencyCallbackModeInd(int slotId,
7790 int indicationType, int token, RIL_Errno e, void *response,
7791 size_t responseLen) {
7792 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7793 #if VDBG
7794 RLOGD("exitEmergencyCallbackModeInd");
7795 #endif
7796 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7797 convertIntToRadioIndicationType(indicationType));
7798 radioService[slotId]->checkReturnStatus(retStatus);
7799 } else {
7800 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7801 slotId);
7802 }
7803
7804 return 0;
7805 }
7806
rilConnectedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7807 int radio::rilConnectedInd(int slotId,
7808 int indicationType, int token, RIL_Errno e, void *response,
7809 size_t responseLen) {
7810 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7811 RLOGD("rilConnectedInd");
7812 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7813 convertIntToRadioIndicationType(indicationType));
7814 radioService[slotId]->checkReturnStatus(retStatus);
7815 } else {
7816 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7817 }
7818
7819 return 0;
7820 }
7821
voiceRadioTechChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7822 int radio::voiceRadioTechChangedInd(int slotId,
7823 int indicationType, int token, RIL_Errno e, void *response,
7824 size_t responseLen) {
7825 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7826 if (response == NULL || responseLen != sizeof(int)) {
7827 RLOGE("voiceRadioTechChangedInd: invalid response");
7828 return 0;
7829 }
7830 int32_t rat = ((int32_t *) response)[0];
7831 #if VDBG
7832 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7833 #endif
7834 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7835 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7836 radioService[slotId]->checkReturnStatus(retStatus);
7837 } else {
7838 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7839 slotId);
7840 }
7841
7842 return 0;
7843 }
7844
convertRilCellInfoListToHal(void * response,size_t responseLen,hidl_vec<CellInfo> & records)7845 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7846 int num = responseLen / sizeof(RIL_CellInfo_v12);
7847 records.resize(num);
7848
7849 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7850 for (int i = 0; i < num; i++) {
7851 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7852 records[i].registered = rillCellInfo->registered;
7853 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7854 records[i].timeStamp = rillCellInfo->timeStamp;
7855 // All vectors should be size 0 except one which will be size 1. Set everything to
7856 // size 0 initially.
7857 records[i].gsm.resize(0);
7858 records[i].wcdma.resize(0);
7859 records[i].cdma.resize(0);
7860 records[i].lte.resize(0);
7861 records[i].tdscdma.resize(0);
7862 switch(rillCellInfo->cellInfoType) {
7863 case RIL_CELL_INFO_TYPE_GSM: {
7864 records[i].gsm.resize(1);
7865 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7866 cellInfoGsm->cellIdentityGsm.mcc =
7867 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7868 cellInfoGsm->cellIdentityGsm.mnc =
7869 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7870 cellInfoGsm->cellIdentityGsm.lac =
7871 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7872 cellInfoGsm->cellIdentityGsm.cid =
7873 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7874 cellInfoGsm->cellIdentityGsm.arfcn =
7875 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7876 cellInfoGsm->cellIdentityGsm.bsic =
7877 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7878 cellInfoGsm->signalStrengthGsm.signalStrength =
7879 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7880 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7881 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7882 cellInfoGsm->signalStrengthGsm.timingAdvance =
7883 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7884 break;
7885 }
7886
7887 case RIL_CELL_INFO_TYPE_WCDMA: {
7888 records[i].wcdma.resize(1);
7889 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7890 cellInfoWcdma->cellIdentityWcdma.mcc =
7891 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7892 cellInfoWcdma->cellIdentityWcdma.mnc =
7893 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7894 cellInfoWcdma->cellIdentityWcdma.lac =
7895 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7896 cellInfoWcdma->cellIdentityWcdma.cid =
7897 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7898 cellInfoWcdma->cellIdentityWcdma.psc =
7899 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7900 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7901 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7902 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7903 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7904 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7905 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7906 break;
7907 }
7908
7909 case RIL_CELL_INFO_TYPE_CDMA: {
7910 records[i].cdma.resize(1);
7911 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7912 cellInfoCdma->cellIdentityCdma.networkId =
7913 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7914 cellInfoCdma->cellIdentityCdma.systemId =
7915 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7916 cellInfoCdma->cellIdentityCdma.baseStationId =
7917 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7918 cellInfoCdma->cellIdentityCdma.longitude =
7919 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7920 cellInfoCdma->cellIdentityCdma.latitude =
7921 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7922 cellInfoCdma->signalStrengthCdma.dbm =
7923 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7924 cellInfoCdma->signalStrengthCdma.ecio =
7925 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7926 cellInfoCdma->signalStrengthEvdo.dbm =
7927 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7928 cellInfoCdma->signalStrengthEvdo.ecio =
7929 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7930 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7931 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7932 break;
7933 }
7934
7935 case RIL_CELL_INFO_TYPE_LTE: {
7936 records[i].lte.resize(1);
7937 CellInfoLte *cellInfoLte = &records[i].lte[0];
7938 cellInfoLte->cellIdentityLte.mcc =
7939 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7940 cellInfoLte->cellIdentityLte.mnc =
7941 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7942 cellInfoLte->cellIdentityLte.ci =
7943 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7944 cellInfoLte->cellIdentityLte.pci =
7945 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7946 cellInfoLte->cellIdentityLte.tac =
7947 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7948 cellInfoLte->cellIdentityLte.earfcn =
7949 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7950 cellInfoLte->signalStrengthLte.signalStrength =
7951 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7952 cellInfoLte->signalStrengthLte.rsrp =
7953 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7954 cellInfoLte->signalStrengthLte.rsrq =
7955 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7956 cellInfoLte->signalStrengthLte.rssnr =
7957 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7958 cellInfoLte->signalStrengthLte.cqi =
7959 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7960 cellInfoLte->signalStrengthLte.timingAdvance =
7961 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7962 break;
7963 }
7964
7965 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7966 records[i].tdscdma.resize(1);
7967 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7968 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7969 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7970 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7971 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7972 cellInfoTdscdma->cellIdentityTdscdma.lac =
7973 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7974 cellInfoTdscdma->cellIdentityTdscdma.cid =
7975 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7976 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7977 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7978 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7979 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7980 break;
7981 }
7982 default: {
7983 break;
7984 }
7985 }
7986 rillCellInfo += 1;
7987 }
7988 }
7989
cellInfoListInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7990 int radio::cellInfoListInd(int slotId,
7991 int indicationType, int token, RIL_Errno e, void *response,
7992 size_t responseLen) {
7993 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7994 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7995 RLOGE("cellInfoListInd: invalid response");
7996 return 0;
7997 }
7998
7999 hidl_vec<CellInfo> records;
8000 convertRilCellInfoListToHal(response, responseLen, records);
8001
8002 #if VDBG
8003 RLOGD("cellInfoListInd");
8004 #endif
8005 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
8006 convertIntToRadioIndicationType(indicationType), records);
8007 radioService[slotId]->checkReturnStatus(retStatus);
8008 } else {
8009 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
8010 }
8011
8012 return 0;
8013 }
8014
imsNetworkStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8015 int radio::imsNetworkStateChangedInd(int slotId,
8016 int indicationType, int token, RIL_Errno e, void *response,
8017 size_t responseLen) {
8018 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8019 #if VDBG
8020 RLOGD("imsNetworkStateChangedInd");
8021 #endif
8022 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
8023 convertIntToRadioIndicationType(indicationType));
8024 radioService[slotId]->checkReturnStatus(retStatus);
8025 } else {
8026 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
8027 slotId);
8028 }
8029
8030 return 0;
8031 }
8032
subscriptionStatusChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8033 int radio::subscriptionStatusChangedInd(int slotId,
8034 int indicationType, int token, RIL_Errno e, void *response,
8035 size_t responseLen) {
8036 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8037 if (response == NULL || responseLen != sizeof(int)) {
8038 RLOGE("subscriptionStatusChangedInd: invalid response");
8039 return 0;
8040 }
8041 bool activate = ((int32_t *) response)[0];
8042 #if VDBG
8043 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
8044 #endif
8045 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
8046 convertIntToRadioIndicationType(indicationType), activate);
8047 radioService[slotId]->checkReturnStatus(retStatus);
8048 } else {
8049 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
8050 slotId);
8051 }
8052
8053 return 0;
8054 }
8055
srvccStateNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8056 int radio::srvccStateNotifyInd(int slotId,
8057 int indicationType, int token, RIL_Errno e, void *response,
8058 size_t responseLen) {
8059 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8060 if (response == NULL || responseLen != sizeof(int)) {
8061 RLOGE("srvccStateNotifyInd: invalid response");
8062 return 0;
8063 }
8064 int32_t state = ((int32_t *) response)[0];
8065 #if VDBG
8066 RLOGD("srvccStateNotifyInd: rat %d", state);
8067 #endif
8068 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
8069 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
8070 radioService[slotId]->checkReturnStatus(retStatus);
8071 } else {
8072 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
8073 }
8074
8075 return 0;
8076 }
8077
convertRilHardwareConfigListToHal(void * response,size_t responseLen,hidl_vec<HardwareConfig> & records)8078 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
8079 hidl_vec<HardwareConfig>& records) {
8080 int num = responseLen / sizeof(RIL_HardwareConfig);
8081 records.resize(num);
8082
8083 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
8084 for (int i = 0; i < num; i++) {
8085 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
8086 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
8087 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
8088 switch (rilHardwareConfig[i].type) {
8089 case RIL_HARDWARE_CONFIG_MODEM: {
8090 records[i].modem.resize(1);
8091 records[i].sim.resize(0);
8092 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
8093 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
8094 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
8095 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
8096 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
8097 break;
8098 }
8099
8100 case RIL_HARDWARE_CONFIG_SIM: {
8101 records[i].sim.resize(1);
8102 records[i].modem.resize(0);
8103 records[i].sim[0].modemUuid =
8104 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
8105 break;
8106 }
8107 }
8108 }
8109 }
8110
hardwareConfigChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8111 int radio::hardwareConfigChangedInd(int slotId,
8112 int indicationType, int token, RIL_Errno e, void *response,
8113 size_t responseLen) {
8114 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8115 if ((response == NULL && responseLen != 0)
8116 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
8117 RLOGE("hardwareConfigChangedInd: invalid response");
8118 return 0;
8119 }
8120
8121 hidl_vec<HardwareConfig> configs;
8122 convertRilHardwareConfigListToHal(response, responseLen, configs);
8123
8124 #if VDBG
8125 RLOGD("hardwareConfigChangedInd");
8126 #endif
8127 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
8128 convertIntToRadioIndicationType(indicationType), configs);
8129 radioService[slotId]->checkReturnStatus(retStatus);
8130 } else {
8131 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
8132 slotId);
8133 }
8134
8135 return 0;
8136 }
8137
convertRilRadioCapabilityToHal(void * response,size_t responseLen,RadioCapability & rc)8138 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
8139 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
8140 rc.session = rilRadioCapability->session;
8141 rc.phase = (V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
8142 rc.raf = rilRadioCapability->rat;
8143 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
8144 rc.status = (V1_0::RadioCapabilityStatus) rilRadioCapability->status;
8145 }
8146
radioCapabilityIndicationInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8147 int radio::radioCapabilityIndicationInd(int slotId,
8148 int indicationType, int token, RIL_Errno e, void *response,
8149 size_t responseLen) {
8150 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8151 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
8152 RLOGE("radioCapabilityIndicationInd: invalid response");
8153 return 0;
8154 }
8155
8156 RadioCapability rc = {};
8157 convertRilRadioCapabilityToHal(response, responseLen, rc);
8158
8159 #if VDBG
8160 RLOGD("radioCapabilityIndicationInd");
8161 #endif
8162 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
8163 convertIntToRadioIndicationType(indicationType), rc);
8164 radioService[slotId]->checkReturnStatus(retStatus);
8165 } else {
8166 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
8167 slotId);
8168 }
8169
8170 return 0;
8171 }
8172
isServiceTypeCfQuery(RIL_SsServiceType serType,RIL_SsRequestType reqType)8173 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
8174 if ((reqType == SS_INTERROGATION) &&
8175 (serType == SS_CFU ||
8176 serType == SS_CF_BUSY ||
8177 serType == SS_CF_NO_REPLY ||
8178 serType == SS_CF_NOT_REACHABLE ||
8179 serType == SS_CF_ALL ||
8180 serType == SS_CF_ALL_CONDITIONAL)) {
8181 return true;
8182 }
8183 return false;
8184 }
8185
onSupplementaryServiceIndicationInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8186 int radio::onSupplementaryServiceIndicationInd(int slotId,
8187 int indicationType, int token, RIL_Errno e,
8188 void *response, size_t responseLen) {
8189 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8190 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
8191 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
8192 return 0;
8193 }
8194
8195 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
8196 StkCcUnsolSsResult ss = {};
8197 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
8198 ss.requestType = (SsRequestType) rilSsResponse->requestType;
8199 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
8200 ss.serviceClass = rilSsResponse->serviceClass;
8201 ss.result = (RadioError) rilSsResponse->result;
8202
8203 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
8204 #if VDBG
8205 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
8206 rilSsResponse->cfData.numValidIndexes);
8207 #endif
8208 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
8209 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
8210 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
8211 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
8212 }
8213
8214 ss.cfData.resize(1);
8215 ss.ssInfo.resize(0);
8216
8217 /* number of call info's */
8218 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
8219
8220 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
8221 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
8222 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
8223
8224 cfInfo->status = (CallForwardInfoStatus) cf.status;
8225 cfInfo->reason = cf.reason;
8226 cfInfo->serviceClass = cf.serviceClass;
8227 cfInfo->toa = cf.toa;
8228 cfInfo->number = convertCharPtrToHidlString(cf.number);
8229 cfInfo->timeSeconds = cf.timeSeconds;
8230 #if VDBG
8231 RLOGD("onSupplementaryServiceIndicationInd: "
8232 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
8233 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
8234 #endif
8235 }
8236 } else {
8237 ss.ssInfo.resize(1);
8238 ss.cfData.resize(0);
8239
8240 /* each int */
8241 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
8242 for (int i = 0; i < SS_INFO_MAX; i++) {
8243 #if VDBG
8244 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
8245 rilSsResponse->ssInfo[i]);
8246 #endif
8247 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
8248 }
8249 }
8250
8251 #if VDBG
8252 RLOGD("onSupplementaryServiceIndicationInd");
8253 #endif
8254 Return<void> retStatus = radioService[slotId]->mRadioIndication->
8255 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
8256 ss);
8257 radioService[slotId]->checkReturnStatus(retStatus);
8258 } else {
8259 RLOGE("onSupplementaryServiceIndicationInd: "
8260 "radioService[%d]->mRadioIndication == NULL", slotId);
8261 }
8262
8263 return 0;
8264 }
8265
stkCallControlAlphaNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8266 int radio::stkCallControlAlphaNotifyInd(int slotId,
8267 int indicationType, int token, RIL_Errno e, void *response,
8268 size_t responseLen) {
8269 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8270 if (response == NULL || responseLen == 0) {
8271 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
8272 return 0;
8273 }
8274 #if VDBG
8275 RLOGD("stkCallControlAlphaNotifyInd");
8276 #endif
8277 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
8278 convertIntToRadioIndicationType(indicationType),
8279 convertCharPtrToHidlString((char *) response));
8280 radioService[slotId]->checkReturnStatus(retStatus);
8281 } else {
8282 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
8283 slotId);
8284 }
8285
8286 return 0;
8287 }
8288
convertRilLceDataInfoToHal(void * response,size_t responseLen,LceDataInfo & lce)8289 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
8290 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
8291 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
8292 lce.confidenceLevel = rilLceDataInfo->confidence_level;
8293 lce.lceSuspended = rilLceDataInfo->lce_suspended;
8294 }
8295
lceDataInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8296 int radio::lceDataInd(int slotId,
8297 int indicationType, int token, RIL_Errno e, void *response,
8298 size_t responseLen) {
8299 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8300 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
8301 RLOGE("lceDataInd: invalid response");
8302 return 0;
8303 }
8304
8305 LceDataInfo lce = {};
8306 convertRilLceDataInfoToHal(response, responseLen, lce);
8307 #if VDBG
8308 RLOGD("lceDataInd");
8309 #endif
8310 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
8311 convertIntToRadioIndicationType(indicationType), lce);
8312 radioService[slotId]->checkReturnStatus(retStatus);
8313 } else {
8314 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8315 }
8316
8317 return 0;
8318 }
8319
pcoDataInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8320 int radio::pcoDataInd(int slotId,
8321 int indicationType, int token, RIL_Errno e, void *response,
8322 size_t responseLen) {
8323 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8324 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8325 RLOGE("pcoDataInd: invalid response");
8326 return 0;
8327 }
8328
8329 PcoDataInfo pco = {};
8330 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8331 pco.cid = rilPcoData->cid;
8332 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8333 pco.pcoId = rilPcoData->pco_id;
8334 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8335
8336 #if VDBG
8337 RLOGD("pcoDataInd");
8338 #endif
8339 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8340 convertIntToRadioIndicationType(indicationType), pco);
8341 radioService[slotId]->checkReturnStatus(retStatus);
8342 } else {
8343 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8344 }
8345
8346 return 0;
8347 }
8348
modemResetInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8349 int radio::modemResetInd(int slotId,
8350 int indicationType, int token, RIL_Errno e, void *response,
8351 size_t responseLen) {
8352 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8353 if (response == NULL || responseLen == 0) {
8354 RLOGE("modemResetInd: invalid response");
8355 return 0;
8356 }
8357 #if VDBG
8358 RLOGD("modemResetInd");
8359 #endif
8360 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8361 convertIntToRadioIndicationType(indicationType),
8362 convertCharPtrToHidlString((char *) response));
8363 radioService[slotId]->checkReturnStatus(retStatus);
8364 } else {
8365 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8366 }
8367
8368 return 0;
8369 }
8370
networkScanResultInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8371 int radio::networkScanResultInd(int slotId,
8372 int indicationType, int token, RIL_Errno e, void *response,
8373 size_t responseLen) {
8374 #if VDBG
8375 RLOGD("networkScanResultInd");
8376 #endif
8377 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8378 if (response == NULL || responseLen == 0) {
8379 RLOGE("networkScanResultInd: invalid response");
8380 return 0;
8381 }
8382 RLOGD("networkScanResultInd");
8383
8384 #if VDBG
8385 RLOGD("networkScanResultInd");
8386 #endif
8387
8388 RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
8389
8390 V1_1::NetworkScanResult result;
8391 result.status = (V1_1::ScanStatus) networkScanResult->status;
8392 result.error = (RadioError) e;
8393 convertRilCellInfoListToHal(
8394 networkScanResult->network_infos,
8395 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
8396 result.networkInfos);
8397
8398 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->networkScanResult(
8399 convertIntToRadioIndicationType(indicationType), result);
8400 radioService[slotId]->checkReturnStatus(retStatus);
8401 } else {
8402 RLOGE("networkScanResultInd: radioService[%d]->mRadioIndicationV1_1 == NULL", slotId);
8403 }
8404 return 0;
8405 }
8406
carrierInfoForImsiEncryption(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8407 int radio::carrierInfoForImsiEncryption(int slotId,
8408 int indicationType, int token, RIL_Errno e, void *response,
8409 size_t responseLen) {
8410 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8411 if (response == NULL || responseLen == 0) {
8412 RLOGE("carrierInfoForImsiEncryption: invalid response");
8413 return 0;
8414 }
8415 RLOGD("carrierInfoForImsiEncryption");
8416 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->
8417 carrierInfoForImsiEncryption(convertIntToRadioIndicationType(indicationType));
8418 radioService[slotId]->checkReturnStatus(retStatus);
8419 } else {
8420 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndicationV1_1 == NULL",
8421 slotId);
8422 }
8423
8424 return 0;
8425 }
8426
keepaliveStatusInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8427 int radio::keepaliveStatusInd(int slotId,
8428 int indicationType, int token, RIL_Errno e, void *response,
8429 size_t responseLen) {
8430 #if VDBG
8431 RLOGD("%s(): token=%d", __FUNCTION__, token);
8432 #endif
8433 if (radioService[slotId] == NULL || radioService[slotId]->mRadioIndication == NULL) {
8434 RLOGE("%s: radioService[%d]->mRadioIndication == NULL", __FUNCTION__, slotId);
8435 return 0;
8436 }
8437
8438 auto ret = V1_1::IRadioIndication::castFrom(
8439 radioService[slotId]->mRadioIndication);
8440 if (!ret.isOk()) {
8441 RLOGE("%s: ret.isOk() == false for radioService[%d]", __FUNCTION__, slotId);
8442 return 0;
8443 }
8444 sp<V1_1::IRadioIndication> radioIndicationV1_1 = ret;
8445
8446 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
8447 RLOGE("%s: invalid response", __FUNCTION__);
8448 return 0;
8449 }
8450
8451 V1_1::KeepaliveStatus ks;
8452 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
8453
8454 Return<void> retStatus = radioIndicationV1_1->keepaliveStatus(
8455 convertIntToRadioIndicationType(indicationType), ks);
8456 radioService[slotId]->checkReturnStatus(retStatus);
8457 return 0;
8458 }
8459
oemHookRawInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8460 int radio::oemHookRawInd(int slotId,
8461 int indicationType, int token, RIL_Errno e, void *response,
8462 size_t responseLen) {
8463 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8464 if (response == NULL || responseLen == 0) {
8465 RLOGE("oemHookRawInd: invalid response");
8466 return 0;
8467 }
8468
8469 hidl_vec<uint8_t> data;
8470 data.setToExternal((uint8_t *) response, responseLen);
8471 #if VDBG
8472 RLOGD("oemHookRawInd");
8473 #endif
8474 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8475 convertIntToRadioIndicationType(indicationType), data);
8476 checkReturnStatus(slotId, retStatus, false);
8477 } else {
8478 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8479 }
8480
8481 return 0;
8482 }
8483
registerService(RIL_RadioFunctions * callbacks,CommandInfo * commands)8484 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8485 using namespace android::hardware;
8486 int simCount = 1;
8487 const char *serviceNames[] = {
8488 android::RIL_getServiceName()
8489 #if (SIM_COUNT >= 2)
8490 , RIL2_SERVICE_NAME
8491 #if (SIM_COUNT >= 3)
8492 , RIL3_SERVICE_NAME
8493 #if (SIM_COUNT >= 4)
8494 , RIL4_SERVICE_NAME
8495 #endif
8496 #endif
8497 #endif
8498 };
8499
8500 #if (SIM_COUNT >= 2)
8501 simCount = SIM_COUNT;
8502 #endif
8503
8504 configureRpcThreadpool(1, true /* callerWillJoin */);
8505 for (int i = 0; i < simCount; i++) {
8506 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8507 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8508 assert(ret == 0);
8509
8510 radioService[i] = new RadioImpl;
8511 radioService[i]->mSlotId = i;
8512 oemHookService[i] = new OemHookImpl;
8513 oemHookService[i]->mSlotId = i;
8514 RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
8515 serviceNames[i]);
8516 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8517 status = oemHookService[i]->registerAsService(serviceNames[i]);
8518
8519 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8520 assert(ret == 0);
8521 }
8522
8523 s_vendorFunctions = callbacks;
8524 s_commands = commands;
8525 }
8526
rilc_thread_pool()8527 void rilc_thread_pool() {
8528 joinRpcThreadpool();
8529 }
8530
getRadioServiceRwlock(int slotId)8531 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8532 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8533
8534 #if (SIM_COUNT >= 2)
8535 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8536 #if (SIM_COUNT >= 3)
8537 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8538 #if (SIM_COUNT >= 4)
8539 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8540 #endif
8541 #endif
8542 #endif
8543
8544 return radioServiceRwlockPtr;
8545 }
8546