summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-08-14 14:25:26 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-08-14 14:25:26 -0700
commit6e3e122eb15f2eb5798669f3f3f0fe9b04917def (patch)
tree0b8930bb3e6d03862d40d342570a95110653e5dc /service
parentce7e09eef532ae11b8e0215a0cf002e04300803a (diff)
parent87ed136e3dc12e605202bb9dca07e8290f908539 (diff)
SoftApManager: Set country code before channel selection
am: 87ed136e3d Change-Id: Ia219fe77cd68e9f416d07216a6f56193b50bf1a3
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");
}