summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2020-02-10 23:29:59 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-02-10 23:29:59 +0000
commit26a1895ac4f7cf2eb01a72a116d542dcfec4b137 (patch)
tree107d22a768a5373c7ab29555750e489f51a3b3b3 /service
parent9c4532126ec24a0fbb0bef0a61cb867162200ad1 (diff)
parent0c4a674accb9bc7169dcfa786a03f38a11200678 (diff)
Merge changes from topic "wificond"
* changes: [WIFICOND][API] MacAddress + capability flags Revert "[WIFICOND][API] Update channel API from array to list"
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java4
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java9
-rw-r--r--service/java/com/android/server/wifi/WakeupController.java11
-rw-r--r--service/java/com/android/server/wifi/WifiNative.java21
-rw-r--r--service/java/com/android/server/wifi/WifiShellCommand.java30
-rw-r--r--service/java/com/android/server/wifi/scanner/KnownBandsChannelHelper.java27
-rw-r--r--service/java/com/android/server/wifi/scanner/PresetKnownBandsChannelHelper.java6
-rw-r--r--service/java/com/android/server/wifi/scanner/WificondChannelHelper.java28
-rw-r--r--service/java/com/android/server/wifi/util/ApConfigUtil.java8
-rw-r--r--service/java/com/android/server/wifi/util/InformationElementUtil.java11
10 files changed, 81 insertions, 74 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 49dc4ff70..ebdfb6864 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -1265,14 +1265,14 @@ public class ClientModeImpl extends StateMachine {
if (mContext.getResources().getBoolean(R.bool.config_wifi5ghzSupport)) {
return true;
}
- return (mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ).size() > 0);
+ return (mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ).length > 0);
}
if (band == WifiScanner.WIFI_BAND_6_GHZ) {
if (mContext.getResources().getBoolean(R.bool.config_wifi6ghzSupport)) {
return true;
}
- return (mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_6_GHZ).size() > 0);
+ return (mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_6_GHZ).length > 0);
}
return false;
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index 46674c3dd..54884cd89 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -884,12 +884,11 @@ public class SoftApManager implements ActiveModeManager {
}
NativeWifiClient nativeClient = (NativeWifiClient) message.obj;
boolean isConnected = (message.arg1 == 1);
- if (nativeClient != null && nativeClient.macAddress != null) {
- MacAddress clientMacAddress =
- MacAddress.fromBytes(nativeClient.macAddress);
- WifiClient client = new WifiClient(clientMacAddress);
+ if (nativeClient != null && nativeClient.getMacAddress() != null) {
+ WifiClient client = new WifiClient(nativeClient.getMacAddress());
Log.d(TAG, "CMD_ASSOCIATED_STATIONS_CHANGED, Client: "
- + clientMacAddress.toString() + " isConnected: " + isConnected);
+ + nativeClient.getMacAddress().toString() + " isConnected: "
+ + isConnected);
updateConnectedClients(client, isConnected);
}
break;
diff --git a/service/java/com/android/server/wifi/WakeupController.java b/service/java/com/android/server/wifi/WakeupController.java
index c9f9eb252..f5dabf35c 100644
--- a/service/java/com/android/server/wifi/WakeupController.java
+++ b/service/java/com/android/server/wifi/WakeupController.java
@@ -298,9 +298,14 @@ public class WakeupController {
/** Returns a list of ScanResults with DFS channels removed. */
private List<ScanResult> filterDfsScanResults(Collection<ScanResult> scanResults) {
- final Set<Integer> dfsChannelSet = new HashSet<>(
- mWifiInjector.getWifiNative().getChannelsForBand(
- WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY));
+ int[] dfsChannels = mWifiInjector.getWifiNative()
+ .getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY);
+ if (dfsChannels == null) {
+ dfsChannels = new int[0];
+ }
+
+ final Set<Integer> dfsChannelSet = Arrays.stream(dfsChannels).boxed()
+ .collect(Collectors.toSet());
return scanResults.stream()
.filter(scanResult -> !dfsChannelSet.contains(scanResult.frequency))
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 259a45555..1e978483d 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -57,7 +57,6 @@ import java.nio.ByteOrder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -1428,12 +1427,11 @@ public class WifiNative {
* WifiScanner.WIFI_BAND_5_GHZ
* WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY
* WifiScanner.WIFI_BAND_6_GHZ
- * @return frequencies List of valid frequencies (MHz), or an empty list for error.
+ * @return frequencies vector of valid frequencies (MHz), or null for error.
* @throws IllegalArgumentException if band is not recognized.
*/
- public List<Integer> getChannelsForBand(@WifiAnnotations.WifiBandBasic int band) {
- List<Integer> result = mWifiCondManager.getChannelsMhzForBand(band);
- return (result == null) ? Collections.emptyList() : result; // insurance on external mgr
+ public int [] getChannelsForBand(@WifiAnnotations.WifiBandBasic int band) {
+ return mWifiCondManager.getChannelsMhzForBand(band);
}
/**
@@ -1488,17 +1486,12 @@ public class WifiNative {
ArrayList<ScanDetail> results = new ArrayList<>();
for (NativeScanResult result : nativeResults) {
WifiSsid wifiSsid = WifiSsid.createFromByteArray(result.getSsid());
- String bssid;
- try {
- bssid = NativeUtil.macAddressFromByteArray(result.getBssid());
- } catch (IllegalArgumentException e) {
- Log.e(TAG, "Illegal argument " + result.getBssid(), e);
- continue;
- }
- if (bssid == null) {
- Log.e(TAG, "Illegal null bssid");
+ MacAddress bssidMac = result.getBssid();
+ if (bssidMac == null) {
+ Log.e(TAG, "Invalid MAC (BSSID) for SSID " + wifiSsid);
continue;
}
+ String bssid = bssidMac.toString();
ScanResult.InformationElement[] ies =
InformationElementUtil.parseInformationElements(result.getInformationElements());
InformationElementUtil.Capabilities capabilities =
diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java
index 05668a124..44081ba36 100644
--- a/service/java/com/android/server/wifi/WifiShellCommand.java
+++ b/service/java/com/android/server/wifi/WifiShellCommand.java
@@ -26,7 +26,7 @@ import android.os.Binder;
import com.android.server.wifi.util.ApConfigUtil;
import java.io.PrintWriter;
-import java.util.List;
+import java.util.Arrays;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;
@@ -411,16 +411,28 @@ public class WifiShellCommand extends BasicShellCommandHandler {
}
private boolean isApChannelMHzValid(int apChannelMHz) {
- List<Integer> allowed2gFreq = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ);
- List<Integer> allowed5gFreq = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ);
- List<Integer> allowed5gDfsFreq =
+ int[] allowed2gFreq = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ);
+ int[] allowed5gFreq = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ);
+ int[] allowed5gDfsFreq =
mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY);
- List<Integer> allowed6gFreq = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_6_GHZ);
+ int[] allowed6gFreq = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_6_GHZ);
+ if (allowed2gFreq == null) {
+ allowed2gFreq = new int[0];
+ }
+ if (allowed5gFreq == null) {
+ allowed5gFreq = new int[0];
+ }
+ if (allowed5gDfsFreq == null) {
+ allowed5gDfsFreq = new int[0];
+ }
+ if (allowed6gFreq == null) {
+ allowed6gFreq = new int[0];
+ }
- return allowed2gFreq.contains(apChannelMHz)
- || allowed5gFreq.contains(apChannelMHz)
- || allowed5gDfsFreq.contains(apChannelMHz)
- || allowed6gFreq.contains(apChannelMHz);
+ return (Arrays.binarySearch(allowed2gFreq, apChannelMHz) >= 0
+ || Arrays.binarySearch(allowed5gFreq, apChannelMHz) >= 0
+ || Arrays.binarySearch(allowed5gDfsFreq, apChannelMHz) >= 0)
+ || Arrays.binarySearch(allowed6gFreq, apChannelMHz) >= 0;
}
private void checkRootPermission() {
diff --git a/service/java/com/android/server/wifi/scanner/KnownBandsChannelHelper.java b/service/java/com/android/server/wifi/scanner/KnownBandsChannelHelper.java
index 520e919b2..6615a2627 100644
--- a/service/java/com/android/server/wifi/scanner/KnownBandsChannelHelper.java
+++ b/service/java/com/android/server/wifi/scanner/KnownBandsChannelHelper.java
@@ -36,7 +36,6 @@ import android.util.ArraySet;
import com.android.server.wifi.WifiNative;
import java.util.Arrays;
-import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -54,37 +53,37 @@ public class KnownBandsChannelHelper extends ChannelHelper {
private WifiScanner.ChannelSpec[][] mBandsToChannels;
- protected void setBandChannels(List<Integer> channels2G, List<Integer> channels5G,
- List<Integer> channelsDfs, List<Integer> channels6G) {
+ protected void setBandChannels(int[] channels2G, int[] channels5G, int[] channelsDfs,
+ int[] channels6G) {
mBandsToChannels = new WifiScanner.ChannelSpec[WIFI_BAND_COUNT][];
- if (!channels2G.isEmpty()) {
+ if (channels2G.length != 0) {
mBandsToChannels[WIFI_BAND_INDEX_24_GHZ] =
- new WifiScanner.ChannelSpec[channels2G.size()];
+ new WifiScanner.ChannelSpec[channels2G.length];
copyChannels(mBandsToChannels[WIFI_BAND_INDEX_24_GHZ], channels2G);
} else {
mBandsToChannels[WIFI_BAND_INDEX_24_GHZ] = NO_CHANNELS;
}
- if (!channels5G.isEmpty()) {
+ if (channels5G.length != 0) {
mBandsToChannels[WIFI_BAND_INDEX_5_GHZ] =
- new WifiScanner.ChannelSpec[channels5G.size()];
+ new WifiScanner.ChannelSpec[channels5G.length];
copyChannels(mBandsToChannels[WIFI_BAND_INDEX_5_GHZ], channels5G);
} else {
mBandsToChannels[WIFI_BAND_INDEX_5_GHZ] = NO_CHANNELS;
}
- if (!channelsDfs.isEmpty()) {
+ if (channelsDfs.length != 0) {
mBandsToChannels[WIFI_BAND_INDEX_5_GHZ_DFS_ONLY] =
- new WifiScanner.ChannelSpec[channelsDfs.size()];
+ new WifiScanner.ChannelSpec[channelsDfs.length];
copyChannels(mBandsToChannels[WIFI_BAND_INDEX_5_GHZ_DFS_ONLY], channelsDfs);
} else {
mBandsToChannels[WIFI_BAND_INDEX_5_GHZ_DFS_ONLY] = NO_CHANNELS;
}
- if (!channels6G.isEmpty()) {
+ if (channels6G.length != 0) {
mBandsToChannels[WIFI_BAND_INDEX_6_GHZ] =
- new WifiScanner.ChannelSpec[channels6G.size()];
+ new WifiScanner.ChannelSpec[channels6G.length];
copyChannels(mBandsToChannels[WIFI_BAND_INDEX_6_GHZ], channels6G);
} else {
mBandsToChannels[WIFI_BAND_INDEX_6_GHZ] = NO_CHANNELS;
@@ -92,9 +91,9 @@ public class KnownBandsChannelHelper extends ChannelHelper {
}
private static void copyChannels(
- WifiScanner.ChannelSpec[] channelSpec, List<Integer> channels) {
- for (int i = 0; i < channels.size(); i++) {
- channelSpec[i] = new WifiScanner.ChannelSpec(channels.get(i));
+ WifiScanner.ChannelSpec[] channelSpec, int[] channels) {
+ for (int i = 0; i < channels.length; i++) {
+ channelSpec[i] = new WifiScanner.ChannelSpec(channels[i]);
}
}
diff --git a/service/java/com/android/server/wifi/scanner/PresetKnownBandsChannelHelper.java b/service/java/com/android/server/wifi/scanner/PresetKnownBandsChannelHelper.java
index 517086f59..e1ddd9182 100644
--- a/service/java/com/android/server/wifi/scanner/PresetKnownBandsChannelHelper.java
+++ b/service/java/com/android/server/wifi/scanner/PresetKnownBandsChannelHelper.java
@@ -16,14 +16,12 @@
package com.android.server.wifi.scanner;
-import java.util.List;
-
/**
* KnownBandsChannelHelper that uses a supplied list of band to channels mappings.
*/
public class PresetKnownBandsChannelHelper extends KnownBandsChannelHelper {
- public PresetKnownBandsChannelHelper(List<Integer> channels2G, List<Integer> channels5G,
- List<Integer> channelsDfs, List<Integer> channels6G) {
+ public PresetKnownBandsChannelHelper(int[] channels2G, int[] channels5G, int[] channelsDfs,
+ int[] channels6G) {
setBandChannels(channels2G, channels5G, channelsDfs, channels6G);
}
}
diff --git a/service/java/com/android/server/wifi/scanner/WificondChannelHelper.java b/service/java/com/android/server/wifi/scanner/WificondChannelHelper.java
index 0a9d777fe..b52ce7e8c 100644
--- a/service/java/com/android/server/wifi/scanner/WificondChannelHelper.java
+++ b/service/java/com/android/server/wifi/scanner/WificondChannelHelper.java
@@ -21,9 +21,6 @@ import android.util.Log;
import com.android.server.wifi.WifiNative;
-import java.util.Collections;
-import java.util.List;
-
/**
* KnownBandsChannelHelper that uses band to channel mappings retrieved from wificond.
* Also supporting updating the channel list from the wificond on demand.
@@ -35,27 +32,30 @@ public class WificondChannelHelper extends KnownBandsChannelHelper {
public WificondChannelHelper(WifiNative wifiNative) {
mWifiNative = wifiNative;
- final List<Integer> emptyFreqList = Collections.emptyList();
+ final int[] emptyFreqList = new int[0];
setBandChannels(emptyFreqList, emptyFreqList, emptyFreqList, emptyFreqList);
updateChannels();
}
@Override
public void updateChannels() {
- List<Integer> channels24G =
+ int[] channels24G =
mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ);
- if (channels24G.isEmpty()) Log.e(TAG, "Failed to get channels for 2.4GHz band");
- List<Integer> channels5G = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ);
- if (channels5G.isEmpty()) Log.e(TAG, "Failed to get channels for 5GHz band");
- List<Integer> channelsDfs =
+ if (channels24G == null) Log.e(TAG, "Failed to get channels for 2.4GHz band");
+ int[] channels5G = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ);
+ if (channels5G == null) Log.e(TAG, "Failed to get channels for 5GHz band");
+ int[] channelsDfs =
mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY);
- if (channelsDfs.isEmpty()) Log.e(TAG, "Failed to get channels for 5GHz DFS only band");
- List<Integer> channels6G =
+ if (channelsDfs == null) Log.e(TAG, "Failed to get channels for 5GHz DFS only band");
+ int[] channels6G =
mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_6_GHZ);
- if (channels6G.isEmpty()) Log.e(TAG, "Failed to get channels for 6GHz band");
+ if (channels6G == null) Log.e(TAG, "Failed to get channels for 6GHz band");
- if (!channels24G.isEmpty() || !channels5G.isEmpty() || !channelsDfs.isEmpty()
- || !channels6G.isEmpty()) {
+ if (channels24G == null || channels5G == null || channelsDfs == null
+ || channels6G == null) {
+ Log.e(TAG, "Failed to get all channels for band, not updating band channel lists");
+ } else if (channels24G.length > 0 || channels5G.length > 0 || channelsDfs.length > 0
+ || channels6G.length > 0) {
setBandChannels(channels24G, channels5G, channelsDfs, channels6G);
} else {
Log.e(TAG, "Got zero length for all channel lists");
diff --git a/service/java/com/android/server/wifi/util/ApConfigUtil.java b/service/java/com/android/server/wifi/util/ApConfigUtil.java
index 4a0a3f8d4..33f08e8d6 100644
--- a/service/java/com/android/server/wifi/util/ApConfigUtil.java
+++ b/service/java/com/android/server/wifi/util/ApConfigUtil.java
@@ -256,13 +256,17 @@ public class ApConfigUtil {
}
// Get the allowed list of channel frequencies in MHz
- List<Integer> regulatoryList = new ArrayList<>(wifiNative.getChannelsForBand(scannerBand));
+ int[] regulatoryArray = wifiNative.getChannelsForBand(scannerBand);
+ List<Integer> regulatoryList = new ArrayList<Integer>();
+ for (int freq : regulatoryArray) {
+ regulatoryList.add(freq);
+ }
if (configuredList == null || configuredList.isEmpty()) {
return regulatoryList;
}
- List<Integer> filteredList = new ArrayList<>();
+ List<Integer> filteredList = new ArrayList<Integer>();
// Otherwise, filter the configured list
for (int channel : configuredList) {
int channelFreq = convertChannelToFrequency(channel, band);
diff --git a/service/java/com/android/server/wifi/util/InformationElementUtil.java b/service/java/com/android/server/wifi/util/InformationElementUtil.java
index 0057b4ec2..b35b20a17 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.wificond.NativeScanResult;
import android.net.wifi.wificond.WifiCondManager;
import android.util.Log;
@@ -892,10 +893,6 @@ public class InformationElementUtil {
* by wpa_supplicant.
*/
public static class Capabilities {
- private static final int CAP_ESS_BITMASK = 0x1 << 0;
- private static final int CAP_IBSS_BITMASK = 0x1 << 1;
- private static final int CAP_PRIVACY_BITMASK = 0x1 << 4;
-
private static final int WPA_VENDOR_OUI_TYPE_ONE = 0x01f25000;
private static final int WPS_VENDOR_OUI_TYPE = 0x04f25000;
private static final short WPA_VENDOR_OUI_VERSION = 0x0001;
@@ -1181,9 +1178,9 @@ public class InformationElementUtil {
if (ies == null) {
return;
}
- isESS = (beaconCap & CAP_ESS_BITMASK) != 0;
- isIBSS = (beaconCap & CAP_IBSS_BITMASK) != 0;
- isPrivacy = (beaconCap & CAP_PRIVACY_BITMASK) != 0;
+ isESS = (beaconCap & NativeScanResult.BSS_CAPABILITY_ESS) != 0;
+ isIBSS = (beaconCap & NativeScanResult.BSS_CAPABILITY_IBSS) != 0;
+ isPrivacy = (beaconCap & NativeScanResult.BSS_CAPABILITY_PRIVACY) != 0;
for (InformationElement ie : ies) {
WifiCondManager.OemSecurityType oemSecurityType =
WifiCondManager.parseOemSecurityTypeElement(