summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2017-02-10 12:11:04 -0800
committerEtan Cohen <etancohen@google.com>2017-02-10 15:15:26 -0800
commit307acde0b29838b817a4fd3659a46c22be0ea314 (patch)
treede3e67263053a0038a991d23c12809cfdf26a03f /service
parentde617e06ecf10ca13f382b67743e3a1489decfe6 (diff)
[HAL Device Manager] API to return available interfaces
Return the set of interfaces supported by the device (all chips) or a particular chip. Bug: 35101185 Test: (new) unit tests Change-Id: I02c7efd0ec1c11aa2301fe7192d202ce40053f24
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/HalDeviceManager.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/HalDeviceManager.java b/service/java/com/android/server/wifi/HalDeviceManager.java
index 9d5648044..46083b4a1 100644
--- a/service/java/com/android/server/wifi/HalDeviceManager.java
+++ b/service/java/com/android/server/wifi/HalDeviceManager.java
@@ -147,6 +147,24 @@ public class HalDeviceManager {
void onStatusChanged();
}
+ /**
+ * Return the set of supported interface types across all Wi-Fi chips on the device.
+ *
+ * @return A set of IfaceTypes constants. Or null on error.
+ */
+ Set<Integer> getSupportedIfaceTypes() {
+ return getSupportedIfaceTypesInternal(null);
+ }
+
+ /**
+ * Return the set of supported interface types for the specified Wi-Fi chip.
+ *
+ * @return A set of IfaceTypes constants. Or null on error.
+ */
+ Set<Integer> getSupportedIfaceTypes(IWifiChip chip) {
+ return getSupportedIfaceTypesInternal(chip);
+ }
+
// interface-specific behavior
/**
@@ -715,6 +733,11 @@ public class HalDeviceManager {
if (DBG) Log.d(TAG, "getAllChipInfo");
synchronized (mLock) {
+ if (mWifi == null) {
+ Log.e(TAG, "getAllChipInfo: called but mWifi is null!?");
+ return null;
+ }
+
try {
MutableBoolean statusOk = new MutableBoolean(false);
Mutable<ArrayList<Integer>> chipIdsResp = new Mutable<>();
@@ -1103,6 +1126,56 @@ public class HalDeviceManager {
}
}
+ Set<Integer> getSupportedIfaceTypesInternal(IWifiChip chip) {
+ WifiChipInfo[] chipInfos = getAllChipInfo();
+ if (chipInfos == null) {
+ Log.e(TAG, "getSupportedIfaceTypesInternal: no chip info found");
+ return null;
+ }
+
+ MutableInt chipIdIfProvided = new MutableInt(0); // NOT using 0 as a magic value
+ if (chip != null) {
+ MutableBoolean statusOk = new MutableBoolean(false);
+ try {
+ chip.getId((WifiStatus status, int id) -> {
+ if (status.code == WifiStatusCode.SUCCESS) {
+ chipIdIfProvided.value = id;
+ statusOk.value = true;
+ } else {
+ Log.e(TAG, "getSupportedIfaceTypesInternal: IWifiChip.getId() error: "
+ + statusString(status));
+ statusOk.value = false;
+ }
+ });
+ } catch (RemoteException e) {
+ Log.e(TAG, "getSupportedIfaceTypesInternal IWifiChip.getId() exception: " + e);
+ return null;
+ }
+ if (!statusOk.value) {
+ return null;
+ }
+ }
+
+ Set<Integer> results = new HashSet<>();
+ for (WifiChipInfo wci: chipInfos) {
+ if (chip != null && wci.chipId != chipIdIfProvided.value) {
+ continue;
+ }
+
+ for (IWifiChip.ChipMode cm: wci.availableModes) {
+ for (IWifiChip.ChipIfaceCombination cic: cm.availableCombinations) {
+ for (IWifiChip.ChipIfaceCombinationLimit cicl: cic.limits) {
+ for (int type: cicl.types) {
+ results.add(type);
+ }
+ }
+ }
+ }
+ }
+
+ return results;
+ }
+
private IWifiIface createIface(int ifaceType, InterfaceDestroyedListener destroyedListener,
Looper looper) {
if (DBG) Log.d(TAG, "createIface: ifaceType=" + ifaceType);