Merge "Handle invalid subIds in Enable2gPreferenceController." into sc-dev

This commit is contained in:
Yomna Nasser
2021-04-22 16:00:02 +00:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 1 deletions

View File

@@ -72,7 +72,7 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
public int getAvailabilityStatus(int subId) {
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
boolean visible =
subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
SubscriptionManager.isUsableSubscriptionId(subId)
&& carrierConfig != null
&& !carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENABLE_2G)
&& mTelephonyManager.isRadioInterfaceCapabilitySupported(
@@ -89,6 +89,9 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
@Override
public boolean setChecked(boolean isChecked) {
if (!SubscriptionManager.isUsableSubscriptionId(mSubId)) {
return false;
}
long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason(
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G);
boolean enabled = (currentlyAllowedNetworkTypes & BITMASK_2G) != 0;