diff options
author | Etan Cohen <etancohen@google.com> | 2018-03-01 17:55:14 -0800 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2018-03-01 18:56:05 -0800 |
commit | 7dadc4d68ea820779ec513073347890b842a6f9c (patch) | |
tree | 3635e4c02ac9c594b6d868dca616eee3d19ba4f8 | |
parent | f889b032189894962c283b003f9f63fadde4c592 (diff) |
[HDM] Pipe through argument to create low priority STA (scanning STA)
Add argument to specify creation of a low priority STA (scanning STA)
or not (normal STA). The CL only adds the argument and modifies all
calling code and test code.
No functional change in behavior!
Bug: 74078114
Test: unit tests pass
Change-Id: Ic4f5c153dd3a4dd68930b40f5e2cd25315f91a90
10 files changed, 112 insertions, 73 deletions
diff --git a/service/java/com/android/server/wifi/HalDeviceManager.java b/service/java/com/android/server/wifi/HalDeviceManager.java index 8928472fc..8cfeca2bc 100644 --- a/service/java/com/android/server/wifi/HalDeviceManager.java +++ b/service/java/com/android/server/wifi/HalDeviceManager.java @@ -210,6 +210,10 @@ public class HalDeviceManager { * Create a STA interface if possible. Changes chip mode and removes conflicting interfaces if * needed and permitted by priority. * + * @param lowPrioritySta Indicates whether the requested STA is a low priority STA. The priority + * and preemption rules for low priority STA are: + * - Do not destroy any interface for it (even another low priority STA) + * - Destroy it for any other request * @param destroyedListener Optional (nullable) listener to call when the allocated interface * is removed. Will only be registered and used if an interface is * created successfully. @@ -218,8 +222,8 @@ public class HalDeviceManager { * iface destruction. * @return A newly created interface - or null if the interface could not be created. */ - public IWifiStaIface createStaIface(@Nullable InterfaceDestroyedListener destroyedListener, - @Nullable Handler handler) { + public IWifiStaIface createStaIface(boolean lowPrioritySta, + @Nullable InterfaceDestroyedListener destroyedListener, @Nullable Handler handler) { return (IWifiStaIface) createIface(IfaceType.STA, destroyedListener, handler); } diff --git a/service/java/com/android/server/wifi/ScanOnlyModeManager.java b/service/java/com/android/server/wifi/ScanOnlyModeManager.java index 30d9383a7..f1351b24f 100644 --- a/service/java/com/android/server/wifi/ScanOnlyModeManager.java +++ b/service/java/com/android/server/wifi/ScanOnlyModeManager.java @@ -162,7 +162,7 @@ public class ScanOnlyModeManager implements ActiveModeManager { public boolean processMessage(Message message) { switch (message.what) { case CMD_START: - mClientInterfaceName = mWifiNative.setupInterfaceForClientMode( + mClientInterfaceName = mWifiNative.setupInterfaceForClientMode(true, mWifiNativeInterfaceCallback); if (TextUtils.isEmpty(mClientInterfaceName)) { Log.e(TAG, "Failed to create ClientInterface. Sit in Idle"); diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index dd1fb4492..908344a15 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -568,10 +568,10 @@ public class WifiNative { * For devices which do not the support the HAL, this will bypass HalDeviceManager & * teardown any existing iface. */ - private String createStaIface(@NonNull Iface iface) { + private String createStaIface(@NonNull Iface iface, boolean lowPrioritySta) { synchronized (mLock) { if (mWifiVendorHal.isVendorHalSupported()) { - return mWifiVendorHal.createStaIface( + return mWifiVendorHal.createStaIface(lowPrioritySta, new InterfaceDestoyedListenerInternal(iface.id)); } else { Log.i(TAG, "Vendor Hal not supported, ignoring createStaIface."); @@ -734,10 +734,13 @@ public class WifiNative { * This method configures an interface in STA mode in all the native daemons * (wificond, wpa_supplicant & vendor HAL). * + * @param lowPrioritySta The requested STA has a low request priority (lower probability of + * getting created, higher probability of getting destroyed). * @param interfaceCallback Associated callback for notifying status changes for the iface. * @return Returns the name of the allocated interface, will be null on failure. */ - public String setupInterfaceForClientMode(@NonNull InterfaceCallback interfaceCallback) { + public String setupInterfaceForClientMode(boolean lowPrioritySta, + @NonNull InterfaceCallback interfaceCallback) { synchronized (mLock) { if (!startHal()) { Log.e(TAG, "Failed to start Hal"); @@ -755,7 +758,7 @@ public class WifiNative { return null; } iface.externalListener = interfaceCallback; - iface.name = createStaIface(iface); + iface.name = createStaIface(iface, lowPrioritySta); if (TextUtils.isEmpty(iface.name)) { Log.e(TAG, "Failed to create iface in vendor HAL"); mIfaceMgr.removeIface(iface.id); diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index c17cf5a0a..24a01e8df 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -3821,7 +3821,7 @@ public class WifiStateMachine extends StateMachine { logStateAndMessage(message, this); switch (message.what) { case CMD_START_SUPPLICANT: - mInterfaceName = mWifiNative.setupInterfaceForClientMode( + mInterfaceName = mWifiNative.setupInterfaceForClientMode(false, mWifiNativeInterfaceCallback); if (TextUtils.isEmpty(mInterfaceName)) { Log.e(TAG, "setup failure when creating client interface."); diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java index 5033d1a39..b91425ef6 100644 --- a/service/java/com/android/server/wifi/WifiVendorHal.java +++ b/service/java/com/android/server/wifi/WifiVendorHal.java @@ -317,7 +317,7 @@ public class WifiVendorHal { if (!startVendorHal()) { return false; } - if (TextUtils.isEmpty(createStaIface(null))) { + if (TextUtils.isEmpty(createStaIface(false, null))) { stopVendorHal(); return false; } @@ -368,12 +368,15 @@ public class WifiVendorHal { /** * Create a STA iface using {@link HalDeviceManager}. * + * @param lowPrioritySta The requested STA has a low request priority (lower probability of + * getting created, higher probability of getting destroyed). * @param destroyedListener Listener to be invoked when the interface is destroyed. * @return iface name on success, null otherwise. */ - public String createStaIface(InterfaceDestroyedListener destroyedListener) { + public String createStaIface(boolean lowPrioritySta, + InterfaceDestroyedListener destroyedListener) { synchronized (sLock) { - IWifiStaIface iface = mHalDeviceManager.createStaIface( + IWifiStaIface iface = mHalDeviceManager.createStaIface(lowPrioritySta, new StaInterfaceDestroyedListenerInternal(destroyedListener), null); if (iface == null) { mLog.err("Failed to create STA iface").flush(); diff --git a/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java b/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java index fbcbca764..3b62d809e 100644 --- a/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java @@ -769,7 +769,7 @@ public class HalDeviceManagerTest { any(IWifiIface.getTypeCallback.class)); doAnswer(new CreateXxxIfaceAnswer(chipMock, mStatusOk, staIface)).when( chipMock.chip).createStaIface(any(IWifiChip.createStaIfaceCallback.class)); - assertEquals(staIface, mDut.createStaIface(staIdl, null)); + assertEquals(staIface, mDut.createStaIface(false, staIdl, null)); mInOrder.verify(chipMock.chip).configureChip(TestChipV1.STA_CHIP_MODE_ID); mInOrder.verify(staIafrl).onAvailabilityChanged(false); @@ -932,7 +932,7 @@ public class HalDeviceManagerTest { inOrderAvail.verify(staAvailListener).onAvailabilityChanged(false); // request STA2: should fail - IWifiIface staIface2 = mDut.createStaIface(null, null); + IWifiIface staIface2 = mDut.createStaIface(false, null, null); collector.checkThat("STA2 should not be created", staIface2, IsNull.nullValue()); // register additional InterfaceDestroyedListeners - including a duplicate (verify that @@ -1115,7 +1115,7 @@ public class HalDeviceManagerTest { verify(staAvailListener1).onAvailabilityChanged(false); // get STA interface again - IWifiIface staIface2 = mDut.createStaIface(staDestroyedListener2, mHandler); + IWifiIface staIface2 = mDut.createStaIface(false, staDestroyedListener2, mHandler); collector.checkThat("STA created", staIface2, IsNull.nullValue()); verifyNoMoreInteractions(mManagerStatusListenerMock, staDestroyedListener1, @@ -1291,7 +1291,7 @@ public class HalDeviceManagerTest { inOrderAvail.verify(staAvailListener).onAvailabilityChanged(false); // request STA2: should fail - IWifiIface staIface2 = mDut.createStaIface(null, null); + IWifiIface staIface2 = mDut.createStaIface(false, null, null); collector.checkThat("STA2 should not be created", staIface2, IsNull.nullValue()); // request AP2: should fail @@ -1324,7 +1324,7 @@ public class HalDeviceManagerTest { inOrderAvail.verify(staAvailListener).onAvailabilityChanged(false); // request STA3: should fail - IWifiIface staIface3 = mDut.createStaIface(null, null); + IWifiIface staIface3 = mDut.createStaIface(false, null, null); collector.checkThat("STA3 should not be created", staIface3, IsNull.nullValue()); // create AP - this will destroy the last STA created, i.e. STA2 @@ -1564,7 +1564,7 @@ public class HalDeviceManagerTest { inOrderAvail.verify(apAvailListener).onAvailabilityChanged(false); // request STA2: should fail - IWifiIface staIface2 = mDut.createStaIface(null, null); + IWifiIface staIface2 = mDut.createStaIface(false, null, null); collector.checkThat("STA2 should not be created", staIface2, IsNull.nullValue()); // request AP2: should fail @@ -1603,7 +1603,7 @@ public class HalDeviceManagerTest { inOrderAvail.verify(staAvailListener).onAvailabilityChanged(false); // request STA3: should fail - IWifiIface staIface3 = mDut.createStaIface(null, null); + IWifiIface staIface3 = mDut.createStaIface(false, null, null); collector.checkThat("STA3 should not be created", staIface3, IsNull.nullValue()); // create NAN: should destroy the last created STA (STA2) @@ -1626,7 +1626,7 @@ public class HalDeviceManagerTest { verify(staDestroyedListener2).onDestroyed(getName(staIface2)); // request STA2: should fail - staIface2 = mDut.createStaIface(null, null); + staIface2 = mDut.createStaIface(false, null, null); collector.checkThat("STA2 should not be created", staIface2, IsNull.nullValue()); verifyNoMoreInteractions(mManagerStatusListenerMock, staDestroyedListener, @@ -1823,7 +1823,7 @@ public class HalDeviceManagerTest { inOrderAvail.verify(apAvailListener).onAvailabilityChanged(false); // request STA2: should fail - IWifiIface staIface2 = mDut.createStaIface(null, null); + IWifiIface staIface2 = mDut.createStaIface(false, null, null); collector.checkThat("STA2 should not be created", staIface2, IsNull.nullValue()); // request AP2: should fail @@ -1845,7 +1845,7 @@ public class HalDeviceManagerTest { verify(apDestroyedListener).onDestroyed(getName(apIface)); // request STA2: should fail - staIface2 = mDut.createStaIface(null, null); + staIface2 = mDut.createStaIface(false, null, null); collector.checkThat("STA2 should not be created", staIface2, IsNull.nullValue()); // create NAN @@ -1864,7 +1864,7 @@ public class HalDeviceManagerTest { inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(false); // request STA2: should fail - staIface2 = mDut.createStaIface(null, null); + staIface2 = mDut.createStaIface(false, null, null); collector.checkThat("STA2 should not be created", staIface2, IsNull.nullValue()); // tear down STA @@ -2213,7 +2213,7 @@ public class HalDeviceManagerTest { doAnswer(new CreateXxxIfaceAnswer(chipMock, mStatusOk, iface)).when( chipMock.chip).createStaIface(any(IWifiChip.createStaIfaceCallback.class)); - mDut.createStaIface(destroyedListener, mHandler); + mDut.createStaIface(false, destroyedListener, mHandler); break; case IfaceType.AP: iface = mock(IWifiApIface.class); diff --git a/tests/wifitests/src/com/android/server/wifi/ScanOnlyModeManagerTest.java b/tests/wifitests/src/com/android/server/wifi/ScanOnlyModeManagerTest.java index 20a2d6880..2556dfcf4 100644 --- a/tests/wifitests/src/com/android/server/wifi/ScanOnlyModeManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ScanOnlyModeManagerTest.java @@ -23,7 +23,17 @@ import static android.net.wifi.WifiManager.WIFI_STATE_ENABLED; import static android.net.wifi.WifiManager.WIFI_STATE_UNKNOWN; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.*; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.anyInt; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; import android.content.Context; import android.content.Intent; @@ -79,12 +89,14 @@ public class ScanOnlyModeManagerTest { } private void startScanOnlyModeAndVerifyEnabled() throws Exception { - when(mWifiNative.setupInterfaceForClientMode(any())).thenReturn(TEST_INTERFACE_NAME); + when(mWifiNative.setupInterfaceForClientMode(anyBoolean(), any())).thenReturn( + TEST_INTERFACE_NAME); mScanOnlyModeManager.start(); mLooper.dispatchAll(); verify(mWifiNative).registerStatusListener(mStatusListenerCaptor.capture()); - verify(mWifiNative).setupInterfaceForClientMode(mInterfaceCallbackCaptor.capture()); + verify(mWifiNative).setupInterfaceForClientMode(eq(true), + mInterfaceCallbackCaptor.capture()); // now mark the interface as up mInterfaceCallbackCaptor.getValue().onUp(TEST_INTERFACE_NAME); @@ -138,7 +150,7 @@ public class ScanOnlyModeManagerTest { */ @Test public void detectAndReportErrorWhenSetupForClientWifiNativeFailure() throws Exception { - when(mWifiNative.setupInterfaceForClientMode(any())).thenReturn(null); + when(mWifiNative.setupInterfaceForClientMode(anyBoolean(), any())).thenReturn(null); mScanOnlyModeManager.start(); mLooper.dispatchAll(); @@ -155,7 +167,7 @@ public class ScanOnlyModeManagerTest { @Test public void scanModeStartDoesNotSendScanningActiveWhenClientInterfaceNameIsEmpty() throws Exception { - when(mWifiNative.setupInterfaceForClientMode(any())).thenReturn(""); + when(mWifiNative.setupInterfaceForClientMode(anyBoolean(), any())).thenReturn(""); mScanOnlyModeManager.start(); mLooper.dispatchAll(); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java index e1d109e15..be8c393ab 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java @@ -22,7 +22,17 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; import android.app.test.MockAnswerUtil; import android.net.InterfaceConfiguration; @@ -96,7 +106,7 @@ public class WifiNativeInterfaceManagementTest { .thenReturn(true); when(mWifiVendorHal.isVendorHalSupported()).thenReturn(true); when(mWifiVendorHal.startVendorHal()).thenReturn(true); - when(mWifiVendorHal.createStaIface(any())).thenReturn(IFACE_NAME_0); + when(mWifiVendorHal.createStaIface(anyBoolean(), any())).thenReturn(IFACE_NAME_0); when(mWifiVendorHal.createApIface(any())).thenReturn(IFACE_NAME_0); when(mWifiVendorHal.removeStaIface(any())).thenReturn(true); when(mWifiVendorHal.removeApIface(any())).thenReturn(true); @@ -416,13 +426,14 @@ public class WifiNativeInterfaceManagementTest { // Trigger the AP interface teardown when STA interface is created. // The iface name will remain the same. doAnswer(new MockAnswerUtil.AnswerWithArguments() { - public String answer(InterfaceDestroyedListener destroyedListener) { + public String answer(boolean lowPrioritySta, + InterfaceDestroyedListener destroyedListener) { mIfaceDestroyedListenerCaptor0.getValue().onDestroyed(IFACE_NAME_0); return IFACE_NAME_0; } - }).when(mWifiVendorHal).createStaIface(any()); + }).when(mWifiVendorHal).createStaIface(anyBoolean(), any()); - assertEquals(IFACE_NAME_0, mWifiNative.setupInterfaceForClientMode(mIfaceCallback1)); + assertEquals(IFACE_NAME_0, mWifiNative.setupInterfaceForClientMode(false, mIfaceCallback1)); mInOrder.verify(mWificondControl).enableSupplicant(); mInOrder.verify(mSupplicantStaIfaceHal).isInitializationStarted(); @@ -430,7 +441,8 @@ public class WifiNativeInterfaceManagementTest { mInOrder.verify(mSupplicantStaIfaceHal).isInitializationComplete(); mInOrder.verify(mSupplicantStaIfaceHal).registerDeathHandler(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); - mInOrder.verify(mWifiVendorHal).createStaIface(mIfaceDestroyedListenerCaptor1.capture()); + mInOrder.verify(mWifiVendorHal).createStaIface(eq(false), + mIfaceDestroyedListenerCaptor1.capture()); // Creation of STA interface should trigger the AP interface destroy. validateOnDestroyedSoftApInterface( true, false, IFACE_NAME_0, mIfaceCallback0, mNetworkObserverCaptor0.getValue()); @@ -585,7 +597,7 @@ public class WifiNativeInterfaceManagementTest { @Test public void testSetupClientInterfaceFailureInStartHal() throws Exception { when(mWifiVendorHal.startVendorHal()).thenReturn(false); - assertNull(mWifiNative.setupInterfaceForClientMode(mIfaceCallback0)); + assertNull(mWifiNative.setupInterfaceForClientMode(false, mIfaceCallback0)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).startVendorHal(); @@ -606,7 +618,7 @@ public class WifiNativeInterfaceManagementTest { @Test public void testSetupClientInterfaceFailureInStartSupplicant() throws Exception { when(mWificondControl.enableSupplicant()).thenReturn(false); - assertNull(mWifiNative.setupInterfaceForClientMode(mIfaceCallback0)); + assertNull(mWifiNative.setupInterfaceForClientMode(false, mIfaceCallback0)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).startVendorHal(); @@ -627,8 +639,8 @@ public class WifiNativeInterfaceManagementTest { */ @Test public void testSetupClientInterfaceFailureInHalCreateStaIface() throws Exception { - when(mWifiVendorHal.createStaIface(any())).thenReturn(null); - assertNull(mWifiNative.setupInterfaceForClientMode(mIfaceCallback0)); + when(mWifiVendorHal.createStaIface(anyBoolean(), any())).thenReturn(null); + assertNull(mWifiNative.setupInterfaceForClientMode(false, mIfaceCallback0)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).startVendorHal(); @@ -638,7 +650,7 @@ public class WifiNativeInterfaceManagementTest { mInOrder.verify(mSupplicantStaIfaceHal).isInitializationComplete(); mInOrder.verify(mSupplicantStaIfaceHal).registerDeathHandler(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); - mInOrder.verify(mWifiVendorHal).createStaIface(any()); + mInOrder.verify(mWifiVendorHal).createStaIface(eq(false), any()); mInOrder.verify(mWifiMetrics).incrementNumWifiOnFailureDueToHal(); // To test if the failure is handled cleanly, invoke teardown and ensure that @@ -657,7 +669,7 @@ public class WifiNativeInterfaceManagementTest { public void testSetupClientInterfaceFailureInWificondSetupInterfaceForClientMode() throws Exception { when(mWificondControl.setupInterfaceForClientMode(any())).thenReturn(null); - assertNull(mWifiNative.setupInterfaceForClientMode(mIfaceCallback0)); + assertNull(mWifiNative.setupInterfaceForClientMode(false, mIfaceCallback0)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).startVendorHal(); @@ -667,7 +679,8 @@ public class WifiNativeInterfaceManagementTest { mInOrder.verify(mSupplicantStaIfaceHal).isInitializationComplete(); mInOrder.verify(mSupplicantStaIfaceHal).registerDeathHandler(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); - mInOrder.verify(mWifiVendorHal).createStaIface(mIfaceDestroyedListenerCaptor0.capture()); + mInOrder.verify(mWifiVendorHal).createStaIface(eq(false), + mIfaceDestroyedListenerCaptor0.capture()); mInOrder.verify(mWificondControl).setupInterfaceForClientMode(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).removeStaIface(any()); @@ -693,7 +706,7 @@ public class WifiNativeInterfaceManagementTest { @Test public void testSetupClientInterfaceFailureInSupplicantSetupIface() throws Exception { when(mSupplicantStaIfaceHal.setupIface(any())).thenReturn(false); - assertNull(mWifiNative.setupInterfaceForClientMode(mIfaceCallback0)); + assertNull(mWifiNative.setupInterfaceForClientMode(false, mIfaceCallback0)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).startVendorHal(); @@ -703,7 +716,8 @@ public class WifiNativeInterfaceManagementTest { mInOrder.verify(mSupplicantStaIfaceHal).isInitializationComplete(); mInOrder.verify(mSupplicantStaIfaceHal).registerDeathHandler(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); - mInOrder.verify(mWifiVendorHal).createStaIface(mIfaceDestroyedListenerCaptor0.capture()); + mInOrder.verify(mWifiVendorHal).createStaIface(eq(false), + mIfaceDestroyedListenerCaptor0.capture()); mInOrder.verify(mWificondControl).setupInterfaceForClientMode(any()); mInOrder.verify(mSupplicantStaIfaceHal).setupIface(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); @@ -730,7 +744,7 @@ public class WifiNativeInterfaceManagementTest { @Test public void testSetupClientInterfaceFailureInNetworkObserverRegister() throws Exception { doThrow(new RemoteException()).when(mNwManagementService).registerObserver(any()); - assertNull(mWifiNative.setupInterfaceForClientMode(mIfaceCallback0)); + assertNull(mWifiNative.setupInterfaceForClientMode(false, mIfaceCallback0)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).startVendorHal(); @@ -740,7 +754,8 @@ public class WifiNativeInterfaceManagementTest { mInOrder.verify(mSupplicantStaIfaceHal).isInitializationComplete(); mInOrder.verify(mSupplicantStaIfaceHal).registerDeathHandler(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); - mInOrder.verify(mWifiVendorHal).createStaIface(mIfaceDestroyedListenerCaptor0.capture()); + mInOrder.verify(mWifiVendorHal).createStaIface(eq(false), + mIfaceDestroyedListenerCaptor0.capture()); mInOrder.verify(mWificondControl).setupInterfaceForClientMode(any()); mInOrder.verify(mSupplicantStaIfaceHal).setupIface(any()); mInOrder.verify(mNwManagementService).registerObserver(mNetworkObserverCaptor0.capture()); @@ -922,7 +937,7 @@ public class WifiNativeInterfaceManagementTest { when(mPropertyService.getString(any(), any())).thenReturn(IFACE_NAME_0); // First setup a STA interface and verify. - assertEquals(IFACE_NAME_0, mWifiNative.setupInterfaceForClientMode(mIfaceCallback0)); + assertEquals(IFACE_NAME_0, mWifiNative.setupInterfaceForClientMode(false, mIfaceCallback0)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWificondControl).enableSupplicant(); @@ -977,7 +992,7 @@ public class WifiNativeInterfaceManagementTest { mInOrder.verify(mNwManagementService).registerObserver(mNetworkObserverCaptor0.capture()); // Now setup a STA interface. - assertEquals(IFACE_NAME_0, mWifiNative.setupInterfaceForClientMode(mIfaceCallback1)); + assertEquals(IFACE_NAME_0, mWifiNative.setupInterfaceForClientMode(false, mIfaceCallback1)); mInOrder.verify(mWificondControl).enableSupplicant(); mInOrder.verify(mSupplicantStaIfaceHal).isInitializationStarted(); @@ -1008,8 +1023,8 @@ public class WifiNativeInterfaceManagementTest { String ifaceName, @Mock WifiNative.InterfaceCallback callback, ArgumentCaptor<InterfaceDestroyedListener> destroyedListenerCaptor, ArgumentCaptor<BaseNetworkObserver> networkObserverCaptor) throws Exception { - when(mWifiVendorHal.createStaIface(any())).thenReturn(ifaceName); - assertEquals(ifaceName, mWifiNative.setupInterfaceForClientMode(callback)); + when(mWifiVendorHal.createStaIface(anyBoolean(), any())).thenReturn(ifaceName); + assertEquals(ifaceName, mWifiNative.setupInterfaceForClientMode(false, callback)); validateSetupClientInterface( existingStaIface, existingApIface, ifaceName, destroyedListenerCaptor, @@ -1032,7 +1047,8 @@ public class WifiNativeInterfaceManagementTest { mInOrder.verify(mSupplicantStaIfaceHal).registerDeathHandler(any()); } mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); - mInOrder.verify(mWifiVendorHal).createStaIface(destroyedListenerCaptor.capture()); + mInOrder.verify(mWifiVendorHal).createStaIface(eq(false), + destroyedListenerCaptor.capture()); mInOrder.verify(mWificondControl).setupInterfaceForClientMode(ifaceName); mInOrder.verify(mSupplicantStaIfaceHal).setupIface(ifaceName); mInOrder.verify(mNwManagementService).registerObserver(networkObserverCaptor.capture()); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 29f8b4847..fe1c2286b 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -410,7 +410,7 @@ public class WifiStateMachineTest { when(mWifiInjector.getWakeupController()).thenReturn(mWakeupController); when(mWifiInjector.getScanRequestProxy()).thenReturn(mScanRequestProxy); - when(mWifiNative.setupInterfaceForClientMode(any())) + when(mWifiNative.setupInterfaceForClientMode(anyBoolean(), any())) .thenReturn(WIFI_IFACE_NAME); when(mWifiNative.initialize()).thenReturn(true); @@ -578,7 +578,7 @@ public class WifiStateMachineTest { @Test public void shouldRequireSupplicantStartupToLeaveInitialState() throws Exception { - when(mWifiNative.setupInterfaceForClientMode(any())).thenReturn(null); + when(mWifiNative.setupInterfaceForClientMode(anyBoolean(), any())).thenReturn(null); mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE); mLooper.dispatchAll(); assertEquals("DefaultState", getCurrentState().getName()); @@ -589,7 +589,7 @@ public class WifiStateMachineTest { @Test public void loadComponentsFailure() throws Exception { - when(mWifiNative.setupInterfaceForClientMode(any())).thenReturn(null); + when(mWifiNative.setupInterfaceForClientMode(anyBoolean(), any())).thenReturn(null); mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE); mLooper.dispatchAll(); @@ -859,7 +859,7 @@ public class WifiStateMachineTest { mLooper.dispatchAll(); verify(mWifiNative, atLeastOnce()) - .setupInterfaceForClientMode(mInterfaceCallbackCaptor.capture()); + .setupInterfaceForClientMode(eq(false), mInterfaceCallbackCaptor.capture()); verify(mWifiLastResortWatchdog, atLeastOnce()).clearAllFailureCounts(); } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java index 2665b8aa1..875cd1b76 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java @@ -221,7 +221,7 @@ public class WifiVendorHalTest { mHalDeviceManagerStatusCallbacks.onStatusChanged(); } }).when(mHalDeviceManager).stop(); - when(mHalDeviceManager.createStaIface(any(), eq(null))) + when(mHalDeviceManager.createStaIface(anyBoolean(), any(), eq(null))) .thenReturn(mIWifiStaIface); when(mHalDeviceManager.createApIface(any(), eq(null))) .thenReturn(mIWifiApIface); @@ -292,7 +292,7 @@ public class WifiVendorHalTest { assertTrue(mWifiVendorHal.isHalStarted()); verify(mHalDeviceManager).start(); - verify(mHalDeviceManager).createStaIface(any(), eq(null)); + verify(mHalDeviceManager).createStaIface(eq(false), any(), eq(null)); verify(mHalDeviceManager).getChip(eq(mIWifiStaIface)); verify(mHalDeviceManager).createRttController(); verify(mHalDeviceManager).isReady(); @@ -318,7 +318,7 @@ public class WifiVendorHalTest { verify(mHalDeviceManager).isReady(); verify(mHalDeviceManager).isStarted(); - verify(mHalDeviceManager, never()).createStaIface(any(), eq(null)); + verify(mHalDeviceManager, never()).createStaIface(anyBoolean(), any(), eq(null)); verify(mHalDeviceManager, never()).createRttController(); } @@ -340,7 +340,7 @@ public class WifiVendorHalTest { verify(mHalDeviceManager).start(); - verify(mHalDeviceManager, never()).createStaIface(any(), eq(null)); + verify(mHalDeviceManager, never()).createStaIface(anyBoolean(), any(), eq(null)); verify(mHalDeviceManager, never()).createApIface(any(), eq(null)); verify(mHalDeviceManager, never()).getChip(any(IWifiIface.class)); verify(mHalDeviceManager, never()).createRttController(); @@ -354,12 +354,12 @@ public class WifiVendorHalTest { */ @Test public void testStartHalFailureInIfaceCreationInStaMode() throws Exception { - when(mHalDeviceManager.createStaIface(any(), eq(null))).thenReturn(null); + when(mHalDeviceManager.createStaIface(anyBoolean(), any(), eq(null))).thenReturn(null); assertFalse(mWifiVendorHal.startVendorHalSta()); assertFalse(mWifiVendorHal.isHalStarted()); verify(mHalDeviceManager).start(); - verify(mHalDeviceManager).createStaIface(any(), eq(null)); + verify(mHalDeviceManager).createStaIface(eq(false), any(), eq(null)); verify(mHalDeviceManager).stop(); verify(mHalDeviceManager, never()).createApIface(any(), eq(null)); @@ -380,7 +380,7 @@ public class WifiVendorHalTest { assertFalse(mWifiVendorHal.isHalStarted()); verify(mHalDeviceManager).start(); - verify(mHalDeviceManager).createStaIface(any(), eq(null)); + verify(mHalDeviceManager).createStaIface(eq(false), any(), eq(null)); verify(mHalDeviceManager).createRttController(); verify(mHalDeviceManager).stop(); verify(mIWifiStaIface).registerEventCallback(any(IWifiStaIfaceEventCallback.class)); @@ -400,7 +400,7 @@ public class WifiVendorHalTest { assertFalse(mWifiVendorHal.isHalStarted()); verify(mHalDeviceManager).start(); - verify(mHalDeviceManager).createStaIface(any(), eq(null)); + verify(mHalDeviceManager).createStaIface(eq(false), any(), eq(null)); verify(mHalDeviceManager).createRttController(); verify(mHalDeviceManager).getChip(any(IWifiIface.class)); verify(mHalDeviceManager).stop(); @@ -421,7 +421,7 @@ public class WifiVendorHalTest { assertFalse(mWifiVendorHal.isHalStarted()); verify(mHalDeviceManager).start(); - verify(mHalDeviceManager).createStaIface(any(), eq(null)); + verify(mHalDeviceManager).createStaIface(eq(false), any(), eq(null)); verify(mHalDeviceManager).stop(); verify(mIWifiStaIface).registerEventCallback(any(IWifiStaIfaceEventCallback.class)); @@ -442,7 +442,7 @@ public class WifiVendorHalTest { assertFalse(mWifiVendorHal.isHalStarted()); verify(mHalDeviceManager).start(); - verify(mHalDeviceManager).createStaIface(any(), eq(null)); + verify(mHalDeviceManager).createStaIface(eq(false), any(), eq(null)); verify(mHalDeviceManager).createRttController(); verify(mHalDeviceManager).getChip(any(IWifiIface.class)); verify(mHalDeviceManager).stop(); @@ -466,7 +466,7 @@ public class WifiVendorHalTest { verify(mHalDeviceManager).createApIface(any(), eq(null)); verify(mHalDeviceManager).stop(); - verify(mHalDeviceManager, never()).createStaIface(any(), eq(null)); + verify(mHalDeviceManager, never()).createStaIface(anyBoolean(), any(), eq(null)); verify(mHalDeviceManager, never()).getChip(any(IWifiIface.class)); verify(mHalDeviceManager, never()).createRttController(); } @@ -485,7 +485,7 @@ public class WifiVendorHalTest { verify(mHalDeviceManager).start(); verify(mHalDeviceManager).stop(); - verify(mHalDeviceManager).createStaIface(any(), eq(null)); + verify(mHalDeviceManager).createStaIface(eq(false), any(), eq(null)); verify(mHalDeviceManager).getChip(eq(mIWifiStaIface)); verify(mHalDeviceManager).createRttController(); verify(mHalDeviceManager, times(2)).isReady(); @@ -513,7 +513,7 @@ public class WifiVendorHalTest { verify(mHalDeviceManager, times(2)).isReady(); verify(mHalDeviceManager, times(2)).isStarted(); - verify(mHalDeviceManager, never()).createStaIface(any(), eq(null)); + verify(mHalDeviceManager, never()).createStaIface(anyBoolean(), any(), eq(null)); verify(mHalDeviceManager, never()).createRttController(); } @@ -527,11 +527,12 @@ public class WifiVendorHalTest { InterfaceDestroyedListener externalLister = mock(InterfaceDestroyedListener.class); assertTrue(mWifiVendorHal.startVendorHal()); - assertNotNull(mWifiVendorHal.createStaIface(externalLister)); + assertNotNull(mWifiVendorHal.createStaIface(false, externalLister)); assertTrue(mWifiVendorHal.isHalStarted()); verify(mHalDeviceManager).start(); - verify(mHalDeviceManager).createStaIface(internalListenerCaptor.capture(), eq(null)); + verify(mHalDeviceManager).createStaIface(eq(false), internalListenerCaptor.capture(), + eq(null)); verify(mHalDeviceManager).getChip(eq(mIWifiStaIface)); verify(mHalDeviceManager).createRttController(); verify(mHalDeviceManager).isReady(); @@ -2027,8 +2028,8 @@ public class WifiVendorHalTest { }).when(mIWifiStaIface).getName(any(IWifiIface.getNameCallback.class)); assertTrue(mWifiVendorHal.startVendorHal()); - assertNull(mWifiVendorHal.createStaIface(null)); - verify(mHalDeviceManager).createStaIface(any(), eq(null)); + assertNull(mWifiVendorHal.createStaIface(true, null)); + verify(mHalDeviceManager).createStaIface(eq(true), any(), eq(null)); } /** @@ -2054,8 +2055,8 @@ public class WifiVendorHalTest { @Test public void testCreateRemoveStaIface() throws RemoteException { assertTrue(mWifiVendorHal.startVendorHal()); - String ifaceName = mWifiVendorHal.createStaIface(null); - verify(mHalDeviceManager).createStaIface(any(), eq(null)); + String ifaceName = mWifiVendorHal.createStaIface(false, null); + verify(mHalDeviceManager).createStaIface(eq(false), any(), eq(null)); assertEquals(TEST_IFACE_NAME, ifaceName); assertTrue(mWifiVendorHal.removeStaIface(ifaceName)); verify(mHalDeviceManager).removeIface(eq(mIWifiStaIface)); |