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

Commit 31bea73f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove ACTION_INTERNAL_SIM_STATE_CHANGED." into pi-dev

parents 7957f42c 2a63f28d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -307,6 +307,10 @@ public class PhoneFactory {
        }
    }

    public static SubscriptionInfoUpdater getSubscriptionInfoUpdater() {
        return sSubInfoRecordUpdater;
    }

    public static ImsResolver getImsResolver() {
        return sImsResolver;
    }
+22 −69
Original line number Diff line number Diff line
@@ -20,12 +20,10 @@ import android.Manifest;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.UserSwitchObserver;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.IPackageManager;
import android.os.AsyncResult;
@@ -55,7 +53,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.euicc.EuiccController;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.IccUtils;
import com.android.internal.telephony.uicc.UiccProfile;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -69,6 +66,7 @@ public class SubscriptionInfoUpdater extends Handler {
    private static final String LOG_TAG = "SubscriptionInfoUpdater";
    private static final int PROJECT_SIM_NUM = TelephonyManager.getDefault().getPhoneCount();

    private static final int EVENT_INVALID = -1;
    private static final int EVENT_GET_NETWORK_SELECTION_MODE_DONE = 2;
    private static final int EVENT_SIM_LOADED = 3;
    private static final int EVENT_SIM_ABSENT = 4;
@@ -133,9 +131,6 @@ public class SubscriptionInfoUpdater extends Handler {
        mEuiccManager = (EuiccManager) mContext.getSystemService(Context.EUICC_SERVICE);
        mPackageManager = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));

        IntentFilter intentFilter = new IntentFilter(UiccProfile.ACTION_INTERNAL_SIM_STATE_CHANGED);
        mContext.registerReceiver(sReceiver, intentFilter);

        mCarrierServiceBindHelper = new CarrierServiceBindHelper(mContext);
        initializeCarrierApps();
    }
