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

Commit fd2a781b authored by Hai Shalom's avatar Hai Shalom Committed by Android (Google) Code Review
Browse files

Merge "packages/apps/Settings: Add logic and strings to support WPA3 and OWE"

parents 92e8a5d8 f2f00313
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -215,10 +215,12 @@
    <string-array name="wifi_security">
        <!-- The Wi-Fi network does not have any security. -->
        <item>@string/wifi_security_none</item>
        <item translatable="false">@string/wifi_security_owe</item>
        <item translatable="false">@string/wifi_security_wep</item>
        <item translatable="false">@string/wifi_security_psk_generic</item>
        <item translatable="false">@string/wifi_security_sae</item>
        <item translatable="false">@string/wifi_security_eap</item>

        <item translatable="false">@string/wifi_security_eap_suiteb</item>
    </string-array>

    <!-- Match this with the constants in AccessPoint. --> <skip />
@@ -228,6 +230,7 @@
        <item>@string/wifi_security_none</item>
        <item translatable="false">@string/wifi_security_wep</item>
        <item translatable="false">@string/wifi_security_psk_generic</item>
        <item translatable="false">@string/wifi_security_sae</item>
    </string-array>

    <!-- Security types for wireless tether -->
+44 −5
Original line number Diff line number Diff line
@@ -454,6 +454,13 @@ public class WifiConfigController implements TextWatcher,
        return false;
    }

    boolean isValidSaePassword(String password) {
        if (password.length() >= 1 && password.length() <= 63) {
            return true;
        }
        return false;
    }

    boolean isSubmittable() {
        boolean enabled = false;
        boolean passwordInvalid = false;
@@ -461,7 +468,9 @@ public class WifiConfigController implements TextWatcher,
                && ((mAccessPointSecurity == AccessPoint.SECURITY_WEP
                        && mPasswordView.length() == 0)
                    || (mAccessPointSecurity == AccessPoint.SECURITY_PSK
                           && !isValidPsk(mPasswordView.getText().toString())))) {
                           && !isValidPsk(mPasswordView.getText().toString()))
                    || (mAccessPointSecurity == AccessPoint.SECURITY_SAE
                        && !isValidSaePassword(mPasswordView.getText().toString())))) {
            passwordInvalid = true;
        }
        if ((mSsidView != null && mSsidView.length() == 0)
@@ -475,7 +484,9 @@ public class WifiConfigController implements TextWatcher,
        } else {
            enabled = ipAndProxyFieldsAreValid();
        }
        if (mAccessPointSecurity == AccessPoint.SECURITY_EAP && mEapCaCertSpinner != null
        if ((mAccessPointSecurity == AccessPoint.SECURITY_EAP ||
                mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B)
                && mEapCaCertSpinner != null
                && mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
            String caCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
            if (caCertSelection.equals(mUnspecifiedCertString)) {
@@ -492,7 +503,9 @@ public class WifiConfigController implements TextWatcher,
                enabled = false;
            }
        }
        if (mAccessPointSecurity == AccessPoint.SECURITY_EAP && mEapUserCertSpinner != null
        if ((mAccessPointSecurity == AccessPoint.SECURITY_EAP ||
                mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B)
                && mEapUserCertSpinner != null
                && mView.findViewById(R.id.l_user_cert).getVisibility() != View.GONE
                && mEapUserCertSpinner.getSelectedItem().equals(mUnspecifiedCertString)) {
            // Disallow submit if the user has not selected a user certificate for an EAP network
@@ -590,8 +603,18 @@ public class WifiConfigController implements TextWatcher,
                break;

            case AccessPoint.SECURITY_EAP:
            case AccessPoint.SECURITY_EAP_SUITE_B:
                config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
                config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
                if (mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B) {
                    config.allowedKeyManagement.set(KeyMgmt.SUITE_B_192);
                    config.requirePMF = true;
                    config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.GCMP_256);
                    config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
                    config.allowedGroupMgmtCiphers.set(WifiConfiguration.GroupMgmtCipher
                            .BIP_GMAC_256);
                    config.allowedSuiteBCiphers.set(WifiConfiguration.SuiteBCipher.ECDHE_RSA);
                }
                config.enterpriseConfig = new WifiEnterpriseConfig();
                int eapMethod = mEapMethodSpinner.getSelectedItemPosition();
                int phase2Method = mPhase2Spinner.getSelectedItemPosition();
@@ -700,6 +723,20 @@ public class WifiConfigController implements TextWatcher,
                    config.enterpriseConfig.setPassword(mPasswordView.getText().toString());
                }
                break;
            case AccessPoint.SECURITY_SAE:
                config.allowedKeyManagement.set(KeyMgmt.SAE);
                config.requirePMF = true;
                if (mPasswordView.length() != 0) {
                    String password = mPasswordView.getText().toString();
                    config.preSharedKey = '"' + password + '"';
                }
                break;

            case AccessPoint.SECURITY_OWE:
                config.allowedKeyManagement.set(KeyMgmt.OWE);
                config.requirePMF = true;
                break;

            default:
                return null;
        }
