[Settings] Add NPE protection for the bundle

Bug: 238980691
Change-Id: I0f5e79ab83701552bc92b07ebdc0ee90b700721f
Test: atest EnabledNetworkModePreferenceControllerTest
This commit is contained in:
Zoey Chen
2022-07-14 11:09:57 +00:00
parent 501cc9837a
commit a3ba183165

View File

@@ -239,8 +239,8 @@ public class EnabledNetworkModePreferenceController extends
void setPreferenceEntries() {
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(mSubId);
final boolean display2gOptions = carrierConfig
.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL);
final boolean display2gOptions = carrierConfig != null
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL);
clearAllEntries();
UiOptions.Builder uiOptions = UiOptions.newBuilder();
uiOptions.setType(getEnabledNetworkType());