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"); }
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 */ }
/* Called on command or reader thread */ static void onATReaderClosed(RILChannelCtx *p_channel) { RLOGI("AT channel closed\n"); at_close(p_channel); assert(0); s_closed = 1; setRadioState (RADIO_STATE_UNAVAILABLE, getRILIdByChannelCtx(p_channel)); }
/* Called on command thread */ static void onATTimeout(RILChannelCtx *p_channel) { RLOGI("AT channel timeout; closing\n"); at_close(p_channel); assert(0); s_closed = 1; /* FIXME cause a radio reset here */ setRadioState (RADIO_STATE_UNAVAILABLE, getRILIdByChannelCtx(p_channel)); }
void onStkSessionEnd(char* urc, RILChannelCtx* p_channel) { RIL_SOCKET_ID rid = getRILIdByChannelCtx(p_channel); RIL_STK_UNUSED_PARM(urc); RIL_onUnsolicitedResponseSocket ( RIL_UNSOL_STK_SESSION_END, NULL, 0, rid); return; }
/** * Called by atchannel when an unsolicited line appears * This is called on atchannel's reader thread. AT commands may * not be issued here */ static void onUnsolicited (const char *s, const char *sms_pdu, void * pChannel) { RLOGI("[Emu]get in onUnsolicited"); RLOGI("[Emu]command %s",s); char *line = NULL; int err; RIL_RadioState radioState = sState; RILChannelCtx * p_channel = (RILChannelCtx *) pChannel; #ifdef MTK_GEMINI if (MTK_RIL_SOCKET_2 == getRILIdByChannelCtx(p_channel)) { radioState = sState2; RLOGI("[Emu]state2"); } #endif /* Ignore unsolicited responses until we're initialized. * This is OK because the RIL library will poll for initial state */ if (radioState == RADIO_STATE_UNAVAILABLE) { return; } if (!(rilNwUnsolicited(s,sms_pdu,p_channel) || rilCcUnsolicited(s,sms_pdu, p_channel) || rilSsUnsolicited(s,sms_pdu, p_channel) || rilSmsUnsolicited(s,sms_pdu, p_channel) || rilStkUnsolicited(s,sms_pdu, p_channel) || rilOemUnsolicited(s,sms_pdu, p_channel) || rilDataUnsolicited(s,sms_pdu, p_channel)|| rilSimUnsolicited(s,sms_pdu, p_channel)) ) { RLOGE("Unhandled unsolicited result code: %s\n", s); } }
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"); }
/* Change name from requestPdpContetList to requestDataCallList */ void requestDataCallList(void * data, size_t datalen, RIL_Token t) { requestOrSendDataCallList(&t, getRILIdByChannelCtx(getRILChannelCtxFromToken(t))); }
void onSimRefresh(char* urc, RILChannelCtx * p_channel) { int *cmd = NULL; int cmd_length = 0; RIL_SOCKET_ID rid = getRILIdByChannelCtx(p_channel); #ifdef MTK_WIFI_CALLING_RIL_SUPPORT int sessionId = 0; int aid_len = 0; char *aid = NULL; #endif switch(urc[9]) { // t point to cmd_deatil tag t[9] mean refresh type case '1': decodeStkRefreshFileChange(urc, &cmd , &cmd_length); break; case '4': #ifndef MTK_WIFI_CALLING_RIL_SUPPORT cmd_length = 2 * sizeof(int); cmd = (int *)calloc(1, cmd_length); cmd[0] = SIM_RESET; cmd[1] = 0; #else /* MTK_WIFI_CALLING_RIL_SUPPORT */ cmd_length = 3 * sizeof(int); cmd = (int *)calloc(1, cmd_length); cmd[0] = -1; cmd[1] = SIM_RESET; cmd[2] = 0; #endif break; case '0': #ifndef MTK_WIFI_CALLING_RIL_SUPPORT cmd_length = 2 * sizeof(int); cmd = (int *)calloc(1, cmd_length); cmd[0] = SIM_INIT_FULL_FILE_CHANGE; cmd[1] = 0; #else cmd_length = 3 * sizeof(int); cmd = (int *)calloc(1, cmd_length); cmd[0] = -1; cmd[1] = SIM_INIT_FULL_FILE_CHANGE; cmd[2] = 0; #endif break; case '2': decodeStkRefreshFileChange(urc, &cmd , &cmd_length); #ifndef MTK_WIFI_CALLING_RIL_SUPPORT cmd[0] = SIM_INIT_FILE_CHANGE; #else cmd[1] = SIM_INIT_FILE_CHANGE; #endif break; case '3': #ifndef MTK_WIFI_CALLING_RIL_SUPPORT cmd_length = 2 * sizeof(int); cmd = (int *)calloc(1, cmd_length); cmd[0] = SIM_INIT; cmd[1] = 0; #else /* MTK_WIFI_CALLING_RIL_SUPPORT */ cmd_length = 3 * sizeof(int); cmd = (int *)calloc(1, cmd_length); cmd[0] = -1; cmd[1] = SIM_INIT; cmd[2] = 0; #endif break; #ifdef MTK_WIFI_CALLING_RIL_SUPPORT case '5': // ISIM app_reset aid_len = decodeStkRefreshAid(urc, &aid); sessionId = getActiveLogicalChannelId(aid); LOGD("[WiFi_Calling]decodeStkRefreshAid sessionId = %d", sessionId); cmd_length = 3 * sizeof(int); cmd = (int *)calloc(1, cmd_length); cmd[0] = sessionId; cmd[1] = APP_INIT; cmd[2] = 0; break; #endif /* MTK_WIFI_CALLING_RIL_SUPPORT */ case '6': #ifndef MTK_WIFI_CALLING_RIL_SUPPORT cmd_length = 2 * sizeof(int); cmd = (int *)calloc(1, cmd_length); cmd[0] = SESSION_RESET; cmd[1] = 0; #else /* MTK_WIFI_CALLING_RIL_SUPPORT */ cmd_length = 3 * sizeof(int); cmd = (int *)calloc(1, cmd_length); cmd[0] = -1; cmd[1] = SESSION_RESET; cmd[2] = 0; #endif break; default: break; } RIL_onUnsolicitedResponseSocket ( RIL_UNSOL_SIM_REFRESH, cmd, cmd_length, rid); free(cmd); }
void onStkEventNotify(char* urc, RILChannelCtx* p_channel) { int err = 0; int temp_int = 0; int cmd_type = 0; int type_pos = 0; int cmd_not_understood = 0; /* mtk02374 20100502*/ unsigned int duration = 0; char *temp_str; char *cmd; RIL_SOCKET_ID rid = getRILIdByChannelCtx(p_channel); int urc_len = 0; bool isStkServiceRunning = false; char *pEventNotify = NULL; ATResponse *p_response = NULL; if(urc != NULL) urc_len = strlen(urc); isStkServiceRunning = getStkServiceRunningFlag(rid); LOGD("onStkEventNotify check %d.urc_len %d.", isStkServiceRunning, urc_len); if(false == isStkServiceRunning) { setStkEventNotifyQueuedFlag(rid, true); pEventNotify = (char*)calloc(1, urc_len + 1); memset(pEventNotify, 0x0, urc_len + 1); memcpy(pEventNotify, urc, urc_len); setStkQueuedEventNotifyWithRid(rid, pEventNotify); LOGD("STK service is not running yet.[%p]", pEventNotify); return; } err = at_tok_start(&urc); err = at_tok_nextint(&urc, &temp_int); err = at_tok_nextstr(&urc, &temp_str); if(temp_str[2] <= '7' ) { /*add comment*/ type_pos = 10; } else if(temp_str[2] > '7' ) { type_pos = 12; } cmd_not_understood = checkStkCmdDisplay(&(temp_str[type_pos - 6])); /*temp_str[type_pos -6] points to cmd_detail tag*/ switch(checkStkCommandType(&(temp_str[type_pos]))) { case CMD_REFRESH: onSimRefresh(&(temp_str[type_pos - 6]), p_channel); break; case CMD_SETUP_CALL: cmd_type = CMD_SETUP_CALL; if(cmd_not_understood == 0) { duration = findStkCallDuration(&temp_str[type_pos - 6]); /*temp_str[type_pos -6] points to cmd_detail tag*/ } else { g_stk_at.cmd_type = CMD_SETUP_CALL; g_stk_at.cmd_res = 50; g_stk_at.rid = rid; RIL_requestProxyTimedCallback(onStkAtSendFromUrc, NULL, &TIMEVAL_0, getChannelCtxbyProxy(rid)->id, "onStkAtSendFromUrc"); } break; case CMD_SEND_SMS: g_stk_at.cmd_type = CMD_SEND_SMS; g_stk_at.cmd_res = 0; g_stk_at.rid = rid; RIL_requestProxyTimedCallback(onStkAtSendFromUrc, NULL, &TIMEVAL_SMS, getChannelCtxbyProxy(rid)->id, "onStkAtSendFromUrc"); break; case CMD_SEND_SS: g_stk_at.cmd_type = CMD_SEND_SS; if(cmd_not_understood == 0) { g_stk_at.cmd_res = 0; } else { g_stk_at.cmd_res = 50; } g_stk_at.rid = rid; RIL_requestProxyTimedCallback(onStkAtSendFromUrc, NULL, &TIMEVAL_0, getChannelCtxbyProxy(rid)->id, "onStkAtSendFromUrc"); break; case CMD_SEND_USSD: g_stk_at.cmd_type = CMD_SEND_USSD; if(cmd_not_understood == 0) { g_stk_at.cmd_res = 0; } else { g_stk_at.cmd_res = 50; } g_stk_at.rid = rid; RIL_requestProxyTimedCallback(onStkAtSendFromUrc, NULL, &TIMEVAL_0, getChannelCtxbyProxy(rid)->id, "onStkAtSendFromUrc"); break; case CMD_DTMF: g_stk_at.cmd_type = CMD_DTMF; g_stk_at.cmd_res = 0; g_stk_at.rid = rid; RIL_requestProxyTimedCallback(onStkAtSendFromUrc, NULL, &TIMEVAL_0, getChannelCtxbyProxy(rid)->id, "onStkAtSendFromUrc"); break; default: break; } RIL_onUnsolicitedResponseSocket ( RIL_UNSOL_STK_EVENT_NOTIFY, temp_str, strlen(temp_str), rid); if(CMD_SETUP_CALL == cmd_type) { RIL_onUnsolicitedResponseSocket ( RIL_UNSOL_STK_CALL_SETUP, &duration, sizeof(duration), rid); } return; }
void onStkProactiveCommand(char* urc, RILChannelCtx* p_channel) { int err = 0, temp_int = 0, type_pos = 0; ATResponse *p_response = NULL; char *temp_str; char *cmd; RIL_SOCKET_ID rid = getRILIdByChannelCtx(p_channel); int urc_len = 0; bool isStkServiceRunning = false; char *pProCmd = NULL; if(urc != NULL) urc_len = strlen(urc); isStkServiceRunning = getStkServiceRunningFlag(rid); LOGD("onStkProactiveCommand check %d.urc_len %d.",isStkServiceRunning, urc_len); if(false == isStkServiceRunning) { setStkProactiveCmdQueuedFlag(rid, true); pProCmd = (char*)calloc(1, urc_len + 1); memset(pProCmd, 0x0, urc_len + 1); memcpy(pProCmd, urc, urc_len); setStkQueuedProCmdWithRid(rid, pProCmd); LOGD("STK service is not running yet.[%p]",pProCmd); return; } err = at_tok_start(&urc); err = at_tok_nextint(&urc, &temp_int); err = at_tok_nextstr(&urc, &temp_str); if(temp_str[2] <= '7' ) { /*add comment*/ type_pos = 10; } else { type_pos = 12; } switch(checkStkCommandType(&(temp_str[type_pos]))) { case CMD_REFRESH: onSimRefresh(&(temp_str[type_pos - 6]), p_channel); // return; break; case CMD_DTMF: g_stk_at.cmd_type = CMD_DTMF; g_stk_at.cmd_res = 0; g_stk_at.rid = rid; RIL_requestProxyTimedCallback(onStkAtSendFromUrc, NULL, &TIMEVAL_0, getChannelCtxbyProxy(rid)->id, "onStkAtSendFromUrc"); RIL_onUnsolicitedResponseSocket ( RIL_UNSOL_STK_EVENT_NOTIFY, temp_str, strlen(temp_str), rid); return; break; default: break; } RIL_onUnsolicitedResponseSocket ( RIL_UNSOL_STK_PROACTIVE_COMMAND, temp_str, strlen(temp_str), rid); return; }