Loading src/com/android/settings/wifi/tether/WifiTetherSettings.java +13 −10 Original line number Diff line number Diff line Loading @@ -84,8 +84,10 @@ public class WifiTetherSettings extends RestrictedDashboardFragment WifiTetherSSIDPreferenceController mSSIDPreferenceController; @VisibleForTesting WifiTetherPasswordPreferenceController mPasswordPreferenceController; private WifiTetherSecurityPreferenceController mSecurityPreferenceController; private WifiTetherMaximizeCompatibilityPreferenceController mMaxCompatibilityPrefController; @VisibleForTesting WifiTetherSecurityPreferenceController mSecurityPreferenceController; @VisibleForTesting WifiTetherMaximizeCompatibilityPreferenceController mMaxCompatibilityPrefController; @VisibleForTesting WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController; Loading Loading @@ -276,15 +278,16 @@ public class WifiTetherSettings extends RestrictedDashboardFragment SoftApConfiguration buildNewConfig() { SoftApConfiguration currentConfig = mWifiTetherViewModel.getSoftApConfiguration(); SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder(currentConfig); int securityType = (mWifiTetherViewModel.isSpeedFeatureAvailable()) configBuilder.setSsid(mSSIDPreferenceController.getSSID()); int securityType = mWifiTetherViewModel.isSpeedFeatureAvailable() ? currentConfig.getSecurityType() : mSecurityPreferenceController.getSecurityType(); configBuilder.setSsid(mSSIDPreferenceController.getSSID()); if (securityType != SoftApConfiguration.SECURITY_TYPE_OPEN) { configBuilder.setPassphrase( mPasswordPreferenceController.getPasswordValidated(securityType), securityType); } String passphrase = securityType == SoftApConfiguration.SECURITY_TYPE_OPEN ? null : mPasswordPreferenceController.getPasswordValidated(securityType); configBuilder.setPassphrase(passphrase, securityType); if (!mWifiTetherViewModel.isSpeedFeatureAvailable()) { mMaxCompatibilityPrefController.setupMaximizeCompatibility(configBuilder); } Loading tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.settings.wifi.tether; import static android.net.wifi.SoftApConfiguration.SECURITY_TYPE_OPEN; import static android.net.wifi.SoftApConfiguration.SECURITY_TYPE_WPA3_SAE; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; Loading Loading @@ -125,9 +126,13 @@ public class WifiTetherSettingsTest { @Mock private WifiTetherSSIDPreferenceController mSSIDPreferenceController; @Mock private WifiTetherSecurityPreferenceController mSecurityPreferenceController; @Mock private WifiTetherPasswordPreferenceController mPasswordPreferenceController; @Mock private WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController; @Mock private WifiTetherMaximizeCompatibilityPreferenceController mMaxCompatibilityPrefController; private WifiTetherSettings mSettings; Loading Loading @@ -156,10 +161,13 @@ public class WifiTetherSettingsTest { mSettings.mMainSwitchBar = mMainSwitchBar; mSettings.mSSIDPreferenceController = mSSIDPreferenceController; when(mSSIDPreferenceController.getSSID()).thenReturn(SSID); mSettings.mSecurityPreferenceController = mSecurityPreferenceController; when(mSecurityPreferenceController.getSecurityType()).thenReturn(SECURITY_TYPE_WPA3_SAE); mSettings.mPasswordPreferenceController = mPasswordPreferenceController; when(mPasswordPreferenceController.getPasswordValidated(anyInt())).thenReturn(PASSWORD); mSettings.mWifiTetherAutoOffPreferenceController = mWifiTetherAutoOffPreferenceController; when(mWifiTetherAutoOffPreferenceController.isEnabled()).thenReturn(true); mSettings.mMaxCompatibilityPrefController = mMaxCompatibilityPrefController; mSettings.mWifiTetherViewModel = mWifiTetherViewModel; when(mSettings.findPreference(KEY_WIFI_HOTSPOT_SECURITY)).thenReturn(mWifiHotspotSecurity); when(mSettings.findPreference(KEY_WIFI_HOTSPOT_SPEED)).thenReturn(mWifiHotspotSpeed); Loading Loading @@ -359,6 +367,23 @@ public class WifiTetherSettingsTest { assertThat(newConfig.getBand()).isEqualTo(currentConfig.getBand()); } @Test public void buildNewConfig_securityTypeChangeToOpen_setSecurityTypeCorrectly() { SoftApConfiguration currentConfig = new SoftApConfiguration.Builder() .setPassphrase(PASSWORD, SECURITY_TYPE_WPA3_SAE) .setBand(BAND_2GHZ_5GHZ_6GHZ) .build(); when(mWifiTetherViewModel.getSoftApConfiguration()).thenReturn(currentConfig); when(mWifiTetherViewModel.isSpeedFeatureAvailable()).thenReturn(false); doNothing().when(mMaxCompatibilityPrefController) .setupMaximizeCompatibility(any(SoftApConfiguration.Builder.class)); when(mSecurityPreferenceController.getSecurityType()).thenReturn(SECURITY_TYPE_OPEN); SoftApConfiguration newConfig = mSettings.buildNewConfig(); assertThat(newConfig.getSecurityType()).isEqualTo(SECURITY_TYPE_OPEN); } @Test public void onRestartingChanged_restartingFalse_setLoadingFalse() { doNothing().when(mSettings).setLoading(anyBoolean(), anyBoolean()); Loading Loading
src/com/android/settings/wifi/tether/WifiTetherSettings.java +13 −10 Original line number Diff line number Diff line Loading @@ -84,8 +84,10 @@ public class WifiTetherSettings extends RestrictedDashboardFragment WifiTetherSSIDPreferenceController mSSIDPreferenceController; @VisibleForTesting WifiTetherPasswordPreferenceController mPasswordPreferenceController; private WifiTetherSecurityPreferenceController mSecurityPreferenceController; private WifiTetherMaximizeCompatibilityPreferenceController mMaxCompatibilityPrefController; @VisibleForTesting WifiTetherSecurityPreferenceController mSecurityPreferenceController; @VisibleForTesting WifiTetherMaximizeCompatibilityPreferenceController mMaxCompatibilityPrefController; @VisibleForTesting WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController; Loading Loading @@ -276,15 +278,16 @@ public class WifiTetherSettings extends RestrictedDashboardFragment SoftApConfiguration buildNewConfig() { SoftApConfiguration currentConfig = mWifiTetherViewModel.getSoftApConfiguration(); SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder(currentConfig); int securityType = (mWifiTetherViewModel.isSpeedFeatureAvailable()) configBuilder.setSsid(mSSIDPreferenceController.getSSID()); int securityType = mWifiTetherViewModel.isSpeedFeatureAvailable() ? currentConfig.getSecurityType() : mSecurityPreferenceController.getSecurityType(); configBuilder.setSsid(mSSIDPreferenceController.getSSID()); if (securityType != SoftApConfiguration.SECURITY_TYPE_OPEN) { configBuilder.setPassphrase( mPasswordPreferenceController.getPasswordValidated(securityType), securityType); } String passphrase = securityType == SoftApConfiguration.SECURITY_TYPE_OPEN ? null : mPasswordPreferenceController.getPasswordValidated(securityType); configBuilder.setPassphrase(passphrase, securityType); if (!mWifiTetherViewModel.isSpeedFeatureAvailable()) { mMaxCompatibilityPrefController.setupMaximizeCompatibility(configBuilder); } Loading
tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.settings.wifi.tether; import static android.net.wifi.SoftApConfiguration.SECURITY_TYPE_OPEN; import static android.net.wifi.SoftApConfiguration.SECURITY_TYPE_WPA3_SAE; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; Loading Loading @@ -125,9 +126,13 @@ public class WifiTetherSettingsTest { @Mock private WifiTetherSSIDPreferenceController mSSIDPreferenceController; @Mock private WifiTetherSecurityPreferenceController mSecurityPreferenceController; @Mock private WifiTetherPasswordPreferenceController mPasswordPreferenceController; @Mock private WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController; @Mock private WifiTetherMaximizeCompatibilityPreferenceController mMaxCompatibilityPrefController; private WifiTetherSettings mSettings; Loading Loading @@ -156,10 +161,13 @@ public class WifiTetherSettingsTest { mSettings.mMainSwitchBar = mMainSwitchBar; mSettings.mSSIDPreferenceController = mSSIDPreferenceController; when(mSSIDPreferenceController.getSSID()).thenReturn(SSID); mSettings.mSecurityPreferenceController = mSecurityPreferenceController; when(mSecurityPreferenceController.getSecurityType()).thenReturn(SECURITY_TYPE_WPA3_SAE); mSettings.mPasswordPreferenceController = mPasswordPreferenceController; when(mPasswordPreferenceController.getPasswordValidated(anyInt())).thenReturn(PASSWORD); mSettings.mWifiTetherAutoOffPreferenceController = mWifiTetherAutoOffPreferenceController; when(mWifiTetherAutoOffPreferenceController.isEnabled()).thenReturn(true); mSettings.mMaxCompatibilityPrefController = mMaxCompatibilityPrefController; mSettings.mWifiTetherViewModel = mWifiTetherViewModel; when(mSettings.findPreference(KEY_WIFI_HOTSPOT_SECURITY)).thenReturn(mWifiHotspotSecurity); when(mSettings.findPreference(KEY_WIFI_HOTSPOT_SPEED)).thenReturn(mWifiHotspotSpeed); Loading Loading @@ -359,6 +367,23 @@ public class WifiTetherSettingsTest { assertThat(newConfig.getBand()).isEqualTo(currentConfig.getBand()); } @Test public void buildNewConfig_securityTypeChangeToOpen_setSecurityTypeCorrectly() { SoftApConfiguration currentConfig = new SoftApConfiguration.Builder() .setPassphrase(PASSWORD, SECURITY_TYPE_WPA3_SAE) .setBand(BAND_2GHZ_5GHZ_6GHZ) .build(); when(mWifiTetherViewModel.getSoftApConfiguration()).thenReturn(currentConfig); when(mWifiTetherViewModel.isSpeedFeatureAvailable()).thenReturn(false); doNothing().when(mMaxCompatibilityPrefController) .setupMaximizeCompatibility(any(SoftApConfiguration.Builder.class)); when(mSecurityPreferenceController.getSecurityType()).thenReturn(SECURITY_TYPE_OPEN); SoftApConfiguration newConfig = mSettings.buildNewConfig(); assertThat(newConfig.getSecurityType()).isEqualTo(SECURITY_TYPE_OPEN); } @Test public void onRestartingChanged_restartingFalse_setLoadingFalse() { doNothing().when(mSettings).setLoading(anyBoolean(), anyBoolean()); Loading