Handle invalid subIds in Enable2gPreferenceController.
Implements improved handling of invalid subIds in the "Allow 2G" controller + unit tests. Bug: 185264531 Test: m & atest -c Enable2gPreferenceControllerTest Change-Id: I7587f1a2a8150bbc6cc0864c9a13d0d910a26682
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user