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

Commit 431d86fb authored by Nathan Harold's avatar Nathan Harold
Browse files

Simplify Nullness Checks for CC Bundle

Centralize the nullness checks for a  CarrierConfig
Bundle in GsmCdmaPhone to increase safety and remove
some boilerplate. Also, one nullness check was previously
missed, so that is addressed as well.

Bug: 303254005
Test: atest FrameworksTelephonyTests #(non-functional change)
Change-Id: I41deabf97502d839b439e0ec4e06ea760a357806
parent 5834b32a
Loading
Loading
Loading
Loading
+18 −39
Original line number Diff line number Diff line
@@ -2361,8 +2361,7 @@ public class GsmCdmaPhone extends Phone {
        return false;
    }

    private void updateSsOverCdmaSupported(PersistableBundle b) {
        if (b == null) return;
    private void updateSsOverCdmaSupported(@NonNull PersistableBundle b) {
        mSsOverCdmaSupported = b.getBoolean(CarrierConfigManager.KEY_SUPPORT_SS_OVER_CDMA_BOOL);
    }

@@ -2417,12 +2416,9 @@ public class GsmCdmaPhone extends Phone {
    }

    /** Only called on the handler thread. */
    private void updateCarrierN1ModeSupported(@Nullable PersistableBundle b) {
    private void updateCarrierN1ModeSupported(@NonNull PersistableBundle b) {
        if (!mFeatureFlags.enableCarrierConfigN1Control()) return;

        if (b == null) return;


        final int[] supportedNrModes = b.getIntArray(
                CarrierConfigManager.KEY_CARRIER_NR_AVAILABILITIES_INT_ARRAY);

@@ -3298,16 +3294,17 @@ public class GsmCdmaPhone extends Phone {

                CarrierConfigManager configMgr = (CarrierConfigManager)
                        getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
                PersistableBundle b = configMgr.getConfigForSubId(getSubId());

                final PersistableBundle b = configMgr.getConfigForSubId(getSubId());
                if (b != null) {
                    updateBroadcastEmergencyCallStateChangesAfterCarrierConfigChanged(b);

                    updateCdmaRoamingSettingsAfterCarrierConfigChanged(b);

                    updateNrSettingsAfterCarrierConfigChanged(b);
                    updateVoNrSettings(b);
                    updateSsOverCdmaSupported(b);
                    updateCarrierN1ModeSupported(b);
                } else {
                    loge("Failed to retrieve a carrier config bundle for subId=" + getSubId());
                }
                loadAllowedNetworksFromSubscriptionDatabase();
                // Obtain new radio capabilities from the modem, since some are SIM-dependent
                mCi.getRadioCapability(obtainMessage(EVENT_GET_RADIO_CAPABILITY));
@@ -5110,12 +5107,7 @@ public class GsmCdmaPhone extends Phone {
    }

    private void updateBroadcastEmergencyCallStateChangesAfterCarrierConfigChanged(
            PersistableBundle config) {
        if (config == null) {
            loge("didn't get broadcastEmergencyCallStateChanges from carrier config");
            return;
        }

            @NonNull PersistableBundle config) {
        // get broadcastEmergencyCallStateChanges
        boolean broadcastEmergencyCallStateChanges = config.getBoolean(
                CarrierConfigManager.KEY_BROADCAST_EMERGENCY_CALL_STATE_CHANGES_BOOL);
@@ -5123,17 +5115,13 @@ public class GsmCdmaPhone extends Phone {
        setBroadcastEmergencyCallStateChanges(broadcastEmergencyCallStateChanges);
    }

    private void updateNrSettingsAfterCarrierConfigChanged(PersistableBundle config) {
        if (config == null) {
            loge("didn't get the carrier_nr_availability_int from the carrier config.");
            return;
        }
    private void updateNrSettingsAfterCarrierConfigChanged(@NonNull PersistableBundle config) {
        int[] nrAvailabilities = config.getIntArray(
                CarrierConfigManager.KEY_CARRIER_NR_AVAILABILITIES_INT_ARRAY);
        mIsCarrierNrSupported = !ArrayUtils.isEmpty(nrAvailabilities);
    }

    private void updateVoNrSettings(PersistableBundle config) {
    private void updateVoNrSettings(@NonNull PersistableBundle config) {
        UiccSlot slot = mUiccController.getUiccSlotForPhone(mPhoneId);

        // If no card is present, do nothing.
@@ -5141,11 +5129,6 @@ public class GsmCdmaPhone extends Phone {
            return;
        }

        if (config == null) {
            loge("didn't get the vonr_enabled_bool from the carrier config.");
            return;
        }

        boolean mIsVonrEnabledByCarrier =
                config.getBoolean(CarrierConfigManager.KEY_VONR_ENABLED_BOOL);
        boolean mDefaultVonr =
@@ -5170,12 +5153,8 @@ public class GsmCdmaPhone extends Phone {
        mCi.setVoNrEnabled(enbleVonr, obtainMessage(EVENT_SET_VONR_ENABLED_DONE), null);
    }

    private void updateCdmaRoamingSettingsAfterCarrierConfigChanged(PersistableBundle config) {
        if (config == null) {
            loge("didn't get the cdma_roaming_mode changes from the carrier config.");
            return;
        }

    private void updateCdmaRoamingSettingsAfterCarrierConfigChanged(
            @NonNull PersistableBundle config) {
        // Changing the cdma roaming settings based carrier config.
        int config_cdma_roaming_mode = config.getInt(
                CarrierConfigManager.KEY_CDMA_ROAMING_MODE_INT);