Updated the 2G enable setting title.

Bug:391709444
Test: atest Enable2gPreferenceControllerTest
Flag: EXEMPT bugfix

Change-Id: I66bd05441e29b4976343d145ebecaf11fa924b0c
This commit is contained in:
talreja
2025-02-03 19:37:19 +00:00
committed by Amit Talreja (xWF)
parent a0e0065766
commit 868299303e
3 changed files with 18 additions and 18 deletions

View File

@@ -173,7 +173,7 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
}
/**
* Return {@code true} if 2g is currently enabled.
* Return {@code true} if only 3G and higher is currently enabled.
*
* <p><b>NOTE:</b> 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
@@ -181,12 +181,12 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
*/
@Override
public boolean isChecked() {
// If an enterprise admin has disabled 2g, we show the toggle as not checked to avoid
// user confusion of seeing a checked toggle, but having 2g actually disabled.
// If an enterprise admin has disabled 2g, we show the toggle as checked to avoid
// user confusion of seeing a unchecked toggle, but having 3G and higher actually enable.
// The RestrictedSwitchPreference will take care of transparently informing the user that
// the setting was disabled by their admin
if (isDisabledByAdmin()) {
return false;
return true;
}
if (mTelephonyManager == null) {
@@ -195,7 +195,7 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
}
long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason(
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G);
return (currentlyAllowedNetworkTypes & BITMASK_2G) != 0;
return (currentlyAllowedNetworkTypes & BITMASK_2G) == 0;
}
/**
@@ -206,7 +206,7 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
* 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
* true} denotes that 2g will be disabled by the modem after this function
* completes, if it is not already.
*/
@Override
@@ -227,21 +227,21 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason(
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G);
boolean enabled = (currentlyAllowedNetworkTypes & BITMASK_2G) != 0;
if (enabled == isChecked) {
if (enabled != isChecked) {
return false;
}
long newAllowedNetworkTypes = currentlyAllowedNetworkTypes;
if (isChecked) {
newAllowedNetworkTypes = currentlyAllowedNetworkTypes | BITMASK_2G;
Log.i(LOG_TAG, "Enabling 2g. Allowed network types: " + newAllowedNetworkTypes);
} else {
newAllowedNetworkTypes = currentlyAllowedNetworkTypes & ~BITMASK_2G;
Log.i(LOG_TAG, "Disabling 2g. Allowed network types: " + newAllowedNetworkTypes);
} else {
newAllowedNetworkTypes = currentlyAllowedNetworkTypes | BITMASK_2G;
Log.i(LOG_TAG, "Enabling 2g. Allowed network types: " + newAllowedNetworkTypes);
}
mTelephonyManager.setAllowedNetworkTypesForReason(
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G, newAllowedNetworkTypes);
mMetricsFeatureProvider.action(
mContext, SettingsEnums.ACTION_2G_ENABLED, isChecked);
mContext, SettingsEnums.ACTION_2G_ENABLED, !isChecked);
return true;
}