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

Commit 36e6584d authored by rambowang's avatar rambowang
Browse files

Fix phone process crash due to null carrier config

Perform null pointer check on the carrier config bundle subset return
from CarrierConfigManager#getConfigForSub call to make sure it will
not crash the phone process.

Bug: 266962389
Test: atest FrameworksTelephonyTests
Change-Id: I2f142279d267705fa678e8b632228eef475d7f6f
Merged-In: I2f142279d267705fa678e8b632228eef475d7f6f
(cherry picked from commit bc8832aa)
parent 032dd289
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -491,7 +491,7 @@ public class AccessNetworksManager extends Handler {
            b = mCarrierConfigManager.getConfigForSubId(mPhone.getSubId(),
                    CarrierConfigManager
                            .KEY_CARRIER_QUALIFIED_NETWORKS_SERVICE_PACKAGE_OVERRIDE_STRING);
            if (!b.isEmpty()) {
            if (b != null && !b.isEmpty()) {
                // If carrier config overrides it, use the one from carrier config
                String carrierConfigPackageName = b.getString(CarrierConfigManager
                        .KEY_CARRIER_QUALIFIED_NETWORKS_SERVICE_PACKAGE_OVERRIDE_STRING);
@@ -522,7 +522,7 @@ public class AccessNetworksManager extends Handler {
            b = mCarrierConfigManager.getConfigForSubId(mPhone.getSubId(),
                    CarrierConfigManager
                            .KEY_CARRIER_QUALIFIED_NETWORKS_SERVICE_CLASS_OVERRIDE_STRING);
            if (!b.isEmpty()) {
            if (b != null && !b.isEmpty()) {
                // If carrier config overrides it, use the one from carrier config
                String carrierConfigClassName = b.getString(CarrierConfigManager
                        .KEY_CARRIER_QUALIFIED_NETWORKS_SERVICE_CLASS_OVERRIDE_STRING);
+2 −2
Original line number Diff line number Diff line
@@ -630,13 +630,13 @@ public class DataServiceManager extends Handler {

    @NonNull
    private PersistableBundle getCarrierConfigSubset(String key) {
        PersistableBundle configs = new PersistableBundle();
        PersistableBundle configs = null;
        try {
            configs = mCarrierConfigManager.getConfigForSubId(mPhone.getSubId(), key);
        } catch (RuntimeException e) {
            loge("CarrierConfigLoader is not available.");
        }
        return configs;
        return configs != null ? configs : new PersistableBundle();
    }

    private void sendCompleteMessage(Message msg, @DataServiceCallback.ResultCode int code) {
+2 −2
Original line number Diff line number Diff line
@@ -350,7 +350,7 @@ public class EmergencyNumberTracker extends Handler {

    @NonNull
    private PersistableBundle getCarrierConfigSubset(String key) {
        PersistableBundle bundle = new PersistableBundle();
        PersistableBundle bundle = null;

        if (mPhone != null) {
            CarrierConfigManager ccm =
@@ -363,7 +363,7 @@ public class EmergencyNumberTracker extends Handler {
                loge("CarrierConfigLoader is not available.");
            }
        }
        return bundle;
        return bundle != null ? bundle : new PersistableBundle();
    }

    private String getInitialCountryIso() {
+2 −2
Original line number Diff line number Diff line
@@ -1819,13 +1819,13 @@ public class UiccProfile extends IccCard {

    @NonNull
    private PersistableBundle getCarrierConfigSubset(int subId, String... keys) {
        PersistableBundle bundle = new PersistableBundle();
        PersistableBundle bundle = null;
        try {
            bundle = mCarrierConfigManager.getConfigForSubId(subId, keys);
        } catch (RuntimeException e) {
            loge("CarrierConfigLoader is not available.");
        }
        return bundle;
        return bundle != null ? bundle : new PersistableBundle();
    }

    private static String eventToString(int event) {