📄 mfw_sim.c
字号:
/*MC SPR1351, replaced previous implementation with wrapper for aci implementation*/
int sim_check_sim_NSlock (void)
{ T_SIMLOCK_STATUS simlock_status;
TRACE_EVENT ("sim_check_sim_NSlock()");
simlock_status =aci_slock_checklock(SIMLOCK_NETWORK_SUBSET);
TRACE_EVENT_P1("NSLock: %d", simlock_status);
/*convert status from ACI to MFW encoding*/
return sim_convert_simlock_status(simlock_status);
}
/*
+---------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : sim_check_sim_Clock |
+---------------------------------------------------------------------+
PURPOSE : Check corporate lock. It only works with SIMs
which support GID1 and GID2 files.
*/
/*MC SPR1351, replaced previous implemnetation with wrapper for aci implementation*/
int sim_check_sim_Clock (void)
{ T_SIMLOCK_STATUS simlock_status;
TRACE_EVENT ("sim_check_sim_Clock()");
simlock_status =aci_slock_checklock(SIMLOCK_CORPORATE);
TRACE_EVENT_P1("CLock: %d", simlock_status);
/*convert status from ACI to MFW encoding*/
return sim_convert_simlock_status(simlock_status);
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : sim_pin_status |
+--------------------------------------------------------------------+
PURPOSE : Request PIN1/PIN2 status
*/
void sim_pin_status(T_MFW_SIM_PIN_STATUS *status)
{
SHORT pn1Cnt;
SHORT pn2Cnt;
SHORT pk1Cnt;
SHORT pk2Cnt;
T_ACI_PVRF_STAT ps1;
T_ACI_PVRF_STAT ps2;
char debug[30];
TRACE_FUNCTION("sim_pin_status()");
status->stat = MFW_SIM_UNKNOWN;
status->set = MFW_SIM_UNKNOWN;
if (qAT_PercentPVRF(CMD_SRC_LCL, &pn1Cnt,
&pn2Cnt, &pk1Cnt, &pk2Cnt, &ps1, &ps2) == AT_CMPL)
{
switch (status->type)
{
case MFW_SIM_PIN1:
/*CONQ 5578, check service table to see if allowed to disable PIN1*/
if (!psaSIM_ChkSIMSrvSup(SRV_CHV1_Disable))
{
status->stat = MFW_SIM_NO_DISABLE;
}
else
{
status->stat = sim_cvtPINstatus(ps1, MFW_SIM_PIN1);
}
status->set = pin1_set;
break;
case MFW_SIM_PIN2:
status->stat = sim_cvtPINstatus(ps2, MFW_SIM_PIN2);
status->set = pin2_set;
break;
}
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : sim_cvtPINstatus |
+--------------------------------------------------------------------+
PURPOSE :
*/
UBYTE sim_cvtPINstatus(T_ACI_PVRF_STAT ps, UBYTE type)
{
TRACE_FUNCTION("sim_cvtPINstatus()");
switch (ps)
{
case PVRF_STAT_NotRequired:
return MFW_SIM_NO_PIN;
case PVRF_STAT_Required:
if (type EQ MFW_SIM_PIN1)
return MFW_SIM_PIN_REQ;
if (type EQ MFW_SIM_PIN2)
return MFW_SIM_PIN2_REQ;
return MFW_SIM_UNKNOWN;
default:
return MFW_SIM_UNKNOWN;
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : simDecodeIMSI |
+--------------------------------------------------------------------+
PURPOSE : convert imsi (packed bcd to ASCIIZ; ->11.11)
*/
void simDecodeIMSI (UBYTE * imsi_field,
UBYTE imsi_c_field,
UBYTE * imsi_extracted)
{
UBYTE length;
UBYTE i;
UBYTE digit;
TRACE_FUNCTION ("simDecodeImsi()");
/*
* calculate number of digits
*/
length = (imsi_c_field-1)*2;
/*
* if odd number of digits add one
*/
if (imsi_field[0] & 0x08)
length++;
/*
* extract all digits
*/
for (i = 0; i < length; i++)
{
digit = (i & 1) ?
imsi_field[(i + 1) / 2] & 0x0f :
(imsi_field[(i + 1) / 2] & 0xf0) >> 4;
#if defined (WIN32)
{
char buf[40];
sprintf (buf, "DIGIT [%d] = %d",i, digit);
TRACE_EVENT (buf);
}
#endif
if (i < LONG_NAME)
imsi_extracted [i] = digit + 0x30;
else
{
imsi_extracted [i] = 0;
return;
}
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : sim_pin_ident |
+--------------------------------------------------------------------+
PURPOSE : handle mfw windows command
*/
void sim_pin_ident(UBYTE id)
{
TRACE_FUNCTION("sim_pin_ident()");
pin_ident = id;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : simCommand |
+--------------------------------------------------------------------+
PURPOSE : handle mfw windows command
*/
static int simCommand (U32 cmd, void *h)
{
switch (cmd)
{
case MfwCmdDelete: /* delete me */
if (!h)
return 0;
sim_delete(h);
return 1;
default:
break;
}
return 0;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : sim_simlock_ok |
+--------------------------------------------------------------------+
PURPOSE : The function checks all simlocks and returns SIMLOCK_DISABLED
if none are set.
*/
/*spr 1351, replaced previous implemntation with a wrapper for aci implentation*/
UBYTE sim_simlock_ok (void)
{
T_SIMLOCK_STATUS simlock_status;
simlock_status = aci_slock_checkpersonalisation();
return sim_convert_simlock_status(simlock_status);
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : sim_get_imsi |
+--------------------------------------------------------------------+
PURPOSE : Request IMSI number in SIM card
*/
UBYTE * sim_get_imsi (void)
{
return mfw_IMSI;
}
/*
+---------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : sim_mmi_update_parameter |
+---------------------------------------------------------------------+
PURPOSE : MMI relevant parameters from the SIM card
*/
void sim_mmi_update_parameter(T_SIM_ACTIVATE_IND *sim_act_ind)
{
TRACE_FUNCTION("sim_mmi_update_parameter()");
memcpy( sim_config.pref_lang, sim_act_ind->pref_lang, 5);
}
#ifdef SIM_TOOLKIT
/*
+---------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : sim_sat_file_update |
+---------------------------------------------------------------------+
PURPOSE : SIM file change indication
*/
void sim_sat_file_update(USHORT dataId)
{
TRACE_FUNCTION("sim_sat_file_update()");
sat_update = TRUE;
switch (dataId)
{
case SIM_SST:
sim_read_sim(SIM_SST, NOT_PRESENT_8BIT, 10);
break;
case SIM_GID1:
sim_read_sim(SIM_GID1, NOT_PRESENT_8BIT, 5);
break;
case SIM_GID2:
sim_read_sim(SIM_GID2, NOT_PRESENT_8BIT, 5);
break;
case SIM_LP:
{
T_ACI_LAN_SUP lngCde;
CHAR lang_buffer[3];
memset(lang_buffer, 0, sizeof(lang_buffer));
lngCde.str = lang_buffer;
if (qAT_PlusCLAN(CMD_SRC_LCL, &lngCde) == AT_EXCT)
return;
#ifdef SIM_TOOLKIT
else
if (mfwSATLPRefresh)
{
sat_update = FALSE;
mfwSATLPRefresh =FALSE;
psaSAT_FUConfirm (0, SIM_FU_ERROR); /*If not possible, notify to the SIM */
}
#endif
}
break;
default:
break;
}
}
#endif
/*
+---------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : sim_read_sst_cnf |
+---------------------------------------------------------------------+
PURPOSE : SIM file change indication
*/
void sim_read_sst_cnf (SHORT error, UBYTE *data)
{
TRACE_FUNCTION("sim_read_sst_cnf()");
if (error EQ SIM_NO_ERROR)
memcpy(sim_service_table, data, sizeof(sim_service_table));
else
TRACE_EVENT("SST read error");
#ifdef SIM_TOOLKIT
if (sat_update)
{
sat_update = FALSE;
satUpdateFiles ( TRUE, SIM_SST );
}
#endif
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : sim_init_CPRS |
+--------------------------------------------------------------------+
PURPOSE : initialize the ciphering indication
*/
UBYTE sim_init_CPRS (CallbackCPRI func, UBYTE CPRImode )
{
UBYTE getCPRImode;
TRACE_FUNCTION("sim_init_CPRS()");
//keep the callback function from MMI
if (func != NULL)
mmi_cprs_cb = func;
else
return FALSE;
//now set the mode
sAT_PercentCPRI (CMD_SRC_LCL, CPRImode);
return TRUE;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : rAT_PercentCPRI |
+--------------------------------------------------------------------+
PURPOSE : is called to inform the application about a received ciphering indication.
gsm_ciph and gprs_ciph are used to inform the application about a change in ciphering
mode in GSM or GPRS.
*/
void rAT_PercentCPRI (UBYTE gsm_ciph, UBYTE gprs_ciph)
{
//call here the function from MMI
mmi_cprs_cb(gsm_ciph, gprs_ciph);
}
/*
+---------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
| STATE : code ROUTINE : sim_read_lp_cnf |
+---------------------------------------------------------------------+
PURPOSE :
*/
void sim_read_lp_cnf (SHORT error, T_ACI_LAN_SUP *CLang)
{
TRACE_FUNCTION("sim_read_lp_cnf()");
#ifdef SIM_TOOLKIT
if ((mfwSATLPRefresh)&&(sat_update))
{
mfwSATLPRefresh= FALSE;
sat_update = FALSE;
if (error EQ SIM_NO_ERROR)
satUpdateFiles ( TRUE, SIM_SST );
else
psaSAT_FUConfirm (0, SIM_FU_ERROR); /*If not possible, notify to the SIM */
}
#endif
}
//glowing, 2004-05-13 import from M188A that used in l1tm_cust_add.c
USHORT get_sim_status(void)
{
if((sim_status.sim_status==MFW_SIM_NO_SIM_CARD)
||(sim_status.sim_status==MFW_SIM_INVALID_CARD))
return ERR_STATUS;
else
return OK_STATUS;
}
/* glowing,2004-05-13, end of import */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -