📄 nvimw.c
字号:
return NV_READONLY_S;
}
else {
/* The PST may try to write a value of 0 one or more times,
simply return success if the current rf_cal_date value is 0 */
if (cmd_ptr->data_ptr->rf_cal_date == 0) {
return NV_DONE_S;
}
}
}
#endif // !_SAMSUNG_BREW_COMMON
/* Turn off permanent file attribute in order to write */
if ((status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_UNRESTRICTED)) != NV_DONE_S)
{
return status;
}
status = nvimw_write_fixed(cmd_ptr->item,
cmd_ptr->data_ptr,
nv_op_get_size(cmd_ptr->item));
/* Turn back on permanent file attribute */
if (status == NV_DONE_S) {
status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_SYS_PERMANENT);
}
return status;
}
#endif
#ifdef FEATURE_RFCAL_VERSION
/*===========================================================================
FUNCTION NVIMW_WRITE_RF_CAL_DAT_FILE
DESCRIPTION
This function processed a write command to the NV_RF_CAL_DAT_FILE_I item.
DEPENDENCIES
None.
RETURN VALUE
NV_DONE_S if it worked error status code if it failed.
SIDE EFFECTS
None
===========================================================================*/
LOCAL nv_stat_enum_type nvimw_write_rf_cal_dat_file
(
nv_cmd_type *cmd_ptr /* Command block */
)
{
int i;
nv_stat_enum_type status;
byte local_rf_cal_dat_file[NV_QC_SERIAL_NUM_LEN]; /* tmp buffer for rf_cal_dat_file */
boolean all_zero_write_value;
boolean empty_value = TRUE;
nvim_efs_params *efs_params = nv_op_get_fparams(cmd_ptr->item);
/* Read the current rf_cal_dat_file. value */
status = nvimr_read_fixed(cmd_ptr->item,
local_rf_cal_dat_file, /* data ptr */
nv_op_get_size(cmd_ptr->item));
if ((status != NV_DONE_S) && (status != NV_NOTACTIVE_S))
{
return status;
}
/* rf_cal_dat_file can only be written once */
if (status == NV_DONE_S) {
for (i=0; i<NV_QC_SERIAL_NUM_LEN; i++) {
if (local_rf_cal_dat_file[i] != 0) {
empty_value = FALSE;
}
}
if (!empty_value)
{
/* The file is now considered read-only */
return NV_READONLY_S;
} else {
/* The PST may try to write a value of 0 one or more times,
simply return success if the current rf_cal_dat_file value is 0 */
all_zero_write_value = TRUE;
for (i=0; i<NV_QC_SERIAL_NUM_LEN; i++) {
if (cmd_ptr->data_ptr->rf_cal_dat_file[i] != 0) {
all_zero_write_value = FALSE;
}
}
if (all_zero_write_value)
{
return NV_DONE_S;
}
}
}
/* Turn off permanent file attribute in order to write */
if ((status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_UNRESTRICTED)) != NV_DONE_S)
{
return status;
}
status = nvimw_write_fixed(cmd_ptr->item,
cmd_ptr->data_ptr,
nv_op_get_size(cmd_ptr->item));
/* Turn back on permanent file attribute */
if (status == NV_DONE_S) {
status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_SYS_PERMANENT);
}
return status;
}
#endif
/*===========================================================================
FUNCTION NVIMW_WRITE_IMEI
DESCRIPTION
This function processed a write command to the NV_UE_IMEI_I item.
DEPENDENCIES
None.
RETURN VALUE
NV_DONE_S if it worked error status code if it failed.
SIDE EFFECTS
None
===========================================================================*/
#ifdef _SAMSUNG_MP_CUSTOM_RESET //sec_ui2_kkw_20051031_1
extern ResetMode_Type ResetMode;
extern int Master_Reset;
#endif
#ifdef _SAMSUNG_BREW_MSL //sec_ui2_mky_060131 /*MSL*/
extern byte ak_permission;
extern byte msl_permission;
extern boolean msl_rw_permission;
#endif
LOCAL nv_stat_enum_type nvimw_write_imei
(
nv_cmd_type *cmd_ptr /* Command block */
)
{
int i;
nv_stat_enum_type status;
nv_ue_imei_type local_ue_imei; /* tmp buffer for ue_imei */
boolean all_zero_write_value;
boolean ue_imei_empty = TRUE;
nvim_efs_params *efs_params = nv_op_get_fparams(cmd_ptr->item);
/* Read the current IMEI value */
status = nvimr_read_fixed(cmd_ptr->item,
&local_ue_imei, /* data ptr */
nv_op_get_size(cmd_ptr->item));
#ifdef _SAMSUNG_BREW_MSL //sec_ui2_mky_060131 //sec_sys_selee: rebuilding 矫 imei 荤扼瘤绰 泅惑 菩摹
if((cm_mp_nv == FALSE) && (msl_permission == FALSE ||ak_permission == FALSE))
{
return NV_FAIL_S;
}
#endif
if ((status != NV_DONE_S) && (status != NV_NOTACTIVE_S))
{
return status;
}
#ifdef _SAMSUNG_MP_CUSTOM_RESET
if(Master_Reset)
return NV_READONLY_S;
if(ResetMode>0 && ResetMode<MAX_MODE)
{
if(keystr == FALSE)return NV_READONLY_S; //sec_system_selee_051106 : keystring reset 矫 檬扁拳
}
#endif
/* IMEI can only be written once */
if (status == NV_DONE_S) {
for (i=0; i<NV_UE_IMEI_SIZE; i++) {
if (local_ue_imei.ue_imei[i] != 0) {
ue_imei_empty = FALSE;
}
}
#ifdef _SAMSUNG_MP_IMEI_WRITE // sec_ui2_kkw_20051005_1
//jwlee 2004.11.25 for writing IMEI only in Test Mode
if (ftm_mode == FTM_MODE || cm_mp_nv == TRUE)
ue_imei_empty = TRUE;
#endif
if (!ue_imei_empty)
{
/* The file is now considered read-only */
return NV_READONLY_S;
} else {
/* The PST may try to write a value of 0 one or more times,
simply return success if the current IMEI value is 0 */
all_zero_write_value = TRUE;
for (i=0; i<NV_UE_IMEI_SIZE; i++) {
if (cmd_ptr->data_ptr->ue_imei.ue_imei[i] != 0) {
all_zero_write_value = FALSE;
}
}
if (all_zero_write_value)
{
return NV_DONE_S;
}
}
}
/* Turn off permanent file attribute in order to write */
if ((status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_UNRESTRICTED)) != NV_DONE_S)
{
return status;
}
status = nvimw_write_fixed(cmd_ptr->item,
cmd_ptr->data_ptr,
nv_op_get_size(cmd_ptr->item));
/* Turn back on permanent file attribute */
if (status == NV_DONE_S) {
status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_SYS_PERMANENT);
}
return status;
}
#ifdef _SAMSUNG_BREW_MSL //sec_ui2_mky_060131
#define NV_MSL_CODE_SIZE 6
#define NV_MSL_ADDR_SIZE 10
LOCAL nv_stat_enum_type nvimw_write_msl_code
(
nv_cmd_type *cmd_ptr /* Command block */
)
{
int i;
nv_stat_enum_type status;
nv_item_type local_msl; /* tmp buffer for msl */
boolean all_zero_write_value;
boolean msl_empty=TRUE;
byte default_msl_code[NV_MSL_CODE_SIZE]={'0','0','0','0','0','0'};
nvim_efs_params *efs_params = nv_op_get_fparams(cmd_ptr->item);
status = nvimr_read_fixed(cmd_ptr->item,
&local_msl, /* data ptr */
nv_op_get_size(cmd_ptr->item));
if((cm_mp_nv == FALSE) && (msl_rw_permission == FALSE))
return NV_FAIL_S;
else msl_rw_permission = FALSE;
if ((status != NV_DONE_S) && (status != NV_NOTACTIVE_S))
{
return status;
}
if (status == NV_DONE_S) {
if(memcmp((void *)default_msl_code,(void *)msl_decrypt_data(local_msl.msl_code.digits),NV_MSL_CODE_SIZE))
msl_empty = FALSE;
if (!msl_empty)
{
return NV_READONLY_S;
}
else
{
all_zero_write_value = TRUE;
if(memcmp((void *)default_msl_code,(void *)msl_decrypt_data(cmd_ptr->data_ptr->msl_code.digits),NV_MSL_CODE_SIZE))
all_zero_write_value = FALSE;
if (all_zero_write_value)
{
return NV_FAIL_S;
}
}
}
if ((status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_UNRESTRICTED)) != NV_DONE_S)
{
return status;
}
status = nvimw_write_fixed(cmd_ptr->item,
cmd_ptr->data_ptr,
nv_op_get_size(cmd_ptr->item));
if (status == NV_DONE_S) {
status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_SYS_PERMANENT);
}
return status;
}
LOCAL nv_stat_enum_type nvimw_write_msl_addr
(
nv_cmd_type *cmd_ptr /* Command block */
)
{
int i;
nv_stat_enum_type status;
nv_item_type local_msl; /* tmp buffer for msl */
boolean all_zero_write_value;
boolean msl_empty=TRUE;
nvim_efs_params *efs_params = nv_op_get_fparams(cmd_ptr->item);
status = nvimr_read_fixed(cmd_ptr->item,
&local_msl, /* data ptr */
nv_op_get_size(cmd_ptr->item));
if((cm_mp_nv == FALSE) && (msl_rw_permission == FALSE))
return NV_FAIL_S;
else msl_rw_permission = FALSE;
if ((status != NV_DONE_S) && (status != NV_NOTACTIVE_S))
{
return status;
}
if (status == NV_DONE_S) {
for (i=0; i<(NV_MSL_ADDR_SIZE); i++) {
if (local_msl.msl_addr.digits[i] != '0') {
msl_empty = FALSE;
}
}
if (!msl_empty)
{
return NV_READONLY_S;
} else {
all_zero_write_value = TRUE;
for (i=0; i<(NV_MSL_ADDR_SIZE); i++) {
if (cmd_ptr->data_ptr->msl_addr.digits[i] != '0') {
all_zero_write_value = FALSE;
}
}
if (all_zero_write_value)
{
return NV_FAIL_S;
}
}
}
if ((status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_UNRESTRICTED)) != NV_DONE_S)
{
return status;
}
status = nvimw_write_fixed(cmd_ptr->item,
cmd_ptr->data_ptr,
nv_op_get_size(cmd_ptr->item));
if (status == NV_DONE_S) {
status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_SYS_PERMANENT);
}
return status;
}
#endif
/*===========================================================================
FUNCTION NVIMW_WRITE_MEID
DESCRIPTION
This function processed a write command to the NV_MEID_I item.
DEPENDENCIES
None.
RETURN VALUE
NV_DONE_S if it worked error status code if it failed.
SIDE EFFECTS
None
===========================================================================*/
LOCAL nv_stat_enum_type nvimw_write_meid
(
nv_cmd_type *cmd_ptr /* Command block */
)
{
nv_stat_enum_type status;
qword local_meid; /* temporary buffer for meid */
local_meid[0] = 0;
local_meid[1] = 0;
/* Read the current MEID value */
status = nvimr_read_fixed(cmd_ptr->item,
local_meid, /* data ptr */
nv_op_get_size(cmd_ptr->item));
if ((status != NV_DONE_S)&&(status != NV_NOTACTIVE_S))
{
MSG_HIGH (" MEID Read was successful. ",0,0,0);
return status;
}
if (!(((local_meid[0] == 0) && (local_meid[1] == 0)) ||
((local_meid[0] == (dword)0xFFFFFFFFUL)
&& (local_meid[1] == (dword)0x00FFFFFFUL))))
{
/* The file is now considered read-only */
MSG_HIGH (" MEID is neither all 0s nor all Fs. ",0,0,0);
return NV_READONLY_S;
}
/* Turn off permanent file attribute in order to write */
if ((status = nvim_update_fs_item_file_attrs(
nv_op_get_fparams(cmd_ptr->item),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -