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

Unverified Commit 1c69bf00 authored by Christian Morlok's avatar Christian Morlok Committed by Michael Bestas
Browse files

telephony: Do not set default subscriptions on shutdown

On some devices the SIM slots are not deactivated at the same time
when the phone is shut down or rebooted. This means that at some point
only one SIM is activated, and all default subscriptions are set to
this SIM (a feature introduced in http://review.cyanogenmod.org/#/c/121239/).

Change-Id: Ief36004619b75530a21b23efc767e1beb1fb0750
parent ac2ec375
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ public class SubscriptionInfoUpdater extends Handler {
    // The current foreground user ID.
    private int mCurrentlyActiveUserId;
    private CarrierServiceBindHelper mCarrierServiceBindHelper;
    private boolean mIsShutdown;

    public SubscriptionInfoUpdater(Context context, Phone[] phone, CommandsInterface[] ci) {
        logd("Constructor invoked");
@@ -124,10 +125,12 @@ public class SubscriptionInfoUpdater extends Handler {
        mSubscriptionManager = SubscriptionManager.from(mContext);
        mPackageManager = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
        mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
        mIsShutdown = false;

        IntentFilter intentFilter = new IntentFilter(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
        intentFilter.addAction(IccCardProxy.ACTION_INTERNAL_SIM_STATE_CHANGED);
        intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
        intentFilter.addAction(Intent.ACTION_SHUTDOWN);
        mContext.registerReceiver(sReceiver, intentFilter);

        mCarrierServiceBindHelper = new CarrierServiceBindHelper(mContext);
@@ -201,6 +204,11 @@ public class SubscriptionInfoUpdater extends Handler {
                return;
            }

            if (action.equals(Intent.ACTION_SHUTDOWN)) {
                mIsShutdown = true;
                return;
            }

            if (!action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED) &&
                    !action.equals(IccCardProxy.ACTION_INTERNAL_SIM_STATE_CHANGED)) {
                return;
@@ -666,7 +674,7 @@ public class SubscriptionInfoUpdater extends Handler {
            }
        }

        if (insertedSimCount == 1) {
        if (!mIsShutdown && insertedSimCount == 1) {
            SubscriptionInfo sir = subInfos.get(0);
            int subId = sir.getSubscriptionId();
            mSubscriptionManager.setDefaultDataSubId(subId);