From dfdf77373982a9b3da32784b3705ef713f4fd2c8 Mon Sep 17 00:00:00 2001 From: lesl Date: Mon, 22 Jun 2020 12:51:42 +0800 Subject: 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 --- .../android/server/wifi/WifiApConfigStoreTest.java | 94 +++++++++++++++++++--- 1 file changed, 81 insertions(+), 13 deletions(-) (limited to 'tests') 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 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); } /** -- cgit v1.2.3