FileDocCategorySizeDatePackage
IccRecords.javaAPI DocAndroid 5.1 API24207Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony.uicc

IccRecords

public abstract class IccRecords extends android.os.Handler implements IccConstants
{@hide}

Fields Summary
protected static final boolean
DBG
protected AtomicBoolean
mDestroyed
protected android.content.Context
mContext
protected com.android.internal.telephony.CommandsInterface
mCi
protected IccFileHandler
mFh
protected UiccCardApplication
mParentApp
protected android.telephony.TelephonyManager
mTelephonyManager
protected android.os.RegistrantList
mRecordsLoadedRegistrants
protected android.os.RegistrantList
mImsiReadyRegistrants
protected android.os.RegistrantList
mRecordsEventsRegistrants
protected android.os.RegistrantList
mNewSmsRegistrants
protected android.os.RegistrantList
mNetworkSelectionModeAutomaticRegistrants
protected int
mRecordsToLoad
protected AdnRecordCache
mAdnCache
protected boolean
mRecordsRequested
protected String
mIccId
protected String
mMsisdn
protected String
mMsisdnTag
protected String
mNewMsisdn
protected String
mNewMsisdnTag
protected String
mVoiceMailNum
protected String
mVoiceMailTag
protected String
mNewVoiceMailNum
protected String
mNewVoiceMailTag
protected boolean
mIsVoiceMailFixed
protected String
mImsi
private IccIoResult
auth_rsp
protected int
mMncLength
protected int
mMailboxIndex
private String
mSpn
protected String
mGid1
private final Object
mLock
protected static final int
UNINITIALIZED
protected static final int
UNKNOWN
public static final int
SPN_RULE_SHOW_SPN
public static final int
SPN_RULE_SHOW_PLMN
protected static final int
EVENT_SET_MSISDN_DONE
public static final int
EVENT_MWI
public static final int
EVENT_CFI
public static final int
EVENT_SPN
public static final int
EVENT_GET_ICC_RECORD_DONE
protected static final int
EVENT_APP_READY
private static final int
EVENT_AKA_AUTHENTICATE_DONE
Constructors Summary
public IccRecords(UiccCardApplication app, android.content.Context c, com.android.internal.telephony.CommandsInterface ci)

        mContext = c;
        mCi = ci;
        mFh = app.getIccFileHandler();
        mParentApp = app;
        mTelephonyManager = (TelephonyManager) mContext.getSystemService(
                Context.TELEPHONY_SERVICE);
    
Methods Summary
public voiddispose()
Call when the IccRecords object is no longer going to be used.

        mDestroyed.set(true);
        mParentApp = null;
        mFh = null;
        mCi = null;
        mContext = null;
    
