diff options
author | Rebecca Silberstein <silberst@google.com> | 2018-05-25 09:23:51 -0700 |
---|---|---|
committer | Rebecca Silberstein <silberst@google.com> | 2018-06-05 14:22:09 -0700 |
commit | ee38c65d579f5363f2ffd63e850582350233d0e4 (patch) | |
tree | d40265eabad4bd35f4050e5219903526c44a9bb0 /service | |
parent | c14521bbc37a0e18c85c4f3baeadfbf70d569cec (diff) |
WifiApConfigStore: convert 5GHZ to ANY for dual mode devices
When setting or getting an ap config, check for necessary apband
conversions. For some devices, apBand options are limited to
2.4(only) and ANY. A second class of devices are limited to
2.4(only) and 5(only). Single band devices are still
limited to 2.4(only).
Bug: 80251951
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: manually confirmed configs are converted for different device
types
Change-Id: I14150f0e890696e12ef04f402c0d8afad09e984e
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiApConfigStore.java | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/WifiApConfigStore.java b/service/java/com/android/server/wifi/WifiApConfigStore.java index e8ad74885..109c0a7af 100644 --- a/service/java/com/android/server/wifi/WifiApConfigStore.java +++ b/service/java/com/android/server/wifi/WifiApConfigStore.java @@ -63,6 +63,9 @@ public class WifiApConfigStore { @VisibleForTesting static final int PSK_MAX_LEN = 63; + @VisibleForTesting + static final int AP_CHANNEL_DEFAULT = 0; + private WifiConfiguration mWifiApConfig = null; private ArrayList<Integer> mAllowed2GChannel = null; @@ -70,6 +73,7 @@ public class WifiApConfigStore { private final Context mContext; private final String mApConfigFile; private final BackupManagerProxy mBackupManagerProxy; + private boolean mRequiresApBandConversion = false; WifiApConfigStore(Context context, BackupManagerProxy backupManagerProxy) { this(context, backupManagerProxy, DEFAULT_AP_CONFIG_FILE); @@ -94,6 +98,9 @@ public class WifiApConfigStore { } } + mRequiresApBandConversion = mContext.getResources().getBoolean( + R.bool.config_wifi_convert_apband_5ghz_to_any); + /* Load AP configuration from persistent storage. */ mWifiApConfig = loadApConfiguration(mApConfigFile); if (mWifiApConfig == null) { @@ -110,6 +117,12 @@ public class WifiApConfigStore { * Return the current soft access point configuration. */ public synchronized WifiConfiguration getApConfiguration() { + WifiConfiguration config = apBandCheckConvert(mWifiApConfig); + if (mWifiApConfig != config) { + Log.d(TAG, "persisted config was converted, need to resave it"); + mWifiApConfig = config; + persistConfigAndTriggerBackupManagerProxy(mWifiApConfig); + } return mWifiApConfig; } @@ -123,18 +136,45 @@ public class WifiApConfigStore { if (config == null) { mWifiApConfig = getDefaultApConfiguration(); } else { - mWifiApConfig = config; + mWifiApConfig = apBandCheckConvert(config); } - writeApConfiguration(mApConfigFile, mWifiApConfig); - - // Stage the backup of the SettingsProvider package which backs this up - mBackupManagerProxy.notifyDataChanged(); + persistConfigAndTriggerBackupManagerProxy(mWifiApConfig); } public ArrayList<Integer> getAllowed2GChannel() { return mAllowed2GChannel; } + private WifiConfiguration apBandCheckConvert(WifiConfiguration config) { + if (mRequiresApBandConversion) { + // some devices are unable to support 5GHz only operation, check for 5GHz and + // move to ANY if apBand conversion is required. + if (config.apBand == WifiConfiguration.AP_BAND_5GHZ) { + Log.w(TAG, "Supplied ap config band was 5GHz only, converting to ANY"); + WifiConfiguration convertedConfig = new WifiConfiguration(config); + convertedConfig.apBand = WifiConfiguration.AP_BAND_ANY; + convertedConfig.apChannel = AP_CHANNEL_DEFAULT; + return convertedConfig; + } + } else { + // this is a single mode device, we do not support ANY. Convert all ANY to 5GHz + if (config.apBand == WifiConfiguration.AP_BAND_ANY) { + Log.w(TAG, "Supplied ap config band was ANY, converting to 5GHz"); + WifiConfiguration convertedConfig = new WifiConfiguration(config); + convertedConfig.apBand = WifiConfiguration.AP_BAND_5GHZ; + convertedConfig.apChannel = AP_CHANNEL_DEFAULT; + return convertedConfig; + } + } + return config; + } + + private void persistConfigAndTriggerBackupManagerProxy(WifiConfiguration config) { + writeApConfiguration(mApConfigFile, mWifiApConfig); + // Stage the backup of the SettingsProvider package which backs this up + mBackupManagerProxy.notifyDataChanged(); + } + /** * Load AP configuration from persistent storage. */ |