MTK-call history operate

 

MTK-call history operate

1.call history的保存。在各种通话状态中的保存过程

1.MO

(1)放弃outgoing call

ProcessPSHangupSucEvent()

       LogCallInfoForCallHistory(*handle);

       GetEndTimeAndNotifyCallAborted();

              CMGetExactTime(GetDateTimeAndNotifyCallAbortedCBack);

                                                 memcpy(&cm_p->state_info.CallStructureForCallLog.start_time, t, sizeof(MYTIME));  拷贝当前时间

                                             memcpy(&cm_p->state_info.CallStructureForCallLog.end_time, t, sizeof(MYTIME));

                                                 LogCall();

                                                        LogCallWithStartTime(&cm_p->state_info.CallStructureForCallLog);

                                                               if (CM_CALL_MO == log->orgination_flag) 判断电话类型:MO, MT

                                                           {

                                                              CHISTLogDialedCall(log);

                                                                             ReqWriteCallLog(call, PHB_LND);

                                                           }

                                                           else if (CM_CALL_MT == log->orgination_flag)

                                                          {

                                                              CHISTLogRecvdCall(log);

                                                                             ReqWriteCallLog(call, PHB_LNR);

                                                           }

                                                 EntryScrNotifyCallAborted();

 

       ReqWriteCallLog()这是最后写入函数

              设置返回消息PRT_MMI_PHB_SET_LAST_NUMBER_RSP的CBack函数:RspWriteDialedNum,RspWriteMissedNum,RspWriteRecvdNum。

              chis_p->process = CALL_LOG_PROC_WRITE;

 

              dataPtr = (SET_LAST_NUMBER_REQ*) OslConstructDataPtr(sizeof(SET_LAST_NUMBER_REQ));

          dataPtr->type = type;

          dataPtr->no_data = 0;

          dataPtr->index = 0xff;

              memset((U8*) & dataPtr->entry.tel, 0, sizeof(CALL_LOG_NUMBER_STRUCT));                   清空号码入口

              memset((U8*) & dataPtr->entry.alpha_id, 0, sizeof(CALL_LOG_NAME_STRUCT));               清空姓名入口

 

              //开始装载号码和姓名

              如果号码第一位是+,dataPtr->entry.tel.type = 145(0x91),否则dataPtr->entry.tel.type = 129(0x81).

              然后把号码转换成ASCII码,并拷贝到dataPtr->entry.tel.number中。

              姓名也要转换成ASCII码,并转换成大端格式。(小端:低位放低地址,大端:低位放高地址)

 

              ConvertMYTIME2RTC(&dataPtr->entry.time, &dailCall->start_time);     开始时间转换成RTC格式

          dataPtr->entry.call_duration = 0;       时间

          dataPtr->entry.count = 1;                  次数

 

              发送消息: PRT_MMI_PHB_SET_LAST_NUMBER_REQ

 

然后PS返回消息PRT_MMI_PHB_SET_LAST_NUMBER_RSP,进入CBACK函数:

RspWriteDialedNum()

       chis_p->nDialedCalls = (U8) rsp->no_list;      当前已拨电话数目

       chis_p->process = CALL_LOG_PROC_NONE;

 

 

(2)网络挂断MO call

ProcessEndCallIdAndGoBack()

       LogCallInfoForCallHistory()

       GetEndTimeAndLogUnconnectedMOCall()

              CMGetExactTime(GetDateTimeAndLogUnconnectedMOCallCBack);

                                                 memcpy(&cm_p->state_info.CallStructureForCallLog.start_time, t, sizeof(MYTIME));

                                             memcpy(&cm_p->state_info.CallStructureForCallLog.end_time, t, sizeof(MYTIME));

                                             LogCall();

       EntryScr1004NotifyEndCallDuration()

 

 

(3)MO call connect

OutgoingCallConnected()

       DTGetRTCTime(&t);   获取当前时间

       UpdateCallStartTimeAndLogCall(handle, &t);

              memcpy(&cm_p->state_info.AllCalls[index].start_time, t, sizeof(MYTIME));   //拷贝当前时间

              LogCallWithStartTime(&cm_p->state_info.AllCalls[index]);

 

