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-08-14 17:30:29 +0000
commit87ed136e3dc12e605202bb9dca07e8290f908539 (patch)
treeef69c3210583868c2237dc834366f0aea595a73d /service
parent4db818057501c2b913825e7eeb78c89a82c98fff (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 (cherry picked from commit 3c57f9c394c6158b3407fd5c5b67857874433168)
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 1afe9ed9d..c880ab639 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");
}