@@ -851,7 +888,8 @@ public class WifiConfigController implements TextWatcher,
    }

    private void showSecurityFields() {
        if (mAccessPointSecurity == AccessPoint.SECURITY_NONE) {
        if (mAccessPointSecurity == AccessPoint.SECURITY_NONE ||
                  mAccessPointSecurity == AccessPoint.SECURITY_OWE) {
            mView.findViewById(R.id.security_fields).setVisibility(View.GONE);
            return;
        }
@@ -870,7 +908,8 @@ public class WifiConfigController implements TextWatcher,
            }
        }

        if (mAccessPointSecurity != AccessPoint.SECURITY_EAP) {
        if (mAccessPointSecurity != AccessPoint.SECURITY_EAP &&
                mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B) {
            mView.findViewById(R.id.eap).setVisibility(View.GONE);
            return;
        }
+8 −4
Original line number Diff line number Diff line
@@ -488,7 +488,8 @@ public class WifiSettings extends RestrictedSettingsFragment
                menu.add(Menu.NONE, MENU_ID_MODIFY, 0, R.string.wifi_menu_modify);
                NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
                if (nfcAdapter != null && nfcAdapter.isEnabled() &&
                        mSelectedAccessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
                        (!(mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_NONE) ||
                                (mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_OWE))) {
                    // Only allow writing of NFC tags for password-protected networks.
                    menu.add(Menu.NONE, MENU_ID_WRITE_NFC, 0, R.string.wifi_menu_write_to_nfc);
                }
@@ -506,7 +507,8 @@ public class WifiSettings extends RestrictedSettingsFragment
                boolean isSavedNetwork = mSelectedAccessPoint.isSaved();
                if (isSavedNetwork) {
                    connect(mSelectedAccessPoint.getConfig(), isSavedNetwork);
                } else if (mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_NONE) {
                } else if ((mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_NONE) ||
                        (mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_OWE)) {
                    /** Bypass dialog for unsecured networks */
                    mSelectedAccessPoint.generateOpenNetworkConfig();
                    connect(mSelectedAccessPoint.getConfig(), isSavedNetwork);
@@ -552,7 +554,8 @@ public class WifiSettings extends RestrictedSettingsFragment
             * networks, or Passpoint provided networks.
             */
            WifiConfiguration config = mSelectedAccessPoint.getConfig();
            if (mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_NONE) {
            if ((mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_NONE) ||
                    (mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_OWE)) {
                mSelectedAccessPoint.generateOpenNetworkConfig();
                connect(mSelectedAccessPoint.getConfig(), mSelectedAccessPoint.isSaved());
            } else if (mSelectedAccessPoint.isSaved() && config != null
@@ -772,7 +775,8 @@ public class WifiSettings extends RestrictedSettingsFragment
                preference.setKey(key);
                preference.setOrder(index);
                if (mOpenSsid != null && mOpenSsid.equals(accessPoint.getSsidStr())
                        && accessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
                        && (accessPoint.getSecurity() != AccessPoint.SECURITY_NONE &&
                        accessPoint.getSecurity() != AccessPoint.SECURITY_OWE)) {
                    if (!accessPoint.isSaved() || isDisabledByWrongPassword(accessPoint)) {
                        onPreferenceTreeClick(preference);
                        mOpenSsid = null;
+5 −5
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public class WifiTetherSecurityPreferenceControllerTest {
    public void onPreferenceChange_securityValueUpdated() {
        mController.onPreferenceChange(mPreference, WPA2_PSK);
        assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
        assertThat(mPreference.getSummary()).isEqualTo("WPA2 PSK");
        assertThat(mPreference.getSummary()).isEqualTo("WPA2-Personal");

        mController.onPreferenceChange(mPreference, NONE);
        assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.NONE);
@@ -75,11 +75,11 @@ public class WifiTetherSecurityPreferenceControllerTest {

    @Test
    public void updateDisplay_preferenceUpdated() {
        // test defaulting to WPA2 PSK on new config
        // test defaulting to WPA2-Personal on new config
        when(mWifiManager.getWifiApConfiguration()).thenReturn(null);
        mController.updateDisplay();
        assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
        assertThat(mPreference.getSummary()).isEqualTo("WPA2 PSK");
        assertThat(mPreference.getSummary()).isEqualTo("WPA2-Personal");

        // test open tether network
        when(mWifiManager.getWifiApConfiguration()).thenReturn(mConfig);
@@ -89,11 +89,11 @@ public class WifiTetherSecurityPreferenceControllerTest {
        assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.NONE);
        assertThat(mPreference.getSummary()).isEqualTo("None");

        // test WPA2 PSK tether network
        // test WPA2-Personal tether network
        mConfig.allowedKeyManagement.clear();
        mConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA2_PSK);
        mController.updateDisplay();
        assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
        assertThat(mPreference.getSummary()).isEqualTo("WPA2 PSK");
        assertThat(mPreference.getSummary()).isEqualTo("WPA2-Personal");
    }
}