MT CALL

(4)reject a MT

ProcessIncomingCallRejected

       LogCallInfoForCallHistory(GetIncomingCallHandle());

   PurgeIncomingCallStructure();

              SetCallState( )

                     GetEndTimeAndNotifyCallRejected()             reject a MT call

                            CMGetExactTime( GetDateTimeAndNotifyCallRejectedCBack );

                                                               memcpy(&cm_p->state_info.CallStructureForCallLog.start_time,t,sizeof(MYTIME));

                                                               memcpy(&cm_p->state_info.CallStructureForCallLog.end_time,t,sizeof(MYTIME));

                                                        CHISTLogRejectedCall(&cm_p->state_info.CallStructureForCallLog);

                                                                      ReqWriteCallLog( call, PHB_LNM );

                                                               EntryScr1004NotifyEndCallDuration( )

 

                     GetEndTimeAndNotifyCallMissed()            miss a MT call

                            memcpy(&cm_p->state_info.CallStructureForCallLog.start_time, &t, sizeof(MYTIME));

                        memcpy(&cm_p->state_info.CallStructureForCallLog.end_time, &t, sizeof(MYTIME));

                        CHISTLogMissedCall(&cm_p->state_info.CallStructureForCallLog);

                                   设置未接电话的status icon以及一些变量

                                   ReqWriteCallLog(call, PHB_LNM);

 

(5)接听MT

ProcessAcceptIncomingCall()

       EntryScr1002ActiveCall()

              DummyScr1002ActiveCall()

                     UpdateCallStartTimeAndLogCall()            与MO接通相同

                            memcpy(&cm_p->state_info.AllCalls[index].start_time, t, sizeof(MYTIME));

                            LogCallWithStartTime(&cm_p->state_info.AllCalls[index]);

 

 

(6)挂断ACTIVE、HOLD call