public voiddump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)

        pw.println("IccRecords: " + this);
        pw.println(" mDestroyed=" + mDestroyed);
        pw.println(" mCi=" + mCi);
        pw.println(" mFh=" + mFh);
        pw.println(" mParentApp=" + mParentApp);
        pw.println(" recordsLoadedRegistrants: size=" + mRecordsLoadedRegistrants.size());
        for (int i = 0; i < mRecordsLoadedRegistrants.size(); i++) {
            pw.println("  recordsLoadedRegistrants[" + i + "]="
                    + ((Registrant)mRecordsLoadedRegistrants.get(i)).getHandler());
        }
        pw.println(" mImsiReadyRegistrants: size=" + mImsiReadyRegistrants.size());
        for (int i = 0; i < mImsiReadyRegistrants.size(); i++) {
            pw.println("  mImsiReadyRegistrants[" + i + "]="
                    + ((Registrant)mImsiReadyRegistrants.get(i)).getHandler());
        }
        pw.println(" mRecordsEventsRegistrants: size=" + mRecordsEventsRegistrants.size());
        for (int i = 0; i < mRecordsEventsRegistrants.size(); i++) {
            pw.println("  mRecordsEventsRegistrants[" + i + "]="
                    + ((Registrant)mRecordsEventsRegistrants.get(i)).getHandler());
        }
        pw.println(" mNewSmsRegistrants: size=" + mNewSmsRegistrants.size());
        for (int i = 0; i < mNewSmsRegistrants.size(); i++) {
            pw.println("  mNewSmsRegistrants[" + i + "]="
                    + ((Registrant)mNewSmsRegistrants.get(i)).getHandler());
        }
        pw.println(" mNetworkSelectionModeAutomaticRegistrants: size="
                + mNetworkSelectionModeAutomaticRegistrants.size());
        for (int i = 0; i < mNetworkSelectionModeAutomaticRegistrants.size(); i++) {
            pw.println("  mNetworkSelectionModeAutomaticRegistrants[" + i + "]="
                    + ((Registrant)mNetworkSelectionModeAutomaticRegistrants.get(i)).getHandler());
        }
        pw.println(" mRecordsRequested=" + mRecordsRequested);
        pw.println(" mRecordsToLoad=" + mRecordsToLoad);
        pw.println(" mRdnCache=" + mAdnCache);
        pw.println(" iccid=" + mIccId);
        pw.println(" mMsisdn=" + mMsisdn);
        pw.println(" mMsisdnTag=" + mMsisdnTag);
        pw.println(" mVoiceMailNum=" + mVoiceMailNum);
        pw.println(" mVoiceMailTag=" + mVoiceMailTag);
        pw.println(" mNewVoiceMailNum=" + mNewVoiceMailNum);
        pw.println(" mNewVoiceMailTag=" + mNewVoiceMailTag);
        pw.println(" mIsVoiceMailFixed=" + mIsVoiceMailFixed);
        pw.println(" mImsi=" + mImsi);
        pw.println(" mMncLength=" + mMncLength);
        pw.println(" mMailboxIndex=" + mMailboxIndex);
        pw.println(" mSpn=" + mSpn);
        pw.flush();
    
public AdnRecordCachegetAdnCache()

        return mAdnCache;
    
public abstract intgetDisplayRule(java.lang.String plmn)
Returns the SpnDisplayRule based on settings on the SIM and the specified plmn (currently-registered PLMN). See TS 22.101 Annex A and TS 51.011 10.3.11 for details. If the SPN is not found on the SIM, the rule is always PLMN_ONLY. Generally used for GSM/UMTS and the like SIMs.

public java.lang.StringgetGid1()
Get the Group Identifier Level 1 (GID1) on a SIM for GSM.

return
null if SIM is not yet ready

        return null;
    
public java.lang.StringgetIMSI()
Get the International Mobile Subscriber ID (IMSI) on a SIM for GSM, UMTS and like networks. Default is null if IMSI is not supported or unavailable.

return
null if SIM is not yet ready or unavailable

        return null;
    
public java.lang.StringgetIccId()

        return mIccId;
    
public java.lang.StringgetIccSimChallengeResponse(int authContext, java.lang.String data)
Returns the response of the SIM application on the UICC to authentication challenge/response algorithm. The data string and challenge response are Base64 encoded Strings. Can support EAP-SIM, EAP-AKA with results encoded per 3GPP TS 31.102.

param
authContext parameter P2 that specifies the authentication context per 3GPP TS 31.102 (Section 7.1.2)
param
data authentication challenge data
return
challenge response

        if (DBG) log("getIccSimChallengeResponse:");

        try {
            synchronized(mLock) {
                CommandsInterface ci = mCi;
                UiccCardApplication parentApp = mParentApp;
                if (ci != null && parentApp != null) {
                    ci.requestIccSimAuthentication(authContext, data,
                            parentApp.getAid(),
                            obtainMessage(EVENT_AKA_AUTHENTICATE_DONE));
                    try {
                        mLock.wait();
                    } catch (InterruptedException e) {
                        loge("getIccSimChallengeResponse: Fail, interrupted"
                                + " while trying to request Icc Sim Auth");
                        return null;
                    }
                } else {
                    loge( "getIccSimChallengeResponse: "
                            + "Fail, ci or parentApp is null");
                    return null;
                }
            }
        } catch(Exception e) {
            loge( "getIccSimChallengeResponse: "
                    + "Fail while trying to request Icc Sim Auth");
            return null;
        }

        if (DBG) log("getIccSimChallengeResponse: return auth_rsp");

        return android.util.Base64.encodeToString(auth_rsp.payload, android.util.Base64.NO_WRAP);
    