@@ -173,56 +168,29 @@ public class SubscriptionInfoUpdater extends Handler {
                mCurrentlyActiveUserId);
    }

    private final BroadcastReceiver sReceiver = new  BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            logd("[Receiver]+");
            String action = intent.getAction();
            logd("Action: " + action);

            if (!action.equals(UiccProfile.ACTION_INTERNAL_SIM_STATE_CHANGED)) {
                return;
    public void updateInternalIccState(String simStatus, String reason, int slotId) {
        int message = internalIccStateToMessage(simStatus);
        if (message != EVENT_INVALID) {
            sendMessage(obtainMessage(message, slotId, -1, reason));
        }

            int slotIndex = intent.getIntExtra(PhoneConstants.PHONE_KEY,
                    SubscriptionManager.INVALID_SIM_SLOT_INDEX);
            logd("slotIndex: " + slotIndex);
            if (!SubscriptionManager.isValidSlotIndex(slotIndex)) {
                logd("ACTION_INTERNAL_SIM_STATE_CHANGED contains invalid slotIndex: " + slotIndex);
                return;
    }

            String simStatus = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE);
            logd("simStatus: " + simStatus);

            if (action.equals(UiccProfile.ACTION_INTERNAL_SIM_STATE_CHANGED)) {
                if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(simStatus)) {
                    sendMessage(obtainMessage(EVENT_SIM_ABSENT, slotIndex, -1));
                } else if (IccCardConstants.INTENT_VALUE_ICC_UNKNOWN.equals(simStatus)) {
                    sendMessage(obtainMessage(EVENT_SIM_UNKNOWN, slotIndex, -1));
                } else if (IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR.equals(simStatus)) {
                    sendMessage(obtainMessage(EVENT_SIM_IO_ERROR, slotIndex, -1));
                } else if (IccCardConstants.INTENT_VALUE_ICC_CARD_RESTRICTED.equals(simStatus)) {
                    sendMessage(obtainMessage(EVENT_SIM_RESTRICTED, slotIndex, -1));
                } else if (IccCardConstants.INTENT_VALUE_ICC_NOT_READY.equals(simStatus)) {
                    sendEmptyMessage(EVENT_SIM_NOT_READY);
                } else if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(simStatus)) {
                    String reason = intent.getStringExtra(
                        IccCardConstants.INTENT_KEY_LOCKED_REASON);
                    sendMessage(obtainMessage(EVENT_SIM_LOCKED, slotIndex, -1, reason));
                } else if (IccCardConstants.INTENT_VALUE_ICC_LOADED.equals(simStatus)) {
                    sendMessage(obtainMessage(EVENT_SIM_LOADED, slotIndex, -1));
                } else if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(simStatus)) {
                    sendMessage(obtainMessage(EVENT_SIM_READY, slotIndex, -1));
                } else if (IccCardConstants.INTENT_VALUE_ICC_IMSI.equals(simStatus)) {
                    sendMessage(obtainMessage(EVENT_SIM_IMSI, slotIndex, -1));
                } else {
    private int internalIccStateToMessage(String simStatus) {
        switch(simStatus) {
            case IccCardConstants.INTENT_VALUE_ICC_ABSENT: return EVENT_SIM_ABSENT;
            case IccCardConstants.INTENT_VALUE_ICC_UNKNOWN: return EVENT_SIM_UNKNOWN;
            case IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR: return EVENT_SIM_IO_ERROR;
            case IccCardConstants.INTENT_VALUE_ICC_CARD_RESTRICTED: return EVENT_SIM_RESTRICTED;
            case IccCardConstants.INTENT_VALUE_ICC_NOT_READY: return EVENT_SIM_NOT_READY;
            case IccCardConstants.INTENT_VALUE_ICC_LOCKED: return EVENT_SIM_LOCKED;
            case IccCardConstants.INTENT_VALUE_ICC_LOADED: return EVENT_SIM_LOADED;
            case IccCardConstants.INTENT_VALUE_ICC_READY: return EVENT_SIM_READY;
            case IccCardConstants.INTENT_VALUE_ICC_IMSI: return EVENT_SIM_IMSI;
            default:
                logd("Ignoring simStatus: " + simStatus);
                return EVENT_INVALID;
        }
    }
            logd("[Receiver]-");
        }
    };

    private boolean isAllIccIdQueryDone() {
        for (int i = 0; i < PROJECT_SIM_NUM; i++) {
@@ -325,16 +293,6 @@ public class SubscriptionInfoUpdater extends Handler {
        sendMessage(obtainMessage(EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS, callback));
    }

    private static class QueryIccIdUserObj {
        public String reason;
        public int slotId;

        QueryIccIdUserObj(String reason, int slotId) {
            this.reason = reason;
            this.slotId = slotId;
        }
    };

    private void handleSimLocked(int slotId, String reason) {
        if (mIccId[slotId] != null && mIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) {
            logd("SIM" + (slotId + 1) + " hot plug in");
@@ -924,11 +882,6 @@ public class SubscriptionInfoUpdater extends Handler {
        }
    }

    public void dispose() {
        logd("[dispose]");
        mContext.unregisterReceiver(sReceiver);
    }

    private void logd(String message) {
        Rlog.d(LOG_TAG, message);
    }
+11 −0
Original line number Diff line number Diff line
@@ -33,7 +33,9 @@ import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.RadioConfig;
import com.android.internal.telephony.SubscriptionInfoUpdater;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -461,6 +463,15 @@ public class UiccController extends Handler {
        }
    }

    static void updateInternalIccState(String value, String reason, int phoneId) {
        SubscriptionInfoUpdater subInfoUpdator = PhoneFactory.getSubscriptionInfoUpdater();
        if (subInfoUpdator != null) {
            subInfoUpdator.updateInternalIccState(value, reason, phoneId);
        } else {
            Rlog.e(LOG_TAG, "subInfoUpdate is null.");
        }
    }

    private synchronized void onGetIccCardStatusDone(AsyncResult ar, Integer index) {
        if (ar.exception != null) {
            Rlog.e(LOG_TAG,"Error getting ICC status. "
+1 −21
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.internal.telephony.uicc;

import android.app.ActivityManager;
import android.app.usage.UsageStatsManager;
import android.content.Context;
import android.content.Intent;
@@ -33,7 +32,6 @@ import android.os.Message;
import android.os.PersistableBundle;
import android.os.Registrant;
import android.os.RegistrantList;
import android.os.UserHandle;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
@@ -134,9 +132,6 @@ public class UiccProfile extends Handler implements IccCard {
    private IccRecords mIccRecords = null;
    private IccCardConstants.State mExternalState = IccCardConstants.State.UNKNOWN;

    public static final String ACTION_INTERNAL_SIM_STATE_CHANGED =
            "android.intent.action.internal_sim_state_changed";

    private final ContentObserver mProvisionCompleteContentObserver =
            new ContentObserver(new Handler()) {
                @Override
@@ -485,21 +480,6 @@ public class UiccProfile extends Handler implements IccCard {
        }
    }

    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, phoneId);  // SubId may not be valid.
        String logStr = "Sending intent ACTION_INTERNAL_SIM_STATE_CHANGED value=" + value
                + " for mPhoneId : " + phoneId;
        log(logStr);
        UiccController.sLocalLog.log("UiccProfile[" + phoneId + "]: " + logStr);
        ActivityManager.broadcastStickyIntent(intent, UserHandle.USER_ALL);
    }

    private void setExternalState(IccCardConstants.State newState, boolean override) {
        synchronized (mLock) {
            if (!SubscriptionManager.isValidSlotIndex(mPhoneId)) {
@@ -535,7 +515,7 @@ public class UiccProfile extends Handler implements IccCard {
            log("setExternalState: set mPhoneId=" + mPhoneId + " mExternalState=" + mExternalState);
            mTelephonyManager.setSimStateForPhone(mPhoneId, getState().toString());

            broadcastInternalIccStateChangedIntent(getIccStateIntentString(mExternalState),
            UiccController.updateInternalIccState(getIccStateIntentString(mExternalState),
                    getIccStateReason(mExternalState), mPhoneId);
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ public class UiccSlot extends Handler {
                    sendMessage(obtainMessage(EVENT_CARD_REMOVED, null));
                }

                UiccProfile.broadcastInternalIccStateChangedIntent(
                UiccController.updateInternalIccState(
                        IccCardConstants.INTENT_VALUE_ICC_ABSENT, null, mPhoneId);

                // no card present in the slot now; dispose card and make mUiccCard null
@@ -324,7 +324,7 @@ public class UiccSlot extends Handler {
        mUiccCard = null;

        if (mPhoneId != INVALID_PHONE_ID) {
            UiccProfile.broadcastInternalIccStateChangedIntent(
            UiccController.updateInternalIccState(
                    IccCardConstants.INTENT_VALUE_ICC_UNKNOWN, null, mPhoneId);
        }

Loading