Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77bd44b5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Send broadcast for ABSENT/UNKNOWN states."

parents f0ebe5fc 06c1f46c
Loading
Loading
Loading
Loading
+13 −15
Original line number Diff line number Diff line
@@ -459,20 +459,18 @@ public class UiccProfile extends Handler implements IccCard {
        }
    }

    private void broadcastInternalIccStateChangedIntent(String value, String reason) {
        synchronized (mLock) {
    static void broadcastInternalIccStateChangedIntent(String value, String reason, int phoneId) {
        Intent intent = new Intent(ACTION_INTERNAL_SIM_STATE_CHANGED);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
                | Intent.FLAG_RECEIVER_FOREGROUND);
        intent.putExtra(PhoneConstants.PHONE_NAME_KEY, "Phone");
        intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE, value);
        intent.putExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON, reason);
            intent.putExtra(PhoneConstants.PHONE_KEY, mPhoneId);  // SubId may not be valid.
        intent.putExtra(PhoneConstants.PHONE_KEY, phoneId);  // SubId may not be valid.
        log("Sending intent ACTION_INTERNAL_SIM_STATE_CHANGED value=" + value
                    + " for mPhoneId : " + mPhoneId);
                + " for mPhoneId : " + phoneId);
        ActivityManager.broadcastStickyIntent(intent, UserHandle.USER_ALL);
    }
    }

    private void setExternalState(IccCardConstants.State newState, boolean override) {
        synchronized (mLock) {
@@ -510,7 +508,7 @@ public class UiccProfile extends Handler implements IccCard {
            mTelephonyManager.setSimStateForPhone(mPhoneId, getState().toString());

            broadcastInternalIccStateChangedIntent(getIccStateIntentString(mExternalState),
                    getIccStateReason(mExternalState));
                    getIccStateReason(mExternalState), mPhoneId);
        }
    }

@@ -1366,7 +1364,7 @@ public class UiccProfile extends Handler implements IccCard {
        return null;
    }

    private void log(String msg) {
    private static void log(String msg) {
        Rlog.d(LOG_TAG, msg);
    }

+14 −3
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.view.WindowManager;
import com.android.internal.R;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.CommandsInterface.RadioState;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.uicc.IccCardStatus.CardState;

import java.io.FileDescriptor;
@@ -59,7 +60,9 @@ public class UiccSlot extends Handler {
    private RadioState mLastRadioState = RadioState.RADIO_UNAVAILABLE;
    private boolean mIsEuicc;
    private String mIccId;
    private Integer mPhoneId = null;

    // todo: remove if this is not needed
    private RegistrantList mAbsentRegistrants = new RegistrantList();

    private static final int EVENT_CARD_REMOVED = 13;
@@ -81,6 +84,7 @@ public class UiccSlot extends Handler {
        synchronized (mLock) {
            CardState oldState = mCardState;
            mCardState = ics.mCardState;
            mPhoneId = phoneId;
            parseAtr(ics.atr);
            mCi = ci;

@@ -98,7 +102,8 @@ public class UiccSlot extends Handler {
                    sendMessage(obtainMessage(EVENT_CARD_REMOVED, null));
                }

                // todo: broadcast sim state changed for absent/unknown when IccCardProxy is removed
                UiccProfile.broadcastInternalIccStateChangedIntent(
                        IccCardConstants.INTENT_VALUE_ICC_ABSENT, null, mPhoneId);

                // no card present in the slot now; dispose card and make mUiccCard null
                mUiccCard.dispose();
@@ -118,7 +123,7 @@ public class UiccSlot extends Handler {
                }

                if (!mIsEuicc) {
                    mUiccCard = new UiccCard(mContext, mCi, ics, phoneId);
                    mUiccCard = new UiccCard(mContext, mCi, ics, mPhoneId);
                } else {
                    // todo: initialize new EuiccCard object here
                    //mUiccCard = new EuiccCard();
@@ -144,6 +149,9 @@ public class UiccSlot extends Handler {
                    mActive = false;
                    // treat as radio state unavailable
                    onRadioStateUnavailable();
                    // set mPhoneId to null only after sim state changed broadcast is sent as it
                    // needs the phoneId. The broadcast is sent from onRadioStateUnavailable()
                    mPhoneId = null;
                }
                parseAtr(iss.atr);
                mCardState = iss.cardState;
@@ -304,7 +312,10 @@ public class UiccSlot extends Handler {
        }
        mUiccCard = null;

        // todo: broadcast sim state changed for absent/unknown when IccCardProxy is removed
        if (mPhoneId != null) {
            UiccProfile.broadcastInternalIccStateChangedIntent(
                    IccCardConstants.INTENT_VALUE_ICC_UNKNOWN, null, mPhoneId);
        }

        mCardState = CardState.CARDSTATE_ABSENT;
        mLastRadioState = RadioState.RADIO_UNAVAILABLE;