ProcessPSHangupSucEvent()

       LogCallInfoForCallHistory()

       GetEndTimeAndNotifyEndCallDuration()

              memcpy(&gTimeStructForEndedCallStartTime, &(cm_p->state_info.AllCalls[GetMMIStructIndexof(handle)].start_time), sizeof(MYTIME));       //开始时间

              memset(&temp, 0, sizeof(MYTIME));

              if (!(memcmp(&gTimeStructForEndedCallStartTime, &temp, sizeof(MYTIME)) == 0))         //开始时间不为0,即:要更新已经写入NVRAM的call log record

              {

                     DTGetRTCTime(&(cm_p->state_info.CallStructureForCallLog.end_time));     //获取电话结束时间

                     CHISTLogDialedCallDuration(&cm_p->state_info.CallStructureForCallLog); 或者

                            if (电话start time 与 end time不同)

                            {

                                   GetTimeDifference(&call->end_time, &call->start_time, &chis_p->last_call_time);                获取时间差,即最后通话时间

                           IncrementTime(chis_p->total_out_time, chis_p->last_call_time, &(chis_p->total_out_time)); 已拨电话总计增加

 

                           WriteRecord(NVRAM_EF_CALL_TIME_LID, 2, (void*)&chis_p->total_out_time, sizeof(MYTIME), &error);

                           WriteRecord(NVRAM_EF_CALL_TIME_LID, 1, (void*)&chis_p->last_call_time, sizeof(MYTIME), &error);

 

                           mmi_chist_log_call_duration(call, PHB_LND);       更新已经写入NVRAM中的record.

                                          首先根据类型:PHB_LND,PHB_LNR设置开始读取的record位置:

                                          if (type == PHB_LND)

                                      {

                                         start_lid = 1;

                                      }

                                      else if (type == PHB_LNR)

                                      {

                                                 //计算结果是5。

                                         start_lid = 1 + ((TOT_SIZE_OF_DIALED_LIST + TOT_SIZE_OF_ONE_LN_LIST -1)/TOT_SIZE_OF_ONE_LN_LIST) +

                                                  ((TOT_SIZE_OF_DIALED_LIST + TOT_SIZE_OF_ONE_LN_LIST -1)/TOT_SIZE_OF_ONE_LN_LIST);

                                     }

                                          注意:关于call log在NVRAM中的存储,文件ID是:NVRAM_EF_PHB_LN_ENTRY_LID。一共有6个record,每个record共924字节。

                                          是不是record1,2存储dialed call log,3,4存储misesed call log,5,6存储received call log?

                                          在下面的ReadRecord( )函数中,变量temp_call_log中最多只能读取10个log entry,那么另外10个call log也就是上面的record 6怎么读取的                                        (每种call log是20个)?

 

                                          temp_call_log = OslMalloc(NVRAM_EF_PHB_LN_ENTRY_SIZE);     分配空间,准备存储读取的call log

                                          ReadRecord(NVRAM_EF_PHB_LN_ENTRY_LID, start_lid, temp_call_log, NVRAM_EF_PHB_LN_ENTRY_SIZE, &error);       读取NVRAM

                                          for (i=0; i< temp_call_log->no_entry; i++)

                                          {

                                                 ConvertRTC2MYTIME(&start_time, &temp_call_log->array[i].time);      获取读取到的call log开始时间

                                                 if (CompareTime(start_time, call->start_time, NULL) == 0)                      与要保存的开始时间相同

                                                 {           

                                                        先把temp_call_log->array[i].addr_bcd[]中的BCD码转换成ASCII码,再转换成UCS2。

                                                        AnsiiToUnicodeString(ucs2_number, (S8*) tempNumber);

                                                        if (pfnUnicodeStrcmp((const S8*)ucs2_number, (const S8*)call->num) == 0)         与要保存的电话号码相同

                                                        {

                                                               更新temp_call_log->array[i].call_duration = call.end_time – call.start_time;

                                                               WriteRecord(NVRAM_EF_PHB_LN_ENTRY_LID, start_lid, temp_call_log, NVRAM_EF_PHB_LN_ENTRY_SIZE, &error);

                                           break;

                                                        }

                                                 }                                       

                                          }                                       

                            }

 

                     CHISTLogRecvdCallDuration(&cm_p->state_info.CallStructureForCallLog);

                            if (电话start time 与 end time不同)

                            {

                                   GetTimeDifference(&call->end_time, &call->start_time, &chis_p->last_call_time);                获取时间差,即最后通话时间

                           IncrementTime(chis_p->total_in_time, chis_p->last_call_time, &(chis_p->total_in_time));      已接电话总计增加

 

                           WriteRecord(NVRAM_EF_CALL_TIME_LID, 3, (void*)&chis_p->total_in_time, sizeof(MYTIME), &error);

                           WriteRecord(NVRAM_EF_CALL_TIME_LID, 1, (void*)&chis_p->last_call_time, sizeof(MYTIME), &error);

 

                           mmi_chist_log_call_duration(call, PHB_LNR);

                            }

              }

 

              CMGetExactTime(GetDateTimeAndNotifyEndCallDurationCBack);

                                                 EntryScr1004NotifyEndCallDuration();

二、增加一个entry

//这是菜单的初始化函数

void mmi_phb_init(void)

{

    mmi_phb_search_init();

    mmi_phb_operate_single_init();

    mmi_phb_operate_mass_init();

    mmi_phb_caller_group_init();

    mmi_phb_extra_number_init();

    mmi_phb_setting_init();

    PhbInitSpeedDial();

    mmi_phb_stubs_to_others_init();

}

 

mmi_phb_highlight_op_add_entry()

       memset(pbNumber, 0, ENCODING_LENGTH);

    g_phb_cntx.set_done_flag = 0;

 

按下左软件,进入:

mmi_phb_op_add_pre_entry()

       判断是否已经存储满了?

       mmi_phb_util_clear_buffer() //清除一些全局变量

       mmi_phb_entry_op_add_choose_storage() 选择存储位置:SIM, phone

       ShowCategory52Screen( )//根据g_phb_cntx.prefer_storage来判断当前应该默认那个高亮

 

