MTK Phonebook初始化流程

开机之后,初始化时,设置如下三个PS消息CBack函数:
    InitializeAll()
        mmi_phb_init_protocol()
            SetProtocolEventHandler(mmi_phb_ind_startup_finish, PRT_PHB_STARTUP_FINISH_IND);
            SetProtocolEventHandler(mmi_phb_ind_startup_begin, PRT_PHB_STARTUP_BEGIN_IND);
            SetProtocolEventHandler(mmi_phb_ind_startup_read, PRT_PHB_STARTUP_READ_IND);

1.L4在到NVRAM读取data之前,发送消息到MMI:PRT_PHB_STARTUP_BEGIN_IND,进入:
    mmi_phb_ind_startup_begin()
    初始化一些变量,准备重新reload entries.
2.L4每读取一个AND entry,都有发送消息到MMI:PRT_PHB_STARTUP_READ_IND,进入:
    mmi_phb_ind_startup_read()
    L4返回消息的结构:
        typedef struct
        {
            LOCAL_PARA_HDR
            l4c_phb_entries_struct phb_entries[1];
            kal_uint8       access_id;
        }mmi_phb_startup_read_ind_struct;

        typedef struct
        {
            kal_uint16 num_of_entry;
            l4c_phb_bcd_entry_struct phb_entry[2000/NVRAM_PHB_SIZE];
        } l4c_phb_entries_struct;
       
        typedef struct {
            kal_uint8 storage;
            kal_uint8 type;
            kal_uint16 index;
            kal_uint16 record_index;
            l4_addr_bcd_struct tel;
            l4_name_struct alpha_id;
        } l4c_phb_bcd_entry_struct;

    MMI中,保存电话entries的全局变量PhoneBook结构如下:
    MMI_PHB_ENTRY_BCD_STRUCT PhoneBook[MAX_PB_ENTRIES];
        typedef struct
        {
            //U8         storage;
            //U8         type;
            //U16                index;
            //U16                record_index;
            MMI_PHB_NUMBER_BCD_STRUCT tel;
            MMI_PHB_NAME_STRUCT alpha_id;
            U8 field;   /* Indicate if an entry has the field */
            U8 dummy;   /* Make sure each phb structure is two-bytes aligned. */
        } MMI_PHB_ENTRY_BCD_STRUCT;
       
        typedef struct
        {
            U8 type;                     /* 129-default; 145-international, begin with '+' */
            U8 length;
            U8 number[(MAX_PB_NUMBER_LENGTH + 1) / 2]; /* half space to store BCD format. */
        } MMI_PHB_NUMBER_BCD_STRUCT;
       
        typedef struct
        {
            U8 name_length; /* Name Length */
            U8 name_dcs;    /* Name Data Coding Scheme */
            U8 name[(MAX_PB_NAME_LENGTH + 1) *ENCODING_LENGTH];
        } MMI_PHB_NAME_STRUCT;
       
    mmi_phb_ind_startup_read()流程
       mmi_phb_ind_startup_read_next_req()   /* Send read confirm messaeg back to L4 */
       if (MMI_SIM)
           mmi_phb_startup_read_entry()
               把消息保存到全局变量PhoneBook中
               mmi_phb_util_make_pinyin_cache() //保存name拼音 g_phb_name_pinyin_index[][]
               g_phb_name_index[PhoneBookEntryCount] = store_index;
               PhoneBookEntryCount++;
       else //NVRAM
          for() //读取一批nvram记录
              mmi_phb_startup_read_entry()

3.当L4从NVRAM中读取完之后,发送消息PRT_PHB_STARTUP_FINISH_IND到MMI,表示L4已经读完了。MMI接收到这个消息之后,开始load all entries from L4。
    返回的消息结构:
        typedef struct
        {
            LOCAL_PARA_HDR
            kal_uint16     sim_max_num;
            kal_uint16     phb_max_num;
            kal_uint8       phb_len;
            kal_uint8       fdn_len;
            kal_uint8       bdn_len;
            kal_uint8       owner_len;
        } mmi_phb_startup_finish_ind_struct;

    mi_phb_ind_startup_finish()流程
        初始化g_phb_cntx中的结构
        if (!g_phb_cntx.nvram_data_init)
        {
            //从NVRAM中读取电话簿的一些信息。比如:群组,栏位设置,存储选择等等。
            mmi_phb_init_get_data_from_nvram();
            g_phb_cntx.view_field
            g_phb_cntx.prefer_storage
            g_phb_cntx.name_list_filter
            g_phb_cntx.caller_group
            g_phb_cntx.nvram_data_init = TRUE;
        }
        mmi_phb_startup_finish_final_step()
            mmi_phb_sort_build_name_index()
            //利用分治策略和插入排序进行快速排序g_phb_name_index[]。
            //g_phb_name_index[]中存储的是PhoneBook[]中entries的存储索引。
            mmi_phb_ind_startup_finish_after_name_sort()
                mmi_phb_init_build_lookup_table()
                //把PhoneBook中以g_phb_name_index[]中的内容为索引的entry的号码,转换成ASCII码,
                //然后转换成32为int型数据,并保存在全局变量LookUpTable[]中。
                //注意:一并保存的还有store_index也就是该entry在PhoneBook中存储位置。
               
                StartTimer(PHB_READ_OPT_FILED_TIMER, 500, mmi_phb_init_populate_lookup_table);
                //500ms后执行mmi_phb_init_populate_lookup_table()
                //以g_phb_name_index[]中的内容为索引,到NVRAM中读取option fields数据
                //ReadMultiRecord()。然后把读取的数据保存在LookUpTable[]中。
                //包括: 传真号码,家庭号码,公司号码。每读取10次,就暂停250ms,然后继续读取。
                //全部读完之后,进入:mmi_phb_lookup_table_sort()
                //All entries populated, begin to sort it。
                //因为在装载电话号码的时候,LookUpTable[]中的内容是按照字母顺装载的,
                //但是在装载NVRAM中的传真,家庭,公司号码时,是按照存储顺序装载的。
                //而这里的排序,是根据电话号码的大小来排序的。
                //即:按照电话号码的大小,从小到大排列。
                //当来电的时候,采取对半查找效率就很高了。
               

小结:到这里,就完成了电话簿的初始化。即:
(1)从NVRAM,SIM卡中读取了数据,并保存在L4中了;
(2)MMI中的全局变量PhoneBook[]与L4中的电话簿已经同步了;
(3)g_phb_name_index[]中按照字母的大小顺序,存储了每一个entry在PhoneBook[]中的存储位置;
(4)所有的号码,包括SIM卡,NVRAM,移动电话,家庭,公司,传真号码,都按照大小顺序,存储在LookUpTable[]中了,并且存储了PhoneBook中的存储位置索引。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值