public IsimRecordsgetIsimRecords()
Return an interface to retrieve the ISIM records for IMS, if available.

return
the interface to retrieve the ISIM records, or null if not supported

        return null;
    
public java.lang.StringgetMsisdnAlphaTag()

        return mMsisdnTag;
    
public java.lang.StringgetMsisdnNumber()

        return mMsisdn;
    
public java.lang.StringgetNAI()
Get the Network Access ID (NAI) on a CSIM for CDMA like networks. Default is null if IMSI is not supported or unavailable.

return
null if NAI is not yet ready or unavailable

        return null;
    
public java.lang.StringgetOperatorNumeric()
Returns the 5 or 6 digit MCC/MNC of the operator that provided the SIM card. Returns null of SIM is not yet ready or is not valid for the type of IccCard. Generally used for GSM/UMTS and the like SIMS

        return null;
    
public booleangetRecordsLoaded()

        if (mRecordsToLoad == 0 && mRecordsRequested == true) {
            return true;
        } else {
            return false;
        }
    
public java.lang.StringgetServiceProviderName()
Return Service Provider Name stored in SIM (EF_SPN=0x6F46) or in RUIM (EF_RUIM_SPN=0x6F41).

return
null if SIM is not yet ready or no RUIM entry

        String providerName = mSpn;

        // Check for null pointers, mParentApp can be null after dispose,
        // which did occur after removing a SIM.
        UiccCardApplication parentApp = mParentApp;
        if (parentApp != null) {
            UiccCard card = parentApp.getUiccCard();
            if (card != null) {
                String brandOverride = card.getOperatorBrandOverride();
                if (brandOverride != null) {
                    log("getServiceProviderName: override");
                    providerName = brandOverride;
                } else {
                    log("getServiceProviderName: no brandOverride");
                }
            } else {
                log("getServiceProviderName: card is null");
            }
        } else {
            log("getServiceProviderName: mParentApp is null");
        }
        log("getServiceProviderName: providerName=" + providerName);
        return providerName;
    
public UsimServiceTablegetUsimServiceTable()

        return null;
    
public booleangetVoiceCallForwardingFlag()
Get the current Voice call forwarding flag for GSM/UMTS and the like SIMs

return
true if enabled

        return false;
    
public java.lang.StringgetVoiceMailAlphaTag()

        return mVoiceMailTag;
    
public java.lang.StringgetVoiceMailNumber()

        return mVoiceMailNum;
    
public abstract intgetVoiceMessageCount()
Called by GsmPhone to update VoiceMail count

public voidhandleMessage(android.os.Message msg)

        AsyncResult ar;

        switch (msg.what) {
            case EVENT_GET_ICC_RECORD_DONE:
                try {
                    ar = (AsyncResult) msg.obj;
                    IccRecordLoaded recordLoaded = (IccRecordLoaded) ar.userObj;
                    if (DBG) log(recordLoaded.getEfName() + " LOADED");

                    if (ar.exception != null) {
                        loge("Record Load Exception: " + ar.exception);
                    } else {
                        recordLoaded.onRecordLoaded(ar);
                    }
                }catch (RuntimeException exc) {
                    // I don't want these exceptions to be fatal
                    loge("Exception parsing SIM record: " + exc);
                } finally {
                    // Count up record load responses even if they are fails
                    onRecordLoaded();
                }
                break;

            case EVENT_AKA_AUTHENTICATE_DONE:
                ar = (AsyncResult)msg.obj;
                auth_rsp = null;
                if (DBG) log("EVENT_AKA_AUTHENTICATE_DONE");
                if (ar.exception != null) {
                    loge("Exception ICC SIM AKA: " + ar.exception);
                } else {
                    try {
                        auth_rsp = (IccIoResult)ar.result;
                        if (DBG) log("ICC SIM AKA: auth_rsp = " + auth_rsp);
                    } catch (Exception e) {
                        loge("Failed to parse ICC SIM AKA contents: " + e);
                    }
                }
                synchronized (mLock) {
                    mLock.notifyAll();
                }

                break;

            default:
                super.handleMessage(msg);
        }
    