PHONE,高亮:

mmi_phb_highlight_op_add_entry_to_phone()

       g_phb_cntx.selected_storage = MMI_NVRAM;

 

SIM高亮:

mmi_phb_highlight_op_add_entry_to_sim()

       g_phb_cntx.selected_storage = MMI_SIM;

 

按下左软件,SHOW的画面是(全部栏位):

Name                   姓名

Number                电话号码

Home Number     家庭电话

Company Name   公司名称

Email Address      电子信箱

Office Number     公司号码

Fax Number         传真号码

None                    无(生日)

None                    无(大头贴)g_phb_cntx.image_name_list(名称),g_phb_cntx.image_id_list(图片的ID)

None                    无(来电录像)g_phb_cntx.video_name_list(名称),g_phb_cntx.video_id_list(录像ID)

None                    无(来电铃声)g_phb_cntx.ring_tone_name_list(名称),g_phb_cntx.ring_tone_list(铃声ID)

None                    无(用户群组)myCallerGrpnames

 

 

无论选择了哪个存储,都进入:

mmi_phb_entry_op_add_entry()

       if (g_phb_cntx.selected_storage == MMI_SIM)

       {

              g_phbnameLength = g_phb_cntx.sim_name_len;

              g_phbnumberLength = MAX_PB_SIM_NUMBER_LENGTH; //20

       }    

       else

       {

              g_phbnameLength = MAX_PB_NAME_LENGTH;

              g_phbnumberLength = MAX_PB_NUMBER_LENGTH;          //40

       }

 

       很多的初始化操作mmi_phb_op_fill_inline_item()

       InitializeCategory57Screen();

       ShowCategory57Screen

 

高亮响应:mmi_phb_op_edit_highlight_hdlr()

 

按下保存键,进入:

mmi_phb_entry_op_add_entry_confirm()

mmi_phb_op_add_pre_save()

       if (!mmi_phb_op_check_pre_save())       //check输入是否正确:姓名号码是否为空pbName,pbNumber,pbHomeNumber,pbOfficeNumber,pbFaxNumber

    {

        return;

    }

       mmi_phb_op_add_entry_req()    //发送消息到L4保存entry

              mmi_phb_show_in_progress()   //显示消息:正在处理

              mmi_phb_op_set_entry_prepare_name_number(&myMsgPtr->list, pbName, pbNumber);    //装载姓名和号码,没有装载optional fields and IDs。

              发送消息:PRT_PHB_SET_ENTRY_REQ

              SetProtocolEventHandler(mmi_phb_op_add_entry_rsp, PRT_PHB_SET_ENTRY_RSP);

 

 

返回消息后,进入CBACK函数:

mmi_phb_op_add_entry_rsp()

