sp<RadioImpl> radioService[1];
#endif
+static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
+
+#if (SIM_COUNT >= 2)
+static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
+#if (SIM_COUNT >= 3)
+static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
+#if (SIM_COUNT >= 4)
+static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
+#endif
+#endif
+#endif
+
struct RadioImpl : public IRadio {
int32_t mSlotId;
+ // counter used for synchronization. It is incremented every time mRadioResponse or
+ // mRadioIndication value is updated.
+ volatile int32_t mCounter;
sp<IRadioResponse> mRadioResponse;
sp<IRadioIndication> mRadioIndication;
// Remote process (RIL.java) hosting the callbacks must be dead. Reset the callback objects;
// there's no other recovery to be done here. When the client process is back up, it will
// call setResponseFunctions()
- mRadioResponse = NULL;
- mRadioIndication = NULL;
+
+ // Caller should already hold rdlock, release that first
+ // note the current counter to avoid overwriting updates made by another thread before
+ // write lock is acquired.
+ int counter = mCounter;
+ pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
+ int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
+ assert(ret == 0);
+
+ // acquire wrlock
+ ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
+ assert(ret == 0);
+
+ // make sure the counter value has not changed
+ if (counter == mCounter) {
+ mRadioResponse = NULL;
+ mRadioIndication = NULL;
+ mCounter++;
+ } else {
+ RLOGE("checkReturnStatus: not resetting responseFunctions as they likely got updated"
+ "on another thread");
+ }
+
+ // release wrlock
+ ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
+ assert(ret == 0);
+
+ // Reacquire rdlock
+ ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
+ assert(ret == 0);
}
}
const ::android::sp<IRadioResponse>& radioResponseParam,
const ::android::sp<IRadioIndication>& radioIndicationParam) {
RLOGD("RadioImpl::setResponseFunctions");
+
+ pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
+ int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
+ assert(ret == 0);
+
mRadioResponse = radioResponseParam;
mRadioIndication = radioIndicationParam;
+ mCounter++;
+
+ ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
+ assert(ret == 0);
+
return Status::ok();
}
}
void radio::radioStateChangedInd(int slotId, int indicationType, RIL_RadioState radioState) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::radioStateChangedInd: radioState %d", radioState);
Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
convertIntToRadioIndicationType(indicationType), (RadioState) radioState);
int radio::callStateChangedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::callStateChangedInd");
Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
convertIntToRadioIndicationType(indicationType));
int radio::voiceNetworkStateChangedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::voiceNetworkStateChangedInd");
Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceNetworkStateChanged(
convertIntToRadioIndicationType(indicationType));
int radio::newSmsInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
int token, RIL_Errno e, void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen == 0) {
RLOGE("radio::newSmsInd: invalid response");
return 0;
int radio::newSmsStatusReportInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen == 0) {
RLOGE("radio::newSmsStatusReportInd: invalid response");
return 0;
int radio::newSmsOnSimInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
int token, RIL_Errno e, void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(int)) {
RLOGE("radio::newSmsOnSimInd: invalid response");
return 0;
int radio::onUssdInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
int token, RIL_Errno e, void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != 2 * sizeof(char *)) {
RLOGE("radio::onUssdInd: invalid response");
return 0;
int radio::nitzTimeReceivedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen == 0) {
RLOGE("radio::nitzTimeReceivedInd: invalid response");
return 0;
int radio::currentSignalStrengthInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e,
void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
RLOGE("radio::currentSignalStrengthInd: invalid response");
return 0;
int radio::dataCallListChangedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
RLOGE("radio::dataCallListChangedInd: invalid response");
return 0;
int radio::suppSvcNotifyInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
int token, RIL_Errno e, void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
RLOGE("radio::suppSvcNotifyInd: invalid response");
return 0;
int radio::stkSessionEndInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
int token, RIL_Errno e, void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::stkSessionEndInd");
Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
convertIntToRadioIndicationType(indicationType));
int radio::stkProactiveCommandInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen == 0) {
RLOGE("radio::stkProactiveCommandInd: invalid response");
return 0;
int radio::stkEventNotifyInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
int token, RIL_Errno e, void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen == 0) {
RLOGE("radio::stkEventNotifyInd: invalid response");
return 0;
int radio::stkCallSetupInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
int token, RIL_Errno e, void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(int)) {
RLOGE("radio::stkCallSetupInd: invalid response");
return 0;
int radio::simSmsStorageFullInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::simSmsStorageFullInd");
Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
convertIntToRadioIndicationType(indicationType));
int radio::simRefreshInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
int token, RIL_Errno e, void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
RLOGE("radio::simRefreshInd: invalid response");
return 0;
int radio::callRingInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
int token, RIL_Errno e, void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
bool isGsm;
CdmaSignalInfoRecord record;
if (response == NULL || responseLen == 0) {
int radio::simStatusChangedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::simStatusChangedInd");
Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
convertIntToRadioIndicationType(indicationType));
int radio::cdmaNewSmsInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
int token, RIL_Errno e, void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
RLOGE("radio::cdmaNewSmsInd: invalid response");
return 0;
int radio::newBroadcastSmsInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen == 0) {
RLOGE("radio::newBroadcastSmsInd: invalid response");
return 0;
int radio::cdmaRuimSmsStorageFullInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::cdmaRuimSmsStorageFullInd");
Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
convertIntToRadioIndicationType(indicationType));
int radio::restrictedStateChangedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(int)) {
RLOGE("radio::restrictedStateChangedInd: invalid response");
return 0;
int radio::enterEmergencyCallbackModeInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::enterEmergencyCallbackModeInd");
Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
convertIntToRadioIndicationType(indicationType));
int radio::cdmaCallWaitingInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
RLOGE("radio::cdmaCallWaitingInd: invalid response");
return 0;
int radio::cdmaOtaProvisionStatusInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(int)) {
RLOGE("radio::cdmaOtaProvisionStatusInd: invalid response");
return 0;
int radio::cdmaInfoRecInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
RLOGE("radio::cdmaInfoRecInd: invalid response");
return 0;
int radio::oemHookRawInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen == 0) {
RLOGE("radio::oemHookRawInd: invalid response");
return 0;
int radio::indicateRingbackToneInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(int)) {
RLOGE("radio::indicateRingbackToneInd: invalid response");
return 0;
int radio::resendIncallMuteInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::resendIncallMuteInd");
Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
convertIntToRadioIndicationType(indicationType));
int radio::cdmaSubscriptionSourceChangedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e,
void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(int)) {
RLOGE("radio::cdmaSubscriptionSourceChangedInd: invalid response");
return 0;
int radio::cdmaPrlChangedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(int)) {
RLOGE("radio::cdmaPrlChangedInd: invalid response");
return 0;
int radio::exitEmergencyCallbackModeInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::exitEmergencyCallbackModeInd");
Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
convertIntToRadioIndicationType(indicationType));
int radio::rilConnectedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::rilConnectedInd");
Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
convertIntToRadioIndicationType(indicationType));
int radio::voiceRadioTechChangedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(int)) {
RLOGE("radio::voiceRadioTechChangedInd: invalid response");
return 0;
int radio::cellInfoListInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
RLOGE("radio::cellInfoListInd: invalid response");
return 0;
int radio::imsNetworkStateChangedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
RLOGD("radio::imsNetworkStateChangedInd");
Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
convertIntToRadioIndicationType(indicationType));
int radio::subscriptionStatusChangedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(int)) {
RLOGE("radio::subscriptionStatusChangedInd: invalid response");
return 0;
int radio::srvccStateNotifyInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(int)) {
RLOGE("radio::srvccStateNotifyInd: invalid response");
return 0;
int radio::hardwareConfigChangedInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
RLOGE("radio::hardwareConfigChangedInd: invalid response");
return 0;
int radio::radioCapabilityIndicationInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
RLOGE("radio::radioCapabilityIndicationInd: invalid response");
return 0;
int radio::onSupplementaryServiceIndicationInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e,
void *response, size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
RLOGE("radio::onSupplementaryServiceIndicationInd: invalid response");
return 0;
int radio::stkCallControlAlphaNotifyInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen == 0) {
RLOGE("radio::stkCallControlAlphaNotifyInd: invalid response");
return 0;
int radio::lceDataInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
RLOGE("radio::lceDataInd: invalid response");
return 0;
int radio::pcoDataInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
RLOGE("radio::pcoDataInd: invalid response");
return 0;
int radio::modemResetInd(android::Parcel &p, int slotId, int requestNumber,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
- if (radioService[slotId]->mRadioIndication != NULL) {
+ if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
if (response == NULL || responseLen == 0) {
RLOGE("radio::modemResetInd: invalid response");
return 0;
configureRpcThreadpool(1, true /* callerWillJoin */);
for (int i = 0; i < simCount; i++) {
+ pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
+ int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
+ assert(ret == 0);
+
radioService[i] = new RadioImpl;
radioService[i]->mSlotId = i;
RLOGD("radio::registerService: starting IRadio %s", serviceNames[i]);
android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
+
+ ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
+ assert(ret == 0);
}
s_callbacks = callbacks;
void rilc_thread_pool() {
joinRpcThreadpool();
+}
+
+pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
+ pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
+
+ #if (SIM_COUNT >= 2)
+ if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
+ #if (SIM_COUNT >= 3)
+ if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
+ #if (SIM_COUNT >= 4)
+ if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
+ #endif
+ #endif
+ #endif
+
+ return radioServiceRwlockPtr;
}
\ No newline at end of file