Search in sources :

Example 1 with PinState

use of com.android.internal.telephony.uicc.IccCardStatus.PinState in project android_frameworks_opt_telephony by LineageOS.

the class IccCardApplicationStatus method PinStateFromRILInt.

public PinState PinStateFromRILInt(int state) {
    PinState newPinState;
    switch(state) {
        case 0:
            newPinState = PinState.PINSTATE_UNKNOWN;
            break;
        case 1:
            newPinState = PinState.PINSTATE_ENABLED_NOT_VERIFIED;
            break;
        case 2:
            newPinState = PinState.PINSTATE_ENABLED_VERIFIED;
            break;
        case 3:
            newPinState = PinState.PINSTATE_DISABLED;
            break;
        case 4:
            newPinState = PinState.PINSTATE_ENABLED_BLOCKED;
            break;
        case 5:
            newPinState = PinState.PINSTATE_ENABLED_PERM_BLOCKED;
            break;
        default:
            newPinState = PinState.PINSTATE_UNKNOWN;
            loge("PinStateFromRILInt: bad pin state: " + state + " use PINSTATE_UNKNOWN");
    }
    return newPinState;
}
Also used : PinState(com.android.internal.telephony.uicc.IccCardStatus.PinState)

Example 2 with PinState

use of com.android.internal.telephony.uicc.IccCardStatus.PinState in project android_frameworks_opt_telephony by LineageOS.

the class UiccCardApplication method update.

@UnsupportedAppUsage
public void update(IccCardApplicationStatus as, Context c, CommandsInterface ci) {
    synchronized (mLock) {
        if (mDestroyed) {
            loge("Application updated after destroyed! Fix me!");
            return;
        }
        if (DBG)
            log(mAppType + " update. New " + as);
        mContext = c;
        mCi = ci;
        AppType oldAppType = mAppType;
        AppState oldAppState = mAppState;
        PersoSubState oldPersoSubState = mPersoSubState;
        PinState oldPin1State = mPin1State;
        mAppType = as.app_type;
        mAuthContext = getAuthContext(mAppType);
        mAppState = as.app_state;
        mPersoSubState = as.perso_substate;
        mAid = as.aid;
        mAppLabel = as.app_label;
        mPin1Replaced = (as.pin1_replaced != 0);
        mPin1State = as.pin1;
        mPin2State = as.pin2;
        if (mAppType != oldAppType) {
            if (mIccFh != null) {
                mIccFh.dispose();
            }
            if (mIccRecords != null) {
                mIccRecords.dispose();
            }
            mIccFh = createIccFileHandler(as.app_type);
            mIccRecords = createIccRecords(as.app_type, c, ci);
        }
        if (mPersoSubState != oldPersoSubState && PersoSubState.isPersoLocked(mPersoSubState)) {
            notifyNetworkLockedRegistrantsIfNeeded(null);
        }
        if (mAppState != oldAppState) {
            if (DBG)
                log(oldAppType + " changed state: " + oldAppState + " -> " + mAppState);
            // as it might have failed in earlier attempt.
            if (mAppState == AppState.APPSTATE_READY) {
                queryFdn();
                queryPin1State();
            }
            notifyPinLockedRegistrantsIfNeeded(null);
            notifyReadyRegistrantsIfNeeded(null);
            notifyDetectedRegistrantsIfNeeded(null);
        } else {
            if (mPin1State != oldPin1State)
                queryPin1State();
        }
    }
}
Also used : PinState(com.android.internal.telephony.uicc.IccCardStatus.PinState) AppState(com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState) AppType(com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType) PersoSubState(com.android.internal.telephony.uicc.IccCardApplicationStatus.PersoSubState) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 3 with PinState

use of com.android.internal.telephony.uicc.IccCardStatus.PinState in project android_frameworks_opt_telephony by LineageOS.

the class IccCardProxy method processLockedState.