{

       if (localPtr->result.flag == 0) //存储成功

       {

              store_index = mmi_phb_op_get_store_index_and_increase_counter(localPtr->list[0].storage, localPtr->list[0].record_index);

                     // record_index是entry的物理存储位置,从1开始。

                     //store_index是entry在数组PhoneBook中的存储位置,从0开始。

              if (localPtr->list[0].storage == MMI_NVRAM)     //存储在NVRAM

              {

                     mmi_phb_op_update_optional_field(store_index, MMI_NVRAM, 1);      //保存optional field to NVRAM

                            //把用户输入的信息拷贝到中PhoneBookOptionalFields

                            UnicodeToAnsii((PS8) PhoneBookOptionalFields.homeNumber, pbHomeNumber);

                    pfnUnicodeStrcpy((PS8) PhoneBookOptionalFields.companyName, pbCompanyName);

                    UnicodeToAnsii((PS8) PhoneBookOptionalFields.emailAddress, pbEmailAddress);

                    UnicodeToAnsii((PS8) PhoneBookOptionalFields.officeNumber, pbOfficeNumber);

                    UnicodeToAnsii((PS8) PhoneBookOptionalFields.faxNumber, pbFaxNumber);

 

                            //写入到NVRAM。可见:在NVRAM中,也是按照store_index的顺序存储的,与PhoneBook一样。不过是从1开始。

                            WriteRecord( NVRAM_EF_PHB_FIELDS_LID, (U16) (store_index + 1), (void*)&PhoneBookOptionalFields,

                                     OPTIONAL_FIELDS_RECORD_SIZE,  &pError);

 

                            //根据store_index来读取这个entry的optional IDS.

                            optid_record = (store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;

                        optid_index = store_index - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;

                        ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);

 

                            把 g_phb_cntx.image_id_list,g_phb_cntx.selected_grp_index,g_phb_cntx.ring_tone_list 信息拷贝到刚刚读取出来的PhbOptIDs中。

                            然后再写入NVRAM中

                            WriteRecord(NVRAM_EF_PHB_IDS_LID, optid_record, PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);

 

                     mmi_phb_op_increase_lookup_table( );   //把家庭,公司,传真号码加入到数组LookUpTable[]中。

                     mmi_phb_video_update_by_index(store_index);    //保存来电的video到NVRAM中。

 

                     UnicodeToAnsii((PS8) num_ascii, (PS8) pbNumber);

              flag += mmi_phb_op_increase_lookup_table(store_index, (S8*) num_ascii, NULL, NULL, NULL);  //把电话加入LookUpTable[]中。

                     mmi_phb_lookup_table_sort()     ;//对数组LookUpTable[]按照号码大小顺序排序

 

                     mmi_phb_op_set_entry_rsp_name_number(&localPtr->list[0], store_index);    //把姓名和号码保存在PhoneBook[store_index]中。

 

                     mmi_phb_op_update_field_flag();//update fileter flag of each entry.

 

                     mmi_phb_bday_update_field(); //保存生日信息

                            ReadRecord(NVRAM_EF_PHB_BIRTHDAY_LID, bday_record, (void*)bday_data, NVRAM_EF_PHB_BIRTHDAY_SIZE, &pError);

                            拷贝pbYear, pbMon, pbDay到bday_data中;

                            WriteRecord(NVRAM_EF_PHB_BIRTHDAY_LID, bday_record, (void*)bday_data, NVRAM_EF_PHB_BIRTHDAY_SIZE, &pError);

 

                     mmi_phb_util_make_pinyin_cache(store_index);    // 把PhoneBook[store_index] 中姓名的拼音加入到g_phb_name_pinyin_index[store_index]中。

 

                     /* Insert name to name mapping table. */

              mmi_phb_sort_insert_name_index(store_index);

 

                     //如果是从CALL LOG中来保存一个entry,那么就更新这个call log

                     ReqUpdateCallLogName(PhoneBook[store_index].alpha_id.name_length, PhoneBook[store_index].alpha_id.name_dcs,

                                                PhoneBook[store_index].alpha_id.name);

 

                     mmi_phb_clear_old_add_history();   //删除历史screen                   

              }

       }

       else                                    //存储失败

       {

              提示错误信息;

              删除历史screen;             

       }

 

       g_phb_enter_from = MMI_PHB_ENTER_NONE;

    g_phb_cntx.current_op = MMI_PHB_OP_NONE;

}

 

 

三、电话列表

Phone Book

       3.View Phonebook         分类查看

              1.View SIM           SIM卡           MITEM111_PBOOK_VIEW_SIM_ENTRY

              2.View Phone         本机              MITEM111_PBOOK_VIEW_PHONE_ENTRY

1.SIM卡

