diff --git a/src/com/android/settings/network/telephony/Enable2gPreferenceController.java b/src/com/android/settings/network/telephony/Enable2gPreferenceController.java index 5ae04ed9f70..99748445a5d 100644 --- a/src/com/android/settings/network/telephony/Enable2gPreferenceController.java +++ b/src/com/android/settings/network/telephony/Enable2gPreferenceController.java @@ -28,6 +28,17 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; /** * Preference controller for "Enable 2G" + * + *
+ * This preference controller is invoked per subscription id, which means toggling 2g is a per-sim + * operation. The requested 2g preference is delegated to + * {@link TelephonyManager#setAllowedNetworkTypesForReason(int reason, long allowedNetworkTypes)} + * with: + *
+ * A return value of {@link #AVAILABLE} denotes that the 2g status can be updated for this + * particular subscription. + * We return {@link #AVAILABLE} if the following conditions are met and {@link + * #CONDITIONALLY_UNAVAILABLE} otherwise. + *
NOTE: This method returns the active state of the preference controller and is not + * the parameter passed into {@link #setChecked(boolean)}, which is instead the requested future + * state.
+ */ @Override public boolean isChecked() { long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason( @@ -91,6 +125,17 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr return (currentlyAllowedNetworkTypes & BITMASK_2G) != 0; } + /** + * Ensure that the modem's allowed network types are configured according to the user's + * preference. + *+ * See {@link com.android.settings.core.TogglePreferenceController#setChecked(boolean)} for + * details. + * + * @param isChecked The toggle value that we're being requested to enforce. A value of {@code + * false} denotes that 2g will be disabled by the modem after this function + * completes, if it is not already. + */ @Override public boolean setChecked(boolean isChecked) { if (!SubscriptionManager.isUsableSubscriptionId(mSubId)) {