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