• 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);
                }
            }
        }
  • 相关阅读:
    解决KDE桌面附带文件索引框架Baloo占用资源过多问题
    [Journey with golang] 7. Traps
    [Journey with golang] 6. Reflection
    Codeforces Round #614 (Div. 2)
    [Journey with golang] 5. Concurrent
    2018-2019 9th BSUIR Open Programming Championship
    2019-2020 ACM-ICPC Pacific Northwest Regional Contest
    UFPE Starters Final Try-Outs 2020
    2019 ICPC Asia Taipei Hsinchu Regional Contest
    [Journey with golang] 4. Interface
  • 原文地址:https://www.cnblogs.com/kaifyou/p/6178476.html
Copyright © 2020-2023  润新知