vsim的hidl接口 framework/boot-radio_interactor_common
vendor.sprd.hardware.radio.V1_0.IExtRadio下的
public void sendCmdAsync(int serial, String cmd);
public String sendCmdSync(int phoneId, String cmd); 这个接口用来发送AT命令给modem
public void setAtcResponseFunctions(IAtcRadioResponse radioResponse, IAtcRadioIndication radioIndication);
void vsimSendCmd(int arg1, int arg2, String arg3);
void simGetAtr(int arg1);
vendor.sprd.hardware.radio.V1_0.IAtcRadioIndication下
public void vsimRSimReqInd(int type, String data);
vendor.sprd.hardware.radio.V1_0.IAtcRadioResponse下
public void vsimSendCmdResponse(RadioResponseInfo info, String response);
=============================
AT+VIRTUALSIMINIT=%d
初始化模式,设置为2
2表示软卡
AT+VIRTUALSIMINIT?
查询虚拟卡模式
AT+SPVSIMAUTHSET=%d
支持哪种鉴权算法,Milenage, Comp128
AT+SPVSIMAUTHSET?
AT+RSIMRSP=
发送rAPDU给modem
启用vsim功能
AT+RSIMRSP="VSIM",1
VSIM_INIT:AT+RSIMRSP=”VSIM”,1
关闭
AT+RSIMRSP="VSIM",0
VSIM_EXIT:AT+RSIMRSP=”VSIM”,0
设置超时
VSIM_TIMEOUT:%d”
=============
命令从 用CRSM发送过来
AT+CRSM=%d,%d,%d,%d,%d
AT^MBAU=
===================
流程
AT+VIRTUALSIMINIT=2
注册循环处理函数setAtcResponseFunctions AtcRadioIndication AtcRadioResponse
VSIM_INIT:AT+RSIMRSP=”VSIM”,1
=========
关闭VirtualSIM功能 (写入到NV)
AT+VIRTUALSIMINIT=0,1
===========
鉴权命令格式
AT^MBAU=?
回应
^MBAU::rand,autn
第1个是状态码
se相关问题
magiskpolicy --live "allow untrusted_app hal_extRadio_hwservice hwservice_manager find"
magiskpolicy --live "allow untrusted_app binder { call transfer }"
magiskpolicy --live "allow rild untrusted_app binder call "
void requestSendAT(RIL_SOCKET_ID socket_id, const char *data, size_t datalen,
RIL_Token t, char *atResp, int responseLen) {
...
...
} else if (strStartsWith(ATcmd, "VSIM_INIT")) {
char *cmd = NULL;
RLOGD("vsim init");
cmd = ATcmd;
at_tok_start(&cmd);
err = at_send_command(socket_id, cmd, &p_response);
} else if (strStartsWith(ATcmd, "VSIM_EXIT")) {
char *cmd = ATcmd;
//send AT
at_tok_start(&cmd);
int simState = getSIMStatus(RIL_EXT_REQUEST_SIMMGR_GET_SIM_STATUS, socket_id);
if (simState != SIM_ABSENT) {
at_send_command(socket_id, "AT+RSIMRSP=\"ERRO\",2", NULL);
err = at_send_command(socket_id, cmd, &p_response);
if (err >= 0 && p_response->success != 0) {
onSimDisabled(socket_id);
}
} else {
RLOGD("no vsim!!");
}
} else if (strStartsWith(ATcmd, "VSIM_TIMEOUT")) {
int time = -1;
char *cmd = ATcmd;
at_tok_start(&cmd);
err = at_tok_nextint(&cmd, &time);
RLOGD("VSIM_TIMEOUT:%d", time);
if (time > 0) {
s_timevalCloseVsim.tv_sec = time;
}
}
开启
void requestVsimCmd(RIL_SOCKET_ID socket_id, void *data, size_t datalen,
RIL_Token t) {
RIL_UNUSED_PARM(data);
RIL_UNUSED_PARM(datalen);
int i = 0, err = -1;
char *ATcmd = (char *)data;
char buf[AT_RESPONSE_LEN] = {0};
char *response[1] = {NULL};
ATLine *p_cur = NULL;
ATResponse *p_response = NULL;
if (ATcmd == NULL) {
RLOGE("Invalid AT command");
goto error;
}
if (strStartsWith(ATcmd, "VSIM_INIT")) {
char *cmd = NULL;
RLOGD("vsim init");
cmd = ATcmd;
at_tok_start(&cmd);
err = at_send_command(socket_id, cmd, &p_response);
} else if (strStartsWith(ATcmd, "VSIM_EXIT")) {
char *cmd = NULL;
// send AT
cmd = ATcmd;
at_tok_start(&cmd);
int simState = getSIMStatus(RIL_EXT_REQUEST_SIMMGR_GET_SIM_STATUS, socket_id);
if (simState != SIM_ABSENT) {
at_send_command(socket_id, "AT+RSIMRSP=\"ERRO\",2", NULL);
err = at_send_command(socket_id, cmd, &p_response);
if (err >= 0 && p_response->success != 0) {
onSimDisabled(socket_id);
}
} else {
RLOGD("no vsim!!");
}
} else if (strStartsWith(ATcmd, "VSIM_TIMEOUT")) {
int time = -1;
char *cmd = NULL;
cmd = ATcmd;
at_tok_start(&cmd);
err = at_tok_nextint(&cmd, &time);
RLOGD("VSIM_TIMEOUT:%d",time);
if (time > 0) {
s_timevalCloseVsim.tv_sec = time;
}
} else {
err = at_send_command_multiline(socket_id, ATcmd, "",
&p_response);
}
if (err < 0 || p_response->success == 0) {
if (p_response != NULL) {
strlcat(buf, p_response->finalResponse, sizeof(buf));
strlcat(buf, "\r\n", sizeof(buf));
response[0] = buf;
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, response,
sizeof(char *));
} else {
goto error;
}
} else {
p_cur = p_response->p_intermediates;
for (i = 0; p_cur != NULL; p_cur = p_cur->p_next, i++) {
strlcat(buf, p_cur->line, sizeof(buf));
strlcat(buf, "\r\n", sizeof(buf));
}
strlcat(buf, p_response->finalResponse, sizeof(buf));
strlcat(buf, "\r\n", sizeof(buf));
response[0] = buf;
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(char *));
if (!strncasecmp(ATcmd, "AT+SFUN=5", strlen("AT+SFUN=5"))) {
setRadioState(socket_id, RADIO_STATE_OFF);
}
}
at_response_free(p_response);
return;
error:
if (t != NULL) {
memset(buf, 0 ,sizeof(buf));
strlcat(buf, "ERROR", sizeof(buf));
strlcat(buf, "\r\n", sizeof(buf));
response[0] = buf;
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, response,
sizeof(char *));
}
at_response_free(p_response);
}
处理modem来的sim cmd
int processMiscUnsolicited(RIL_SOCKET_ID socket_id, const char *s) {
...
} else if (strStartsWith(s, "%RSIMREQ:")) {
char *tmp = NULL;
char *response = NULL;
line = strdup(s);
tmp = line;
at_tok_start(&tmp);
skipWhiteSpace(&tmp);
response = (char *)calloc((strlen(tmp) + 5), sizeof(char));
snprintf(response, strlen(tmp) + 4, "%d,%s\r\n", socket_id, tmp);
RIL_onUnsolicitedResponse(RIL_ATC_UNSOL_VSIM_RSIM_REQ, response,
strlen(response) + 1, socket_id);
free(response);
}
...
/vendor/bin/hw/sprdrild
E RILC : vsimRSimReqInd: radioService[0]->mAtcRadioIndication == NULL
I RILC : RIL_SOCKET_1 UNSOLICITED: UNSOL_VSIM_RSIM_REQ length:37