Search in sources :

Example 6 with SoftApConfiguration

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

the class WifiTetherSSIDPreferenceControllerTest method displayPreference_hasCustomWifiConfig_shouldDisplayCustomSSID.

@Test
public void displayPreference_hasCustomWifiConfig_shouldDisplayCustomSSID() {
    final SoftApConfiguration config = new SoftApConfiguration.Builder().setSsid("test_1234").build();
    when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
    mController.displayPreference(mScreen);
    assertThat(mController.getSSID()).isEqualTo(config.getSsid());
}
Also used : SoftApConfiguration(android.net.wifi.SoftApConfiguration) Test(org.junit.Test)

Example 7 with SoftApConfiguration

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

the class WifiTetherSSIDPreferenceControllerTest method displayPreference_wifiApEnabled_shouldShowQrCodeIcon.

@Test
public void displayPreference_wifiApEnabled_shouldShowQrCodeIcon() {
    when(mWifiManager.isWifiApEnabled()).thenReturn(true);
    final SoftApConfiguration config = new SoftApConfiguration.Builder().setSsid("test_1234").setPassphrase("test_password", SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
    when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
    mController.displayPreference(mScreen);
    assertThat(mController.isQrCodeButtonAvailable()).isEqualTo(true);
}
Also used : SoftApConfiguration(android.net.wifi.SoftApConfiguration) Test(org.junit.Test)

Example 8 with SoftApConfiguration

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

the class AllInOneTetherSettings method onTetherConfigUpdated.

@Override
public void onTetherConfigUpdated(AbstractPreferenceController controller) {
    final SoftApConfiguration config = buildNewConfig();
    mPasswordPreferenceController.setSecurityType(config.getSecurityType());
    mWifiManager.setSoftApConfiguration(config);
    if (mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED) {
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "Wifi AP config changed while enabled, stop and restart");
        }
        mRestartWifiApAfterConfigChange = true;
        mTetherEnabler.stopTethering(TETHERING_WIFI);
    }
}
Also used : SoftApConfiguration(android.net.wifi.SoftApConfiguration)

Example 9 with SoftApConfiguration

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

the class WifiTetherMaximizeCompatibilityPreferenceController method isMaximizeCompatibilityEnabled.

@VisibleForTesting
boolean isMaximizeCompatibilityEnabled() {
    if (mWifiManager == null) {
        return false;
    }
    final SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
    if (config == null) {
        return false;
    }
    if (mWifiManager.isBridgedApConcurrencySupported()) {
        final boolean isEnabled = config.isBridgedModeOpportunisticShutdownEnabled();
        Log.d(TAG, "isBridgedModeOpportunisticShutdownEnabled:" + isEnabled);
        // Need to return the reverse value.
        return !isEnabled;
    }
    // If the BridgedAp Concurrency is not supported in early Pixel devices (e.g. Pixel 2~5),
    // show toggle on when band is 2.4G only.
    final int band = config.getBand();
    Log.d(TAG, "getBand:" + band);
    return band == SoftApConfiguration.BAND_2GHZ;
}
Also used : SoftApConfiguration(android.net.wifi.SoftApConfiguration) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 10 with SoftApConfiguration

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

the class WifiTetherAutoOffPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    SoftApConfiguration softApConfiguration = mWifiManager.getSoftApConfiguration();
    final boolean settingsOn = softApConfiguration.isAutoShutdownEnabled();
    ((SwitchPreference) preference).setChecked(settingsOn);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) SoftApConfiguration(android.net.wifi.SoftApConfiguration)

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