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

Commit 819e58fd authored by Bruno Martins's avatar Bruno Martins
Browse files

Avoid SubscriptionManager#getUriForSubscriptionId calls with invalid subIds

It seems like the SIM card can take longer to load on certain legacy CDMA devices,
thus causing the subscription ID not to be valid during early telephony init.

Just skip calling SubscriptionController#setMccMnc or setCountryIso at that point,
so to avoid any subsequent calls to SubscriptionManager#getUriForSubscriptionId with
an invalid subId, which then makes the phone process crash. Once the SIM is loaded,
SubscriptionInfoUpdater will take care of updating the DB with the proper URI.

Change-Id: I8bd71127aecff9577bb0d3b9d7cab7a01a076e87
parent 71d4f01c
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -439,8 +439,6 @@ public class GsmCdmaPhone extends Phone {
                logd("update icc_operator_numeric=" + operatorNumeric);
                tm.setSimOperatorNumericForPhone(mPhoneId, operatorNumeric);

                SubscriptionController.getInstance().setMccMnc(operatorNumeric, getSubId());

                // Sets iso country property by retrieving from build-time system property
                String iso = "";
                try {
@@ -451,7 +449,14 @@ public class GsmCdmaPhone extends Phone {

                logd("init: set 'gsm.sim.operator.iso-country' to iso=" + iso);
                tm.setSimCountryIsoForPhone(mPhoneId, iso);
                SubscriptionController.getInstance().setCountryIso(iso, getSubId());

                // Skip if the subscription ID is not valid, because it can happen
                // that the SIM is not loaded yet at this point.
                final int subId = getSubId();
                if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
                    SubscriptionController.getInstance().setMccMnc(operatorNumeric, subId);
                    SubscriptionController.getInstance().setCountryIso(iso, subId);
                }

                // Updates MCC MNC device configuration information
                logd("update mccmnc=" + operatorNumeric);