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

Commit b1a8579f authored by Michael W's avatar Michael W
Browse files

Telephony: Keep preferred SMS Sim

* If the selected sim for SMS was not set to the first sim, the code added
  to fix CYNGNOS-2185 was setting the default SMS sim to the first one
  because the phoneId for the second subId was still invalid at boot
* Check for the defaultSmsSubId once and set it accordingly once the second
  sim comes up

Change-Id: I26ffca42bcc3cf5cd03a62324f6d92fd483da4be
parent bc432281
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ public class SubscriptionController extends ISub.Stub {

    private AppOpsManager mAppOps;

    private int mUserPreferredSmsSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;

    // FIXME: Does not allow for multiple subs in a slot and change to SparseArray
    private static Map<Integer, Integer> sSlotIdxToSubId =
            new ConcurrentHashMap<Integer, Integer>();
@@ -811,10 +813,15 @@ public class SubscriptionController extends ISub.Stub {
                            if (phoneId < 0 || phoneId >= TelephonyManager.getDefault()
                                    .getPhoneCount()) {
                                Rlog.i(LOG_TAG, "Subscription is invalid. Set default to " + subId);
                                mUserPreferredSmsSubId = getDefaultSmsSubId();
                                setDefaultSmsSubId(subId);
                                PhoneFactory.setSMSPromptEnabled(subIdCountMax > 1);
                            } else if (subId == mUserPreferredSmsSubId) {
                                Rlog.i(LOG_TAG, "SMS subscription was different than user choice");
                                setDefaultSmsSubId(subId);
                                mUserPreferredSmsSubId =
                                        SubscriptionManager.INVALID_SUBSCRIPTION_ID;
                            }

                        } else {
                            if (DBG) {
                                logdl("[addSubInfoRecord] currentSubId != null"
@@ -830,6 +837,12 @@ public class SubscriptionController extends ISub.Stub {
                }
            }

            // Reset user choice for defaultSmsSubId in case only one Sim is inserted
            if (sSlotIdxToSubId.size() == 1) {
                Rlog.i(LOG_TAG, "Only one SIM found, resetting user preferred SMS sub");
                mUserPreferredSmsSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
            }

            // Set Display name after sub id is set above so as to get valid simCarrierName
            int[] subIds = getSubId(slotId);
            if (subIds == null || subIds.length == 0) {