summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/Android.mk1
-rw-r--r--service/java/com/android/server/wifi/HalDeviceManager.java4
-rw-r--r--service/java/com/android/server/wifi/WifiNative.java21
-rw-r--r--service/java/com/android/server/wifi/WifiVendorHal.java96
4 files changed, 115 insertions, 7 deletions
diff --git a/service/Android.mk b/service/Android.mk
index b6288be07..27ecf219b 100644
--- a/service/Android.mk
+++ b/service/Android.mk
@@ -63,6 +63,7 @@ LOCAL_JAVA_LIBRARIES := \
services
LOCAL_STATIC_JAVA_LIBRARIES := \
android.hardware.wifi-V1.0-java \
+ android.hardware.wifi-V1.1-java \
android.hardware.wifi.supplicant-V1.0-java
LOCAL_REQUIRED_MODULES := services
LOCAL_MODULE_TAGS :=
diff --git a/service/java/com/android/server/wifi/HalDeviceManager.java b/service/java/com/android/server/wifi/HalDeviceManager.java
index 2bf3dd455..383a76150 100644
--- a/service/java/com/android/server/wifi/HalDeviceManager.java
+++ b/service/java/com/android/server/wifi/HalDeviceManager.java
@@ -170,7 +170,7 @@ public class HalDeviceManager {
*
* @return A set of IfaceTypes constants (possibly empty, e.g. on error).
*/
- Set<Integer> getSupportedIfaceTypes() {
+ public Set<Integer> getSupportedIfaceTypes() {
return getSupportedIfaceTypesInternal(null);
}
@@ -179,7 +179,7 @@ public class HalDeviceManager {
*
* @return A set of IfaceTypes constants (possibly empty, e.g. on error).
*/
- Set<Integer> getSupportedIfaceTypes(IWifiChip chip) {
+ public Set<Integer> getSupportedIfaceTypes(IWifiChip chip) {
return getSupportedIfaceTypesInternal(chip);
}
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 20c9bad26..56ddbc876 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -1683,6 +1683,27 @@ public class WifiNative {
return mWifiVendorHal.configureRoaming(new RoamingConfig());
}
+ /**
+ * Set the TX power limit.
+ * Primarily used for meeting SAR requirements during voice calls.
+ *
+ * @param powerLevelInDbm Power level to set in dBm.
+ * @return true for success; false for failure or if the HAL version does not support this API.
+ */
+ public boolean setTxPowerLimit(int powerLevelInDbm) {
+ return mWifiVendorHal.setTxPowerLimit(powerLevelInDbm);
+ }
+
+ /**
+ * Reset the TX power limit.
+ * Primarily used for meeting SAR requirements during voice calls.
+ *
+ * @return true for success; false for failure or if the HAL version does not support this API.
+ */
+ public boolean resetTxPowerLimit() {
+ return mWifiVendorHal.resetTxPowerLimit();
+ }
+
/********************************************************
* JNI operations
********************************************************/
diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java
index 976eee4a9..50bbe750c 100644
--- a/service/java/com/android/server/wifi/WifiVendorHal.java
+++ b/service/java/com/android/server/wifi/WifiVendorHal.java
@@ -778,9 +778,35 @@ public class WifiVendorHal {
}
/**
+ * Translation table used by getSupportedFeatureSet for translating IWifiChip caps
+ */
+ private static final int[][] sChipFeatureCapabilityTranslation = {
+ {WifiManager.WIFI_FEATURE_TX_POWER_LIMIT,
+ android.hardware.wifi.V1_1.IWifiChip.ChipCapabilityMask.SET_TX_POWER_LIMIT
+ },
+ };
+
+ /**
+ * Feature bit mask translation for Chip
+ *
+ * @param capabilities bitmask defined IWifiChip.ChipCapabilityMask
+ * @return bitmask defined by WifiManager.WIFI_FEATURE_*
+ */
+ @VisibleForTesting
+ int wifiFeatureMaskFromChipCapabilities(int capabilities) {
+ int features = 0;
+ for (int i = 0; i < sChipFeatureCapabilityTranslation.length; i++) {
+ if ((capabilities & sChipFeatureCapabilityTranslation[i][1]) != 0) {
+ features |= sChipFeatureCapabilityTranslation[i][0];
+ }
+ }
+ return features;
+ }
+
+ /**
* Translation table used by getSupportedFeatureSet for translating IWifiStaIface caps
*/
- private static final int[][] sFeatureCapabilityTranslation = {
+ private static final int[][] sStaFeatureCapabilityTranslation = {
{WifiManager.WIFI_FEATURE_INFRA_5G,
IWifiStaIface.StaIfaceCapabilityMask.STA_5G
},
@@ -831,9 +857,9 @@ public class WifiVendorHal {
@VisibleForTesting
int wifiFeatureMaskFromStaCapabilities(int capabilities) {
int features = 0;
- for (int i = 0; i < sFeatureCapabilityTranslation.length; i++) {
- if ((capabilities & sFeatureCapabilityTranslation[i][1]) != 0) {
- features |= sFeatureCapabilityTranslation[i][0];
+ for (int i = 0; i < sStaFeatureCapabilityTranslation.length; i++) {
+ if ((capabilities & sStaFeatureCapabilityTranslation[i][1]) != 0) {
+ features |= sStaFeatureCapabilityTranslation[i][0];
}
}
return features;
@@ -854,10 +880,16 @@ public class WifiVendorHal {
try {
final MutableInt feat = new MutableInt(0);
synchronized (sLock) {
+ if (mIWifiChip != null) {
+ mIWifiChip.getCapabilities((status, capabilities) -> {
+ if (!ok(status)) return;
+ feat.value = wifiFeatureMaskFromChipCapabilities(capabilities);
+ });
+ }
if (mIWifiStaIface != null) {
mIWifiStaIface.getCapabilities((status, capabilities) -> {
if (!ok(status)) return;
- feat.value = wifiFeatureMaskFromStaCapabilities(capabilities);
+ feat.value |= wifiFeatureMaskFromStaCapabilities(capabilities);
});
}
}
@@ -2321,6 +2353,60 @@ public class WifiVendorHal {
}
}
+ /**
+ * Method to mock out the V1_1 IWifiChip retrieval in unit tests.
+ *
+ * @return 1.1 IWifiChip object if the device is running the 1.1 wifi hal service, null
+ * otherwise.
+ */
+ protected android.hardware.wifi.V1_1.IWifiChip getWifiChipForV1_1Mockable() {
+ if (mIWifiChip == null) return null;
+ return android.hardware.wifi.V1_1.IWifiChip.castFrom(mIWifiChip);
+ }
+
+ /**
+ * Set the TX power limit.
+ * Primarily used for meeting SAR requirements during voice calls.
+ *
+ * @param powerLevelInDbm Power level to set in dBm.
+ * @return true for success; false for failure or if the HAL version does not support this API.
+ */
+ public boolean setTxPowerLimit(int powerLevelInDbm) {
+ synchronized (sLock) {
+ try {
+ android.hardware.wifi.V1_1.IWifiChip iWifiChipV11 = getWifiChipForV1_1Mockable();
+ if (iWifiChipV11 == null) return boolResult(false);
+ WifiStatus status = iWifiChipV11.setTxPowerLimit(powerLevelInDbm);
+ if (!ok(status)) return false;
+ } catch (RemoteException e) {
+ handleRemoteException(e);
+ return false;
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Reset the TX power limit.
+ * Primarily used for meeting SAR requirements during voice calls.
+ *
+ * @return true for success; false for failure or if the HAL version does not support this API.
+ */
+ public boolean resetTxPowerLimit() {
+ synchronized (sLock) {
+ try {
+ android.hardware.wifi.V1_1.IWifiChip iWifiChipV11 = getWifiChipForV1_1Mockable();
+ if (iWifiChipV11 == null) return boolResult(false);
+ WifiStatus status = iWifiChipV11.resetTxPowerLimit();
+ if (!ok(status)) return false;
+ } catch (RemoteException e) {
+ handleRemoteException(e);
+ return false;
+ }
+ return true;
+ }
+ }
+
// This creates a blob of IE elements from the array received.
// TODO: This ugly conversion can be removed if we put IE elements in ScanResult.
private static byte[] hidlIeArrayToFrameworkIeBlob(ArrayList<WifiInformationElement> ies) {