diff options
author | lesl <lesl@google.com> | 2020-06-22 12:51:42 +0800 |
---|---|---|
committer | lesl <lesl@google.com> | 2020-06-23 16:17:20 +0800 |
commit | dfdf77373982a9b3da32784b3705ef713f4fd2c8 (patch) | |
tree | 10aef3f8f3fd6d83383f9579d5327413a95c1c17 /service | |
parent | 6ea82ec26afa0d8b72ccc84b9d644c1e539fd5d5 (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 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiApConfigStore.java | 77 | ||||
-rw-r--r-- | service/res/values/config.xml | 15 | ||||
-rw-r--r-- | service/res/values/overlayable.xml | 4 |
3 files changed, 76 insertions, 20 deletions
diff --git a/service/java/com/android/server/wifi/WifiApConfigStore.java b/service/java/com/android/server/wifi/WifiApConfigStore.java index 961cbbd3b..eb2b11245 100644 --- a/service/java/com/android/server/wifi/WifiApConfigStore.java +++ b/service/java/com/android/server/wifi/WifiApConfigStore.java @@ -153,10 +153,13 @@ public class WifiApConfigStore { /** * Returns SoftApConfiguration in which some parameters might be reset to supported default - * config. + * config since it depends on UI or HW. * - * MaxNumberOfClients and setClientControlByUserEnabled will need HAL support client force - * disconnect. Reset to default when device doesn't support it. + * MaxNumberOfClients and isClientControlByUserEnabled will need HAL support client force + * disconnect, and Band setting (5g/6g) need HW support. + * + * HiddenSsid, Channel, ShutdownTimeoutMillis and AutoShutdownEnabled are features + * which need UI(Setting) support. * * SAE/SAE-Transition need hardware support, reset to secured WPA2 security type when device * doesn't support it. @@ -164,15 +167,20 @@ public class WifiApConfigStore { public SoftApConfiguration resetToDefaultForUnsupportedConfig( @NonNull SoftApConfiguration config) { SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder(config); - if (!ApConfigUtil.isClientForceDisconnectSupported(mContext)) { - configBuilder.setMaxNumberOfClients(0); + if ((!ApConfigUtil.isClientForceDisconnectSupported(mContext) + || mContext.getResources().getBoolean( + R.bool.config_wifiSoftapResetUserControlConfig)) + && config.isClientControlByUserEnabled()) { configBuilder.setClientControlByUserEnabled(false); - if (config.getMaxNumberOfClients() != 0) { - Log.e(TAG, "Reset MaxNumberOfClients to 0 due to device doesn't support"); - } - if (config.isClientControlByUserEnabled()) { - Log.e(TAG, "Reset ClientControlByUser to false due to device doesn't support"); - } + Log.i(TAG, "Reset ClientControlByUser to false due to device doesn't support"); + } + + if ((!ApConfigUtil.isClientForceDisconnectSupported(mContext) + || mContext.getResources().getBoolean( + R.bool.config_wifiSoftapResetMaxClientSettingConfig)) + && config.getMaxNumberOfClients() != 0) { + configBuilder.setMaxNumberOfClients(0); + Log.i(TAG, "Reset MaxNumberOfClients to 0 due to device doesn't support"); } if (!ApConfigUtil.isWpa3SaeSupported(mContext) && (config.getSecurityType() @@ -181,18 +189,51 @@ public class WifiApConfigStore { == SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION)) { configBuilder.setPassphrase(generatePassword(), SoftApConfiguration.SECURITY_TYPE_WPA2_PSK); - Log.e(TAG, "Device doesn't support WPA3-SAE, reset config to WPA2"); + Log.i(TAG, "Device doesn't support WPA3-SAE, reset config to WPA2"); } - if (mContext.getResources().getBoolean(R.bool.config_wifiSoftapResetChannelConfig)) { + if (mContext.getResources().getBoolean(R.bool.config_wifiSoftapResetChannelConfig) + && config.getChannel() != 0) { // The device might not support customize channel or forced channel might not // work in some countries. Need to reset it. - if (config.getChannel() != 0) { - // Add 2.4G by default - configBuilder.setBand(SoftApConfiguration.BAND_2GHZ | config.getBand()); - Log.i(TAG, "Reset SAP channel configuration"); - } + // Add 2.4G by default + configBuilder.setBand(config.getBand() | SoftApConfiguration.BAND_2GHZ); + Log.i(TAG, "Reset SAP channel configuration"); + } + + int newBand = config.getBand(); + if (!mContext.getResources().getBoolean(R.bool.config_wifi6ghzSupport) + && (newBand & SoftApConfiguration.BAND_6GHZ) != 0) { + newBand &= ~SoftApConfiguration.BAND_6GHZ; + Log.i(TAG, "Device doesn't support 6g, remove 6G band from band setting"); } + + if (!mContext.getResources().getBoolean(R.bool.config_wifi5ghzSupport) + && (newBand & SoftApConfiguration.BAND_5GHZ) != 0) { + newBand &= ~SoftApConfiguration.BAND_5GHZ; + Log.i(TAG, "Device doesn't support 5g, remove 5G band from band setting"); + } + + if (newBand != config.getBand()) { + // Always added 2.4G by default when reset the band. + Log.i(TAG, "Reset band from " + config.getBand() + " to " + + (newBand | SoftApConfiguration.BAND_2GHZ)); + configBuilder.setBand(newBand | SoftApConfiguration.BAND_2GHZ); + } + + if (mContext.getResources().getBoolean(R.bool.config_wifiSoftapResetHiddenConfig) + && config.isHiddenSsid()) { + configBuilder.setHiddenSsid(false); + Log.i(TAG, "Reset SAP Hidden Network configuration"); + } + + if (mContext.getResources().getBoolean( + R.bool.config_wifiSoftapResetAutoShutdownTimerConfig) + && config.getShutdownTimeoutMillis() != 0) { + configBuilder.setShutdownTimeoutMillis(0); + Log.i(TAG, "Reset SAP auto shutdown configuration"); + } + mWifiMetrics.noteSoftApConfigReset(config, configBuilder.build()); return configBuilder.build(); } diff --git a/service/res/values/config.xml b/service/res/values/config.xml index 7e35eed19..4ea23adc0 100644 --- a/service/res/values/config.xml +++ b/service/res/values/config.xml @@ -133,13 +133,24 @@ are no connected devices. --> <integer translatable="false" name="config_wifiFrameworkSoftApShutDownTimeoutMilliseconds">600000</integer> - <!-- Integer indicating maximum hardware supported client number of soft ap --> <integer translatable="false" name="config_wifiHardwareSoftapMaxClientCount">16</integer> - <!-- boolean indicating whether reset channel configuration or not during cloud configuration restore --> + <!-- boolean indicating whether or not to reset channel configuration during cloud configuration restore --> <bool translatable="false" name ="config_wifiSoftapResetChannelConfig">true</bool> + <!-- boolean indicating whether or not to reset hiddenSsid configuration during cloud configuration restore --> + <bool translatable="false" name ="config_wifiSoftapResetHiddenConfig">true</bool> + + <!-- boolean indicating whether or not to reset user control configuration during cloud configuration restore --> + <bool translatable="false" name ="config_wifiSoftapResetUserControlConfig">true</bool> + + <!-- boolean indicating whether or not to reset auto shotdown configuration during cloud configuration restore --> + <bool translatable="false" name ="config_wifiSoftapResetAutoShutdownTimerConfig">true</bool> + + <!-- boolean indicating whether or not to reset max client setting configuration during cloud configuration restore --> + <bool translatable="false" name ="config_wifiSoftapResetMaxClientSettingConfig">true</bool> + <!-- List of allowed channels in 2GHz band for softap. If the device doesn't want to restrict channels this should be empty. Values is a comma separated channel string and/or channel range string like '1-6,11'. --> diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml index bf96fde62..b02eb9e77 100644 --- a/service/res/values/overlayable.xml +++ b/service/res/values/overlayable.xml @@ -58,6 +58,10 @@ <item type="integer" name="config_wifiFrameworkScoreGoodRssiThreshold6ghz" /> <item type="integer" name="config_wifiFrameworkSoftApShutDownTimeoutMilliseconds" /> <item type="bool" name="config_wifiSoftapResetChannelConfig" /> + <item type="bool" name="config_wifiSoftapResetHiddenConfig" /> + <item type="bool" name="config_wifiSoftapResetUserControlConfig" /> + <item type="bool" name="config_wifiSoftapResetAutoShutdownTimerConfig" /> + <item type="bool" name="config_wifiSoftapResetMaxClientSettingConfig" /> <item type="string" name="config_wifiSoftap2gChannelList" /> <item type="string" name="config_wifiSoftap5gChannelList" /> <item type="string" name="config_wifiSoftap6gChannelList" /> |