Search in sources :

Example 26 with EuiccCard

use of com.android.internal.telephony.uicc.euicc.EuiccCard in project android_frameworks_opt_telephony by LineageOS.

the class UiccSlot method update.

/**
 * Update slot. The main trigger for this is a change in the ICC Card status.
 */
public void update(CommandsInterface ci, IccCardStatus ics, int phoneId, int slotIndex) {
    if (DBG)
        log("cardStatus update: " + ics.toString());
    synchronized (mLock) {
        CardState oldState = mCardState;
        mCardState = ics.mCardState;
        mIccId = ics.iccid;
        mPhoneId = phoneId;
        parseAtr(ics.atr);
        mCi = ci;
        mIsRemovable = isSlotRemovable(slotIndex);
        int radioState = mCi.getRadioState();
        if (DBG) {
            log("update: radioState=" + radioState + " mLastRadioState=" + mLastRadioState);
        }
        if (absentStateUpdateNeeded(oldState)) {
            updateCardStateAbsent();
        // Because mUiccCard may be updated in both IccCardStatus and IccSlotStatus, we need to
        // create a new UiccCard instance in two scenarios:
        // 1. mCardState is changing from ABSENT to non ABSENT.
        // 2. The latest mCardState is not ABSENT, but there is no UiccCard instance.
        } else if ((oldState == null || oldState == CardState.CARDSTATE_ABSENT || mUiccCard == null) && mCardState != CardState.CARDSTATE_ABSENT) {
            // No notification while we are just powering up
            if (radioState != TelephonyManager.RADIO_POWER_UNAVAILABLE && mLastRadioState != TelephonyManager.RADIO_POWER_UNAVAILABLE) {
                if (DBG)
                    log("update: notify card added");
                sendMessage(obtainMessage(EVENT_CARD_ADDED, null));
            }
            // card is present in the slot now; create new mUiccCard
            if (mUiccCard != null) {
                loge("update: mUiccCard != null when card was present; disposing it now");
                mUiccCard.dispose();
            }
            if (!mIsEuicc) {
                mUiccCard = new UiccCard(mContext, mCi, ics, mPhoneId, mLock);
            } else {
                // to catch that here
                if (TextUtils.isEmpty(ics.eid)) {
                    loge("update: eid is missing. ics.eid=" + ics.eid);
                }
                mUiccCard = new EuiccCard(mContext, mCi, ics, phoneId, mLock);
            }
        } else {
            if (mUiccCard != null) {
                mUiccCard.update(mContext, mCi, ics);
            }
        }
        mLastRadioState = radioState;
    }
}
Also used : EuiccCard(com.android.internal.telephony.uicc.euicc.EuiccCard) CardState(com.android.internal.telephony.uicc.IccCardStatus.CardState)

Example 27 with EuiccCard

use of com.android.internal.telephony.uicc.euicc.EuiccCard in project android_frameworks_opt_telephony by LineageOS.

the class UiccProfile method updateExternalState.

