summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-04-29 13:22:44 -0700
committerRoshan Pius <rpius@google.com>2019-05-02 16:07:16 +0000
commit1ee5f9d29c788a692e188bf08ec8d89882bec39e (patch)
tree7c7eb29ba9005b174ff722424c1585a7cfab1176 /service
parentc83767fd106fc5a9bffe4ee6d16c389aa726e492 (diff)
SoftApManager: Simplify band preference violation metrics update
Changes in the CL: a) Refactor the metrics update for user band preference violation into a separate method. b) Use a simple frequency check to verify if band preference is violated (don't fetch the channel list from wificond). c) Don't do anything for ANY band preference. Bug: 131557372 Test: atest FrameworksWifiTests Test: Toggle softap on/off Change-Id: Ifbee921acd45539b6c92e08b7482ffdd8a58b119 (cherry-picked from 42d56aa3f4d42c56790ce98fe6023adb4a6db2c1)
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java45
1 files changed, 18 insertions, 27 deletions
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index 6ace54fc2..dfc397cfe 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -24,9 +24,9 @@ import android.annotation.NonNull;
import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
+import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
-import android.net.wifi.WifiScanner;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -38,7 +38,6 @@ import android.util.Log;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.util.ArrayUtils;
import com.android.internal.util.IState;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
@@ -50,10 +49,8 @@ import com.android.server.wifi.util.ApConfigUtil;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
-import java.util.Arrays;
import java.util.Date;
import java.util.Locale;
-import java.util.stream.Stream;
/**
* Manage WiFi in AP mode.
@@ -567,6 +564,22 @@ public class SoftApManager implements ActiveModeManager {
mStateMachine.quitNow();
}
+ private void updateUserBandPreferenceViolationMetricsIfNeeded() {
+ boolean bandPreferenceViolated = false;
+ if (mApConfig.apBand == WifiConfiguration.AP_BAND_2GHZ
+ && ScanResult.is5GHz(mReportedFrequency)) {
+ bandPreferenceViolated = true;
+ } else if (mApConfig.apBand == WifiConfiguration.AP_BAND_5GHZ
+ && ScanResult.is24GHz(mReportedFrequency)) {
+ bandPreferenceViolated = true;
+ }
+ if (bandPreferenceViolated) {
+ Log.e(TAG, "Channel does not satisfy user band preference: "
+ + mReportedFrequency);
+ mWifiMetrics.incrementNumSoftApUserBandPreferenceUnsatisfied();
+ }
+ }
+
@Override
public boolean processMessage(Message message) {
switch (message.what) {
@@ -585,29 +598,7 @@ public class SoftApManager implements ActiveModeManager {
+ " Bandwidth: " + mReportedBandwidth);
mWifiMetrics.addSoftApChannelSwitchedEvent(mReportedFrequency,
mReportedBandwidth, mMode);
- int[] allowedChannels = new int[0];
- if (mApConfig.apBand == WifiConfiguration.AP_BAND_2GHZ) {
- allowedChannels =
- mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ);
- } else if (mApConfig.apBand == WifiConfiguration.AP_BAND_5GHZ) {
- allowedChannels =
- mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ);
- } else if (mApConfig.apBand == WifiConfiguration.AP_BAND_ANY) {
- int[] allowed2GChannels =
- mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ);
- int[] allowed5GChannels =
- mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ);
- allowedChannels = Stream.concat(
- Arrays.stream(allowed2GChannels).boxed(),
- Arrays.stream(allowed5GChannels).boxed())
- .mapToInt(Integer::valueOf)
- .toArray();
- }
- if (!ArrayUtils.contains(allowedChannels, mReportedFrequency)) {
- Log.e(TAG, "Channel does not satisfy user band preference: "
- + mReportedFrequency);
- mWifiMetrics.incrementNumSoftApUserBandPreferenceUnsatisfied();
- }
+ updateUserBandPreferenceViolationMetricsIfNeeded();
break;
case CMD_TIMEOUT_TOGGLE_CHANGED:
boolean isEnabled = (message.arg1 == 1);