extern int rilCcUnsolicited(const char *s, const char *sms_pdu, RILChannelCtx *p_channel) { RILId rid = getRILIdByChannelCtx(p_channel); /* MTK proprietary start */ if (strStartsWith(s, "RING") || strStartsWith(s, "+CRING")) { LOGD("receiving RING!!!!!!"); if (!hasReceivedRing) { LOGD("receiving first RING!!!!!!"); hasReceivedRing = 1; } if (setupCpiData[0] != NULL) { LOGD("sending ECPI!!!!!!"); RIL_onUnsolicitedResponse(RIL_UNSOL_CALL_PROGRESS_INFO, setupCpiData, 9 * sizeof(char *), rid); int i; for (i = 0; i < 9; i++) { free(setupCpiData[i]); setupCpiData[i] = NULL; } sleep(1); } #ifdef MTK_VT3G324M_SUPPORT if (strStartsWith(s, "+CRING: VIDEO")) { if (!isReplaceRequest) { RIL_onUnsolicitedResponse(RIL_UNSOL_VT_RING_INFO, NULL, 0, rid); } } else { #endif if (!isReplaceRequest) { RIL_onUnsolicitedResponse(RIL_UNSOL_CALL_RING, NULL, 0, rid); } #ifdef MTK_VT3G324M_SUPPORT } #endif return 1; } else if (strStartsWith(s, "+ECPI")) { onCallProgressInfo((char *)s, rid); return 1; } else if (strStartsWith(s, "+ESPEECH")) { onSpeechInfo((char *)s, rid); return 1; } else if (strStartsWith(s, "+EAIC")) { onIncomingCallIndication((char *)s, rid); return 1; } #ifdef MTK_VT3G324M_SUPPORT else if (strStartsWith(s, "+EVTSTATUS")) { onVtStatusInfo((char *)s, rid); return 1; } #endif return 0; /* MTK proprietary end */ }
/** * *EACE: Ringback tone received */ void onAudioCallEventNotify(const char *s) { char *line; char *tok; int err; int res; tok = line = strdup(s); err = at_tok_start(&tok); if (err < 0) goto error; err = at_tok_nextint(&tok, &res); if (err < 0) goto error; /* * *EACE:0/1 indicates stop/start of comfort tone. * *EACE:2 indicates voice call stopped. * *EACE:3 indicates voice call start, RIL uses this to inform Android * call state changed. This indicates call state has changed to ALERTING. */ if (res == 3) { #ifdef ENABLE_REPORTING_ALERTING_UPON_MISSING_CALL_STATE_FROM_NETWORK g_voice_call_start = true; #endif RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0); goto exit; } else if (res == 2) { #ifdef ENABLE_REPORTING_ALERTING_UPON_MISSING_CALL_STATE_FROM_NETWORK g_voice_call_start = false; #endif goto exit; } goto finally; error: LOGE("EACE: Failed to parse %s.", s); /* Stop a potential ringback tone from going forever due to failed parsing*/ res = 0; finally: RIL_onUnsolicitedResponse(RIL_UNSOL_RINGBACK_TONE, &res, sizeof(int *)); exit: free(line); return; }
static int onCmeError(char* s, char* sms_pdu) { char* line = NULL; int err; if (ussdStatus) { int code; line = strdup(s); at_tok_start(&line); err = at_tok_nextint(&line, &code); free(line); if (err < 0) goto out; if(code == 258 || code == 257 || code == 100){ char *responseStr[2]; responseStr[1] = NULL; asprintf(&responseStr[0], "%d", -1); RIL_onUnsolicitedResponse (RIL_UNSOL_ON_USSD, responseStr, 1*sizeof(char*)); } } out: return UNSOLICITED_SUCCESSED; }
void onStkCallControl(char* urc, RILChannelCtx* p_channel) { RIL_SOCKET_ID rid = getRILIdByChannelCtx(p_channel); int err, i = 0; char *p_cur = (char *)urc; char *responseStr[NUM_STK_CALL_CTRL] = {0}; LOGD("onStkCallControl URC = %s", urc); /** * +STKCTRL: <mmi_info_type>,"<alphs_id>","<address>or<ss string>or<ussd string>" **/ err = at_tok_start(&p_cur); if (err < 0) goto error; for (i = 0; i < NUM_STK_CALL_CTRL; i++) { err = at_tok_nextstr(&p_cur, &(responseStr[i])); if (err < 0) { //responseStr[i] = 0xFF; LOGE("There is something wrong with item [%d]",i); }//goto error; } RIL_onUnsolicitedResponse( RIL_UNSOL_STK_CALL_CTRL, responseStr, sizeof(responseStr), rid); return; error: LOGE("There is something wrong with the +STKCTRL"); }
void triggerUSSDNotification(void* param) { P_ND_USSD_STATUS pUssdStatus = (P_ND_USSD_STATUS)param; RIL_onUnsolicitedResponse (RIL_UNSOL_ON_USSD, pUssdStatus, sizeof(S_ND_USSD_POINTERS)); free(pUssdStatus); }
static int onNewMessageOrStatus(char* s, char* sms_pdu) { if (strStartsWith(s, "+CMT:")) { RIL_onUnsolicitedResponse ( RIL_UNSOL_RESPONSE_NEW_SMS, sms_pdu, strlen(sms_pdu)); } else if (strStartsWith(s, "+CDS:")) { RIL_onUnsolicitedResponse ( RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT, sms_pdu, strlen(sms_pdu)); } else if (strStartsWith(s, "+CMGR:")) { RIL_onUnsolicitedResponse ( RIL_UNSOL_RESPONSE_NEW_SMS, sms_pdu, strlen(sms_pdu)); } return UNSOLICITED_SUCCESSED; }
void reportSignalStrength(void *param) { ATResponse *p_response = NULL; int err, tmp; char *line; RIL_SignalStrength_v6 resp; memset(&resp,0,sizeof(resp)); resp.GW_SignalStrength.signalStrength = -1; resp.GW_SignalStrength.bitErrorRate = -1; resp.LTE_SignalStrength.signalStrength = -1; resp.LTE_SignalStrength.rsrp = -1; resp.LTE_SignalStrength.rsrq = -1; resp.LTE_SignalStrength.rssnr = -1; resp.LTE_SignalStrength.cqi = -1; err = at_send_command_singleline("AT+CSQ", "+CSQ:", &p_response); if (err < 0 || p_response->success == 0) { goto error; } line = p_response->p_intermediates->line; err = at_tok_start(&line); if (err < 0) goto error; err = at_tok_nextint(&line, &(resp.GW_SignalStrength.signalStrength)); if (err < 0) goto error; err = at_tok_nextint(&line, &(resp.GW_SignalStrength.bitErrorRate)); if (err < 0) goto error; at_response_free(p_response); p_response = NULL; if (param != NULL) resp.GW_SignalStrength.signalStrength = *(int*)param; resp.LTE_SignalStrength.signalStrength = -1; resp.LTE_SignalStrength.rsrp = -1; resp.LTE_SignalStrength.rsrq = -1; resp.LTE_SignalStrength.rssnr = -1; resp.LTE_SignalStrength.cqi = -1; RIL_onUnsolicitedResponse ( RIL_UNSOL_SIGNAL_STRENGTH, & resp, sizeof(resp)); return; error: at_response_free(p_response); }
void triggerSIMAppError(const void* param) { sOEM_HOOK_RAW_UNSOL_SIM_APP_ERR_IND data; data.command = RIL_OEM_HOOK_RAW_UNSOL_SIM_APP_ERR_IND; PrintStringNullTerminate(data.szSimError, SIM_APP_ERROR_SIZE+1, (char*)param); RIL_onUnsolicitedResponse(RIL_UNSOL_OEM_HOOK_RAW, (void*)&data, sizeof(sOEM_HOOK_RAW_UNSOL_SIM_APP_ERR_IND)); }
void onNewStatusReport(const char *sms_pdu) { char *response = NULL; /* Baseband will not prepend SMSC addr, but Android expects it. */ asprintf(&response, "%s%s", "00", sms_pdu); RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT, response, strlen(response)); }
/** * RIL_UNSOL_SIGNAL_STRENGTH * * Radio may report signal strength rather than have it polled. * * "data" is a const RIL_SignalStrength * */ void pollSignalStrength(void *arg) { RIL_SignalStrength_v6 signalStrength; (void) arg; if (getSignalStrength(&signalStrength) < 0) LOGE("%s() Polling the signal strength failed", __func__); else RIL_onUnsolicitedResponse(RIL_UNSOL_SIGNAL_STRENGTH, &signalStrength, sizeof(RIL_SignalStrength_v6)); }
static int onNetworkStateChanged(char* s, char* sms_pdu) { int err; int reg_value; if (strStartsWith(s,"+CREG:") || strStartsWith(s,"+CGREG") ) { RIL_onUnsolicitedResponse ( RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, NULL, 0); } return UNSOLICITED_SUCCESSED; }
void triggerDataResumedInd(void* param) { const int DATA_RESUMED = 1; sOEM_HOOK_RAW_UNSOL_DATA_STATUS_IND data; CTE::GetTE().SetDataSuspended(FALSE); data.command = RIL_OEM_HOOK_RAW_UNSOL_DATA_STATUS_IND; data.status = DATA_RESUMED; RIL_onUnsolicitedResponse(RIL_UNSOL_OEM_HOOK_RAW, (void*)&data, sizeof(sOEM_HOOK_RAW_UNSOL_DATA_STATUS_IND)); }
/** * RIL_UNSOL_NITZ_TIME_RECEIVED * * Called when radio has received a NITZ time message. * * "data" is const char * pointing to NITZ time string * */ void onNetworkTimeReceived(const char *s) { /* Special handling of DST for Android framework Module does not include DST correction in NITZ, but Android expects it */ char *line, *tok, *response, *time, *timestamp; int tz, dst; tok = line = strdup(s); if (NULL == tok) { LOGE("%s() Failed to allocate memory", __func__); return; } at_tok_start(&tok); LOGD("%s() Got nitz: %s", __func__, s); if (at_tok_nextint(&tok, &tz) != 0) LOGE("%s() Failed to parse NITZ tz %s", __func__, s); else if (at_tok_nextstr(&tok, &time) != 0) LOGE("%s() Failed to parse NITZ time %s", __func__, s); else if (at_tok_nextstr(&tok, ×tamp) != 0) LOGE("%s() Failed to parse NITZ timestamp %s", __func__, s); else { if (at_tok_nextint(&tok, &dst) != 0) { dst = 0; LOGE("%s() Failed to parse NITZ dst, fallbacking to dst=0 %s", __func__, s); } if (!(asprintf(&response, "%s%+03d,%02d", time + 2, tz + (dst * 4), dst))) { free(line); LOGE("%s() Failed to allocate string", __func__); return; } if (strncmp(response, last_nitz_time, strlen(response)) != 0) { RIL_onUnsolicitedResponse(RIL_UNSOL_NITZ_TIME_RECEIVED, response, sizeof(char *)); strncpy(last_nitz_time, response, strlen(response)); } else LOGD("%s() Discarding NITZ since it hasn't changed since last update", __func__); free(response); enqueueRILEvent(RIL_EVENT_QUEUE_NORMAL, sendTime, NULL, NULL); } free(line); }
void triggerDataSuspendInd(void* param) { if (!CTE::GetTE().IsDataSuspended() || (RADIO_STATE_ON != CTE::GetTE().GetRadioState())) return; const int DATA_SUSPENDED = 0; sOEM_HOOK_RAW_UNSOL_DATA_STATUS_IND data; data.command = RIL_OEM_HOOK_RAW_UNSOL_DATA_STATUS_IND; data.status = DATA_SUSPENDED; RIL_onUnsolicitedResponse(RIL_UNSOL_OEM_HOOK_RAW, (void*)&data, sizeof(sOEM_HOOK_RAW_UNSOL_DATA_STATUS_IND)); }
/** * RIL_UNSOL_ON_USSD * * Called when a new USSD message is received. */ int onUSSDReceived(const char *s, char* sms_pdu) { char *line, *linestart; int typeCode, count, err, len; char *message; char *outputmessage; char *responseStr[2]; linestart=line=strdup(s); err = at_tok_start(&line); if(err < 0) goto out; err = at_tok_nextint(&line, &typeCode); if(err < 0) goto out; if(at_tok_hasmore(&line)) { int format; char message[256]; int n = sscanf(s+6,"%*d,\"%[^\"]\",%d",message,&format); LOGD("%s,%d",message,format); if(format == 15){ responseStr[1] = malloc(strlen(message)+1); strcpy(responseStr[1],message); }else{ int len = strlen(message); outputmessage = malloc(len/2); gsm_hex_to_bytes((cbytes_t)message,len,(bytes_t)outputmessage); responseStr[1] = malloc(len); len = ucs2_to_utf8((cbytes_t)outputmessage,len/2,(bytes_t)responseStr[1]); free(outputmessage); } count = 2; } else { responseStr[1]=NULL; count = 1; } free(linestart); asprintf(&responseStr[0], "%d", typeCode); RIL_onUnsolicitedResponse (RIL_UNSOL_ON_USSD, responseStr, count*sizeof(char*)); out: return UNSOLICITED_SUCCESSED; }
void onNetworkStatusChanged(const char *s) { int err; int skip; int cs_status, ps_status; int resp; char *line = NULL, *tok = NULL; cs_status = ps_status = 0; tok = line = strdup(s); if (tok == NULL) goto error; at_tok_start(&tok); err = at_tok_nextint(&tok, &skip); if (err < 0) goto error; err = at_tok_nextint(&tok, &cs_status); if (err < 0) goto error; err = at_tok_nextint(&tok, &ps_status); if (err < 0) goto error; resp = RIL_RESTRICTED_STATE_NONE; if (cs_status == E2REG_ACCESS_CLASS_BARRED) resp |= RIL_RESTRICTED_STATE_CS_ALL; if (ps_status == E2REG_ACCESS_CLASS_BARRED) resp |= RIL_RESTRICTED_STATE_PS_ALL; RIL_onUnsolicitedResponse(RIL_UNSOL_RESTRICTED_STATE_CHANGED, &resp, sizeof(int *)); /* If registered, poll signal strength for faster update of signal bar */ if ((cs_status == E2REG_REGISTERED) || (ps_status == E2REG_REGISTERED)) enqueueRILEvent(RIL_EVENT_QUEUE_PRIO, pollSignalStrength, (void *)-1, NULL); error: free(line); }
static int onMessageListing(char* s, char* sms_pdu) { int* index = malloc(sizeof(int)); int stat = -1; char* line = NULL; line = strdup(s); at_tok_start(&line); at_tok_nextint(&line, index); at_tok_nextint(&line, &stat); RIL_requestTimedCallback (deleteMessageByIndex, index, NULL); if(stat == 0){ RIL_onUnsolicitedResponse ( RIL_UNSOL_RESPONSE_NEW_SMS, sms_pdu, strlen(sms_pdu)); } free(line); return UNSOLICITED_SUCCESSED; }
void setRadioState(RIL_RadioState newState) { RIL_RadioState oldState; pthread_mutex_lock(&s_state_mutex); oldState = sState; if (s_closed > 0) { // If we're closed, the only reasonable state is // RADIO_STATE_UNAVAILABLE // This is here because things on the main thread // may attempt to change the radio state after the closed // event happened in another thread newState = RADIO_STATE_UNAVAILABLE; } if (sState != newState || s_closed > 0) { sState = newState; pthread_cond_broadcast (&s_state_cond); } pthread_mutex_unlock(&s_state_mutex); /* do these outside of the mutex */ if (sState != oldState) { LOGD("RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED sState = %d,old = %d",sState,oldState); RIL_onUnsolicitedResponse (RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); if (sState == RADIO_STATE_SIM_READY) { onSIMReady(); } else if (sState == RADIO_STATE_SIM_NOT_READY) { onRadioPowerOn(); } } }
void onStkEventNotify(const char *s) { char *str; char *line; char *tok; int err; tok = line = strdup(s); err = at_tok_start(&tok); if (err < 0) goto error; err = at_tok_nextstr(&tok, &str); if (err < 0) goto error; RIL_onUnsolicitedResponse(RIL_UNSOL_STK_EVENT_NOTIFY, str, sizeof(char *)); error: free(line); }
/** * RIL_UNSOL_STK_PROACTIVE_COMMAND * * Indicate when SIM issue a STK proactive command to applications. * */ void onStkProactiveCommand(const char *s) { char *str; char *line; char *tok; int err; tok = line = strdup(s); err = at_tok_start(&tok); if (err < 0) goto error; err = at_tok_nextstr(&tok, &str); if (err < 0) goto error; RIL_onUnsolicitedResponse(RIL_UNSOL_STK_PROACTIVE_COMMAND, str, sizeof(char *)); error: free(line); }
void onSuppServiceNotification(const char *s, int type) { RIL_SuppSvcNotification ssnResponse; char *line; char *tok; int err; line = tok = strdup(s); memset(&ssnResponse, 0, sizeof(ssnResponse)); ssnResponse.notificationType = type; err = at_tok_start(&tok); if (err < 0) goto error; err = at_tok_nextint(&tok, &ssnResponse.code); if (err < 0) goto error; if (ssnResponse.code == 16 || (type == 0 && ssnResponse.code == 4) || (type == 1 && ssnResponse.code == 1)) { err = at_tok_nextint(&tok, &ssnResponse.index); if (err < 0) goto error; } /* RIL_SuppSvcNotification has two more members that we won't get from the +CSSI/+CSSU. Where do we get them, if we ever do? */ RIL_onUnsolicitedResponse(RIL_UNSOL_SUPP_SVC_NOTIFICATION, &ssnResponse, sizeof(ssnResponse)); error: free(line); }
void onNewSmsOnSIM(const char *s) { char *line; char *mem; char *tok; int err = 0; int index = -1; tok = line = strdup(s); err = at_tok_start(&tok); if (err < 0) goto error; err = at_tok_nextstr(&tok, &mem); if (err < 0) goto error; if (strncmp(mem, "SM", 2) != 0) goto error; err = at_tok_nextint(&tok, &index); if (err < 0) goto error; RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM, &index, sizeof(int *)); finally: free(line); return; error: LOGE("Failed to parse +CMTI."); goto finally; }
void onStkEventDownloadCall(char* urc, RILChannelCtx* p_channel) { RIL_SOCKET_ID rid = getRILIdByChannelCtx(p_channel); int err, i = 0; char *p_cur = (char *)urc; int response[NUM_EVDL_CALL]={0}; //RIL_EVDLCall response = NULL; /* * +EVDLCALL: <status>,<ti>,<is_mt_call>,<is_far_end>,<cause_len>,<cause> */ for(i = 0; i < NUM_EVDL_CALL-1; i++) { response[i] = 0xff; } err = at_tok_start(&p_cur); if (err < 0) goto error; for(i = 0; i < NUM_EVDL_CALL-1; i++) { err = at_tok_nextint(&p_cur, &(response[i])); if(err < 0) { response[i] = 0xFF; LOGE("There is something wrong with item [%d]",i);}//goto error; } err = at_tok_nexthexint(&p_cur, &(response[i])); if(err < 0) { LOGE("There is something wrong with item [%d]",i);//goto error; } RIL_onUnsolicitedResponse( RIL_UNSOL_STK_EVDL_CALL, response, NUM_EVDL_CALL * sizeof(int), rid); return; error: LOGE("There is something wrong with the +EVDLCALL"); }
void onNewBroadcastSms(const char *pdu) { char *message = NULL; int i; if (strlen(pdu) != (2 * 88)) { LOGE("Broadcast Message length error! Discarding!"); goto error; } message = alloca(88); memset(message, 0, 88); for (i = 0; i < 88; i++) { message[i] |= (char2nib(pdu[i * 2]) << 4); message[i] |= char2nib(pdu[i * 2 + 1]); } RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS, message, sizeof(char *)); error: return; }
void onConnectionStateChanged(const char *s) { int m_state = -1, m_cause = -1, err; int commas; err = at_tok_start((char **) &s); if (err < 0) return; /* Count number of commas */ err = at_tok_charcounter((char *) s, ',', &commas); if (err < 0) return; err = at_tok_nextint((char **) &s, &m_state); if (err < 0 || m_state < E2NAP_ST_DISCONNECTED || m_state > E2NAP_ST_CONNECTED) { m_state = -1; return; } err = at_tok_nextint((char **) &s, &m_cause); /* The <cause> will only be indicated/considered when <state> * is disconnected */ if (err < 0 || m_cause < E2NAP_C_SUCCESS || m_cause > E2NAP_C_MAXIMUM || m_state != E2NAP_ST_DISCONNECTED) m_cause = -1; if (commas == 3) { int m_state2 = -1, m_cause2 = -1; err = at_tok_nextint((char **) &s, &m_state2); if (err < 0 || m_state2 < E2NAP_ST_DISCONNECTED || m_state2 > E2NAP_ST_CONNECTED) { m_state = -1; return; } if (m_state2 == E2NAP_ST_DISCONNECTED) { err = at_tok_nextint((char **) &s, &m_cause2); if (err < 0 || m_cause2 < E2NAP_C_SUCCESS || m_cause2 > E2NAP_C_MAXIMUM) { m_cause2 = -1; } } if ((err = pthread_mutex_lock(&s_e2nap_mutex)) != 0) LOGE("%s() failed to take e2nap mutex: %s", __func__, strerror(err)); if (m_state == E2NAP_ST_CONNECTING || m_state2 == E2NAP_ST_CONNECTING) { s_e2napState = E2NAP_ST_CONNECTING; } else if (m_state == E2NAP_ST_CONNECTED) { s_e2napCause = m_cause2; s_e2napState = E2NAP_ST_CONNECTED; } else if (m_state2 == E2NAP_ST_CONNECTED) { s_e2napCause = m_cause; s_e2napState = E2NAP_ST_CONNECTED; } else { s_e2napCause = m_cause; s_e2napState = E2NAP_ST_DISCONNECTED; } if ((err = pthread_mutex_unlock(&s_e2nap_mutex)) != 0) LOGE("%s() failed to release e2nap mutex: %s", __func__, strerror(err)); } else { if ((err = pthread_mutex_lock(&s_e2nap_mutex)) != 0) LOGE("%s() failed to take e2nap mutex: %s", __func__, strerror(err)); s_e2napState = m_state; s_e2napCause = m_cause; if ((err = pthread_mutex_unlock(&s_e2nap_mutex)) != 0) LOGE("%s() failed to release e2nap mutex: %s", __func__, strerror(err)); } LOGD("%s() %s", e2napStateToString(m_state), __func__); if (m_state != E2NAP_ST_CONNECTING) enqueueRILEvent(RIL_EVENT_QUEUE_PRIO, onPDPContextListChanged, NULL, NULL); /* Make system request network information. This will allow RIL to report any new * technology made available from connection. */ if (E2NAP_ST_CONNECTED == m_state) RIL_onUnsolicitedResponse( RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, NULL, 0); mbm_check_error_cause(); }
void onSimStateChanged(const char *s) { int state; char *tok = NULL; char *line = NULL; /* let the status from EESIMSWAP override * that of ESIMSR */ if (s_simRemoved) return; line = tok = strdup(s); if (NULL == line) { ALOGE("%s() failed to allocate memory!", __func__); return; } if (at_tok_start(&line) < 0) goto error; if (at_tok_nextint(&line, &state) < 0) goto error; /* * s_simResetting is used to coordinate state changes during sim resetting, * i.e. ESIMSR state changing from 7 to 4 or 5. */ switch (state) { case 7: /* SIM STATE POWER OFF, or indicating no SIM inserted. */ s_simResetting = 1; setRadioState(RADIO_STATE_SIM_LOCKED_OR_ABSENT); break; case 4: /* SIM STATE WAIT FOR PIN */ if (s_simResetting) { s_simResetting = 0; /* * Android will not poll for SIM state if Radio State has no * changes. Therefore setRadioState twice to make Android poll for * Sim state when there is a PIN state change. */ setRadioState(RADIO_STATE_SIM_NOT_READY); setRadioState(RADIO_STATE_SIM_LOCKED_OR_ABSENT); } break; case 5: /* SIM STATE ACTIVE */ if (s_simResetting) { s_simResetting = 0; /* * Android will not poll for SIM state if Radio State has no * changes. Therefore setRadioState twice to make Android poll for * Sim state when there is a PIN state change. */ setRadioState(RADIO_STATE_SIM_NOT_READY); setRadioState(RADIO_STATE_SIM_READY); } break; case 2: /* SIM STATE BLOCKED */ case 3: /* SIM STATE BLOCKED FOREVER */ setRadioState(RADIO_STATE_SIM_LOCKED_OR_ABSENT); break; default: /* * s_simResetting should not be changed in the states between SIM POWER * OFF to SIM STATE WAIT FOR PIN or SIM STATE ACTIVE. */ break; } RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0); finally: free(tok); return; error: ALOGE("Error in %s", __func__); goto finally; }
void ipc_gprs_pdp_context(struct ipc_message_info *info) { struct ril_gprs_connection *gprs_connection; struct ipc_gprs_ip_configuration *ip_configuration; struct ipc_gprs_pdp_context_get *context = (struct ipc_gprs_pdp_context_get *) info->data; #if RIL_VERSION >= 6 RIL_Data_Call_Response_v6 data_call_list[IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT]; #else RIL_Data_Call_Response data_call_list[IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT]; #endif memset(data_call_list, 0, sizeof(data_call_list)); int i; for(i=0 ; i < IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT ; i++) { data_call_list[i].cid = context->desc[i].cid; data_call_list[i].active = ipc2ril_gprs_connection_active(context->desc[i].state); if(context->desc[i].state == IPC_GPRS_STATE_ENABLED) { gprs_connection = ril_gprs_connection_get_cid(context->desc[i].cid); if(gprs_connection == NULL) { LOGE("CID %d reported as enabled but not listed here", context->desc[i].cid); continue; } ip_configuration = &(gprs_connection->ip_configuration); char *addr = NULL; asprintf(&addr, "%i.%i.%i.%i", (ip_configuration->ip)[0], (ip_configuration->ip)[1], (ip_configuration->ip)[2], (ip_configuration->ip)[3]); #if RIL_VERSION >= 6 RIL_Data_Call_Response_v6 *resp = &data_call_list[i]; #else RIL_Data_Call_Response *resp = &data_call_list[i]; #endif resp->type = strdup("IP"); #if RIL_VERSION < 6 resp->address = addr; asprintf(&(resp->apn), "%s", gprs_connection->define_context.apn); #else resp->addresses = addr; resp->gateways = strdup(addr); resp->ifname = strdup(gprs_connection->interface); asprintf(&resp->dnses, "%i.%i.%i.%i %i.%i.%i.%i", ip_configuration->dns1[0], ip_configuration->dns1[1], ip_configuration->dns1[2], ip_configuration->dns1[3], ip_configuration->dns2[0], ip_configuration->dns2[1], ip_configuration->dns2[2], ip_configuration->dns2[3]); #endif } } ipc_gprs_pdp_context_fix(data_call_list, IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT); if(info->aseq == 0xff) RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED, &data_call_list, sizeof(data_call_list)); else RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, &data_call_list, sizeof(data_call_list)); for(i = 0; i < IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT; i++) { ril_data_call_response_free(data_call_list + i); } }
/** * RIL_UNSOL_SIM_REFRESH * * Indicate when SIM issue a REFRESH proactive command to applications. */ void onStkSimRefresh(const char *s) { int commas = 0; char *line = NULL; char *tok = NULL; int i, skip; int err = -1; int response[2]; /* *ESIMRF: <cmdnumber>,<type>[[,< fileid>,<pathid>][…]] */ tok = line = strdup(s); err = at_tok_charcounter(tok, ',', &commas); if (err < 0) commas = 0; else commas -= 1; err = at_tok_start(&tok); if (err < 0) goto error; err = at_tok_nextint(&tok, &(s_refeshStatus.cmdNumber)); if (err < 0) goto error; err = at_tok_nextint(&tok, &(s_refeshStatus.cmdQualifier)); if (err < 0) goto error; switch(s_refeshStatus.cmdQualifier) { case SAT_SIM_INITIALIZATION_AND_FULL_FILE_CHANGE_NOTIFICATION: case SAT_SIM_INITIALIZATION_AND_FILE_CHANGE_NOTIFICATION: case SAT_SIM_INITIALIZATION: case SAT_NAA_APPLICATION_RESET: /* SIM initialized. All files should be re-read. */ response[0] = SIM_INIT; s_refeshStatus.Result = 3; /* success, EFs read */ break; case SAT_FILE_CHANGE_NOTIFICATION: /* one or more files on SIM has been updated */ response[0] = SIM_FILE_UPDATE; s_refeshStatus.Result = 3; /* success, EFs read */ break; case SAT_SIM_RESET: /* SIM reset. All files should be re-read. */ response[0] = SIM_RESET; break; case SAT_NAA_SESSION_RESET: /* one or more files on SIM has been updated */ response[0] = SIM_FILE_UPDATE; s_refeshStatus.Result = 3; /* success, EFs read */ break; case SAT_STEERING_OF_ROAMING: /* not set in Terminal Profile for Android, should never happen */ default: goto error; break; } if (response[0] != SIM_FILE_UPDATE) { response[1] = 0; RIL_onUnsolicitedResponse(RIL_UNSOL_SIM_REFRESH, response, sizeof(response)); goto finally; } for (i = 0; i < commas; i += 2) { err = at_tok_nextint(&tok, &(response[1])); if (err < 0) { /* check if response is already sent to Android */ if (i > 0) goto finally; else goto error; } /* <pathid> is not used by Android */ err = at_tok_nextint(&tok, &skip); if (err < 0) { /* check if response is already sent to Android */ if (i > 0) goto finally; else goto error; } RIL_onUnsolicitedResponse(RIL_UNSOL_SIM_REFRESH, response, sizeof(response)); } finally: #ifndef USE_U8500_RIL if (response[0] != SIM_RESET) { // AT commands cannot be sent from the at reader thread enqueueRILEvent(RIL_EVENT_QUEUE_PRIO, sendRefreshTerminalResponse, NULL, NULL); } #endif free(line); return; error: ALOGE("%s: failed to parse %s, default to SIM_INITIALIZATION", __func__, s); if (s_refeshStatus.cmdNumber < 0) s_refeshStatus.cmdNumber = 1; if (s_refeshStatus.cmdQualifier < 0) s_refeshStatus.cmdQualifier = SAT_SIM_INITIALIZATION; if (s_refeshStatus.Result < 0) s_refeshStatus.Result = 2; /* command performed with missing information */ response[0] = SIM_INIT; response[1] = 0; RIL_onUnsolicitedResponse(RIL_UNSOL_SIM_REFRESH, response, sizeof(response)); goto finally; }
// [in] param = 1 for mobile release and 0 for network release void triggerDropCallEvent(void* param) { sOEM_HOOK_RAW_UNSOL_CRASHTOOL_EVENT_IND data; char szBuffer[CRASHTOOL_BUFFER_SIZE]; BOOL bMobileRelease = (1 == (UINT32)param); data.command = RIL_OEM_HOOK_RAW_UNSOL_CRASHTOOL_EVENT_IND; data.type = CRASHTOOL_STATS; PrintStringNullTerminate(data.name, CRASHTOOL_NAME_SIZE, "TFT_STAT_CDROP"); data.nameSize = strnlen(data.name, CRASHTOOL_NAME_SIZE); // Pre-initialize all data size to 0 for (int i = 0; i < CRASHTOOL_NB_DATA; i++) { data.dataSize[i] = 0; } // See the definition of sOEM_HOOK_RAW_UNSOL_CRASHTOOL_EVENT_IND in // CORE/oemhookids.h for the raw unsol content. if (bMobileRelease) { PrintStringNullTerminate(data.data0, CRASHTOOL_BUFFER_SIZE, "MOBILE RELEASE"); data.dataSize[0] = strnlen(data.data0, CRASHTOOL_BUFFER_SIZE); } else { data.dataSize[0] = snprintf(data.data0, CRASHTOOL_BUFFER_SIZE, "%s", CTE::GetTE().GetLastCEER()); } if (strlen(CTE::GetTE().GetNetworkData(LAST_NETWORK_CREG)) != 0) { data.dataSize[1] = snprintf(data.data1, CRASHTOOL_BUFFER_SIZE, "+CREG: %s;", CTE::GetTE().GetNetworkData(LAST_NETWORK_CREG)); } if (strlen(CTE::GetTE().GetNetworkData(LAST_NETWORK_XREG)) != 0) { data.dataSize[1] += snprintf(szBuffer, CRASHTOOL_BUFFER_SIZE - data.dataSize[1], "+XREG: %s;", CTE::GetTE().GetNetworkData(LAST_NETWORK_XREG)); strncat(data.data1, szBuffer, CRASHTOOL_BUFFER_SIZE); } if (strlen(CTE::GetTE().GetNetworkData(LAST_NETWORK_XCSQ)) != 0) { data.dataSize[2] = snprintf(data.data2, CRASHTOOL_LARGE_BUFFER_SIZE, "%s;", CTE::GetTE().GetNetworkData(LAST_NETWORK_XCSQ)); } data.dataSize[3] = snprintf(data.data3, CRASHTOOL_BUFFER_SIZE, "%s,%s,%s", CTE::GetTE().GetNetworkData(LAST_NETWORK_OP_NAME_NUMERIC), CTE::GetTE().GetNetworkData(LAST_NETWORK_LAC), CTE::GetTE().GetNetworkData(LAST_NETWORK_CID)); data.dataSize[4] = snprintf(data.data4, CRASHTOOL_LARGE_BUFFER_SIZE, "%s", CTE::GetTE().GetNetworkData(LAST_NETWORK_OP_NAME_SHORT)); RIL_onUnsolicitedResponse (RIL_UNSOL_OEM_HOOK_RAW, (void*)&data, sizeof(sOEM_HOOK_RAW_UNSOL_CRASHTOOL_EVENT_IND)); }
void requestOrSendPDPContextList(RIL_Token *token) { ATResponse *atresponse = NULL; RIL_Data_Call_Response_v6 response; int e2napState = getE2napState(); int err; int cid; char *line, *apn, *type; char* addresses = NULL; char* dnses = NULL; char* gateways = NULL; in_addr_t addr; in_addr_t gateway; memset(&response, 0, sizeof(response)); response.ifname = ril_iface; err = at_send_command_multiline("AT+CGDCONT?", "+CGDCONT:", &atresponse); if (err != AT_NOERROR) goto error; line = atresponse->p_intermediates->line; err = at_tok_start(&line); if (err < 0) goto error; err = at_tok_nextint(&line, &cid); if (err < 0) goto error; response.cid = cid; if (e2napState == E2NAP_ST_CONNECTED) response.active = 1; err = at_tok_nextstr(&line, &type); if (err < 0) goto error; response.type = alloca(strlen(type) + 1); strcpy(response.type, type); err = at_tok_nextstr(&line, &apn); if (err < 0) goto error; at_response_free(atresponse); atresponse = NULL; /* TODO: Check if we should check ip for a specific CID instead */ if (parse_ip_information(&addresses, &gateways, &dnses, &addr, &gateway) < 0) { LOGE("%s() Failed to parse network interface data", __func__); goto error; } response.addresses = addresses; response.gateways = gateways; response.dnses = dnses; response.suggestedRetryTime = -1; if (token != NULL) RIL_onRequestComplete(*token, RIL_E_SUCCESS, &response, sizeof(RIL_Data_Call_Response_v6)); else RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED, &response, sizeof(RIL_Data_Call_Response_v6)); free(addresses); free(gateways); free(dnses); return; error: if (token != NULL) RIL_onRequestComplete(*token, RIL_E_GENERIC_FAILURE, NULL, 0); else RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED, NULL, 0); at_response_free(atresponse); }