Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b55282a2 authored by Les Lee's avatar Les Lee Committed by Automerger Merge Worker
Browse files

Merge "wifi setting: Add psk length check" into tm-dev am: 4801983e

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/17130190

Change-Id: I4532d9a8b28012ac97ac60fdf8d0a21466003e9a
parents 2d9363ba 4801983e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ public class WifiUtils extends com.android.settingslib.wifi.WifiUtils {
    private static final int SSID_ASCII_MIN_LENGTH = 1;
    private static final int SSID_ASCII_MAX_LENGTH = 32;

    private static final int PSK_PASSPHRASE_ASCII_MIN_LENGTH = 8;
    private static final int PSK_PASSPHRASE_ASCII_MAX_LENGTH = 63;

    public static boolean isSSIDTooLong(String ssid) {
        if (TextUtils.isEmpty(ssid)) {
@@ -62,6 +64,13 @@ public class WifiUtils extends com.android.settingslib.wifi.WifiUtils {
    public static boolean isHotspotPasswordValid(String password, int securityType) {
        final SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder();
        try {
            if (securityType == SoftApConfiguration.SECURITY_TYPE_WPA2_PSK
                    || securityType == SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION) {
                if (password.length() < PSK_PASSPHRASE_ASCII_MIN_LENGTH
                        || password.length() > PSK_PASSPHRASE_ASCII_MAX_LENGTH) {
                    return false;
                }
            }
            configBuilder.setPassphrase(password, securityType);
        } catch (IllegalArgumentException e) {
            return false;