/**
 * Update the external SIM state
 */
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
public void updateExternalState() {
    // First check if card state is IO_ERROR or RESTRICTED
    if (mUiccCard.getCardState() == IccCardStatus.CardState.CARDSTATE_ERROR) {
        setExternalState(IccCardConstants.State.CARD_IO_ERROR);
        return;
    }
    if (mUiccCard.getCardState() == IccCardStatus.CardState.CARDSTATE_RESTRICTED) {
        setExternalState(IccCardConstants.State.CARD_RESTRICTED);
        return;
    }
    if (mUiccCard instanceof EuiccCard && ((EuiccCard) mUiccCard).getEid() == null) {
        // for RadioConfig<1.2 the EID is not known when the EuiccCard is constructed
        if (DBG)
            log("EID is not ready yet.");
        return;
    }
    // based on apps
    if (mUiccApplication == null) {
        loge("updateExternalState: setting state to NOT_READY because mUiccApplication is " + "null");
        setExternalState(IccCardConstants.State.NOT_READY);
        return;
    }
    // Check if SIM is locked
    boolean cardLocked = false;
    IccCardConstants.State lockedState = null;
    IccCardApplicationStatus.AppState appState = mUiccApplication.getState();
    PinState pin1State = mUiccApplication.getPin1State();
    if (pin1State == PinState.PINSTATE_ENABLED_PERM_BLOCKED) {
        if (VDBG)
            log("updateExternalState: PERM_DISABLED");
        cardLocked = true;
        lockedState = IccCardConstants.State.PERM_DISABLED;
    } else {
        if (appState == IccCardApplicationStatus.AppState.APPSTATE_PIN) {
            if (VDBG)
                log("updateExternalState: PIN_REQUIRED");
            cardLocked = true;
            lockedState = IccCardConstants.State.PIN_REQUIRED;
        } else if (appState == IccCardApplicationStatus.AppState.APPSTATE_PUK) {
            if (VDBG)
                log("updateExternalState: PUK_REQUIRED");
            cardLocked = true;
            lockedState = IccCardConstants.State.PUK_REQUIRED;
        } else if (appState == IccCardApplicationStatus.AppState.APPSTATE_SUBSCRIPTION_PERSO) {
            if (PersoSubState.isPersoLocked(mUiccApplication.getPersoSubState())) {
                if (VDBG)
                    log("updateExternalState: PERSOSUBSTATE_SIM_NETWORK");
                cardLocked = true;
                lockedState = IccCardConstants.State.NETWORK_LOCKED;
            }
        }
    }
    // If SIM is locked, broadcast state as NOT_READY/LOCKED depending on if records are loaded
    if (cardLocked) {
        if (mIccRecords != null && (mIccRecords.getLockedRecordsLoaded() || mIccRecords.getNetworkLockedRecordsLoaded())) {
            // locked records loaded
            if (VDBG) {
                log("updateExternalState: card locked and records loaded; " + "setting state to locked");
            }
            setExternalState(lockedState);
        } else {
            if (VDBG) {
                log("updateExternalState: card locked but records not loaded; " + "setting state to NOT_READY");
            }
            setExternalState(IccCardConstants.State.NOT_READY);
        }
        return;
    }
    // Check for remaining app states
    switch(appState) {
        case APPSTATE_UNKNOWN:
            /*
                 * APPSTATE_UNKNOWN is a catch-all state reported whenever the app
                 * is not explicitly in one of the other states. To differentiate the
                 * case where we know that there is a card present, but the APP is not
                 * ready, we choose NOT_READY here instead of unknown. This is possible
                 * in at least two cases:
                 * 1) A transient during the process of the SIM bringup
                 * 2) There is no valid App on the SIM to load, which can be the case with an
                 *    eSIM/soft SIM.
                 */
            if (VDBG) {
                log("updateExternalState: app state is unknown; setting state to NOT_READY");
            }
            setExternalState(IccCardConstants.State.NOT_READY);
            break;
        case APPSTATE_DETECTED:
            if (VDBG) {
                log("updateExternalState: app state is detected; setting state to NOT_READY");
            }
            setExternalState(IccCardConstants.State.NOT_READY);
            break;
        case APPSTATE_READY:
            checkAndUpdateIfAnyAppToBeIgnored();
            if (areReadyAppsRecordsLoaded() && areCarrierPriviligeRulesLoaded()) {
                if (VDBG)
                    log("updateExternalState: setting state to LOADED");
                setExternalState(IccCardConstants.State.LOADED);
            } else {
                if (VDBG) {
                    log("updateExternalState: setting state to READY; records loaded " + areReadyAppsRecordsLoaded() + ", carrier privilige rules loaded " + areCarrierPriviligeRulesLoaded());
                }
                setExternalState(IccCardConstants.State.READY);
            }
            break;
    }
}
Also used : EuiccCard(com.android.internal.telephony.uicc.euicc.EuiccCard) PinState(com.android.internal.telephony.uicc.IccCardStatus.PinState) IccCardConstants(com.android.internal.telephony.IccCardConstants) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Aggregations

EuiccCard (com.android.internal.telephony.uicc.euicc.EuiccCard)27 RemoteException (android.os.RemoteException)22 AsyncResultCallback (com.android.internal.telephony.uicc.euicc.async.AsyncResultCallback)22 EuiccProfileInfo (android.service.euicc.EuiccProfileInfo)3 EuiccNotification (android.telephony.euicc.EuiccNotification)3 AsyncResult (android.os.AsyncResult)1 EuiccRulesAuthTable (android.telephony.euicc.EuiccRulesAuthTable)1 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)1 IccCardConstants (com.android.internal.telephony.IccCardConstants)1 CardState (com.android.internal.telephony.uicc.IccCardStatus.CardState)1 PinState (com.android.internal.telephony.uicc.IccCardStatus.PinState)1 UiccController (com.android.internal.telephony.uicc.UiccController)1 UiccSlot (com.android.internal.telephony.uicc.UiccSlot)1