diff options
Diffstat (limited to 'libwifi_system/hostapd_manager.cpp')
-rw-r--r-- | libwifi_system/hostapd_manager.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/libwifi_system/hostapd_manager.cpp b/libwifi_system/hostapd_manager.cpp index 8c7de320b..d6f31fed0 100644 --- a/libwifi_system/hostapd_manager.cpp +++ b/libwifi_system/hostapd_manager.cpp @@ -45,7 +45,6 @@ namespace android { namespace wifi_system { namespace { -const int kDefaultApChannel = 6; const char kHostapdServiceName[] = "hostapd"; const char kHostapdConfigFilePath[] = "/data/misc/wifi/hostapd.conf"; @@ -126,15 +125,11 @@ string HostapdManager::CreateHostapdConfig( const string& interface_name, const vector<uint8_t> ssid, bool is_hidden, - int channel, + BandType band, EncryptionType encryption_type, const vector<uint8_t> passphrase) { string result; - if (channel < 0) { - channel = kDefaultApChannel; - } - if (ssid.size() > 32) { LOG(ERROR) << "SSIDs must be <= 32 bytes long"; return result; @@ -171,6 +166,21 @@ string HostapdManager::CreateHostapdConfig( } } + // hw_mode will be used to specify band for acs. + string hw_mode; + if (band == BandType::kBand2G) { + hw_mode = "g"; + } else if (band == BandType::kBand5G) { + hw_mode = "a"; + } else if (band == BandType::kBandAny) { + hw_mode = "any"; + } else { + LOG(ERROR) << "Unknown band type (" + << static_cast<int>(band) + << ")"; + return result; + } + result = StringPrintf( "interface=%s\n" "driver=nl80211\n" @@ -179,16 +189,17 @@ string HostapdManager::CreateHostapdConfig( // for use as a SSID. In this case, we're giving it a hex string // and hostapd needs to expect that. "ssid2=%s\n" - "channel=%d\n" + // channel can be selected automatically at run time. + "channel=0\n" + "acs_exclude_dfs=1\n" "ieee80211n=1\n" - "hw_mode=%c\n" + "hw_mode=%s\n" "ignore_broadcast_ssid=%d\n" "wowlan_triggers=any\n" "%s", interface_name.c_str(), ssid_as_string.c_str(), - channel, - (channel <= 14) ? 'g' : 'a', + hw_mode.c_str(), (is_hidden) ? 1 : 0, encryption_config.c_str()); return result; |