From 1735d4549641ff431997446d02f59810953bda9e Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Mon, 6 Apr 2020 15:12:28 -0700 Subject: HalDeviceManager: Add a new query API for device capabilities This will return whether the HAL iface combination supports the requested iface combination or not. Use this new API to respond to WifiManager.isStaApConcurrencySupported() public API. Also, added dump of chip capabilities in dumpsys. Bug: 153204351 Test: atest android.net.wifi.cts.WifiManagerTest#testIsStaApConcurrencySupported Ran tests on both taimen (STA + AP not supported) and crosshatch (STA + AP supported) Test: atest com.android.server.wifi Change-Id: If3ad4693514a5715759a2bbc20c62f76c7e12c19 --- .../android/server/wifi/ActiveModeWardenTest.java | 40 +----- .../android/server/wifi/HalDeviceManagerTest.java | 146 +++++++++++++++++++++ .../android/server/wifi/WifiApConfigStoreTest.java | 12 +- .../android/server/wifi/WifiServiceImplTest.java | 4 +- 4 files changed, 159 insertions(+), 43 deletions(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java index c68cd9ac5..701ffb345 100644 --- a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java @@ -2151,41 +2151,11 @@ public class ActiveModeWardenTest extends WifiBaseTest { } @Test - public void canSupportAtleastOneConcurrentClientAndSoftApManager() throws Exception { - assertNotNull(mClientIfaceAvailableListener.getValue()); - assertNotNull(mSoftApIfaceAvailableListener.getValue()); - - // No mode manager - assertFalse(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); - - // client mode manager active, but cannot create one more softap manager - enterClientModeActiveState(); - assertFalse(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); - - // client mode manager active, can create one more softap manager - mSoftApIfaceAvailableListener.getValue().onAvailabilityChanged(true); - mLooper.dispatchAll(); - assertTrue(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); - - // Tear down client mode manager - enterStaDisabledMode(false); + public void isStaApConcurrencySupported() throws Exception { + when(mWifiNative.isStaApConcurrencySupported()).thenReturn(false); + assertFalse(mActiveModeWarden.isStaApConcurrencySupported()); - // active softap manager, but cannot create one more client mode manager - reset(mSoftApManager, mBatteryStats); - enterSoftApActiveMode(); - assertFalse(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); - - // active softap manager, can create one more client mode manager - mClientIfaceAvailableListener.getValue().onAvailabilityChanged(true); - mLooper.dispatchAll(); - assertTrue(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); - - // softap manager + client mode manager active, cannot create any more mode managers - reset(mClientModeManager, mBatteryStats, mScanRequestProxy); - enterClientModeActiveState(); - mSoftApIfaceAvailableListener.getValue().onAvailabilityChanged(false); - mClientIfaceAvailableListener.getValue().onAvailabilityChanged(false); - mLooper.dispatchAll(); - assertTrue(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); + when(mWifiNative.isStaApConcurrencySupported()).thenReturn(true); + assertTrue(mActiveModeWarden.isStaApConcurrencySupported()); } } diff --git a/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java b/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java index 36bf52b6b..1b195cfc7 100644 --- a/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java @@ -56,6 +56,7 @@ import android.os.Handler; import android.os.IHwBinder; import android.os.test.TestLooper; import android.util.Log; +import android.util.SparseArray; import androidx.test.filters.SmallTest; @@ -1361,6 +1362,66 @@ public class HalDeviceManagerTest extends WifiBaseTest { assertEquals(correctResults, results); } + /** + * Validate {@link HalDeviceManager#canSupportIfaceCombo(SparseArray)} + */ + @Test + public void testCanSupportIfaceComboTestChipV1() throws Exception { + final String name = "wlan0"; + + TestChipV1 chipMock = new TestChipV1(); + chipMock.initialize(); + mInOrder = inOrder(mServiceManagerMock, mWifiMock, chipMock.chip, + mManagerStatusListenerMock); + executeAndValidateInitializationSequence(); + executeAndValidateStartupSequence(); + + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.AP, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.P2P, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.NAN, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 1); + put(IfaceType.P2P, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 1); + put(IfaceType.NAN, 1); + }} + )); + + assertFalse(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 1); + put(IfaceType.AP, 1); + }} + )); + assertFalse(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 2); + }} + )); + assertFalse(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.P2P, 1); + put(IfaceType.NAN, 1); + }} + )); + + verifyNoMoreInteractions(mManagerStatusListenerMock); + } + + ////////////////////////////////////////////////////////////////////////////////////// // TestChipV2 Specific Tests ////////////////////////////////////////////////////////////////////////////////////// @@ -1632,6 +1693,91 @@ public class HalDeviceManagerTest extends WifiBaseTest { assertEquals(correctResults, results); } + /** + * Validate {@link HalDeviceManager#canSupportIfaceCombo(SparseArray)} + */ + @Test + public void testCanSupportIfaceComboTestChipV2() throws Exception { + final String name = "wlan0"; + + TestChipV2 chipMock = new TestChipV2(); + chipMock.initialize(); + mInOrder = inOrder(mServiceManagerMock, mWifiMock, chipMock.chip, + mManagerStatusListenerMock); + executeAndValidateInitializationSequence(); + executeAndValidateStartupSequence(); + + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.AP, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.P2P, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.NAN, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 1); + put(IfaceType.P2P, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 1); + put(IfaceType.NAN, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 1); + put(IfaceType.AP, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 2); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.P2P, 1); + put(IfaceType.AP, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 1); + put(IfaceType.P2P, 1); + put(IfaceType.AP, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 1); + put(IfaceType.AP, 1); + put(IfaceType.NAN, 1); + }} + )); + + assertFalse(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.P2P, 1); + put(IfaceType.NAN, 1); + }} + )); + assertFalse(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.AP, 2); + }} + )); + assertFalse(mDut.canSupportIfaceCombo(new SparseArray() {{ + put(IfaceType.STA, 2); + put(IfaceType.AP, 1); + }} + )); + + verifyNoMoreInteractions(mManagerStatusListenerMock); + } + ////////////////////////////////////////////////////////////////////////////////////// // TestChipV3 Specific Tests ////////////////////////////////////////////////////////////////////////////////////// diff --git a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java index 3a5ce5272..50fd4d8c1 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java @@ -112,7 +112,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { mResources.setString(R.string.wifi_localhotspot_configure_ssid_default, TEST_DEFAULT_HOTSPOT_SSID); /* Default to device that does not require ap band conversion */ - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(false); when(mContext.getResources()).thenReturn(mResources); @@ -282,7 +282,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { */ @Test public void convertDevice5GhzToAny() throws Exception { - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); /* Initialize WifiApConfigStore with default configuration. */ @@ -321,7 +321,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { */ @Test public void deviceAnyNotConverted() throws Exception { - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); /* Initialize WifiApConfigStore with default configuration. */ @@ -350,7 +350,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { */ @Test public void deviceWithChannelNotConverted() throws Exception { - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); /* Initialize WifiApConfigStore with default configuration. */ @@ -380,7 +380,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { */ @Test public void device5GhzConvertedToAnyAtRetrieval() throws Exception { - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); SoftApConfiguration persistedConfig = setupApConfig( @@ -414,7 +414,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { */ @Test public void deviceNotConvertedAtRetrieval() throws Exception { - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); SoftApConfiguration persistedConfig = setupApConfig( diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index ca8c9dbc6..b5c5e7b42 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -5632,14 +5632,14 @@ public class WifiServiceImplTest extends WifiBaseTest { when(mClientModeImpl.syncGetSupportedFeatures( any())).thenReturn(supportedFeaturesFromClientModeImpl); - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(false); mLooper.startAutoDispatch(); assertEquals(supportedFeaturesFromClientModeImpl, mWifiServiceImpl.getSupportedFeatures()); mLooper.stopAutoDispatchAndIgnoreExceptions(); - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); mLooper.startAutoDispatch(); assertEquals(supportedFeaturesFromClientModeImpl | WifiManager.WIFI_FEATURE_AP_STA, -- cgit v1.2.3