summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmed ElArabawy <arabawy@google.com>2020-05-25 17:46:31 -0700
committerAhmed ElArabawy <arabawy@google.com>2020-05-26 06:49:52 -0700
commitc57a88d72e9d0f87d1bf4135ddb2bb02df67762c (patch)
treee7c9b04082bce4ce4a5563471376b070cc39610f
parent573ce2e5a0fdad896804f6a2408b6802c29588dd (diff)
Use utility methods to calculate channel frequencies
This commit removes some use of explicit numbers to calculate channel frequencies. Instead it uses the utility methods provided by ScanResult. Bug: 153896822 Test: atest FrameworksWifiTests Change-Id: I356fc9d0eca4e242ab740ce294f62942da2c3a48
-rw-r--r--service/java/com/android/server/wifi/util/InformationElementUtil.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/util/InformationElementUtil.java b/service/java/com/android/server/wifi/util/InformationElementUtil.java
index 0b10bf45e..60d074e00 100644
--- a/service/java/com/android/server/wifi/util/InformationElementUtil.java
+++ b/service/java/com/android/server/wifi/util/InformationElementUtil.java
@@ -20,6 +20,7 @@ import android.net.wifi.ScanResult.InformationElement;
import android.net.wifi.WifiAnnotations.Cipher;
import android.net.wifi.WifiAnnotations.KeyMgmt;
import android.net.wifi.WifiAnnotations.Protocol;
+import android.net.wifi.WifiScanner;
import android.net.wifi.nl80211.NativeScanResult;
import android.net.wifi.nl80211.WifiNl80211Manager;
import android.util.Log;
@@ -279,8 +280,8 @@ public class InformationElementUtil {
if (mCenterFreqIndex1 == 0 || mChannelMode == 0) {
return 0;
} else {
- //convert channel index to frequency in MHz, channel 36 is 5180MHz
- return (mCenterFreqIndex1 - 36) * 5 + 5180;
+ return ScanResult.convertChannelToFrequencyMhz(mCenterFreqIndex1,
+ WifiScanner.WIFI_BAND_5_GHZ);
}
}
@@ -294,8 +295,8 @@ public class InformationElementUtil {
if (mCenterFreqIndex2 == 0 || mChannelMode == 0) {
return 0;
} else {
- //convert channel index to frequency in MHz, channel 36 is 5180MHz
- return (mCenterFreqIndex2 - 36) * 5 + 5180;
+ return ScanResult.convertChannelToFrequencyMhz(mCenterFreqIndex2,
+ WifiScanner.WIFI_BAND_5_GHZ);
}
}
@@ -392,7 +393,8 @@ public class InformationElementUtil {
* Only applicable for 6GHz channels
*/
public int getPrimaryFreq() {
- return (mPrimaryChannel * 5) + 5940;
+ return ScanResult.convertChannelToFrequencyMhz(mPrimaryChannel,
+ WifiScanner.WIFI_BAND_6_GHZ);
}
/**
@@ -404,7 +406,8 @@ public class InformationElementUtil {
if (mCenterFreqSeg0 == 0) {
return 0;
} else {
- return (mCenterFreqSeg0 * 5) + 5940;
+ return ScanResult.convertChannelToFrequencyMhz(mCenterFreqSeg0,
+ WifiScanner.WIFI_BAND_6_GHZ);
}
} else {
return 0;
@@ -420,7 +423,8 @@ public class InformationElementUtil {
if (mCenterFreqSeg1 == 0) {
return 0;
} else {
- return (mCenterFreqSeg1 * 5) + 5940;
+ return ScanResult.convertChannelToFrequencyMhz(mCenterFreqSeg1,
+ WifiScanner.WIFI_BAND_6_GHZ);
}
} else {
return 0;