diff --git a/res/values/strings.xml b/res/values/strings.xml index 0494e0458fd..a2a36995558 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -11086,10 +11086,10 @@ %1$s requires 2G to be available - - Allow less secure connection - - May improve your signal in some locations. For emergency calls, less secure connections are always allowed. + + Require encryption + + Encryption is more secure, but you might not be able to connect in some locations. For emergency calls, encryption is never required All services diff --git a/res/xml/mobile_network_settings.xml b/res/xml/mobile_network_settings.xml index 169356b9e03..3e3e545f59c 100644 --- a/res/xml/mobile_network_settings.xml +++ b/res/xml/mobile_network_settings.xml @@ -251,9 +251,9 @@ settings:userRestriction="no_cellular_2g"/> diff --git a/src/com/android/settings/network/telephony/NullAlgorithmsPreferenceController.java b/src/com/android/settings/network/telephony/NullAlgorithmsPreferenceController.java index cfb5344bd54..be5b01ee83b 100644 --- a/src/com/android/settings/network/telephony/NullAlgorithmsPreferenceController.java +++ b/src/com/android/settings/network/telephony/NullAlgorithmsPreferenceController.java @@ -21,9 +21,9 @@ import android.telephony.TelephonyManager; import android.util.Log; /** - * Preference controller for "Allow Null Algorithms" + * Preference controller for "Require Encryption" * - *

This preference controller is toggling null algorithms is not a per-sim operation. + *

This preference controller is toggling null algorithms. This applies to all active SIMs. */ public class NullAlgorithmsPreferenceController extends TelephonyTogglePreferenceController { @@ -33,7 +33,7 @@ public class NullAlgorithmsPreferenceController extends TelephonyTogglePreferenc private TelephonyManager mTelephonyManager; /** - * Class constructor of "Allow Null Algorithms" toggle. + * Class constructor of "Require Encryption" toggle. * * @param context of settings * @param key assigned within UI entry of XML file @@ -81,7 +81,7 @@ public class NullAlgorithmsPreferenceController extends TelephonyTogglePreferenc } /** - * Return {@code true} if null algorithms are currently allowed. + * Return {@code true} if encryption is required (null algorithms not allowed) * *

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 @@ -90,7 +90,7 @@ public class NullAlgorithmsPreferenceController extends TelephonyTogglePreferenc @Override public boolean isChecked() { try { - return mTelephonyManager.isNullCipherAndIntegrityPreferenceEnabled(); + return !mTelephonyManager.isNullCipherAndIntegrityPreferenceEnabled(); } catch (Exception e) { Log.e(LOG_TAG, "Failed isNullCipherAndIntegrityEnabled. Defaulting toggle to " @@ -109,24 +109,22 @@ public class NullAlgorithmsPreferenceController extends TelephonyTogglePreferenc * details. * * @param isChecked The toggle value that we're being requested to enforce. A value of {@code - * false} denotes that null ciphers will be disabled by the modem after this - * function - * completes, if it is not already. + * true} denotes that null ciphers will be disabled by the modem after this + * function completes, if it is not already. */ @Override public boolean setChecked(boolean isChecked) { if (isChecked) { - Log.i(LOG_TAG, "Enabling null algorithms"); + Log.i(LOG_TAG, "Encryption required. Disabling null algorithms."); } else { - Log.i(LOG_TAG, "Disabling null algorithms"); + Log.i(LOG_TAG, "Encryption not required. Enabling null algorithms."); } try { - mTelephonyManager.setNullCipherAndIntegrityEnabled(isChecked); + mTelephonyManager.setNullCipherAndIntegrityEnabled(!isChecked); } catch (Exception e) { Log.e(LOG_TAG, "Failed setNullCipherAndIntegrityEnabled. Setting not updated. Exception: " + e.getMessage()); - // The underlying setting was not updated return false; } return true; diff --git a/tests/unit/src/com/android/settings/network/telephony/NullAlgorithmsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/NullAlgorithmsPreferenceControllerTest.java index 99d0a43562f..87907e0d0a2 100644 --- a/tests/unit/src/com/android/settings/network/telephony/NullAlgorithmsPreferenceControllerTest.java +++ b/tests/unit/src/com/android/settings/network/telephony/NullAlgorithmsPreferenceControllerTest.java @@ -142,22 +142,22 @@ public final class NullAlgorithmsPreferenceControllerTest { } @Test - public void setChecked_true() { + public void setChecked_true_nullCiphersDisabled() { mController.setChecked(true); - verify(mTelephonyManager, times(1)).setNullCipherAndIntegrityEnabled(true); + verify(mTelephonyManager, times(1)).setNullCipherAndIntegrityEnabled(false); } @Test - public void setChecked_false() { + public void setChecked_false_nullCiphersEnabled() { mController.setChecked(false); - verify(mTelephonyManager, times(1)).setNullCipherAndIntegrityEnabled(false); + verify(mTelephonyManager, times(1)).setNullCipherAndIntegrityEnabled(true); } @Test public void setChecked_exceptionThrown() { doThrow(IllegalStateException.class).when( mTelephonyManager).setNullCipherAndIntegrityEnabled(true); - assertFalse(mController.setChecked(true)); + assertFalse(mController.setChecked(false)); verify(mTelephonyManager, times(1)).setNullCipherAndIntegrityEnabled(true); } }