From 93f603c4e168c30fbc1366c1b6c6ac0f0a4b4b6e Mon Sep 17 00:00:00 2001 From: Amit Mahajan Date: Mon, 15 May 2017 16:41:44 -0700 Subject: [PATCH] Fix multi sim support and warnings in new hal code. Test: Basic telephony sanity for single sim Bug: 38228839 Merged-in: I7df7ed41354b50f335a6f5fba7dffde03127b4f1 Change-Id: I7df7ed41354b50f335a6f5fba7dffde03127b4f1 --- include/telephony/ril.h | 3 +- libril/Android.mk | 2 +- libril/ril.cpp | 4 --- libril/ril_service.cpp | 83 ++++++++++++++++++++++++++++--------------------- rild/Android.mk | 2 +- 5 files changed, 51 insertions(+), 43 deletions(-) diff --git a/include/telephony/ril.h b/include/telephony/ril.h index 40745a0..5b1e2d6 100644 --- a/include/telephony/ril.h +++ b/include/telephony/ril.h @@ -31,7 +31,7 @@ extern "C" { #endif - +#ifndef SIM_COUNT #if defined(ANDROID_SIM_COUNT_2) #define SIM_COUNT 2 #elif defined(ANDROID_SIM_COUNT_3) @@ -45,6 +45,7 @@ extern "C" { #ifndef ANDROID_MULTI_SIM #define SIM_COUNT 1 #endif +#endif /* * RIL version. diff --git a/libril/Android.mk b/libril/Android.mk index 952e6be..3ba5bba 100644 --- a/libril/Android.mk +++ b/libril/Android.mk @@ -27,10 +27,10 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \ libprotobuf-c-nano-enable_malloc \ -#LOCAL_CFLAGS := -DANDROID_MULTI_SIM -DDSDA_RILD1 LOCAL_CFLAGS += -Wno-unused-parameter ifeq ($(SIM_COUNT), 2) + LOCAL_CFLAGS += -DANDROID_MULTI_SIM -DDSDA_RILD1 LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 endif diff --git a/libril/ril.cpp b/libril/ril.cpp index 45a06c0..6366920 100644 --- a/libril/ril.cpp +++ b/libril/ril.cpp @@ -192,12 +192,8 @@ extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, #if defined(ANDROID_MULTI_SIM) #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c), (d)) -#define CALL_ONREQUEST(a, b, c, d, e) s_callbacks.onRequest((a), (b), (c), (d), (e)) -#define CALL_ONSTATEREQUEST(a) s_callbacks.onStateRequest(a) #else #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c)) -#define CALL_ONREQUEST(a, b, c, d, e) s_callbacks.onRequest((a), (b), (c), (d)) -#define CALL_ONSTATEREQUEST(a) s_callbacks.onStateRequest() #endif static UserCallbackInfo * internalRequestTimedCallback diff --git a/libril/ril_service.cpp b/libril/ril_service.cpp index 7837897..40333bf 100644 --- a/libril/ril_service.cpp +++ b/libril/ril_service.cpp @@ -49,6 +49,15 @@ using android::sp; #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1) #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal) +#if defined(ANDROID_MULTI_SIM) +#define CALL_ONREQUEST(a, b, c, d, e) \ + s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e))) +#define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a)) +#else +#define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d)) +#define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest() +#endif + RIL_RadioFunctions *s_vendorFunctions = NULL; static CommandInfo *s_commands; @@ -500,7 +509,7 @@ bool dispatchVoid(int serial, int slotId, int request) { if (pRI == NULL) { return false; } - s_vendorFunctions->onRequest(request, NULL, 0, pRI); + CALL_ONREQUEST(request, NULL, 0, pRI, slotId); return true; } @@ -515,7 +524,7 @@ bool dispatchString(int serial, int slotId, int request, const char * str) { return false; } - s_vendorFunctions->onRequest(request, pString, sizeof(char *), pRI); + CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId); memsetAndFreeStrings(1, pString); return true; @@ -549,7 +558,7 @@ bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) } va_end(ap); - s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI); + CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId); if (pStrings != NULL) { for (int i = 0 ; i < countStrings ; i++) { @@ -589,7 +598,7 @@ bool dispatchStrings(int serial, int slotId, int request, const hidl_veconRequest(request, pStrings, countStrings * sizeof(char *), pRI); + CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId); if (pStrings != NULL) { for (int i = 0 ; i < countStrings ; i++) { @@ -624,7 +633,7 @@ bool dispatchInts(int serial, int slotId, int request, int countInts, ...) { } va_end(ap); - s_vendorFunctions->onRequest(request, pInts, countInts * sizeof(int), pRI); + CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId); if (pInts != NULL) { #ifdef MEMSET_FREED @@ -653,7 +662,7 @@ bool dispatchCallForwardStatus(int serial, int slotId, int request, return false; } - s_vendorFunctions->onRequest(request, &cf, sizeof(cf), pRI); + CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId); memsetAndFreeStrings(1, cf.number); @@ -668,7 +677,7 @@ bool dispatchRaw(int serial, int slotId, int request, const hidl_vec& r const uint8_t *uData = rawBytes.data(); - s_vendorFunctions->onRequest(request, (void *) uData, rawBytes.size(), pRI); + CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId); return true; } @@ -692,7 +701,7 @@ bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message return false; } - s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI); + CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId); memsetAndFreeStrings(1, apdu.data); @@ -890,7 +899,7 @@ Return RadioImpl::dial(int32_t serial, const Dial& dialInfo) { dial.uusInfo = &uusInfo; } - s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI); + CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId); memsetAndFreeStrings(2, dial.address, uusInfo.uusData); @@ -1135,7 +1144,7 @@ Return RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) { return Void(); } - s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI); + CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId); memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr); @@ -1402,7 +1411,7 @@ Return RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWri return Void(); } - s_vendorFunctions->onRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI); + CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId); memsetAndFreeStrings(2, args.smsc, args.pdu); @@ -1621,7 +1630,7 @@ Return RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) { RIL_CDMA_SMS_Message rcsm = {}; constructCdmaSms(rcsm, sms); - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId); return Void(); } @@ -1639,7 +1648,7 @@ Return RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const Cdm rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass; rcsa.uSMSCauseCode = smsAck.smsCauseCode; - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId); return Void(); } @@ -1676,8 +1685,8 @@ Return RadioImpl::setGsmBroadcastConfig(int32_t serial, gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, gsmBciPtrs, - num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs, + num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId); return Void(); } @@ -1721,8 +1730,8 @@ Return RadioImpl::setCdmaBroadcastConfig(int32_t serial, cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, cdmaBciPtrs, - num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs, + num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId); return Void(); } @@ -1757,7 +1766,7 @@ Return RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& c rcsw.status = (int) cdmaSms.status; constructCdmaSms(rcsw.message, cdmaSms.message); - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId); return Void(); } @@ -1914,7 +1923,7 @@ Return RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInf return Void(); } - s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI); + CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId); memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password); } else { @@ -1958,7 +1967,7 @@ Return RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInf return Void(); } - s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI); + CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId); memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username, iaa.password, iaa.mvnoMatchData); @@ -2017,8 +2026,8 @@ bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) { } rism.message.gsmMessage = pStrings; - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + - sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + + sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id); for (int i = 0 ; i < countStrings ; i++) { memsetAndFreeStrings(1, pStrings[i]); @@ -2049,8 +2058,8 @@ bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) { constructCdmaSms(rcsm, message.cdmaMessage[0]); - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + - sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + + sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI, pRI->socket_id); return true; } @@ -2106,7 +2115,7 @@ Return RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& return Void(); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId); memsetAndFreeStrings(1, params.aidPtr); } @@ -2141,7 +2150,7 @@ Return RadioImpl::nvReadItem(int32_t serial, NvItem itemId) { RIL_NV_ReadItem nvri = {}; nvri.itemID = (RIL_NV_Item) itemId; - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId); return Void(); } @@ -2162,7 +2171,7 @@ Return RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) { return Void(); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId); memsetAndFreeStrings(1, nvwi.value); return Void(); @@ -2219,7 +2228,7 @@ Return RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType; rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus; - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId); return Void(); } @@ -2263,7 +2272,7 @@ Return RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t auth return Void(); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId); memsetAndFreeStrings(2, pf.authData, pf.aid); return Void(); @@ -2374,8 +2383,8 @@ Return RadioImpl::setDataProfile(int32_t serial, const hidl_veconRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs, - num * sizeof(RIL_DataProfileInfo *), pRI); + CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs, + num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId); freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4, &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol, @@ -2452,8 +2461,8 @@ Return RadioImpl::setDataProfile(int32_t serial, const hidl_veconRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs, - num * sizeof(RIL_DataProfileInfo_v15 *), pRI); + CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs, + num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId); freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6, &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol, @@ -2498,7 +2507,7 @@ Return RadioImpl::setRadioCapability(int32_t serial, const RadioCapability rilRc.status = (int) rc.status; strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH); - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId); return Void(); } @@ -2590,7 +2599,7 @@ Return RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed, excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str(); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId); #ifdef MEMSET_FREED memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier)); @@ -2817,6 +2826,7 @@ int radio::supplyIccPinForAppResponse(int slotId, int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen); Return retStatus = radioService[slotId]->mRadioResponse-> supplyIccPinForAppResponse(responseInfo, ret); + RLOGE("supplyIccPinForAppResponse: amit ret %d", ret); radioService[slotId]->checkReturnStatus(retStatus); } else { RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL", @@ -6374,7 +6384,8 @@ int radio::radioStateChangedInd(int slotId, int indicationType, int token, RIL_Errno e, void *response, size_t responseLen) { if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { - RadioState radioState = (RadioState) s_vendorFunctions->onStateRequest(); + RadioState radioState = + (RadioState) CALL_ONSTATEREQUEST(slotId); RLOGD("radioStateChangedInd: radioState %d", radioState); Return retStatus = radioService[slotId]->mRadioIndication->radioStateChanged( convertIntToRadioIndicationType(indicationType), radioState); diff --git a/rild/Android.mk b/rild/Android.mk index abcc522..4f5802b 100644 --- a/rild/Android.mk +++ b/rild/Android.mk @@ -17,9 +17,9 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \ librilutils_static LOCAL_CFLAGS := -DRIL_SHLIB -#LOCAL_CFLAGS += -DANDROID_MULTI_SIM ifeq ($(SIM_COUNT), 2) + LOCAL_CFLAGS += -DANDROID_MULTI_SIM LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 endif -- 2.11.0