summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-07-12 18:57:08 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-07-12 18:57:08 +0000
commit467ad9b2e48b20ae087da3cd4d8a4ffb97822f90 (patch)
treeeee7a28977ff467ea81073ccdbe47b5312fd30bc /tests
parentfcbfa80a8deed21b2c7e6f43f9b1305f73b89132 (diff)
parentf96c17f4f142156b04346368f9d6c1bd2f2e60c8 (diff)
Merge "WifiVendorHal: Add support for new SAR related HAL API's" into oc-dr1-dev am: 94e6a40d25
am: f96c17f4f1 Change-Id: I90b4e71e3b61af95f2ccd08facd0d949d9243e75
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java125
1 files changed, 124 insertions, 1 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
index 34ddf2378..f1d451cae 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
@@ -24,6 +24,7 @@ import android.hardware.wifi.V1_0.IWifiRttController;
import android.hardware.wifi.V1_0.IWifiRttControllerEventCallback;
import android.hardware.wifi.V1_0.IWifiStaIface;
import android.hardware.wifi.V1_0.IWifiStaIfaceEventCallback;
+import android.hardware.wifi.V1_0.IfaceType;
import android.hardware.wifi.V1_0.RttCapabilities;
import android.hardware.wifi.V1_0.RttConfig;
import android.hardware.wifi.V1_0.StaApfPacketFilterCapabilities;
@@ -55,6 +56,7 @@ import android.net.wifi.WifiManager;
import android.net.wifi.WifiScanner;
import android.net.wifi.WifiSsid;
import android.net.wifi.WifiWakeReasonAndCounts;
+import android.os.Looper;
import android.os.RemoteException;
import android.os.test.TestLooper;
import android.util.Pair;
@@ -75,8 +77,10 @@ import org.mockito.stubbing.Answer;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Random;
+import java.util.Set;
/**
* Unit tests for {@link com.android.server.wifi.WifiVendorHal}.
@@ -98,6 +102,8 @@ public class WifiVendorHalTest {
@Mock
private IWifiChip mIWifiChip;
@Mock
+ private android.hardware.wifi.V1_1.IWifiChip mIWifiChipV11;
+ @Mock
private IWifiStaIface mIWifiStaIface;
@Mock
private IWifiRttController mIWifiRttController;
@@ -107,6 +113,21 @@ public class WifiVendorHalTest {
private WifiNative.VendorHalDeathEventHandler mVendorHalDeathHandler;
/**
+ * Spy used to return the V1_1 IWifiChip mock object to simulate the 1.1 HAL running on the
+ * device.
+ */
+ private class WifiVendorHalSpyV1_1 extends WifiVendorHal {
+ WifiVendorHalSpyV1_1(HalDeviceManager halDeviceManager, Looper looper) {
+ super(halDeviceManager, looper);
+ }
+
+ @Override
+ protected android.hardware.wifi.V1_1.IWifiChip getWifiChipForV1_1Mockable() {
+ return mIWifiChipV11;
+ }
+ }
+
+ /**
* Identity function to supply a type to its argument, which is a lambda
*/
static Answer<WifiStatus> answerWifiStatus(Answer<WifiStatus> statusLambda) {
@@ -560,7 +581,7 @@ public class WifiVendorHalTest {
* driven we don't have to work hard to exercise all of it.
*/
@Test
- public void testFeatureMaskTranslation() {
+ public void testStaIfaceFeatureMaskTranslation() {
int caps = (
IWifiStaIface.StaIfaceCapabilityMask.BACKGROUND_SCAN
| IWifiStaIface.StaIfaceCapabilityMask.LINK_LAYER_STATS
@@ -572,6 +593,62 @@ public class WifiVendorHalTest {
}
/**
+ * Test translation to WifiManager.WIFI_FEATURE_*
+ *
+ * Just do a spot-check with a few feature bits here; since the code is table-
+ * driven we don't have to work hard to exercise all of it.
+ */
+ @Test
+ public void testChipFeatureMaskTranslation() {
+ int caps = android.hardware.wifi.V1_1.IWifiChip.ChipCapabilityMask.SET_TX_POWER_LIMIT;
+ int expected = WifiManager.WIFI_FEATURE_TX_POWER_LIMIT;
+ assertEquals(expected, mWifiVendorHal.wifiFeatureMaskFromChipCapabilities(caps));
+ }
+
+ /**
+ * Test get supported features. Tests whether we coalesce information from different sources
+ * (IWifiStaIface, IWifiChip and HalDeviceManager) into the bitmask of supported features
+ * correctly.
+ */
+ @Test
+ public void testGetSupportedFeatures() throws Exception {
+ assertTrue(mWifiVendorHal.startVendorHal(true));
+
+ int staIfaceHidlCaps = (
+ IWifiStaIface.StaIfaceCapabilityMask.BACKGROUND_SCAN
+ | IWifiStaIface.StaIfaceCapabilityMask.LINK_LAYER_STATS
+ );
+ int chipHidlCaps =
+ android.hardware.wifi.V1_1.IWifiChip.ChipCapabilityMask.SET_TX_POWER_LIMIT;
+ Set<Integer> halDeviceManagerSupportedIfaces = new HashSet<Integer>() {{
+ add(IfaceType.STA);
+ add(IfaceType.P2P);
+ }};
+ int expectedFeatureSet = (
+ WifiManager.WIFI_FEATURE_SCANNER
+ | WifiManager.WIFI_FEATURE_LINK_LAYER_STATS
+ | WifiManager.WIFI_FEATURE_TX_POWER_LIMIT
+ | WifiManager.WIFI_FEATURE_INFRA
+ | WifiManager.WIFI_FEATURE_P2P
+ );
+
+ doAnswer(new AnswerWithArguments() {
+ public void answer(IWifiStaIface.getCapabilitiesCallback cb) throws RemoteException {
+ cb.onValues(mWifiStatusSuccess, staIfaceHidlCaps);
+ }
+ }).when(mIWifiStaIface).getCapabilities(any(IWifiStaIface.getCapabilitiesCallback.class));
+ doAnswer(new AnswerWithArguments() {
+ public void answer(IWifiChip.getCapabilitiesCallback cb) throws RemoteException {
+ cb.onValues(mWifiStatusSuccess, chipHidlCaps);
+ }
+ }).when(mIWifiChip).getCapabilities(any(IWifiChip.getCapabilitiesCallback.class));
+ when(mHalDeviceManager.getSupportedIfaceTypes())
+ .thenReturn(halDeviceManagerSupportedIfaces);
+
+ assertEquals(expectedFeatureSet, mWifiVendorHal.getSupportedFeatureSet());
+ }
+
+ /**
* Test enablement of link layer stats after startup
*
* Request link layer stats before HAL start
@@ -1758,6 +1835,52 @@ public class WifiVendorHalTest {
verify(mVendorHalDeathHandler).onDeath();
}
+ /**
+ * Test the new setTxPowerLimit HIDL method invocation. This should return failure if the
+ * HAL service is exposing the 1.0 interface.
+ */
+ @Test
+ public void testSetTxPowerLimit() throws RemoteException {
+ int powerLevelInDbm = -45;
+
+ assertTrue(mWifiVendorHal.startVendorHal(true));
+ // Should fail because we exposed the 1.0 IWifiChip.
+ assertFalse(mWifiVendorHal.setTxPowerLimit(powerLevelInDbm));
+ verify(mIWifiChipV11, never()).setTxPowerLimit(eq(powerLevelInDbm));
+ mWifiVendorHal.stopVendorHal();
+
+ // Now expose the 1.1 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV11.setTxPowerLimit(anyInt())).thenReturn(mWifiStatusSuccess);
+
+ assertTrue(mWifiVendorHal.startVendorHal(true));
+ assertTrue(mWifiVendorHal.setTxPowerLimit(powerLevelInDbm));
+ verify(mIWifiChipV11).setTxPowerLimit(eq(powerLevelInDbm));
+ mWifiVendorHal.stopVendorHal();
+ }
+
+ /**
+ * Test the new setTxPowerLimit HIDL method invocation. This should return failure if the
+ * HAL service is exposing the 1.0 interface.
+ */
+ @Test
+ public void testResetTxPowerLimit() throws RemoteException {
+ assertTrue(mWifiVendorHal.startVendorHal(true));
+ // Should fail because we exposed the 1.0 IWifiChip.
+ assertFalse(mWifiVendorHal.resetTxPowerLimit());
+ verify(mIWifiChipV11, never()).resetTxPowerLimit();
+ mWifiVendorHal.stopVendorHal();
+
+ // Now expose the 1.1 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV11.resetTxPowerLimit()).thenReturn(mWifiStatusSuccess);
+
+ assertTrue(mWifiVendorHal.startVendorHal(true));
+ assertTrue(mWifiVendorHal.resetTxPowerLimit());
+ verify(mIWifiChipV11).resetTxPowerLimit();
+ mWifiVendorHal.stopVendorHal();
+ }
+
private void startBgScan(WifiNative.ScanEventHandler eventHandler) throws Exception {
when(mIWifiStaIface.startBackgroundScan(
anyInt(), any(StaBackgroundScanParameters.class))).thenReturn(mWifiStatusSuccess);