public booleanisCspPlmnEnabled()
Return true if "Restriction of menu options for manual PLMN selection" bit is set or EF_CSP data is unavailable, return false otherwise. Generally used for GSM/UMTS and the like SIMs.

        return false;
    
public booleanisProvisioned()
Indicates wether SIM is in provisioned state or not. Overridden only if SIM can be dynamically provisioned via OTA.

return
true if provisioned

        return true;
    
protected abstract voidlog(java.lang.String s)
Write string to log file

param
s is the string to write

protected abstract voidloge(java.lang.String s)
Write error string to log file.

param
s is the string to write

protected abstract voidonAllRecordsLoaded()

protected voidonIccRefreshInit()
Called by subclasses (SimRecords and RuimRecords) whenever IccRefreshResponse.REFRESH_RESULT_INIT event received

        mAdnCache.reset();
        UiccCardApplication parentApp = mParentApp;
        if ((parentApp != null) &&
                (parentApp.getState() == AppState.APPSTATE_READY)) {
            // This will cause files to be reread
            sendMessage(obtainMessage(EVENT_APP_READY));
        }
    
public abstract voidonReady()

protected abstract voidonRecordLoaded()

public abstract voidonRefresh(boolean fileChanged, int[] fileList)
Called by STK Service when REFRESH is received.

param
fileChanged indicates whether any files changed
param
fileList if non-null, a list of EF files that changed

public voidregisterForImsiReady(android.os.Handler h, int what, java.lang.Object obj)

        if (mDestroyed.get()) {
            return;
        }

        Registrant r = new Registrant(h, what, obj);
        mImsiReadyRegistrants.add(r);

        if (mImsi != null) {
            r.notifyRegistrant(new AsyncResult(null, null, null));
        }
    
public voidregisterForNetworkSelectionModeAutomatic(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);
        mNetworkSelectionModeAutomaticRegistrants.add(r);
    
public voidregisterForNewSms(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);
        mNewSmsRegistrants.add(r);
    
public voidregisterForRecordsEvents(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);
        mRecordsEventsRegistrants.add(r);

        /* Notify registrant of all the possible events. This is to make sure registrant is
        notified even if event occurred in the past. */
        r.notifyResult(EVENT_MWI);
        r.notifyResult(EVENT_CFI);
    
public voidregisterForRecordsLoaded(android.os.Handler h, int what, java.lang.Object obj)

        if (mDestroyed.get()) {
            return;
        }

        Registrant r = new Registrant(h, what, obj);
        mRecordsLoadedRegistrants.add(r);

        if (mRecordsToLoad == 0 && mRecordsRequested == true) {
            r.notifyRegistrant(new AsyncResult(null, null, null));
        }
    
public voidsetImsi(java.lang.String imsi)
Imsi could be set by ServiceStateTrackers in case of cdma

param
imsi

        mImsi = imsi;
        mImsiReadyRegistrants.notifyRegistrants();
    
public voidsetMsisdnNumber(java.lang.String alphaTag, java.lang.String number, android.os.Message onComplete)
Set subscriber number to SIM record The subscriber number is stored in EF_MSISDN (TS 51.011) When the operation is complete, onComplete will be sent to its handler

param
alphaTag alpha-tagging of the dailing nubmer (up to 10 characters)
param
number dailing nubmer (up to 20 digits) if the number starts with '+', then set to international TOA
param
onComplete onComplete.obj will be an AsyncResult ((AsyncResult)onComplete.obj).exception == null on success ((AsyncResult)onComplete.obj).exception != null on fail


        mMsisdn = number;
        mMsisdnTag = alphaTag;

        if (DBG) log("Set MSISDN: " + mMsisdnTag +" " + mMsisdn);


        AdnRecord adn = new AdnRecord(mMsisdnTag, mMsisdn);

        new AdnRecordLoader(mFh).updateEF(adn, EF_MSISDN, EF_EXT1, 1, null,
                obtainMessage(EVENT_SET_MSISDN_DONE, onComplete));
    