private void processLockedState() {
    synchronized (mLock) {
        if (mUiccApplication == null) {
            // Don't need to do anything if non-existent application is locked
            return;
        }
        PinState pin1State = mUiccApplication.getPin1State();
        if (pin1State == PinState.PINSTATE_ENABLED_PERM_BLOCKED) {
            setExternalState(State.PERM_DISABLED);
            return;
        }
        AppState appState = mUiccApplication.getState();
        switch(appState) {
            case APPSTATE_PIN:
                mPinLockedRegistrants.notifyRegistrants();
                setExternalState(State.PIN_REQUIRED);
                break;
            case APPSTATE_PUK:
                setExternalState(State.PUK_REQUIRED);
                break;
            case APPSTATE_DETECTED:
            case APPSTATE_READY:
            case APPSTATE_SUBSCRIPTION_PERSO:
            case APPSTATE_UNKNOWN:
                // Neither required
                break;
        }
    }
}
Also used : PinState(com.android.internal.telephony.uicc.IccCardStatus.PinState) AppState(com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState)

Example 4 with PinState

use of com.android.internal.telephony.uicc.IccCardStatus.PinState in project android_frameworks_opt_telephony by LineageOS.

the class IccCardProxy method updateExternalState.

private void updateExternalState() {
    // been received from UiccController.
    if (mUiccCard == null) {
        setExternalState(State.UNKNOWN);
        return;
    }
    if (mUiccCard.getCardState() == CardState.CARDSTATE_ABSENT) {
        /*
             * Both IccCardProxy and UiccController are registered for
             * RadioState changes. When the UiccController receives a radio
             * state changed to Unknown it will dispose of all of the IccCard
             * objects, which will then notify the IccCardProxy and the null
             * object will force the state to unknown. However, because the
             * IccCardProxy is also registered for RadioState changes, it will
             * recieve that signal first. By triggering on radio state changes
             * directly, we reduce the time window during which the modem is
             * UNAVAILABLE but the IccStatus is reported as something valid.
             * This is not ideal.
             */
        if (mRadioState == RadioState.RADIO_UNAVAILABLE) {
            setExternalState(State.UNKNOWN);
        } else {
            setExternalState(State.ABSENT);
        }
        return;
    }
    if (mUiccCard.getCardState() == CardState.CARDSTATE_ERROR) {
        setExternalState(State.CARD_IO_ERROR);
        return;
    }
    if (mUiccCard.getCardState() == CardState.CARDSTATE_RESTRICTED) {
        setExternalState(State.CARD_RESTRICTED);
        return;
    }
    if (mUiccApplication == null) {
        setExternalState(State.NOT_READY);
        return;
    }
    // By process of elimination, the UICC Card State = PRESENT
    switch(mUiccApplication.getState()) {
        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.
                 */
            setExternalState(State.NOT_READY);
            break;
        case APPSTATE_DETECTED:
            HandleDetectedState();
            break;
        case APPSTATE_PIN:
            setExternalState(State.PIN_REQUIRED);
            break;
        case APPSTATE_PUK:
            PinState pin1State = mUiccApplication.getPin1State();
            if (pin1State.isPermBlocked()) {
                setExternalState(State.PERM_DISABLED);
                return;
            }
            setExternalState(State.PUK_REQUIRED);
            break;
        case APPSTATE_SUBSCRIPTION_PERSO:
            if (mUiccApplication.getPersoSubState() == PersoSubState.PERSOSUBSTATE_SIM_NETWORK) {
                setExternalState(State.NETWORK_LOCKED);
            }
            // Otherwise don't change external SIM state.
            break;
        case APPSTATE_READY:
            setExternalState(State.READY);
            break;
    }
}
Also used : PinState(com.android.internal.telephony.uicc.IccCardStatus.PinState)

Example 5 with PinState

use of com.android.internal.telephony.uicc.IccCardStatus.PinState 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

PinState (com.android.internal.telephony.uicc.IccCardStatus.PinState)5 AppState (com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState)2 UnsupportedAppUsage (android.compat.annotation.UnsupportedAppUsage)1 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)1 IccCardConstants (com.android.internal.telephony.IccCardConstants)1 AppType (com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType)1 PersoSubState (com.android.internal.telephony.uicc.IccCardApplicationStatus.PersoSubState)1 EuiccCard (com.android.internal.telephony.uicc.euicc.EuiccCard)1