美文网首页
高通平台ICCID乱码问题

高通平台ICCID乱码问题

作者: 平头说人生 | 来源:发表于2018-05-23 19:26 被阅读23次

    高通平台ICCID乱码问题

    Qcom平台Sim卡信息跟新流程如下:

    1 路径一
    QtiUiccCardProvisioner 注册 EVENT_UNSOL_MANUAL_PROVISION_STATUS_CHANGED 主动上报事件

    --> handleUnsolManualProvisionEvent--> queryUiccProvisionInfo
    (QtiRilInterface.getUiccIccId(phoneId) 通过QcRilHook,通过HIDL 直接获取IccId信息)
    --> handleAddSubInfoRecordEvent
    --> updateSubscriptionInfoByIccId
    --> SubscriptionController.addSubInfoRecord

    这个流程是没有对iccId做校验的,通过HIDL获取什么值就是什么值, 这个路径会产生乱码。

    2 路径二

    QtiUiccCardProvisioner 通过UiccController注册EVENT_ICC_CHANGED事件
    -->queryUiccProvisionInfo
    -->loadIccId
    -->IccFileHandler.loadEFTransparent(IccConstants.EF_ICCID,
    obtainMessage(EVENT_GET_ICCID_DONE)
    -->IccUtils.bchToString
    (进行校验,按照逻辑校验结果是0-9, a-f之间的所有字符)

    SubscriptionController.java

    /**
         * Add a new SubInfoRecord to subinfo database if needed
         * @param iccId the IccId of the SIM card
         * @param slotIndex the slot which the SIM is inserted
         * @return 0 if success, < 0 on error.
         */
        @Override
        public int addSubInfoRecord(String iccId, int slotIndex) {
            if (DBG) logdl("[addSubInfoRecord]+ iccId:" + SubscriptionInfo.givePrintableIccid(iccId) +
                    " slotIndex:" + slotIndex);
    
            enforceModifyPhoneState("addSubInfoRecord");
    
            // Now that all security checks passes, perform the operation as ourselves.
            final long identity = Binder.clearCallingIdentity();
            try {
                if (iccId == null) {
                    if (DBG) logdl("[addSubInfoRecord]- null iccId");
                    return -1;
                }
    
                //Add begin by meitu.liuyt
                //MEITU_TAG_FORMAT_ICCID
                slogd("Before format rawIccId is " + iccId);
                //在将ICCID 写入db前先format下
                iccId = formatIccId(iccId); 
                slogd("After format rawIccId is " + iccId);
                ......
        }
    
        //Add begin by meitu.liuyt for ICCID's last character sometimes is garbled, like has '?' and so on
        //We're sure last character must be digit or a-f
        //So we format it as following
        //MEITU_TAG_FORMAT_ICCID
        private String formatIccId(String rawIccId) {
            if(TextUtils.isEmpty(rawIccId)) {
                slogd("Impossible, iccId is null");
                return rawIccId;
            }
            Pattern pattern = Pattern.compile("^0-9A-Fa-f");
            Matcher matcher = pattern.matcher(rawIccId);
            return matcher.replaceAll("").trim();
        }
        //Add end
    

    相关文章

      网友评论

          本文标题:高通平台ICCID乱码问题

          本文链接:https://www.haomeiwen.com/subject/kdrdjftx.html