summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-07-09 10:36:03 -0700
committerRoshan Pius <rpius@google.com>2018-07-11 14:20:41 +0000
commit3c57f9c394c6158b3407fd5c5b67857874433168 (patch)
tree0450ee2839321572d85713cb2ee6e1ad6764abe3 /service
parentb4cce48d5d5223375fc5020813031ebe8990cd5e (diff)
SoftApManager: Set country code before channel selection
If the country code is not set for some reason previously (For example: STA was off when telephony sent the country code update), we should first set the country code before performing channel selection for AP. Also, added an extra error check for country code when the band selected is 5Ghz. Bug: 111135704 Test: Unit tests Test: Able to toggle hotspot on/off. Test: Ran SoftapManager ACTS tests locally. Change-Id: Icbc16dac9acf7ba4a35905703ea4cff44fa542ee
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java32
1 files changed, 20 insertions, 12 deletions
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index 1a67fdec8..f7932d8f9 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -232,6 +232,26 @@ public class SoftApManager implements ActiveModeManager {
Log.e(TAG, "Unable to start soft AP without valid configuration");
return ERROR_GENERIC;
}
+ // Setup country code
+ if (TextUtils.isEmpty(mCountryCode)) {
+ if (config.apBand == WifiConfiguration.AP_BAND_5GHZ) {
+ // Country code is mandatory for 5GHz band.
+ Log.e(TAG, "Invalid country code, required for setting up "
+ + "soft ap in 5GHz");
+ return ERROR_GENERIC;
+ }
+ // Absence of country code is not fatal for 2Ghz & Any band options.
+ } else if (!mWifiNative.setCountryCodeHal(
+ mApInterfaceName, mCountryCode.toUpperCase(Locale.ROOT))) {
+ if (config.apBand == WifiConfiguration.AP_BAND_5GHZ) {
+ // Return an error if failed to set country code when AP is configured for
+ // 5GHz band.
+ Log.e(TAG, "Failed to set country code, required for setting up "
+ + "soft ap in 5GHz");
+ return ERROR_GENERIC;
+ }
+ // Failure to set country code is not fatal for 2Ghz & Any band options.
+ }
// Make a copy of configuration for updating AP band and channel.
WifiConfiguration localConfig = new WifiConfiguration(config);
@@ -245,18 +265,6 @@ public class SoftApManager implements ActiveModeManager {
return result;
}
- // Setup country code if it is provided.
- if (mCountryCode != null) {
- // Country code is mandatory for 5GHz band, return an error if failed to set
- // country code when AP is configured for 5GHz band.
- if (!mWifiNative.setCountryCodeHal(
- mApInterfaceName, mCountryCode.toUpperCase(Locale.ROOT))
- && config.apBand == WifiConfiguration.AP_BAND_5GHZ) {
- Log.e(TAG, "Failed to set country code, required for setting up "
- + "soft ap in 5GHz");
- return ERROR_GENERIC;
- }
- }
if (localConfig.hiddenSSID) {
Log.d(TAG, "SoftAP is a hidden network");
}