summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorlesl <lesl@google.com>2020-02-21 18:04:51 +0800
committerLes Lee <lesl@google.com>2020-02-24 06:28:50 +0000
commitc9f4fb984a68a23475b9b39dc25f9f6b2408fc51 (patch)
treec1b16412f1d48b299a7fc63cdab9c55788aec4bb /service
parent3f287f8eef3cec1f09a2e68d40ebc77a7b7f3e70 (diff)
wifi: Change framework channel selection to high band channel prefer
Test: atest frameworks/opt/net/wifi/tests/wifitests/ Test: Manual test to switch band setting between 2.4G and 5G prefer, check log to make sure the behavior. Bug: 149974192 Merged-In: Id6a625d733a4549f03a67f398ac6a66734575459 Change-Id: Id6a625d733a4549f03a67f398ac6a66734575459 (cherry picked from commit faed97a0b7891c4a704b60edc8715663081b26bc)
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/util/ApConfigUtil.java74
1 files changed, 22 insertions, 52 deletions
diff --git a/service/java/com/android/server/wifi/util/ApConfigUtil.java b/service/java/com/android/server/wifi/util/ApConfigUtil.java
index bf319b4f2..883c1a76a 100644
--- a/service/java/com/android/server/wifi/util/ApConfigUtil.java
+++ b/service/java/com/android/server/wifi/util/ApConfigUtil.java
@@ -292,72 +292,42 @@ public class ApConfigUtil {
return -1;
}
- int totalChannelCount = 0;
- int size2gList = 0;
- int size5gList = 0;
- int size6gList = 0;
- List<Integer> allowed2gFreqList = null;
- List<Integer> allowed5gFreqList = null;
- List<Integer> allowed6gFreqList = null;
+ List<Integer> allowedFreqList = null;
- if ((apBand & SoftApConfiguration.BAND_2GHZ) != 0) {
- allowed2gFreqList = getAvailableChannelFreqsForBand(SoftApConfiguration.BAND_2GHZ,
- wifiNative, resources);
- if (allowed2gFreqList != null) {
- size2gList = allowed2gFreqList.size();
- totalChannelCount += size2gList;
- }
- }
- if ((apBand & SoftApConfiguration.BAND_5GHZ) != 0) {
- allowed5gFreqList = getAvailableChannelFreqsForBand(SoftApConfiguration.BAND_5GHZ,
- wifiNative, resources);
- if (allowed5gFreqList != null) {
- size5gList = allowed5gFreqList.size();
- totalChannelCount += size5gList;
- }
- }
if ((apBand & SoftApConfiguration.BAND_6GHZ) != 0) {
- allowed6gFreqList = getAvailableChannelFreqsForBand(SoftApConfiguration.BAND_6GHZ,
+ allowedFreqList = getAvailableChannelFreqsForBand(SoftApConfiguration.BAND_6GHZ,
wifiNative, resources);
- if (allowed6gFreqList != null) {
- size6gList = allowed6gFreqList.size();
- totalChannelCount += size6gList;
+ if (allowedFreqList != null && allowedFreqList.size() > 0) {
+ return allowedFreqList.get(sRandom.nextInt(allowedFreqList.size())).intValue();
}
}
- if (totalChannelCount == 0) {
- // If the default AP band is allowed, just use the default channel
- if (containsBand(apBand, DEFAULT_AP_BAND)) {
- Log.d(TAG, "Allowed channel list not specified, selecting default channel");
- /* Use default channel. */
- return convertChannelToFrequency(DEFAULT_AP_CHANNEL,
- DEFAULT_AP_BAND);
- } else {
- Log.e(TAG, "No available channels");
- return -1;
+ if ((apBand & SoftApConfiguration.BAND_5GHZ) != 0) {
+ allowedFreqList = getAvailableChannelFreqsForBand(SoftApConfiguration.BAND_5GHZ,
+ wifiNative, resources);
+ if (allowedFreqList != null && allowedFreqList.size() > 0) {
+ return allowedFreqList.get(sRandom.nextInt(allowedFreqList.size())).intValue();
}
}
- // Pick a channel
- int selectedChannelIndex = sRandom.nextInt(totalChannelCount);
-
- if (size2gList != 0) {
- if (selectedChannelIndex < size2gList) {
- return allowed2gFreqList.get(selectedChannelIndex).intValue();
- } else {
- selectedChannelIndex -= size2gList;
+ if ((apBand & SoftApConfiguration.BAND_2GHZ) != 0) {
+ allowedFreqList = getAvailableChannelFreqsForBand(SoftApConfiguration.BAND_2GHZ,
+ wifiNative, resources);
+ if (allowedFreqList != null && allowedFreqList.size() > 0) {
+ return allowedFreqList.get(sRandom.nextInt(allowedFreqList.size())).intValue();
}
}
- if (size5gList != 0) {
- if (selectedChannelIndex < size5gList) {
- return allowed5gFreqList.get(selectedChannelIndex).intValue();
- } else {
- selectedChannelIndex -= size5gList;
- }
+ // If the default AP band is allowed, just use the default channel
+ if (containsBand(apBand, DEFAULT_AP_BAND)) {
+ Log.e(TAG, "Allowed channel list not specified, selecting default channel");
+ /* Use default channel. */
+ return convertChannelToFrequency(DEFAULT_AP_CHANNEL,
+ DEFAULT_AP_BAND);
}
- return allowed6gFreqList.get(selectedChannelIndex).intValue();
+ Log.e(TAG, "No available channels");
+ return -1;
}
/**