summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorlesl <lesl@google.com>2020-06-22 12:51:42 +0800
committerlesl <lesl@google.com>2020-06-23 16:17:20 +0800
commitdfdf77373982a9b3da32784b3705ef713f4fd2c8 (patch)
tree10aef3f8f3fd6d83383f9579d5327413a95c1c17 /tests
parent6ea82ec26afa0d8b72ccc84b9d644c1e539fd5d5 (diff)
wifi: Use overlay to control reset SAP configration during restoring
The AOSP setting(UI) doesn't support several SAP configration. ex: Channel selection, hidden network option, autoShutDown timer selection etc... Once those UI depends features config are restored from cloud. It will causes User use wrong config and it can't modify anymore. Bug: 159572880 Bug: 159325231 Test: atest FrameworksWifiTests Change-Id: I7a6bf855fbb08a4808af5f166e5354f4bf67e4cd
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java94
1 files changed, 81 insertions, 13 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
index bc646c1eb..d19a4f002 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
@@ -659,24 +659,92 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
@Test
public void testResetToDefaultForUnsupportedConfig() throws Exception {
- mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, false);
- mResources.setBoolean(R.bool.config_wifi_softap_sae_supported, false);
- mResources.setBoolean(R.bool.config_wifiSoftapResetChannelConfig, true);
- SoftApConfiguration sae_config = new SoftApConfiguration.Builder()
- .setPassphrase("secretsecret", SoftApConfiguration.SECURITY_TYPE_WPA3_SAE)
- .setMaxNumberOfClients(10)
- .setClientControlByUserEnabled(true)
- .setChannel(149, SoftApConfiguration.BAND_5GHZ)
- .build();
+ mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, true);
+ mResources.setBoolean(R.bool.config_wifi_softap_sae_supported, true);
+ mResources.setBoolean(R.bool.config_wifi6ghzSupport, true);
+ mResources.setBoolean(R.bool.config_wifi5ghzSupport, true);
+
+ // Test all of the features support and all of the reset config are false.
+ String testPassphrase = "secretsecret";
+ SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder();
+ configBuilder.setPassphrase(testPassphrase, SoftApConfiguration.SECURITY_TYPE_WPA3_SAE);
WifiApConfigStore store = createWifiApConfigStore();
+ SoftApConfiguration resetedConfig = store.resetToDefaultForUnsupportedConfig(
+ configBuilder.build());
+ assertEquals(resetedConfig, configBuilder.build());
- SoftApConfiguration resetedConfig = store.resetToDefaultForUnsupportedConfig(sae_config);
- assertEquals(resetedConfig.getMaxNumberOfClients(), 0);
- assertFalse(resetedConfig.isClientControlByUserEnabled());
+ verify(mWifiMetrics).noteSoftApConfigReset(configBuilder.build(), resetedConfig);
+
+ // Test SAE not support case.
+ mResources.setBoolean(R.bool.config_wifi_softap_sae_supported, false);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertEquals(resetedConfig.getSecurityType(), SoftApConfiguration.SECURITY_TYPE_WPA2_PSK);
+ // Test force channel
+ configBuilder.setChannel(149, SoftApConfiguration.BAND_5GHZ);
+ mResources.setBoolean(
+ R.bool.config_wifiSoftapResetChannelConfig, true);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
assertEquals(resetedConfig.getChannel(), 0);
assertEquals(resetedConfig.getBand(),
SoftApConfiguration.BAND_2GHZ | SoftApConfiguration.BAND_5GHZ);
- verify(mWifiMetrics).noteSoftApConfigReset(sae_config, resetedConfig);
+
+ // Test forced channel band doesn't support.
+ mResources.setBoolean(R.bool.config_wifi5ghzSupport, false);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertEquals(resetedConfig.getChannel(), 0);
+ assertEquals(resetedConfig.getBand(),
+ SoftApConfiguration.BAND_2GHZ);
+
+ // Test band not support with auto channel
+ configBuilder.setBand(SoftApConfiguration.BAND_5GHZ);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertEquals(resetedConfig.getBand(), SoftApConfiguration.BAND_2GHZ);
+
+ // Test reset hidden network
+ mResources.setBoolean(
+ R.bool.config_wifiSoftapResetHiddenConfig, true);
+ configBuilder.setHiddenSsid(true);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertFalse(resetedConfig.isHiddenSsid());
+
+ // Test auto shutdown timer
+ mResources.setBoolean(
+ R.bool.config_wifiSoftapResetAutoShutdownTimerConfig, true);
+ configBuilder.setShutdownTimeoutMillis(8888);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertEquals(resetedConfig.getShutdownTimeoutMillis(), 0);
+
+ // Test max client setting when force client disconnect doesn't support
+ mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, false);
+ configBuilder.setMaxNumberOfClients(10);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertEquals(resetedConfig.getMaxNumberOfClients(), 0);
+
+ // Test client control setting when force client disconnect doesn't support
+ mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, false);
+ ArrayList<MacAddress> blockedClientList = new ArrayList<>();
+ blockedClientList.add(MacAddress.fromString("11:22:33:44:55:66"));
+ configBuilder.setBlockedClientList(blockedClientList);
+
+ configBuilder.setClientControlByUserEnabled(true);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertFalse(resetedConfig.isClientControlByUserEnabled());
+ // The blocked list still keep
+ assertEquals(resetedConfig.getBlockedClientList(), blockedClientList);
+
+ // Test max client setting when reset enabled but force client disconnect supported
+ mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, true);
+ mResources.setBoolean(
+ R.bool.config_wifiSoftapResetMaxClientSettingConfig, true);
+ assertEquals(resetedConfig.getMaxNumberOfClients(), 0);
+
+ // Test client control setting when reset enabled but force client disconnect supported
+ mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, true);
+ mResources.setBoolean(
+ R.bool.config_wifiSoftapResetUserControlConfig, true);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertFalse(resetedConfig.isClientControlByUserEnabled());
+ assertEquals(resetedConfig.getBlockedClientList(), blockedClientList);
}
/**