1 /*
2 **
3 ** Copyright 2020, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17
18 #define LOG_TAG "RILC"
19
20 #include <android/hardware/radio/config/1.1/IRadioConfig.h>
21 #include <android/hardware/radio/config/1.2/IRadioConfigResponse.h>
22 #include <android/hardware/radio/config/1.3/IRadioConfigResponse.h>
23 #include <android/hardware/radio/config/1.3/IRadioConfig.h>
24 #include <android/hardware/radio/config/1.2/IRadioConfigIndication.h>
25 #include <android/hardware/radio/1.1/types.h>
26
27 #include <ril.h>
28 #include <guest/hals/ril/reference-libril/ril_service.h>
29 #include <hidl/HidlTransportSupport.h>
30
31 using namespace android::hardware::radio::V1_0;
32 using namespace android::hardware::radio::config;
33 using namespace android::hardware::radio::config::V1_0;
34 using namespace android::hardware::radio::config::V1_3;
35 using ::android::hardware::configureRpcThreadpool;
36 using ::android::hardware::joinRpcThreadpool;
37 using ::android::hardware::Return;
38 using ::android::hardware::hidl_string;
39 using ::android::hardware::hidl_vec;
40 using ::android::hardware::Void;
41 using android::CommandInfo;
42 using android::RequestInfo;
43 using android::requestToString;
44 using android::sp;
45
46 RIL_RadioFunctions *s_vendorFunctions_config = NULL;
47 static CommandInfo *s_configCommands;
48 struct RadioConfigImpl;
49 sp<RadioConfigImpl> radioConfigService;
50 volatile int32_t mCounterRadioConfig;
51
52 #if defined (ANDROID_MULTI_SIM)
53 #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c), (d))
54 #define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions_config->onRequest((a), (b), (c), (d), (e))
55 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions_config->onStateRequest(a)
56 #else
57 #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c))
58 #define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions_config->onRequest((a), (b), (c), (d))
59 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions_config->onStateRequest()
60 #endif
61
62 extern void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
63 RIL_Errno e);
64
65 extern void populateResponseInfo_1_6(
66 ::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo,
67 int serial, int responseType, RIL_Errno e);
68
69 extern bool dispatchVoid(int serial, int slotId, int request);
70 extern bool dispatchString(int serial, int slotId, int request, const char * str);
71 extern bool dispatchStrings(int serial, int slotId, int request, bool allowEmpty,
72 int countStrings, ...);
73 extern bool dispatchInts(int serial, int slotId, int request, int countInts, ...);
74 extern hidl_string convertCharPtrToHidlString(const char *ptr);
75 extern void sendErrorResponse(android::RequestInfo *pRI, RIL_Errno err);
76 extern RadioIndicationType convertIntToRadioIndicationType(int indicationType);
77
78 extern bool isChangeSlotId(int serviceId, int slotId);
79
80 struct RadioConfigImpl : public V1_3::IRadioConfig {
81 int32_t mSlotId;
82 sp<V1_0::IRadioConfigResponse> mRadioConfigResponse;
83 sp<V1_0::IRadioConfigIndication> mRadioConfigIndication;
84 sp<V1_1::IRadioConfigResponse> mRadioConfigResponseV1_1;
85 sp<V1_2::IRadioConfigResponse> mRadioConfigResponseV1_2;
86 sp<V1_2::IRadioConfigIndication> mRadioConfigIndicationV1_2;
87 sp<V1_3::IRadioConfigResponse> mRadioConfigResponseV1_3;
88
89 Return<void> setResponseFunctions(
90 const ::android::sp<V1_0::IRadioConfigResponse>& radioConfigResponse,
91 const ::android::sp<V1_0::IRadioConfigIndication>& radioConfigIndication);
92
93 Return<void> getSimSlotsStatus(int32_t serial);
94
95 Return<void> setSimSlotsMapping(int32_t serial, const hidl_vec<uint32_t>& slotMap);
96
97 Return<void> getPhoneCapability(int32_t serial);
98
99 Return<void> setPreferredDataModem(int32_t serial, uint8_t modemId);
100
101 Return<void> setModemsConfig(int32_t serial, const V1_1::ModemsConfig& modemsConfig);
102
103 Return<void> getModemsConfig(int32_t serial);
104
105 Return<void> getHalDeviceCapabilities(int32_t serial);
106
107 void checkReturnStatus_config(Return<void>& ret);
108 };
setResponseFunctions(const::android::sp<V1_0::IRadioConfigResponse> & radioConfigResponse,const::android::sp<V1_0::IRadioConfigIndication> & radioConfigIndication)109 Return<void> RadioConfigImpl::setResponseFunctions(
110 const ::android::sp<V1_0::IRadioConfigResponse>& radioConfigResponse,
111 const ::android::sp<V1_0::IRadioConfigIndication>& radioConfigIndication) {
112 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_6::getRadioServiceRwlock(RIL_SOCKET_1);
113 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
114 assert(ret == 0);
115
116 mRadioConfigResponse = radioConfigResponse;
117 mRadioConfigIndication = radioConfigIndication;
118
119
120 mRadioConfigResponseV1_1 =
121 V1_1::IRadioConfigResponse::castFrom(mRadioConfigResponse).withDefault(nullptr);
122 if (mRadioConfigResponseV1_1 == nullptr) {
123 mRadioConfigResponseV1_1 = nullptr;
124 }
125
126 mRadioConfigResponseV1_2 =
127 V1_2::IRadioConfigResponse::castFrom(mRadioConfigResponse).withDefault(nullptr);
128 mRadioConfigIndicationV1_2 =
129 V1_2::IRadioConfigIndication::castFrom(mRadioConfigIndication).withDefault(nullptr);
130 if (mRadioConfigResponseV1_2 == nullptr || mRadioConfigIndicationV1_2 == nullptr) {
131 mRadioConfigResponseV1_2 = nullptr;
132 mRadioConfigIndicationV1_2 = nullptr;
133 }
134
135 mRadioConfigResponseV1_3 =
136 V1_3::IRadioConfigResponse::castFrom(mRadioConfigResponse).withDefault(nullptr);
137 if (mRadioConfigResponseV1_3 == nullptr || mRadioConfigResponseV1_3 == nullptr) {
138 mRadioConfigResponseV1_3 = nullptr;
139 }
140
141 mCounterRadioConfig++;
142
143 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
144 assert(ret == 0);
145
146 return Void();
147 }
148
getSimSlotsStatus(int32_t serial)149 Return<void> RadioConfigImpl::getSimSlotsStatus(int32_t serial) {
150 #if VDBG
151 RLOGD("getSimSlotsStatus: serial %d", serial);
152 #endif
153 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFIG_GET_SLOT_STATUS);
154
155 return Void();
156 }
157
setSimSlotsMapping(int32_t serial,const hidl_vec<uint32_t> & slotMap)158 Return<void> RadioConfigImpl::setSimSlotsMapping(int32_t serial, const hidl_vec<uint32_t>& slotMap) {
159 #if VDBG
160 RLOGD("setSimSlotsMapping: serial %d", serial);
161 #endif
162 RequestInfo *pRI = android::addRequestToList(serial, RIL_SOCKET_1,
163 RIL_REQUEST_CONFIG_SET_SLOT_MAPPING);
164 if (pRI == NULL) {
165 return Void();
166 }
167 size_t slotNum = slotMap.size();
168
169 if (slotNum > RIL_SOCKET_NUM) {
170 RLOGE("setSimSlotsMapping: invalid parameter");
171 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
172 return Void();
173 }
174
175 for (size_t socket_id = 0; socket_id < slotNum; socket_id++) {
176 if (slotMap[socket_id] >= RIL_SOCKET_NUM) {
177 RLOGE("setSimSlotsMapping: invalid parameter[%zu]", socket_id);
178 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
179 return Void();
180 }
181 // confirm logical id is not duplicate
182 for (size_t nextId = socket_id + 1; nextId < slotNum; nextId++) {
183 if (slotMap[socket_id] == slotMap[nextId]) {
184 RLOGE("setSimSlotsMapping: slot parameter is the same:[%zu] and [%zu]",
185 socket_id, nextId);
186 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
187 return Void();
188 }
189 }
190 }
191 int *pSlotMap = (int *)calloc(slotNum, sizeof(int));
192
193 for (size_t socket_id = 0; socket_id < slotNum; socket_id++) {
194 pSlotMap[socket_id] = slotMap[socket_id];
195 }
196
197 CALL_ONREQUEST(RIL_REQUEST_CONFIG_SET_SLOT_MAPPING, pSlotMap,
198 slotNum * sizeof(int), pRI, pRI->socket_id);
199 if (pSlotMap != NULL) {
200 free(pSlotMap);
201 }
202
203 return Void();
204 }
205
getPhoneCapability(int32_t serial)206 Return<void> RadioConfigImpl::getPhoneCapability(int32_t serial) {
207 #if VDBG
208 RLOGD("getPhoneCapability: serial %d", serial);
209 #endif
210 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFIG_GET_PHONE_CAPABILITY);
211 return Void();
212 }
213
setPreferredDataModem(int32_t serial,uint8_t modemId)214 Return<void> RadioConfigImpl::setPreferredDataModem(int32_t serial, uint8_t modemId) {
215 #if VDBG
216 RLOGD("setPreferredDataModem: serial %d", serial);
217 #endif
218 dispatchInts(serial, mSlotId, RIL_REQUEST_CONFIG_SET_PREFER_DATA_MODEM, 1, modemId);
219 return Void();
220 }
221
setModemsConfig(int32_t serial,const V1_1::ModemsConfig & modemsConfig)222 Return<void> RadioConfigImpl::setModemsConfig(int32_t serial, const V1_1::ModemsConfig& modemsConfig) {
223 #if VDBG
224 RLOGD("setModemsConfig: serial %d", serial);
225 #endif
226 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
227 RIL_REQUEST_CONFIG_SET_MODEM_CONFIG);
228 if (pRI == NULL) {
229 return Void();
230 }
231
232 RIL_ModemConfig mdConfig = {};
233
234 mdConfig.numOfLiveModems = modemsConfig.numOfLiveModems;
235
236
237 CALL_ONREQUEST(RIL_REQUEST_CONFIG_SET_MODEM_CONFIG, &mdConfig,
238 sizeof(RIL_ModemConfig), pRI, pRI->socket_id);
239
240 return Void();
241 }
242
getModemsConfig(int32_t serial)243 Return<void> RadioConfigImpl::getModemsConfig(int32_t serial) {
244 #if VDBG
245 RLOGD("getModemsConfig: serial %d", serial);
246 #endif
247 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFIG_GET_MODEM_CONFIG);
248 return Void();
249 }
250
getHalDeviceCapabilities(int32_t serial)251 Return<void> RadioConfigImpl::getHalDeviceCapabilities(int32_t serial) {
252 #if VDBG
253 RLOGD("getHalDeviceCapabilities: serial %d", serial);
254 #endif
255 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFIG_GET_HAL_DEVICE_CAPABILITIES);
256 return Void();
257 }
258
registerConfigService(RIL_RadioFunctions * callbacks,CommandInfo * commands)259 void radio_1_6::registerConfigService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
260 using namespace android::hardware;
261 RLOGD("Entry %s", __FUNCTION__);
262 const char *serviceNames = "default";
263
264 s_vendorFunctions_config = callbacks;
265 s_configCommands = commands;
266
267 int slotId = RIL_SOCKET_1;
268
269 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(0);
270 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
271 assert(ret == 0);
272 RLOGD("registerConfigService: starting V1_2::IConfigRadio %s", serviceNames);
273 radioConfigService = new RadioConfigImpl;
274
275 radioConfigService->mSlotId = slotId;
276 radioConfigService->mRadioConfigResponse = NULL;
277 radioConfigService->mRadioConfigIndication = NULL;
278 radioConfigService->mRadioConfigResponseV1_1 = NULL;
279 radioConfigService->mRadioConfigResponseV1_2 = NULL;
280 radioConfigService->mRadioConfigResponseV1_3 = NULL;
281 radioConfigService->mRadioConfigIndicationV1_2 = NULL;
282 android::status_t status = radioConfigService->registerAsService(serviceNames);
283 RLOGD("registerConfigService registerService: status %d", status);
284 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
285 assert(ret == 0);
286 }
287
checkReturnStatus(Return<void> & ret)288 void checkReturnStatus(Return<void>& ret) {
289 if (ret.isOk() == false) {
290 RLOGE("checkReturnStatus_config: unable to call response/indication callback");
291 // Remote process hosting the callbacks must be dead. Reset the callback objects;
292 // there's no other recovery to be done here. When the client process is back up, it will
293 // call setResponseFunctions()
294
295 // Caller should already hold rdlock, release that first
296 // note the current counter to avoid overwriting updates made by another thread before
297 // write lock is acquired.
298 int counter = mCounterRadioConfig;
299 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_6::getRadioServiceRwlock(0);
300 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
301 assert(ret == 0);
302
303 // acquire wrlock
304 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
305 assert(ret == 0);
306
307 // make sure the counter value has not changed
308 if (counter == mCounterRadioConfig) {
309 radioConfigService->mRadioConfigResponse = NULL;
310 radioConfigService->mRadioConfigIndication = NULL;
311 radioConfigService->mRadioConfigResponseV1_1 = NULL;
312 radioConfigService->mRadioConfigResponseV1_2 = NULL;
313 radioConfigService->mRadioConfigResponseV1_3 = NULL;
314 radioConfigService->mRadioConfigIndicationV1_2 = NULL;
315 mCounterRadioConfig++;
316 } else {
317 RLOGE("checkReturnStatus_config: not resetting responseFunctions as they likely "
318 "got updated on another thread");
319 }
320
321 // release wrlock
322 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
323 assert(ret == 0);
324
325 // Reacquire rdlock
326 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
327 assert(ret == 0);
328 }
329 }
330
checkReturnStatus_config(Return<void> & ret)331 void RadioConfigImpl::checkReturnStatus_config(Return<void>& ret) {
332 ::checkReturnStatus(ret);
333 }
334
getSimSlotsStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)335 int radio_1_6::getSimSlotsStatusResponse(int slotId, int responseType, int serial,
336 RIL_Errno e, void *response, size_t responseLen) {
337 #if VDBG
338 RLOGD("getSimSlotsResponse: serial %d", serial);
339 #endif
340
341 if (radioConfigService->mRadioConfigResponse != NULL) {
342 RadioResponseInfo responseInfo = {};
343 populateResponseInfo(responseInfo, serial, responseType, e);
344 hidl_vec<SimSlotStatus> simSlotStatus = {};
345
346 if ((response == NULL) || (responseLen % sizeof(RIL_SimSlotStatus_V1_2) != 0)) {
347 RLOGE("getSimSlotsStatusResponse: Invalid response");
348 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
349 } else {
350 RIL_SimSlotStatus_V1_2 *psimSlotStatus = ((RIL_SimSlotStatus_V1_2 *) response);
351 int num = responseLen / sizeof(RIL_SimSlotStatus_V1_2);
352 simSlotStatus.resize(num);
353 for (int i = 0; i < num; i++) {
354 simSlotStatus[i].cardState = (CardState)psimSlotStatus->base.cardState;
355 simSlotStatus[i].slotState = (SlotState)psimSlotStatus->base.slotState;
356 simSlotStatus[i].atr = convertCharPtrToHidlString(psimSlotStatus->base.atr);
357 simSlotStatus[i].logicalSlotId = psimSlotStatus->base.logicalSlotId;
358 simSlotStatus[i].iccid = convertCharPtrToHidlString(psimSlotStatus->base.iccid);
359 psimSlotStatus += 1;
360 }
361 }
362 Return<void> retStatus = radioConfigService->mRadioConfigResponse->getSimSlotsStatusResponse(
363 responseInfo, simSlotStatus);
364 radioConfigService->checkReturnStatus_config(retStatus);
365 } else {
366 RLOGE("getSimSlotsResponse: radioConfigService->mRadioConfigResponse == NULL");
367 }
368
369 return 0;
370 }
371
setSimSlotsMappingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)372 int radio_1_6::setSimSlotsMappingResponse(int slotId, int responseType, int serial,
373 RIL_Errno e, void *response, size_t responseLen) {
374 #if VDBG
375 RLOGD("setSimSlotsMappingResponse: serial %d", serial);
376 #endif
377
378 if (radioConfigService->mRadioConfigResponse != NULL) {
379 RadioResponseInfo responseInfo = {};
380 populateResponseInfo(responseInfo, serial, responseType, e);
381 Return<void> retStatus = radioConfigService->mRadioConfigResponse->setSimSlotsMappingResponse(
382 responseInfo);
383 radioConfigService->checkReturnStatus_config(retStatus);
384 } else {
385 RLOGE("setSimSlotsMappingResponse: radioConfigService->mRadioConfigResponse == NULL");
386 }
387
388 return 0;
389 }
390
getPhoneCapabilityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)391 int radio_1_6::getPhoneCapabilityResponse(int slotId, int responseType, int serial,
392 RIL_Errno e, void *response, size_t responseLen) {
393 #if VDBG
394 RLOGD("getPhoneCapabilityResponse: serial %d", serial);
395 #endif
396
397 if (radioConfigService->mRadioConfigResponseV1_1 != NULL) {
398 RadioResponseInfo responseInfo = {};
399 populateResponseInfo(responseInfo, serial, responseType, e);
400 V1_1::PhoneCapability phoneCapability = {};
401 if ((response == NULL) || (responseLen % sizeof(RIL_PhoneCapability) != 0)) {
402 RLOGE("getPhoneCapabilityResponse Invalid response: NULL");
403 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
404 } else {
405 RIL_PhoneCapability *pCapability = (RIL_PhoneCapability *)response;
406 phoneCapability.maxActiveData = pCapability->maxActiveData;
407 phoneCapability.maxActiveInternetData = pCapability->maxActiveInternetData;
408 phoneCapability.isInternetLingeringSupported = pCapability->isInternetLingeringSupported;
409 phoneCapability.logicalModemList.resize(SIM_COUNT);
410 for (int i = 0 ; i < SIM_COUNT; i++) {
411 RIL_ModemInfo logicalModemInfo = pCapability->logicalModemList[i];
412 phoneCapability.logicalModemList[i].modemId = logicalModemInfo.modemId;
413 }
414 }
415 Return<void> retStatus = radioConfigService->mRadioConfigResponseV1_1->getPhoneCapabilityResponse(
416 responseInfo, phoneCapability);
417 radioConfigService->checkReturnStatus_config(retStatus);
418 } else {
419 RLOGE("getPhoneCapabilityResponse: radioConfigService->mRadioConfigResponseV1_1 == NULL");
420 }
421
422 return 0;
423 }
424
setPreferredDataModemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)425 int radio_1_6::setPreferredDataModemResponse(int slotId, int responseType, int serial,
426 RIL_Errno e, void *response, size_t responseLen) {
427 #if VDBG
428 RLOGD("setPreferredDataModemResponse: serial %d", serial);
429 #endif
430
431 if (radioConfigService->mRadioConfigResponseV1_1 != NULL) {
432 RadioResponseInfo responseInfo = {};
433 populateResponseInfo(responseInfo, serial, responseType, e);
434 Return<void> retStatus = radioConfigService->mRadioConfigResponseV1_1->setPreferredDataModemResponse(
435 responseInfo);
436 radioConfigService->checkReturnStatus_config(retStatus);
437 } else {
438 RLOGE("setPreferredDataModemResponse: radioConfigService->mRadioConfigResponseV1_1 == NULL");
439 }
440
441 return 0;
442 }
443
setModemsConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)444 int radio_1_6::setModemsConfigResponse(int slotId, int responseType, int serial,
445 RIL_Errno e, void *response, size_t responseLen) {
446 #if VDBG
447 RLOGD("setModemsConfigResponse: serial %d", serial);
448 #endif
449
450 if (radioConfigService->mRadioConfigResponseV1_1 != NULL) {
451 RadioResponseInfo responseInfo = {};
452 populateResponseInfo(responseInfo, serial, responseType, e);
453 Return<void> retStatus = radioConfigService->mRadioConfigResponseV1_1->setModemsConfigResponse(
454 responseInfo);
455 radioConfigService->checkReturnStatus_config(retStatus);
456 } else {
457 RLOGE("setModemsConfigResponse: radioConfigService->mRadioConfigResponseV1_1 == NULL");
458 }
459
460 return 0;
461 }
462
getModemsConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)463 int radio_1_6::getModemsConfigResponse(int slotId, int responseType, int serial,
464 RIL_Errno e, void *response, size_t responseLen) {
465 #if VDBG
466 RLOGD("getModemsConfigResponse: serial %d", serial);
467 #endif
468
469 if (radioConfigService->mRadioConfigResponseV1_1 != NULL) {
470 RadioResponseInfo responseInfo = {};
471 populateResponseInfo(responseInfo, serial, responseType, e);
472 V1_1::ModemsConfig mdCfg = {};
473 RIL_ModemConfig *pMdCfg = (RIL_ModemConfig *)response;
474 if ((response == NULL) || (responseLen != sizeof(RIL_ModemConfig))) {
475 RLOGE("getModemsConfigResponse Invalid response: NULL");
476 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
477 } else {
478 mdCfg.numOfLiveModems = pMdCfg->numOfLiveModems;
479 }
480 Return<void> retStatus = radioConfigService->mRadioConfigResponseV1_1->getModemsConfigResponse(
481 responseInfo, mdCfg);
482 radioConfigService->checkReturnStatus_config(retStatus);
483 } else {
484 RLOGE("getModemsConfigResponse: radioConfigService->mRadioConfigResponseV1_1 == NULL");
485 }
486
487 return 0;
488 }
489
getHalDeviceCapabilitiesResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)490 int radio_1_6::getHalDeviceCapabilitiesResponse(int slotId, int responseType, int serial,
491 RIL_Errno e, void *response, size_t responseLen) {
492 #if VDBG
493 RLOGD("getHalDeviceCapabilitiesResponse: serial %d", serial);
494 #endif
495
496 if (radioConfigService->mRadioConfigResponseV1_3 != NULL) {
497 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo = {};
498 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
499
500 bool modemReducedFeatureSet1 = false;
501 if (response == NULL || responseLen != sizeof(bool)) {
502 RLOGE("getHalDeviceCapabilitiesResponse Invalid response.");
503 } else {
504 modemReducedFeatureSet1 = (*((bool *) response));
505 }
506
507 Return<void> retStatus = radioConfigService->mRadioConfigResponseV1_3->getHalDeviceCapabilitiesResponse(
508 responseInfo, modemReducedFeatureSet1);
509 radioConfigService->checkReturnStatus_config(retStatus);
510 } else {
511 RLOGE("getHalDeviceCapabilitiesResponse: radioConfigService->getHalDeviceCapabilities == NULL");
512 }
513
514 return 0;
515 }
516
simSlotsStatusChanged(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)517 int radio_1_6::simSlotsStatusChanged(int slotId, int indicationType, int token, RIL_Errno e,
518 void *response, size_t responseLen) {
519 if (radioConfigService != NULL &&
520 (radioConfigService->mRadioConfigIndication != NULL ||
521 radioConfigService->mRadioConfigIndicationV1_2 != NULL)) {
522 if ((response == NULL) || (responseLen % sizeof(RIL_SimSlotStatus_V1_2) != 0)) {
523 RLOGE("simSlotsStatusChanged: invalid response");
524 return 0;
525 }
526
527 RIL_SimSlotStatus_V1_2 *psimSlotStatus = ((RIL_SimSlotStatus_V1_2 *)response);
528 int num = responseLen / sizeof(RIL_SimSlotStatus_V1_2);
529 if (radioConfigService->mRadioConfigIndication != NULL) {
530 hidl_vec<SimSlotStatus> simSlotStatus = {};
531 simSlotStatus.resize(num);
532 for (int i = 0; i < num; i++) {
533 simSlotStatus[i].cardState = (CardState) psimSlotStatus->base.cardState;
534 simSlotStatus[i].slotState = (SlotState) psimSlotStatus->base.slotState;
535 simSlotStatus[i].atr = convertCharPtrToHidlString(psimSlotStatus->base.atr);
536 simSlotStatus[i].logicalSlotId = psimSlotStatus->base.logicalSlotId;
537 simSlotStatus[i].iccid = convertCharPtrToHidlString(psimSlotStatus->base.iccid);
538 #if VDBG
539 RLOGD("simSlotsStatusChanged: cardState %d slotState %d", simSlotStatus[i].cardState,
540 simSlotStatus[i].slotState);
541 #endif
542 psimSlotStatus += 1;
543 }
544
545 Return<void> retStatus = radioConfigService->mRadioConfigIndication->simSlotsStatusChanged(
546 convertIntToRadioIndicationType(indicationType), simSlotStatus);
547 radioConfigService->checkReturnStatus_config(retStatus);
548 } else if (radioConfigService->mRadioConfigIndicationV1_2) {
549 hidl_vec<V1_2::SimSlotStatus> simSlotStatus;
550 simSlotStatus.resize(num);
551 for (int i = 0; i < num; i++) {
552 simSlotStatus[i].base.cardState = (CardState)(psimSlotStatus->base.cardState);
553 simSlotStatus[i].base.slotState = (SlotState) psimSlotStatus->base.slotState;
554 simSlotStatus[i].base.atr = convertCharPtrToHidlString(psimSlotStatus->base.atr);
555 simSlotStatus[i].base.logicalSlotId = psimSlotStatus->base.logicalSlotId;
556 simSlotStatus[i].base.iccid = convertCharPtrToHidlString(psimSlotStatus->base.iccid);
557 simSlotStatus[i].eid = convertCharPtrToHidlString(psimSlotStatus->eid);
558 psimSlotStatus += 1;
559 #if VDBG
560 RLOGD("simSlotsStatusChanged_1_2: cardState %d slotState %d",
561 simSlotStatus[i].base.cardState, simSlotStatus[i].base.slotState);
562 #endif
563 }
564
565 Return<void> retStatus = radioConfigService->mRadioConfigIndicationV1_2->simSlotsStatusChanged_1_2(
566 convertIntToRadioIndicationType(indicationType), simSlotStatus);
567 radioConfigService->checkReturnStatus_config(retStatus);
568 }
569 } else {
570 RLOGE("simSlotsStatusChanged: radioService->mRadioIndication == NULL");
571 }
572
573 return 0;
574 }
575