微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > mt2503卡1卡2短信拷贝移动?

mt2503卡1卡2短信拷贝移动?

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
卡1卡2短信拷贝移动,供参考
[SOLUTION]
1.1卡1卡2短信拷贝移动.sop
1.在SMSSrv层增加新的接口函数
voidsrv_sms_copy_SIM_msg(
U16msg_id,
srv_sms_storage_enumdest_storage,
srv_sms_sim_enumdest_sim_id,
SrvSmsCallbackFunccallback_func,
void*user_data)
{
/*----------------------------------------------------------------*/
/*LocalVariables*/
/*----------------------------------------------------------------*/
srv_sms_cause_enumerror_cause;
/*----------------------------------------------------------------*/
/*CodeBody*/
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_COMMON_TRC_G6_MSG,TRC_SRV_SMS_COPY_MSG,msg_id,dest_storage);
srv_sms_enter_mmi_operating();
error_cause=srv_sms_check_common_msg_error(msg_id,SRV_SMS_ACTION_COPY);
if(error_cause==SRV_SMS_CAUSE_NO_ERROR)
{
if(srv_sms_get_msg_sim_id(msg_id)==dest_sim_id)
{
srv_sms_copy_msg_cb_structcopy_msg_cb_data;
copy_msg_cb_data.dest_msg_id=msg_id;
srv_sms_storage_succ_callback(
SRV_SMS_ACTION_COPY,
©_msg_cb_data,
user_data,
callback_func);
}
else
{
U16unused_entry;
U16msg_seg_num;
srv_sms_sim_enumsim_id;
msg_seg_num=srv_sms_get_msg_total_seg(msg_id);
sim_id=srv_sms_get_msg_sim_id(msg_id);
if(unused_entry>=msg_seg_num)
{
srv_sms_copy_cntx_struct*copy_cntx;
copy_cntx=OslMalloc(sizeof(srv_sms_copy_cntx_struct));
MMI_TRACE(MMI_COMMON_TRC_G6_MSG,TRC_SRV_SMS_COPY_MSG_1,copy_cntx);
srv_sms_copy_msg_init(
copy_cntx,
msg_id,
dest_storage,
callback_func,
user_data);
d_sim_id=dest_sim_id;
/*ReadtheCopiedPDUfirst,thenSaveittoDestinationStorage*/
srv_sms_read_pdu(
copy_cntx->src_pdu_list[copy_cntx->curr_index],
srv_sms_copy_msg_callback,
copy_cntx);
}
else
{
if(unused_entry>0)
{
error_cause=SRV_SMS_CAUSE_MEM_INSUFFICIENT;
}
else
{
error_cause=SRV_SMS_CAUSE_MEM_FULL;
}
srv_sms_storage_error_callback(
SRV_SMS_ACTION_COPY,
error_cause,
user_data,
callback_func);
}
}
}
else
{
srv_sms_storage_error_callback(
SRV_SMS_ACTION_COPY,
error_cause,
user_data,
callback_func);
}
}
2.定义SIM1和SIM2SMS互相移动的API:
voidsrv_sms_move_sim_msg(
U16msg_id,
srv_sms_storage_enumdest_storage,
srv_sms_sim_enumdest_sim_id,
SrvSmsCallbackFunccallback_func,
void*user_data)
{
/*----------------------------------------------------------------*/
/*LocalVariables*/
/*----------------------------------------------------------------*/
srv_sms_cause_enumerror_cause;
/*----------------------------------------------------------------*/
/*CodeBody*/
/*----------------------------------------------------------------*/
/*ThehandlingofMoveissimiliarwithCopy,itmayberevise,andmergetoonecase*/
MMI_TRACE(MMI_COMMON_TRC_G6_MSG,TRC_SRV_SMS_MOVE_MSG,msg_id,dest_storage);
srv_sms_enter_mmi_operating();
error_cause=srv_sms_check_common_msg_error(msg_id,SRV_SMS_ACTION_COPY);
if(error_cause==SRV_SMS_CAUSE_NO_ERROR)
{
if(srv_sms_get_msg_sim_id(msg_id)==dest_sim_id)
{
srv_sms_move_msg_cb_structmove_msg_cb_data;
move_msg_cb_data.dest_msg_id=msg_id;
srv_sms_storage_succ_callback(
SRV_SMS_ACTION_COPY,
&move_msg_cb_data,
user_data,
callback_func);
}
else
{
U16unused_entry;
U16msg_seg_num;
srv_sms_sim_enumsim_id;
U8same_pdu_num;
sim_id=srv_sms_get_msg_sim_id(msg_id);
unused_entry=srv_sms_get_unused_space(dest_storage,dest_sim_id);
msg_seg_num=srv_sms_get_msg_total_seg(msg_id);
same_pdu_num=srv_sms_get_msg_pdu_num_by_storage(msg_id,dest_storage);
/*IfthismessagecontainssamestoragetpyePDUasthedestinationstorage,
*needn'ttomoveit(includereading,adding,deletingthisPDU)*/
if(unused_entry>=(msg_seg_num-same_pdu_num))
{
srv_sms_move_cntx_struct*move_cntx;
move_cntx=OslMalloc(sizeof(srv_sms_move_cntx_struct));
MMI_TRACE(MMI_COMMON_TRC_G6_MSG,TRC_SRV_SMS_MOVE_MSG,move_cntx);
srv_sms_move_msg_init(
move_cntx,
msg_id,
dest_storage,
callback_func,
user_data);
d_sim_id=dest_sim_id;
srv_sms_move_msg_read(move_cntx);
}
else
{
if(unused_entry>0)
{
error_cause=SRV_SMS_CAUSE_MEM_INSUFFICIENT;
}
else
{
error_cause=SRV_SMS_CAUSE_MEM_FULL;
}
srv_sms_storage_error_callback(
SRV_SMS_ACTION_MOVE,
error_cause,
user_data,
callback_func);
}
}
}
else
{
srv_sms_storage_error_callback(
SRV_SMS_ACTION_MOVE,
error_cause,
user_data,
callback_func);
}
}
3.定义一个全局变量
srv_sms_sim_enumd_sim_id=SRV_SMS_SIM_TOTAL;
4.修改如下函数,修改的地方以#ifdef__sim1_sim2_sms__标记:
staticvoidsrv_sms_move_msg_read(srv_sms_move_cntx_struct*move_cntx)
{
/*----------------------------------------------------------------*/
/*LocalVariables*/
/*----------------------------------------------------------------*/
U16curr_pdu_id;
srv_sms_storage_enumdest_storage=move_cntx->dest_storage;
void*user_data=move_cntx->user_data;
SrvSmsCallbackFunccallback_func=move_cntx->callback_func;
/*----------------------------------------------------------------*/
/*CodeBody*/
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_COMMON_TRC_G6_MSG,TRC_SRV_SMS_MOVE_MSG_READ,move_cntx->curr_index);
curr_pdu_id=move_cntx->src_pdu_list[move_cntx->curr_index];
/*SkipthesamestoragePDU*/
#ifdef__sim1_sim2_sms__
while((move_cntx->curr_index<move_cntx->total_pdu)&&
(srv_sms_get_pdu_storage_type(curr_pdu_id)==dest_storage)&&
(srv_sms_get_msg_sim_id(move_cntx->msg_id)==d_sim_id))
#else
while((move_cntx->curr_index<move_cntx->total_pdu)&&
(srv_sms_get_pdu_storage_type(curr_pdu_id)==dest_storage))
#endif
{
move_cntx->dest_pdu_list[move_cntx->curr_index]=curr_pdu_id;
move_cntx->curr_index++;
curr_pdu_id=move_cntx->src_pdu_list[move_cntx->curr_index];
}
MMI_TRACE(MMI_COMMON_TRC_G6_MSG,TRC_SRV_SMS_MOVE_MSG_READ_1,move_cntx->curr_index);
if(move_cntx->curr_index<move_cntx->total_pdu)
{
srv_sms_read_pdu(
move_cntx->src_pdu_list[move_cntx->curr_index],
srv_sms_move_msg_callback,
move_cntx);
}
else
{
/*ReadMessageFinish,CleartheREADINGFlag*/
srv_sms_clear_pdu_array_flag(
move_cntx->src_pdu_list,
move_cntx->total_pdu,
SRV_SMS_NODE_READING);
if(move_cntx->moved_pdu_num>0)
{
move_cntx->curr_index=0;
srv_sms_set_pdu_array_flag(
move_cntx->moved_pdu_list,
move_cntx->moved_pdu_num,
SRV_SMS_NODE_DELETING);
srv_sms_delete_pdu(
move_cntx->moved_pdu_list[move_cntx->curr_index],
srv_sms_move_msg_del_moved_callback,
move_cntx);
}
else
{
srv_sms_move_msg_cb_structmove_msg_cb_data;
move_msg_cb_data.dest_msg_id=move_cntx->msg_id;
srv_sms_move_msg_deinit(move_cntx);
srv_sms_storage_succ_callback(
SRV_SMS_ACTION_MOVE,
&move_msg_cb_data,
user_data,
callback_func);
}
}
}
5.修改如下函数,修改的地方以#ifdef__sim1_sim2_sms__标记:
staticvoidsrv_sms_move_msg_del_moved_callback(srv_sms_callback_struct*callback_data)
{
/*----------------------------------------------------------------*/
/*LocalVariables*/
/*----------------------------------------------------------------*/
srv_sms_move_cntx_struct*move_cntx;
/*----------------------------------------------------------------*/
/*CodeBody*/
/*----------------------------------------------------------------*/
move_cntx=(srv_sms_move_cntx_struct*)callback_data->user_data;
MMI_TRACE(MMI_COMMON_TRC_G6_MSG,TRC_SRV_SMS_MOVE_MSG_DEL_MOVED_CALLBACK,callback_data->result,move_cntx->curr_index);
if(callback_data->result==MMI_FALSE)
{
U16pdu_id=move_cntx->moved_pdu_list[move_cntx->curr_index];
srv_sms_clear_pdu_flag(pdu_id,SRV_SMS_NODE_DELETING);
}
move_cntx->curr_index++;
if(move_cntx->curr_index<move_cntx->moved_pdu_num)
{
srv_sms_delete_pdu(
move_cntx->moved_pdu_list[move_cntx->curr_index],
srv_sms_move_msg_del_moved_callback,
move_cntx);
}
else
{
srv_sms_event_update_struct*event_data;
srv_sms_move_msg_cb_structmove_msg_cb_data;
void*user_data=move_cntx->user_data;
SrvSmsCallbackFunccallback_func=move_cntx->callback_func;
U16msg_id=move_cntx->msg_id;
srv_sms_msg_node_struct*msg_node;
MMI_BOOLint_result;
event_data=OslMalloc(sizeof(srv_sms_event_update_struct));
msg_node=srv_sms_get_msg_node(msg_id);
/*GetOldMsgInfo*/
srv_sms_msg_node_to_msg_info(&event_data->old_msg_info,msg_node);
msg_node->storage_type=move_cntx->dest_storage;
#ifdef__sim1_sim2_sms__
msg_node->sim_id=d_sim_id;
#endif
srv_sms_concat_pdu_list(
msg_id,
move_cntx->dest_pdu_list,
move_cntx->total_pdu);
/*SetEventDataForMessageChange*/
event_data->msg_id=msg_id;
event_data->change_para_flag=SRV_SMS_PARA_STORAGE_TYPE;
srv_sms_msg_node_to_msg_info(&event_data->new_msg_info,msg_node);
srv_sms_clear_pdu_array_flag(
move_cntx->added_pdu_list,
move_cntx->moved_pdu_num,
SRV_SMS_NODE_LOCKING);
srv_sms_move_msg_deinit(move_cntx);
/*ExecMessageChangeInterruptEvent*/
int_result=srv_sms_exec_interrupt_event(EVT_ID_SRV_SMS_UPDATE_MSG,event_data);
/*ExecCallbackFunction*/
move_msg_cb_data.dest_msg_id=msg_id;
srv_sms_storage_succ_callback(
SRV_SMS_ACTION_MOVE,
&move_msg_cb_data,
user_data,
callback_func);
if(int_result==MMI_FALSE)
{
/*emitMessageChangeEvent*/
srv_sms_emit_event(EVT_ID_SRV_SMS_UPDATE_MSG,event_data);
}
OslMfree(event_data);
#ifdef__sim1_sim2_sms__
d_sim_id=SRV_SMS_SIM_TOTAL;
#endif
srv_sms_handle_mem_change();
}
}
6.修改如下函数,修改的地方以#ifdef__sim1_sim2_sms__标记:
staticvoidsrv_sms_copy_msg_callback(srv_sms_callback_struct*callback_data)
{
/*----------------------------------------------------------------*/
/*LocalVariables*/
/*----------------------------------------------------------------*/
srv_sms_copy_cntx_struct*copy_cntx;
void*user_data;
SrvSmsCallbackFunccallback_func;
/*----------------------------------------------------------------*/
/*CodeBody*/
/*----------------------------------------------------------------*/
copy_cntx=(srv_sms_copy_cntx_struct*)callback_data->user_data;
MMI_TRACE(MMI_COMMON_TRC_G6_MSG,TRC_SRV_SMS_COPY_MSG_CALLBACK,callback_data->result,copy_cntx->curr_index,callback_data->action);
user_data=copy_cntx->user_data;
callback_func=copy_cntx->callback_func;
if(callback_data->result==MMI_TRUE)
{
switch(callback_data->action)
{
caseSRV_SMS_ACTION_READ:
{
srv_sms_read_pdu_cb_struct*read_pdu_cb_data;
U8ori_status;
read_pdu_cb_data=(srv_sms_read_pdu_cb_struct*)callback_data->action_data;
ori_status=read_pdu_cb_data->spdu_data->status;
/*1.Ifthemessage'soriginalstatusisUNREAD,allofthesegments
*shouldbesameaftercopyingevenifsomeoriginalsegmentsisnotUNREAD
*(IfitexistssegmentswhichtheirstatusisUNREAD,wewillconsiderthis
*messageasUNREAD);
*2>IftheoriginalstatusisDraftanditsstorageisSIM,after
*copyittoME,thestatusshouldbeDraftnottheUNSENT.*/
read_pdu_cb_data->spdu_data->status=(U8)srv_sms_get_msg_status(copy_cntx->msg_id);
srv_sms_add_pdu(
read_pdu_cb_data->spdu_data,
copy_cntx->segment[copy_cntx->curr_index],
copy_cntx->dest_storage,
srv_sms_copy_msg_callback,
copy_cntx);
read_pdu_cb_data->spdu_data->status=ori_status;
break;
}
caseSRV_SMS_ACTION_SAVE:
{
srv_sms_add_pdu_cb_struct*add_pdu_cb_data;
U16pdu_id;
add_pdu_cb_data=(srv_sms_add_pdu_cb_struct*)callback_data->action_data;
pdu_id=add_pdu_cb_data->pdu_id;
copy_cntx->dest_pdu_list[copy_cntx->curr_index]=pdu_id;
copy_cntx->dest_total_pdu++;
/*SetPDUtoWritingFlaginordertoforbidotheroperating*/
srv_sms_set_pdu_flag(pdu_id,SRV_SMS_NODE_LOCKING);
copy_cntx->curr_index++;
if(copy_cntx->curr_index<copy_cntx->src_total_pdu)
{
srv_sms_read_pdu(
copy_cntx->src_pdu_list[copy_cntx->curr_index],
srv_sms_copy_msg_callback,
copy_cntx);
}
else
{
srv_sms_event_add_struct*event_data;
srv_sms_copy_msg_cb_structcopy_msg_cb_data;
srv_sms_msg_node_struct*scr_msg_node;
srv_sms_msg_node_struct*dest_msg_node;
#ifdef__sim1_sim2_sms__
srv_sms_sim_enumsim_id;
#endif
U16dest_msg_id;
MMI_BOOLint_result;
scr_msg_node=srv_sms_get_msg_node(copy_cntx->msg_id);
#ifdef__sim1_sim2_sms__
sim_id=d_sim_id;
#endif
dest_msg_node=OslMalloc(sizeof(srv_sms_msg_node_struct));
meMCPy(dest_msg_node,scr_msg_node,sizeof(srv_sms_msg_node_struct));
dest_msg_node->storage_type=copy_cntx->dest_storage;
dest_msg_node->start_pdu_id=SRV_SMS_INVALID_PDU_ID;
#ifdef__sim1_sim2_sms__
dest_msg_node->sim_id=sim_id;
#endif
dest_msg_id=srv_sms_add_msg_node(dest_msg_node);
srv_sms_concat_pdu_list(
dest_msg_id,
copy_cntx->dest_pdu_list,
copy_cntx->dest_total_pdu);
/*SetEventDataForAddEvent*/
event_data=OslMalloc(sizeof(srv_sms_event_add_struct));
event_data->msg_id=dest_msg_id;
srv_sms_msg_node_to_msg_info(&event_data->msg_info,dest_msg_node);
OslMfree(dest_msg_node);
/*FreeCopyContextBuffer*/
srv_sms_copy_msg_deinit(copy_cntx);
/*ExecInterruptAddEvent*/
int_result=srv_sms_exec_interrupt_event(EVT_ID_SRV_SMS_ADD_MSG,event_data);
/*ExecCallbackFunction*/
copy_msg_cb_data.dest_msg_id=dest_msg_id;
srv_sms_storage_succ_callback(
SRV_SMS_ACTION_COPY,
©_msg_cb_data,
user_data,
callback_func);
if(int_result==MMI_FALSE)
{
/*EmitAddEvent*/
srv_sms_emit_event(EVT_ID_SRV_SMS_ADD_MSG,event_data);
}
OslMfree(event_data);
#ifdef__sim1_sim2_sms__
d_sim_id=SRV_SMS_SIM_TOTAL;
#endif
srv_sms_handle_mem_change();
}
break;
}
default:
MMI_ASSERT(0);
break;
}
}
else
{
copy_cntx->error_cause=callback_data->cause;
if(copy_cntx->dest_total_pdu>0)
{
copy_cntx->curr_index=0;
srv_sms_clear_pdu_array_flag(
copy_cntx->dest_pdu_list,
copy_cntx->dest_total_pdu,
SRV_SMS_NODE_LOCKING);
srv_sms_set_pdu_array_flag(
copy_cntx->dest_pdu_list,
copy_cntx->dest_total_pdu,
SRV_SMS_NODE_DELETING);
srv_sms_delete_pdu(
copy_cntx->dest_pdu_list[copy_cntx->curr_index],
srv_sms_copy_msg_del_callback,
copy_cntx);
}
else
{
srv_sms_copy_msg_deinit(copy_cntx);
srv_sms_storage_error_callback(
SRV_SMS_ACTION_COPY,
callback_data->cause,
user_data,
callback_func);
}
}
}
7.修改如下函数,修改的地方以#ifdef__sim1_sim2_sms__标记:
voidsrv_sms_add_pdu(
srv_sms_spdu_struct*spdu_data,
U8curr_seg,
srv_sms_storage_enumstorage_type,
SrvSmsCallbackFunccallback_func,
void*user_data)
{
/*----------------------------------------------------------------*/
/*LocalVariables*/
/*----------------------------------------------------------------*/
U16unused_pdu_id;
srv_sms_sim_enumsim_id=SRV_SMS_SIM_1;
/*----------------------------------------------------------------*/
/*CodeBody*/
/*----------------------------------------------------------------*/
#ifdef__SRV_SMS_MULTI_SIM__
#ifdef__sim1_sim2_sms__
if(d_sim_id!=SRV_SMS_SIM_TOTAL)
{
sim_id=d_sim_id;
}
else
{
sim_id=spdu_data->sim_id;
}
#else
sim_id=spdu_data->sim_id;
#endif
#endif/*__SRV_SMS_MULTI_SIM__*/
MMI_TRACE(MMI_COMMON_TRC_G6_MSG,TRC_SRV_SMS_ADD_PDU,curr_seg,storage_type,sim_id);
if(storage_cntx.is_ready==MMI_TRUE)
{
unused_pdu_id=srv_sms_get_unused_pdu_id(storage_type,sim_id);
if(unused_pdu_id!=SRV_SMS_INVALID_PDU_ID)
{
srv_sms_add_pdu_cntx_struct*add_pdu_cntx;
srv_sms_storage_enumdest_storage;
srv_sms_sim_enumtmp_sim_id;
U8ori_msg_status;
U16index;
add_pdu_cntx=OslMalloc(sizeof(srv_sms_add_pdu_cntx_struct));
add_pdu_cntx->pdu_id=unused_pdu_id;
add_pdu_cntx->callback_func=callback_func;
add_pdu_cntx->user_data=user_data;
/*AddthePDUNodefirst,formarkitasUSED,andincrementtheusedcount*/
srv_sms_add_pdu_node(
unused_pdu_id,
curr_seg,
(srv_sms_status_enum)spdu_data->status);
index=srv_sms_pdu_id_to_record_index(unused_pdu_id,&dest_storage,&tmp_sim_id);
MMI_ASSERT(index!=SRV_SMS_INVALID_INDEX);
MMI_ASSERT((storage_type==SRV_SMS_STORAGE_UNSPECIFIC)||(storage_type==dest_storage));
/*Remindtheoriginalstatus*/
ori_msg_status=spdu_data->status;
MMI_TRACE(MMI_COMMON_TRC_G6_MSG,TRC_SRV_SMS_ADD_PDU_1,dest_storage,ori_msg_status);
/*IntheSIMCard,thereisn'tDRAFTstatus*/
if((dest_storage==SRV_SMS_STORAGE_SIM)&&
(ori_msg_status==SRV_SMS_STATUS_DRAFT))
{
spdu_data->status=SRV_SMS_STATUS_UNSENT;
}
spdu_data->status=srv_sms_msg_status_to_spdu_status(spdu_data->status);
if(dest_storage==SRV_SMS_STORAGE_ME)
{
srv_sms_write_me_sms(
index,
spdu_data,
srv_sms_add_pdu_callback,
add_pdu_cntx);
}
else
{
srv_sms_write_sim_sms(
index,
sim_id,
spdu_data,
srv_sms_add_pdu_callback,
add_pdu_cntx);
}
/*Restorethestatus*/
spdu_data->status=ori_msg_status;
}
else
{
srv_sms_error_callback(
SRV_SMS_ACTION_SAVE,
SRV_SMS_CAUSE_MEM_FULL,
user_data,
callback_func);
}
}
else
{
srv_sms_error_callback(
SRV_SMS_ACTION_SAVE,
SRV_SMS_CAUSE_NOT_READY,
user_data,
callback_func);
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top