Search in sources :

Example 11 with SoftApConfiguration

use of android.net.wifi.SoftApConfiguration in project android_packages_apps_Settings by omnirom.

the class WifiTetherSecurityPreferenceControllerTest method updateDisplay_toWpa3SaeTransitionButNotSupportWpa3_shouldBeDefaultToWpa2.

@Test
public void updateDisplay_toWpa3SaeTransitionButNotSupportWpa3_shouldBeDefaultToWpa2() {
    mController.mIsWpa3Supported = false;
    SoftApConfiguration config = new SoftApConfiguration.Builder(mConfig).setPassphrase("test_password", SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION).build();
    when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
    mController.updateDisplay();
    assertThat(mController.getSecurityType()).isEqualTo(SoftApConfiguration.SECURITY_TYPE_WPA2_PSK);
    assertThat(mPreference.getSummary().toString()).isEqualTo("WPA2-Personal");
}
Also used : SoftApConfiguration(android.net.wifi.SoftApConfiguration) Test(org.junit.Test)

Example 12 with SoftApConfiguration

use of android.net.wifi.SoftApConfiguration in project android_packages_apps_Settings by omnirom.

the class WifiTetherSecurityPreferenceControllerTest method updateDisplay_toWpa3Sae_shouldUpdateSecurityValue.

@Test
public void updateDisplay_toWpa3Sae_shouldUpdateSecurityValue() {
    SoftApConfiguration config = new SoftApConfiguration.Builder(mConfig).setPassphrase("test_password", SoftApConfiguration.SECURITY_TYPE_WPA3_SAE).build();
    when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
    mController.updateDisplay();
    assertThat(mController.getSecurityType()).isEqualTo(SoftApConfiguration.SECURITY_TYPE_WPA3_SAE);
    assertThat(mPreference.getSummary().toString()).isEqualTo("WPA3-Personal");
}
Also used : SoftApConfiguration(android.net.wifi.SoftApConfiguration) Test(org.junit.Test)

Example 13 with SoftApConfiguration

use of android.net.wifi.SoftApConfiguration in project android_packages_apps_Settings by omnirom.

the class WifiTetherSecurityPreferenceControllerTest method updateDisplay_toWpa3SaeButNotSupportWpa3_shouldBeDefaultToWpa2.

@Test
public void updateDisplay_toWpa3SaeButNotSupportWpa3_shouldBeDefaultToWpa2() {
    mController.mIsWpa3Supported = false;
    SoftApConfiguration config = new SoftApConfiguration.Builder(mConfig).setPassphrase("test_password", SoftApConfiguration.SECURITY_TYPE_WPA3_SAE).build();
    when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
    mController.updateDisplay();
    assertThat(mController.getSecurityType()).isEqualTo(SoftApConfiguration.SECURITY_TYPE_WPA2_PSK);
    assertThat(mPreference.getSummary().toString()).isEqualTo("WPA2-Personal");
}
Also used : SoftApConfiguration(android.net.wifi.SoftApConfiguration) Test(org.junit.Test)

Example 14 with SoftApConfiguration

use of android.net.wifi.SoftApConfiguration in project android_packages_apps_Settings by omnirom.

the class WifiTetherSecurityPreferenceControllerTest method updateDisplay_toNone_shouldUpdateSecurityValue.

@Test
public void updateDisplay_toNone_shouldUpdateSecurityValue() {
    SoftApConfiguration config = new SoftApConfiguration.Builder(mConfig).setPassphrase(null, SoftApConfiguration.SECURITY_TYPE_OPEN).build();
    when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
    mController.updateDisplay();
    assertThat(mController.getSecurityType()).isEqualTo(SoftApConfiguration.SECURITY_TYPE_OPEN);
    assertThat(mPreference.getSummary().toString()).isEqualTo("None");
}
Also used : SoftApConfiguration(android.net.wifi.SoftApConfiguration) Test(org.junit.Test)

Example 15 with SoftApConfiguration

use of android.net.wifi.SoftApConfiguration in project android_packages_apps_Settings by omnirom.

the class WifiTetherApBandPreferenceController method updateDisplay.

@Override
public void updateDisplay() {
    final SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
    if (config == null) {
        mBandIndex = SoftApConfiguration.BAND_2GHZ;
        Log.d(TAG, "Updating band index to BAND_2GHZ because no config");
    } else if (is5GhzBandSupported()) {
        mBandIndex = validateSelection(config.getBand());
        Log.d(TAG, "Updating band index to " + mBandIndex);
    } else {
        mWifiManager.setSoftApConfiguration(new SoftApConfiguration.Builder(config).setBand(SoftApConfiguration.BAND_2GHZ).build());
        mBandIndex = SoftApConfiguration.BAND_2GHZ;
        Log.d(TAG, "5Ghz not supported, updating band index to 2GHz");
    }
    ListPreference preference = (ListPreference) mPreference;
    preference.setEntries(mBandSummaries);
    preference.setEntryValues(mBandEntries);
    if (!is5GhzBandSupported()) {
        preference.setEnabled(false);
        preference.setSummary(R.string.wifi_ap_choose_2G);
    } else {
        preference.setValue(Integer.toString(config.getBand()));
        preference.setSummary(getConfigSummary());
    }
}
Also used : SoftApConfiguration(android.net.wifi.SoftApConfiguration) ListPreference(androidx.preference.ListPreference)

Aggregations

SoftApConfiguration (android.net.wifi.SoftApConfiguration)28 Test (org.junit.Test)16 ValidatedEditTextPreference (com.android.settings.widget.ValidatedEditTextPreference)3 VisibleForTesting (androidx.annotation.VisibleForTesting)2 Intent (android.content.Intent)1 WifiManager (android.net.wifi.WifiManager)1 ListPreference (androidx.preference.ListPreference)1 PreferenceManager (androidx.preference.PreferenceManager)1 SwitchPreference (androidx.preference.SwitchPreference)1 ShadowWifiManager (com.android.settings.testutils.shadow.ShadowWifiManager)1 Before (org.junit.Before)1