mmi_phb_highlight_view_sim()

       mmi_phb_view_sim()

              g_edit_listview  = MMI_PHB_LIST_FOR_SIM; //每次进入phone entry list view时,都要设置这个变量。

              检查电话簿已经读取完毕,并且此刻没有电话簿的操作,SIM卡有号码

              mmi_phb_entry_list2(g_phb_cntx.sim_used, /*Total Entry*/

                                                   STR_PHB_VIEW, /*Title String*/

                                                   IMG_SCR_PBOOK_CAPTION, /*Title Image*/

                                                   STR_GLOBAL_OPTIONS, /*LSK*/

                                                   IMG_GLOBAL_OPTIONS, /*LSK*/

                                                   #if defined( __MMI_INTELLIGENT_CALL_ALERT__ )

                                                              mmi_phb_get_index_speak_name_sim,

                                                   #else

                                                             mmi_phb_get_index_sim,//mmi_phb_get_index, /*Highlight Callback*/    

                                                   #endif                                             

                                                   mmi_phb_entry_op_option_sim, /*LSK Callback*/

                                                   mmi_phb_choose_number_normal, /*SEND Key Callback*/

                                                   mmi_phb_list_get_item_sim,//mmi_phb_list_get_item, /*List Callback*/

                                                   mmi_phb_list_get_hint_sim,//mmi_phb_list_get_hint, /*Hint Callback*/

                                                   mmi_phb_view_sim, /*Re-Entry Callback*/

                                                   TRUE, /*Alpha Index*/

                                                   TRUE);       /*Right Arrow Key*/

       详细看上面注册的函数:

       (1)高亮:mmi_phb_get_index_sim()

                     设置:g_phb_cntx.active_index。注意:g_phb_cntx.active_index是在 g_phb_name_index[]数组中的位置。0,1,2,3,4…。即:当前高亮的entry在数 组:                         g_phb_name_index[]中的顺序位置。

       (2)左软件响应mmi_phb_entry_op_option_sim()

              ShowCategory15Screen() 每一个entry的选项菜单

       (3)SEND键响应mmi_phb_choose_number_normal()

              mmi_phb_list_pre_choose_number() //当该entry有多个号码时,让用户选择拨哪个

                     mmi_phb_entry_list_choose_number()

       (4)获取SIM卡item:mmi_phb_list_get_item_sim()

                     获取SIM卡中entry的姓名。没有姓名的就获取号码

       (5)hint callback:mmi_phb_list_get_hint_sim()

                     获取hint信息:号码

 

mmi_phb_entry_list2( )

       mmi_phb_list_build_alpha_index()   //用户快捷方式。按照g_phb_name_index[]中保存的字母顺序,提取PhoneBook中的姓名,按照首字母的顺序以字母(26个)为 索                 引,把每个entry在电话列表中的list index保存在g_phb_alpha_index_list[]中。即:g_phb_alpha_index_list[]中保存的是该entry的 list index。这样,当用户输入某个字         母时,如:c,那么就可以直接跳转到g_phb_alpha_index_list[2]的值所指示的位置。

       ShowCategory184Screen()

              ShowCategory185Screen()

                     init_dynamic_item_buffer()

                            dynamic_item_buffer.load_func = get_item_func;

                         dynamic_item_buffer.hint_func = get_hint_func;

                     load_dynamic_item_buffer()

                            for (i = 0; i < n_items; i++)

                         {

                             if (dynamic_item_buffer.load_func(i, (UI_string_type) subMenuData[i], ℑ, 3))//调用刚才注册的获取item函数。

                             {

                                 MMI_fixed_icontext_menuitems[i].item_icon = image;

                                 MMI_fixed_icontext_menuitems[i].item_text = (UI_string_type) subMenuData[i];

                                 MMI_fixed_icontext_menuitems[i].flags = flags;  /* 032905 Calvin modified */

                                 dynamic_item_buffer.count++;

                             }

                             else

                             {

                                 break;

                             }

                         }

 

 

       if(alpha_index)       //快捷方式所需要的设置。其他地方如果需要这样处理的可以参考。比如:在gap205的区号查询中。

       {

              register_multitap_no_draw_key_handlers();

              set_multitap_functions(mmi_phb_list_alpha_index, mmi_phb_list_alpha_index_input_callback);

              change_multitap_mode(0);

       }

 

小结:在show 电话号码列表时,也就是SHOW动态的 LIST。过程是:从g_phb_name_index[]中取出每个entryPhoneBook[]中的store_index,然后获取PhoneBook[]中的姓名,转载subMenuData[],最后拷贝到MMI_fixed_icontext_menuitems[]中。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值