protected voidsetServiceProviderName(java.lang.String spn)

        mSpn = spn;
    
protected voidsetSystemProperty(java.lang.String key, java.lang.String val)

        TelephonyManager.getDefault().setTelephonyProperty(mParentApp.getPhoneId(), key, val);

        log("[key, value]=" + key + ", " +  val);
    
public voidsetVoiceCallForwardingFlag(int line, boolean enable, java.lang.String number)
Set the voice call forwarding flag for GSM/UMTS and the like SIMs

param
line to enable/disable
param
enable
param
number to which CFU is enabled

    
public abstract voidsetVoiceMailNumber(java.lang.String alphaTag, java.lang.String voiceNumber, android.os.Message onComplete)
Set voice mail number to SIM record The voice mail number can be stored either in EF_MBDN (TS 51.011) or EF_MAILBOX_CPHS (CPHS 4.2) If EF_MBDN is available, store the voice mail number to EF_MBDN If EF_MAILBOX_CPHS is enabled, store the voice mail number to EF_CHPS So the voice mail number will be stored in both EFs if both are available Return error only if both EF_MBDN and EF_MAILBOX_CPHS fail. When the operation is complete, onComplete will be sent to its handler

param
alphaTag alpha-tagging of the dailing nubmer (upto 10 characters)
param
voiceNumber dailing nubmer (upto 20 digits) if the number is start with '+', then set to international TOA
param
onComplete onComplete.obj will be an AsyncResult ((AsyncResult)onComplete.obj).exception == null on success ((AsyncResult)onComplete.obj).exception != null on fail

public abstract voidsetVoiceMessageWaiting(int line, int countWaiting)
Sets the SIM voice message waiting indicator records

param
line GSM Subscriber Profile Number, one-based. Only '1' is supported
param
countWaiting The number of messages waiting, if known. Use -1 to indicate that an unknown number of messages are waiting

public java.lang.StringtoString()


    
       
        return "mDestroyed=" + mDestroyed
                + " mContext=" + mContext
                + " mCi=" + mCi
                + " mFh=" + mFh
                + " mParentApp=" + mParentApp
                + " recordsLoadedRegistrants=" + mRecordsLoadedRegistrants
                + " mImsiReadyRegistrants=" + mImsiReadyRegistrants
                + " mRecordsEventsRegistrants=" + mRecordsEventsRegistrants
                + " mNewSmsRegistrants=" + mNewSmsRegistrants
                + " mNetworkSelectionModeAutomaticRegistrants="
                        + mNetworkSelectionModeAutomaticRegistrants
                + " recordsToLoad=" + mRecordsToLoad
                + " adnCache=" + mAdnCache
                + " recordsRequested=" + mRecordsRequested
                + " iccid=" + mIccId
                + " msisdnTag=" + mMsisdnTag
                + " voiceMailNum=" + mVoiceMailNum
                + " voiceMailTag=" + mVoiceMailTag
                + " newVoiceMailNum=" + mNewVoiceMailNum
                + " newVoiceMailTag=" + mNewVoiceMailTag
                + " isVoiceMailFixed=" + mIsVoiceMailFixed
                + " mImsi=" + mImsi
                + " mncLength=" + mMncLength
                + " mailboxIndex=" + mMailboxIndex
                + " spn=" + mSpn;

    
public voidunregisterForImsiReady(android.os.Handler h)

        mImsiReadyRegistrants.remove(h);
    
public voidunregisterForNetworkSelectionModeAutomatic(android.os.Handler h)

        mNetworkSelectionModeAutomaticRegistrants.remove(h);
    
public voidunregisterForNewSms(android.os.Handler h)

        mNewSmsRegistrants.remove(h);
    
public voidunregisterForRecordsEvents(android.os.Handler h)

        mRecordsEventsRegistrants.remove(h);
    
public voidunregisterForRecordsLoaded(android.os.Handler h)

        mRecordsLoadedRegistrants.remove(h);