Updated the 2G enable setting title.
Bug:391709444 Test: atest Enable2gPreferenceControllerTest Flag: EXEMPT bugfix Change-Id: I66bd05441e29b4976343d145ebecaf11fa924b0c
This commit is contained in:
committed by
Amit Talreja (xWF)
parent
a0e0065766
commit
868299303e
@@ -13587,9 +13587,9 @@ Data usage charges may apply.</string>
|
|||||||
<string name="smart_forwarding_missing_alert_dialog_text">OK</string>
|
<string name="smart_forwarding_missing_alert_dialog_text">OK</string>
|
||||||
|
|
||||||
<!-- Title for toggle if user wants to enable 2G [CHAR LIMIT=40] -->
|
<!-- Title for toggle if user wants to enable 2G [CHAR LIMIT=40] -->
|
||||||
<string name="enable_2g_title">Allow 2G</string>
|
<string name="enable_2g_title">2G network protection</string>
|
||||||
<!-- Title for toggle if user wants to enable 2G [CHAR LIMIT=NONE] -->
|
<!-- Title for toggle if user wants to enable 2G [CHAR LIMIT=NONE] -->
|
||||||
<string name="enable_2g_summary">2G is less secure, but may improve your connection in some locations. For emergency calls, 2G is always allowed.</string>
|
<string name="enable_2g_summary">Avoids 2G networks, which are less secure. This may limit connectivity in some places. Emergency calling is always allowed.</string>
|
||||||
<!-- Title for if toggle access is disabled by carrier [CHAR LIMIT=NONE] -->
|
<!-- Title for if toggle access is disabled by carrier [CHAR LIMIT=NONE] -->
|
||||||
<string name="enable_2g_summary_disabled_carrier"><xliff:g id="carrier_name_2g" example="Google Fi">%1$s</xliff:g> requires 2G to be available</string>
|
<string name="enable_2g_summary_disabled_carrier"><xliff:g id="carrier_name_2g" example="Google Fi">%1$s</xliff:g> requires 2G to be available</string>
|
||||||
|
|
||||||
|
@@ -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
|
* <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
|
* the parameter passed into {@link #setChecked(boolean)}, which is instead the requested future
|
||||||
@@ -181,12 +181,12 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
// If an enterprise admin has disabled 2g, we show the toggle as not checked to avoid
|
// If an enterprise admin has disabled 2g, we show the toggle as checked to avoid
|
||||||
// user confusion of seeing a checked toggle, but having 2g actually disabled.
|
// 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 RestrictedSwitchPreference will take care of transparently informing the user that
|
||||||
// the setting was disabled by their admin
|
// the setting was disabled by their admin
|
||||||
if (isDisabledByAdmin()) {
|
if (isDisabledByAdmin()) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTelephonyManager == null) {
|
if (mTelephonyManager == null) {
|
||||||
@@ -195,7 +195,7 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
|||||||
}
|
}
|
||||||
long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason(
|
long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason(
|
||||||
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G);
|
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.
|
* details.
|
||||||
*
|
*
|
||||||
* @param isChecked The toggle value that we're being requested to enforce. A value of {@code
|
* @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.
|
* completes, if it is not already.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -227,21 +227,21 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
|||||||
long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason(
|
long currentlyAllowedNetworkTypes = mTelephonyManager.getAllowedNetworkTypesForReason(
|
||||||
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G);
|
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G);
|
||||||
boolean enabled = (currentlyAllowedNetworkTypes & BITMASK_2G) != 0;
|
boolean enabled = (currentlyAllowedNetworkTypes & BITMASK_2G) != 0;
|
||||||
if (enabled == isChecked) {
|
if (enabled != isChecked) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
long newAllowedNetworkTypes = currentlyAllowedNetworkTypes;
|
long newAllowedNetworkTypes = currentlyAllowedNetworkTypes;
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
newAllowedNetworkTypes = currentlyAllowedNetworkTypes | BITMASK_2G;
|
|
||||||
Log.i(LOG_TAG, "Enabling 2g. Allowed network types: " + newAllowedNetworkTypes);
|
|
||||||
} else {
|
|
||||||
newAllowedNetworkTypes = currentlyAllowedNetworkTypes & ~BITMASK_2G;
|
newAllowedNetworkTypes = currentlyAllowedNetworkTypes & ~BITMASK_2G;
|
||||||
Log.i(LOG_TAG, "Disabling 2g. Allowed network types: " + newAllowedNetworkTypes);
|
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.setAllowedNetworkTypesForReason(
|
||||||
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G, newAllowedNetworkTypes);
|
mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G, newAllowedNetworkTypes);
|
||||||
mMetricsFeatureProvider.action(
|
mMetricsFeatureProvider.action(
|
||||||
mContext, SettingsEnums.ACTION_2G_ENABLED, isChecked);
|
mContext, SettingsEnums.ACTION_2G_ENABLED, !isChecked);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -147,7 +147,7 @@ public final class Enable2gPreferenceControllerTest {
|
|||||||
when2gIsEnabledForReasonEnable2g();
|
when2gIsEnabledForReasonEnable2g();
|
||||||
|
|
||||||
// Disable 2G
|
// Disable 2G
|
||||||
boolean changed = mController.setChecked(false);
|
boolean changed = mController.setChecked(true);
|
||||||
assertThat(changed).isEqualTo(true);
|
assertThat(changed).isEqualTo(true);
|
||||||
|
|
||||||
verify(mTelephonyManager, times(1)).setAllowedNetworkTypesForReason(
|
verify(mTelephonyManager, times(1)).setAllowedNetworkTypesForReason(
|
||||||
@@ -159,7 +159,7 @@ public final class Enable2gPreferenceControllerTest {
|
|||||||
public void disabledByAdmin_toggleUnchecked() {
|
public void disabledByAdmin_toggleUnchecked() {
|
||||||
when2gIsEnabledForReasonEnable2g();
|
when2gIsEnabledForReasonEnable2g();
|
||||||
when2gIsDisabledByAdmin(true);
|
when2gIsDisabledByAdmin(true);
|
||||||
assertThat(mController.isChecked()).isFalse();
|
assertThat(mController.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -167,15 +167,15 @@ public final class Enable2gPreferenceControllerTest {
|
|||||||
// Initially, 2g is enabled
|
// Initially, 2g is enabled
|
||||||
when2gIsEnabledForReasonEnable2g();
|
when2gIsEnabledForReasonEnable2g();
|
||||||
when2gIsDisabledByAdmin(false);
|
when2gIsDisabledByAdmin(false);
|
||||||
assertThat(mController.isChecked()).isTrue();
|
assertThat(mController.isChecked()).isFalse();
|
||||||
|
|
||||||
// When we disable the preference by an admin, the preference should be unchecked
|
// When we disable the preference by an admin, the preference should be unchecked
|
||||||
when2gIsDisabledByAdmin(true);
|
when2gIsDisabledByAdmin(true);
|
||||||
assertThat(mController.isChecked()).isFalse();
|
assertThat(mController.isChecked()).isTrue();
|
||||||
|
|
||||||
// If the preference is re-enabled by an admin, former state should hold
|
// If the preference is re-enabled by an admin, former state should hold
|
||||||
when2gIsDisabledByAdmin(false);
|
when2gIsDisabledByAdmin(false);
|
||||||
assertThat(mController.isChecked()).isTrue();
|
assertThat(mController.isChecked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user