• Android 7.0 UICC 分析(三)


    本文讲解UICCCardApplication

    /frameworks/opt/telephony/src/java/com/android/internal/telephony/uicc/UiccCardApplication.java

    根据UiccCard 对象和IccCardStatus 的IccCardApplicationStatus[] 数组创建UiccCardApplication 对象,其构造方法:

        public UiccCardApplication(UiccCard uiccCard,
                            IccCardApplicationStatus as,
                            Context c,
                            CommandsInterface ci) {
            if (DBG) log("Creating UiccApp: " + as);
            mUiccCard = uiccCard;
            .......
            mCi = ci;
            根据app_type类型实例化IccFileHandler和IccRecords
            mIccFh = createIccFileHandler(as.app_type);
            mIccRecords = createIccRecords(as.app_type, mContext, mCi);
            if (mAppState == AppState.APPSTATE_READY) {
                queryFdn();
                queryPin1State();//查询PIN1码状态
            }
            mCi.registerForNotAvailable(mHandler, EVENT_RADIO_UNAVAILABLE, null);//注册消息EVENT_RADIO_UNAVAILABLE
        }

    app_type 卡类型,定义在IccCardApplicationStatus 类中

        public enum AppType{
            APPTYPE_UNKNOWN,
            APPTYPE_SIM,  //GSM卡
            APPTYPE_USIM,  //WCDMA卡 
            APPTYPE_RUIM,  //CDMA卡
            APPTYPE_CSIM,
            APPTYPE_ISIM
        }

    app_state 卡状态,定义在IccCardApplicationStatus 类中

        public enum AppState{
            APPSTATE_UNKNOWN,  //卡不存在
            APPSTATE_DETECTED,  //卡已经检测到
            APPSTATE_PIN,  //卡已经被PIN码锁定
            APPSTATE_PUK,  //卡已经被PUK码锁定
            APPSTATE_SUBSCRIPTION_PERSO,  //卡已经被网络锁定
            APPSTATE_READY;  //卡已经准备好了
        }

    PIN码的状态,定义在IccCardStatus 类中

        public enum PinState {
            PINSTATE_UNKNOWN,  //PIN码状态不确定
            PINSTATE_ENABLED_NOT_VERIFIED,  //PIN码锁定,用户输入的PIN码错误,无法进入手机
            PINSTATE_ENABLED_VERIFIED,  //PIN码锁定,用户输入的PIN码正确,进入手机
            PINSTATE_DISABLED,  //没有进行PIN码锁定
            PINSTATE_ENABLED_BLOCKED,  //PIN码解锁失败,提示输入PUK码
            PINSTATE_ENABLED_PERM_BLOCKED;  //PUK码解锁失败后,永久锁定
      }

    SIM卡状态,定义在IccCardStatus 类中

        public enum CardState {
            CARDSTATE_ABSENT,  //表示掉卡
            CARDSTATE_PRESENT,  //表示卡正常
    CARDSTATE_ERROR;  //表示卡出现了错误 }

    PersoSubState 描述卡被网络锁定的信息,对国内用户来说意义不大; 

    createIccFileHandler() 方法根据app_type 创建不同的IccFileHandler 对象:

        private IccFileHandler createIccFileHandler(AppType type) {
            switch (type) {
                case APPTYPE_SIM:
                    return new SIMFileHandler(this, mAid, mCi);
                case APPTYPE_RUIM:
                    return new RuimFileHandler(this, mAid, mCi);
                case APPTYPE_USIM:
                    return new UsimFileHandler(this, mAid, mCi);
                case APPTYPE_CSIM:
                    return new CsimFileHandler(this, mAid, mCi);
                case APPTYPE_ISIM:
                    return new IsimFileHandler(this, mAid, mCi);
                default:
                    return null;
            }
        }

    createIccRecords() 方法根据app_type 创建不同的IccRecords 对象:

        private IccRecords createIccRecords(AppType type, Context c, CommandsInterface ci) {
            if (type == AppType.APPTYPE_USIM || type == AppType.APPTYPE_SIM) {
                return new SIMRecords(this, c, ci);
            } else if (type == AppType.APPTYPE_RUIM || type == AppType.APPTYPE_CSIM){
                return new RuimRecords(this, c, ci);
            } else if (type == AppType.APPTYPE_ISIM) {
                return new IsimUiccRecords(this, c, ci);
            } else {
                // Unknown app type (maybe detection is still in progress)
                return null;
            }
        }

    UICCApplication 类的更新方法update():

        public void update (IccCardApplicationStatus as, Context c, CommandsInterface ci) {
                if (DBG) log(mAppType + " update. New " + as);
                AppType oldAppType = mAppType;
                AppState oldAppState = mAppState;
    
                if (mAppType != oldAppType) {  //app_type 更新
                    if (mIccFh != null) { mIccFh.dispose();}
                    if (mIccRecords != null) { mIccRecords.dispose();}
                    mIccFh = createIccFileHandler(as.app_type);
                    mIccRecords = createIccRecords(as.app_type, c, ci);
                }
    
                if (mAppState != oldAppState) {  //app_state 更新
                    if (DBG) log(oldAppType + " changed state: " + oldAppState + " -> " + mAppState);
                    // If the app state turns to APPSTATE_READY, then query FDN status,
                    //as it might have failed in earlier attempt.
                    if (mAppState == AppState.APPSTATE_READY) {  //如果卡已经准备好
                        queryFdn();
                        queryPin1State();
                    }
                    notifyPinLockedRegistrantsIfNeeded(null);  //发出PIN码锁定通知,所以监听者将会接收到此通知
                    notifyReadyRegistrantsIfNeeded(null);
                }
            }
        }
  • 相关阅读:
    VM环境安装Linux系统
    设置ShowDialog
    sqlserver同步表的脚本
    C#winform设置DateTimePicker的时间格式
    C#winform解析marc显示在datagridview中以及marc卡片显示
    C#实现图书馆程序导入ISO-2709格式(MARC)功能
    时间格式转换+固定字段加空格
    sqlserver 保留小数方法
    winform的datagridview单元格输入限制和右键单击datagridview单元格焦点跟着改变
    怎么查看那个端口被占用
  • 原文地址:https://www.cnblogs.com/kaifyou/p/6178476.html
Copyright © 2020-2023  润新知