Search in sources :

Example 1 with CardState

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

the class UiccCard method update.

public void update(Context c, CommandsInterface ci, IccCardStatus ics) {
    synchronized (mLock) {
        CardState oldState = mCardState;
        mCardState = ics.mCardState;
        mUniversalPinState = ics.mUniversalPinState;
        mGsmUmtsSubscriptionAppIndex = ics.mGsmUmtsSubscriptionAppIndex;
        mCdmaSubscriptionAppIndex = ics.mCdmaSubscriptionAppIndex;
        mImsSubscriptionAppIndex = ics.mImsSubscriptionAppIndex;
        mContext = c;
        mCi = ci;
        // update applications
        if (DBG)
            log(ics.mApplications.length + " applications");
        for (int i = 0; i < mUiccApplications.length; i++) {
            if (mUiccApplications[i] == null) {
                // Create newly added Applications
                if (i < ics.mApplications.length) {
                    mUiccApplications[i] = new UiccCardApplication(this, ics.mApplications[i], mContext, mCi);
                }
            } else if (i >= ics.mApplications.length) {
                // Delete removed applications
                mUiccApplications[i].dispose();
                mUiccApplications[i] = null;
            } else {
                // Update the rest
                mUiccApplications[i].update(ics.mApplications[i], mContext, mCi);
            }
        }
        createAndUpdateCatServiceLocked();
        // Reload the carrier privilege rules if necessary.
        log("Before privilege rules: " + mCarrierPrivilegeRules + " : " + mCardState);
        if (mCarrierPrivilegeRules == null && mCardState == CardState.CARDSTATE_PRESENT) {
            mCarrierPrivilegeRules = new UiccCarrierPrivilegeRules(this, mHandler.obtainMessage(EVENT_CARRIER_PRIVILEGES_LOADED));
        } else if (mCarrierPrivilegeRules != null && mCardState != CardState.CARDSTATE_PRESENT) {
            mCarrierPrivilegeRules = null;
        }
        sanitizeApplicationIndexesLocked();
        RadioState radioState = mCi.getRadioState();
        if (DBG)
            log("update: radioState=" + radioState + " mLastRadioState=" + mLastRadioState);
        // No notifications while radio is off or we just powering up
        if (radioState == RadioState.RADIO_ON && mLastRadioState == RadioState.RADIO_ON) {
            if (oldState != CardState.CARDSTATE_ABSENT && mCardState == CardState.CARDSTATE_ABSENT) {
                if (DBG)
                    log("update: notify card removed");
                mAbsentRegistrants.notifyRegistrants();
                mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARD_REMOVED, null));
            } else if (oldState == CardState.CARDSTATE_ABSENT && mCardState != CardState.CARDSTATE_ABSENT) {
                if (DBG)
                    log("update: notify card added");
                mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARD_ADDED, null));
            }
        }
        if (needsSimActivation()) {
            if (mCardState == CardState.CARDSTATE_PRESENT) {
                if (!mDefaultAppsActivated) {
                    activateDefaultApps();
                    mDefaultAppsActivated = true;
                }
            } else {
                // SIM removed, reset activation flag to make sure
                // to re-run the activation at the next insertion
                mDefaultAppsActivated = false;
            }
        }
        mLastRadioState = radioState;
    }
}
Also used : CardState(com.android.internal.telephony.uicc.IccCardStatus.CardState) RadioState(com.android.internal.telephony.CommandsInterface.RadioState)

Example 2 with CardState

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

the class CatService method updateIccAvailability.

void updateIccAvailability() {
    if (null == mUiccController) {
        return;
    }
    CardState newState = CardState.CARDSTATE_ABSENT;
    UiccCard newCard = mUiccController.getUiccCard(mSlotId);
    if (newCard != null) {
        newState = newCard.getCardState();
    }
    CardState oldState = mCardState;
    mCardState = newState;
    CatLog.d(this, "New Card State = " + newState + " " + "Old Card State = " + oldState);
    if (oldState == CardState.CARDSTATE_PRESENT && newState != CardState.CARDSTATE_PRESENT) {
        broadcastCardStateAndIccRefreshResp(newState, null);
    } else if (oldState != CardState.CARDSTATE_PRESENT && newState == CardState.CARDSTATE_PRESENT) {
        // Card moved to PRESENT STATE.
        mCmdIf.reportStkServiceIsRunning(null);
    }
}
Also used : UiccCard(com.android.internal.telephony.uicc.UiccCard) CardState(com.android.internal.telephony.uicc.IccCardStatus.CardState)

Example 3 with CardState

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

the class UiccSlot method update.

/**
 * Update slot based on IccSlotStatus.
 */
public void update(CommandsInterface ci, IccSlotStatus iss, int slotIndex) {
    if (DBG)
        log("slotStatus update: " + iss.toString());
    synchronized (mLock) {
        CardState oldState = mCardState;
        mCi = ci;
        parseAtr(iss.atr);
        mCardState = iss.cardState;
        mIccId = iss.iccid;
        mEid = iss.eid;
        mIsRemovable = isSlotRemovable(slotIndex);
        if (iss.slotState == IccSlotStatus.SlotState.SLOTSTATE_INACTIVE) {
            // TODO: (b/79432584) evaluate whether should broadcast card state change
            // even if it's inactive.
            UiccController.updateInternalIccStateForInactiveSlot(mContext, mPhoneId, mIccId);
            if (mActive) {
                mActive = false;
                mLastRadioState = TelephonyManager.RADIO_POWER_UNAVAILABLE;
                mPhoneId = INVALID_PHONE_ID;
                nullifyUiccCard(true);
            }
        } else {
            mActive = true;
            mPhoneId = iss.logicalSlotIndex;
            if (absentStateUpdateNeeded(oldState)) {
                updateCardStateAbsent();
            }
        // TODO: (b/79432584) Create UiccCard or EuiccCard object here.
        // Right now It's OK not creating it because Card status update will do it.
        // But we should really make them symmetric.
        }
    }
}
Also used : CardState(com.android.internal.telephony.uicc.IccCardStatus.CardState)

Example 4 with CardState

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

Aggregations

CardState (com.android.internal.telephony.uicc.IccCardStatus.CardState)4 RadioState (com.android.internal.telephony.CommandsInterface.RadioState)1 UiccCard (com.android.internal.telephony.uicc.UiccCard)1 EuiccCard (com.android.internal.telephony.uicc.euicc.EuiccCard)1