WificondControl: Use iface name for interface objects
Bug: 67365651
Test: ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: Will send for regression tests.
Change-Id: Id5cd28439a2458832b9a2a6893fa289f919845ba
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 0b1719d..35dec2e 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -16,6 +16,7 @@
package com.android.server.wifi;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.net.apf.ApfCapabilities;
import android.net.wifi.IApInterface;
@@ -109,12 +110,12 @@
* @return Pair of <Integer, IClientInterface> to indicate the status and the associated wificond
* client interface binder handler (will be null on failure).
*/
- public Pair<Integer, IClientInterface> setupForClientMode() {
+ public Pair<Integer, IClientInterface> setupForClientMode(@NonNull String ifaceName) {
if (!startHalIfNecessary(true)) {
Log.e(mTAG, "Failed to start HAL for client mode");
return Pair.create(SETUP_FAILURE_HAL, null);
}
- IClientInterface iClientInterface = mWificondControl.setupDriverForClientMode();
+ IClientInterface iClientInterface = mWificondControl.setupDriverForClientMode(ifaceName);
if (iClientInterface == null) {
return Pair.create(SETUP_FAILURE_WIFICOND, null);
}
@@ -130,12 +131,12 @@
* @return Pair of <Integer, IApInterface> to indicate the status and the associated wificond
* AP interface binder handler (will be null on failure).
*/
- public Pair<Integer, IApInterface> setupForSoftApMode() {
+ public Pair<Integer, IApInterface> setupForSoftApMode(@NonNull String ifaceName) {
if (!startHalIfNecessary(false)) {
Log.e(mTAG, "Failed to start HAL for AP mode");
return Pair.create(SETUP_FAILURE_HAL, null);
}
- IApInterface iApInterface = mWificondControl.setupDriverForSoftApMode();
+ IApInterface iApInterface = mWificondControl.setupDriverForSoftApMode(ifaceName);
if (iApInterface == null) {
return Pair.create(SETUP_FAILURE_WIFICOND, null);
}
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 1f6cada..0c2cc32 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -4165,7 +4165,7 @@
switch (message.what) {
case CMD_START_SUPPLICANT:
Pair<Integer, IClientInterface> statusAndInterface =
- mWifiNative.setupForClientMode();
+ mWifiNative.setupForClientMode(mInterfaceName);
if (statusAndInterface.first == WifiNative.SETUP_SUCCESS) {
mClientInterface = statusAndInterface.second;
} else {
@@ -6954,7 +6954,8 @@
mMode = config.getTargetMode();
IApInterface apInterface = null;
- Pair<Integer, IApInterface> statusAndInterface = mWifiNative.setupForSoftApMode();
+ Pair<Integer, IApInterface> statusAndInterface =
+ mWifiNative.setupForSoftApMode(mInterfaceName);
if (statusAndInterface.first == WifiNative.SETUP_SUCCESS) {
apInterface = statusAndInterface.second;
} else {
diff --git a/service/java/com/android/server/wifi/WifiStateMachinePrime.java b/service/java/com/android/server/wifi/WifiStateMachinePrime.java
index 2006884..cd1948f 100644
--- a/service/java/com/android/server/wifi/WifiStateMachinePrime.java
+++ b/service/java/com/android/server/wifi/WifiStateMachinePrime.java
@@ -290,7 +290,8 @@
}
try {
- mApInterface = mWificond.createApInterface();
+ mApInterface = mWificond.createApInterface(
+ mWifiInjector.getWifiNative().getInterfaceName());
} catch (RemoteException e1) { }
if (mApInterface == null) {
diff --git a/service/java/com/android/server/wifi/WificondControl.java b/service/java/com/android/server/wifi/WificondControl.java
index 056777f..5483670 100644
--- a/service/java/com/android/server/wifi/WificondControl.java
+++ b/service/java/com/android/server/wifi/WificondControl.java
@@ -16,6 +16,7 @@
package com.android.server.wifi;
+import android.annotation.NonNull;
import android.net.wifi.IApInterface;
import android.net.wifi.IClientInterface;
import android.net.wifi.IPnoScanEvent;
@@ -133,7 +134,7 @@
* @return An IClientInterface as wificond client interface binder handler.
* Returns null on failure.
*/
- public IClientInterface setupDriverForClientMode() {
+ public IClientInterface setupDriverForClientMode(@NonNull String ifaceName) {
Log.d(TAG, "Setting up driver for client mode");
mWificond = mWifiInjector.makeWificond();
if (mWificond == null) {
@@ -143,7 +144,7 @@
IClientInterface clientInterface = null;
try {
- clientInterface = mWificond.createClientInterface();
+ clientInterface = mWificond.createClientInterface(ifaceName);
} catch (RemoteException e1) {
Log.e(TAG, "Failed to get IClientInterface due to remote exception");
return null;
@@ -181,7 +182,7 @@
* @return An IApInterface as wificond Ap interface binder handler.
* Returns null on failure.
*/
- public IApInterface setupDriverForSoftApMode() {
+ public IApInterface setupDriverForSoftApMode(@NonNull String ifaceName) {
Log.d(TAG, "Setting up driver for soft ap mode");
mWificond = mWifiInjector.makeWificond();
if (mWificond == null) {
@@ -191,7 +192,7 @@
IApInterface apInterface = null;
try {
- apInterface = mWificond.createApInterface();
+ apInterface = mWificond.createApInterface(ifaceName);
} catch (RemoteException e1) {
Log.e(TAG, "Failed to get IApInterface due to remote exception");
return null;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
index 32d1daa..72a2479 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
@@ -47,6 +47,7 @@
*/
@SmallTest
public class WifiNativeTest {
+ private static final String WIFI_IFACE_NAME = "mockWlan";
private static final long FATE_REPORT_DRIVER_TIMESTAMP_USEC = 12345;
private static final byte[] FATE_REPORT_FRAME_BYTES = new byte[] {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 0, 1, 2, 3, 4, 5, 6, 7};
@@ -481,127 +482,139 @@
// TODO(b/28005116): Add test for the success case of getDriverStateDump().
/**
- * Verifies that setupDriverForClientMode() calls underlying WificondControl.
+ * Verifies that setupDriverForClientMode(WIFI_IFACE_NAME) calls underlying WificondControl.
*/
@Test
public void testSetupDriverForClientMode() {
IClientInterface clientInterface = mock(IClientInterface.class);
- when(mWificondControl.setupDriverForClientMode()).thenReturn(clientInterface);
+ when(mWificondControl.setupDriverForClientMode(WIFI_IFACE_NAME))
+ .thenReturn(clientInterface);
- Pair<Integer, IClientInterface> statusAndClientInterface = mWifiNative.setupForClientMode();
+ Pair<Integer, IClientInterface> statusAndClientInterface =
+ mWifiNative.setupForClientMode(WIFI_IFACE_NAME);
assertTrue(WifiNative.SETUP_SUCCESS == statusAndClientInterface.first);
assertEquals(clientInterface, statusAndClientInterface.second);
verify(mWifiVendorHal).startVendorHal(eq(true));
- verify(mWificondControl).setupDriverForClientMode();
+ verify(mWificondControl).setupDriverForClientMode(WIFI_IFACE_NAME);
}
/**
- * Verifies that setupDriverForClientMode() does not call start vendor HAL when it is not
- * supported and calls underlying WificondControl setup.
+ * Verifies that setupDriverForClientMode(WIFI_IFACE_NAME) does not call start vendor HAL
+ * when it is not supported and calls underlying WificondControl setup.
*/
@Test
public void testSetupDriverForClientModeWithNoVendorHal() {
when(mWifiVendorHal.isVendorHalSupported()).thenReturn(false);
IClientInterface clientInterface = mock(IClientInterface.class);
- when(mWificondControl.setupDriverForClientMode()).thenReturn(clientInterface);
+ when(mWificondControl.setupDriverForClientMode(WIFI_IFACE_NAME))
+ .thenReturn(clientInterface);
- Pair<Integer, IClientInterface> statusAndClientInterface = mWifiNative.setupForClientMode();
+ Pair<Integer, IClientInterface> statusAndClientInterface =
+ mWifiNative.setupForClientMode(WIFI_IFACE_NAME);
assertTrue(WifiNative.SETUP_SUCCESS == statusAndClientInterface.first);
assertEquals(clientInterface, statusAndClientInterface.second);
verify(mWifiVendorHal, never()).startVendorHal(anyBoolean());
- verify(mWificondControl).setupDriverForClientMode();
+ verify(mWificondControl).setupDriverForClientMode(WIFI_IFACE_NAME);
}
/**
- * Verifies that setupDriverForClientMode() returns null when underlying WificondControl
- * call fails.
+ * Verifies that setupDriverForClientMode(WIFI_IFACE_NAME) returns null when underlying
+ * WificondControl call fails.
*/
@Test
public void testSetupDriverForClientModeWificondError() {
- when(mWificondControl.setupDriverForClientMode()).thenReturn(null);
+ when(mWificondControl.setupDriverForClientMode(WIFI_IFACE_NAME)).thenReturn(null);
- Pair<Integer, IClientInterface> statusAndClientInterface = mWifiNative.setupForClientMode();
+ Pair<Integer, IClientInterface> statusAndClientInterface =
+ mWifiNative.setupForClientMode(WIFI_IFACE_NAME);
assertTrue(WifiNative.SETUP_FAILURE_WIFICOND == statusAndClientInterface.first);
assertEquals(null, statusAndClientInterface.second);
verify(mWifiVendorHal).startVendorHal(eq(true));
- verify(mWificondControl).setupDriverForClientMode();
+ verify(mWificondControl).setupDriverForClientMode(WIFI_IFACE_NAME);
}
/**
- * Verifies that setupDriverForClientMode() returns null when underlying Hal call fails.
+ * Verifies that setupDriverForClientMode(WIFI_IFACE_NAME) returns null when underlying Hal
+ * call fails.
*/
@Test
public void testSetupDriverForClientModeHalError() {
when(mWifiVendorHal.startVendorHal(anyBoolean())).thenReturn(false);
- Pair<Integer, IClientInterface> statusAndClientInterface = mWifiNative.setupForClientMode();
+ Pair<Integer, IClientInterface> statusAndClientInterface =
+ mWifiNative.setupForClientMode(WIFI_IFACE_NAME);
assertTrue(WifiNative.SETUP_FAILURE_HAL == statusAndClientInterface.first);
assertEquals(null, statusAndClientInterface.second);
verify(mWifiVendorHal).startVendorHal(eq(true));
- verify(mWificondControl, never()).setupDriverForClientMode();
+ verify(mWificondControl, never()).setupDriverForClientMode(WIFI_IFACE_NAME);
}
/**
- * Verifies that setupDriverForSoftApMode() calls underlying WificondControl.
+ * Verifies that setupDriverForSoftApMode(WIFI_IFACE_NAME) calls underlying WificondControl.
*/
@Test
public void testSetupDriverForSoftApMode() {
IApInterface apInterface = mock(IApInterface.class);
- when(mWificondControl.setupDriverForSoftApMode()).thenReturn(apInterface);
+ when(mWificondControl.setupDriverForSoftApMode(WIFI_IFACE_NAME)).thenReturn(apInterface);
- Pair<Integer, IApInterface> statusAndApInterface = mWifiNative.setupForSoftApMode();
+ Pair<Integer, IApInterface> statusAndApInterface =
+ mWifiNative.setupForSoftApMode(WIFI_IFACE_NAME);
assertTrue(WifiNative.SETUP_SUCCESS == statusAndApInterface.first);
assertEquals(apInterface, statusAndApInterface.second);
verify(mWifiVendorHal).startVendorHal(eq(false));
- verify(mWificondControl).setupDriverForSoftApMode();
+ verify(mWificondControl).setupDriverForSoftApMode(WIFI_IFACE_NAME);
}
/**
- * Verifies that setupDriverForClientMode() does not call start vendor HAL when it is not
- * supported and calls underlying WificondControl setup.
+ * Verifies that setupDriverForClientMode(WIFI_IFACE_NAME) does not call start vendor HAL when
+ * it is not supported and calls underlying WificondControl setup.
*/
@Test
public void testSetupDriverForSoftApModeWithNoVendorHal() {
when(mWifiVendorHal.isVendorHalSupported()).thenReturn(false);
IApInterface apInterface = mock(IApInterface.class);
- when(mWificondControl.setupDriverForSoftApMode()).thenReturn(apInterface);
+ when(mWificondControl.setupDriverForSoftApMode(WIFI_IFACE_NAME)).thenReturn(apInterface);
- Pair<Integer, IApInterface> statusAndApInterface = mWifiNative.setupForSoftApMode();
+ Pair<Integer, IApInterface> statusAndApInterface =
+ mWifiNative.setupForSoftApMode(WIFI_IFACE_NAME);
assertTrue(WifiNative.SETUP_SUCCESS == statusAndApInterface.first);
assertEquals(apInterface, statusAndApInterface.second);
verify(mWifiVendorHal, never()).startVendorHal(anyBoolean());
- verify(mWificondControl).setupDriverForSoftApMode();
+ verify(mWificondControl).setupDriverForSoftApMode(WIFI_IFACE_NAME);
}
/**
- * Verifies that setupDriverForSoftApMode() returns null when underlying WificondControl
- * call fails.
+ * Verifies that setupDriverForSoftApMode(WIFI_IFACE_NAME) returns null when underlying
+ * WificondControl call fails.
*/
@Test
public void testSetupDriverForSoftApModeWificondError() {
- when(mWificondControl.setupDriverForSoftApMode()).thenReturn(null);
+ when(mWificondControl.setupDriverForSoftApMode(WIFI_IFACE_NAME)).thenReturn(null);
- Pair<Integer, IApInterface> statusAndApInterface = mWifiNative.setupForSoftApMode();
+ Pair<Integer, IApInterface> statusAndApInterface =
+ mWifiNative.setupForSoftApMode(WIFI_IFACE_NAME);
assertTrue(WifiNative.SETUP_FAILURE_WIFICOND == statusAndApInterface.first);
assertEquals(null, statusAndApInterface.second);
verify(mWifiVendorHal).startVendorHal(eq(false));
- verify(mWificondControl).setupDriverForSoftApMode();
+ verify(mWificondControl).setupDriverForSoftApMode(WIFI_IFACE_NAME);
}
/**
- * Verifies that setupDriverForSoftApMode() returns null when underlying Hal call fails.
+ * Verifies that setupDriverForSoftApMode(WIFI_IFACE_NAME) returns null when underlying Hal
+ * call fails.
*/
@Test
public void testSetupDriverForSoftApModeHalError() {
when(mWifiVendorHal.startVendorHal(anyBoolean())).thenReturn(false);
- Pair<Integer, IApInterface> statusAndApInterface = mWifiNative.setupForSoftApMode();
+ Pair<Integer, IApInterface> statusAndApInterface =
+ mWifiNative.setupForSoftApMode(WIFI_IFACE_NAME);
assertTrue(WifiNative.SETUP_FAILURE_HAL == statusAndApInterface.first);
assertEquals(null, statusAndApInterface.second);
verify(mWifiVendorHal).startVendorHal(eq(false));
- verify(mWificondControl, never()).setupDriverForSoftApMode();
+ verify(mWificondControl, never()).setupDriverForSoftApMode(WIFI_IFACE_NAME);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachinePrimeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachinePrimeTest.java
index 49c7d18..060919d 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachinePrimeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachinePrimeTest.java
@@ -50,8 +50,10 @@
private static final String CLIENT_MODE_ACTIVE_STATE_STRING = "ClientModeActiveState";
private static final String SCAN_ONLY_MODE_ACTIVE_STATE_STRING = "ScanOnlyModeActiveState";
private static final String SOFT_AP_MODE_ACTIVE_STATE_STRING = "SoftAPModeActiveState";
+ private static final String WIFI_IFACE_NAME = "mockWlan";
@Mock WifiInjector mWifiInjector;
+ @Mock WifiNative mWifiNative;
@Mock WifiApConfigStore mWifiApConfigStore;
TestLooper mLooper;
@Mock IWificond mWificond;
@@ -71,7 +73,8 @@
MockitoAnnotations.initMocks(this);
mLooper = new TestLooper();
- mWifiInjector = mock(WifiInjector.class);
+ when(mWifiInjector.getWifiNative()).thenReturn(mWifiNative);
+ when(mWifiNative.getInterfaceName()).thenReturn(WIFI_IFACE_NAME);
mWifiStateMachinePrime = createWifiStateMachinePrime();
}
@@ -100,7 +103,7 @@
private void enterSoftApActiveMode(WifiConfiguration wifiConfig) throws Exception {
String fromState = mWifiStateMachinePrime.getCurrentMode();
when(mWifiInjector.makeWificond()).thenReturn(mWificond);
- when(mWificond.createApInterface()).thenReturn(mApInterface);
+ when(mWificond.createApInterface(WIFI_IFACE_NAME)).thenReturn(mApInterface);
doAnswer(
new Answer<Object>() {
public SoftApManager answer(InvocationOnMock invocation) {
@@ -232,7 +235,7 @@
@Test
public void testAPInterfaceFailedWhenSwitchingToApMode() throws Exception {
when(mWifiInjector.makeWificond()).thenReturn(mWificond);
- when(mWificond.createApInterface()).thenReturn(null);
+ when(mWificond.createApInterface(WIFI_IFACE_NAME)).thenReturn(null);
mWifiStateMachinePrime.enterSoftAPMode(null);
mLooper.dispatchAll();
assertEquals(SOFT_AP_MODE_STATE_STRING, mWifiStateMachinePrime.getCurrentMode());
@@ -246,7 +249,7 @@
@Test
public void testEnterSoftApModeActiveWhenAlreadyInSoftApMode() throws Exception {
when(mWifiInjector.makeWificond()).thenReturn(mWificond);
- when(mWificond.createApInterface()).thenReturn(null);
+ when(mWificond.createApInterface(WIFI_IFACE_NAME)).thenReturn(null);
mWifiStateMachinePrime.enterSoftAPMode(null);
mLooper.dispatchAll();
assertEquals(SOFT_AP_MODE_STATE_STRING, mWifiStateMachinePrime.getCurrentMode());
@@ -318,7 +321,7 @@
@Test
public void testNullConfigFailsSecondCallWithConfigSuccessful() throws Exception {
when(mWifiInjector.makeWificond()).thenReturn(mWificond);
- when(mWificond.createApInterface()).thenReturn(null);
+ when(mWificond.createApInterface(WIFI_IFACE_NAME)).thenReturn(null);
mWifiStateMachinePrime.enterSoftAPMode(null);
mLooper.dispatchAll();
assertEquals(SOFT_AP_MODE_STATE_STRING, mWifiStateMachinePrime.getCurrentMode());
@@ -354,7 +357,7 @@
@Test
public void testStartSoftApModeTwiceWithTwoConfigs() throws Exception {
when(mWifiInjector.makeWificond()).thenReturn(mWificond);
- when(mWificond.createApInterface()).thenReturn(mApInterface);
+ when(mWificond.createApInterface(WIFI_IFACE_NAME)).thenReturn(mApInterface);
when(mWifiInjector.getWifiApConfigStore()).thenReturn(mWifiApConfigStore);
WifiConfiguration config1 = new WifiConfiguration();
config1.SSID = "ThisIsAConfig";
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 29590af..f7c98ea 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -413,9 +413,9 @@
when(mWifiInjector.makeTelephonyManager()).thenReturn(mTelephonyManager);
when(mWifiInjector.getClock()).thenReturn(mClock);
- when(mWifiNative.setupForClientMode())
+ when(mWifiNative.setupForClientMode(WIFI_IFACE_NAME))
.thenReturn(Pair.create(WifiNative.SETUP_SUCCESS, mClientInterface));
- when(mWifiNative.setupForSoftApMode())
+ when(mWifiNative.setupForSoftApMode(WIFI_IFACE_NAME))
.thenReturn(Pair.create(WifiNative.SETUP_SUCCESS, mApInterface));
when(mApInterface.getInterfaceName()).thenReturn(WIFI_IFACE_NAME);
when(mWifiNative.getInterfaceName()).thenReturn(WIFI_IFACE_NAME);
@@ -585,7 +585,7 @@
assertEquals("SoftApState", getCurrentState().getName());
- verify(mWifiNative).setupForSoftApMode();
+ verify(mWifiNative).setupForSoftApMode(WIFI_IFACE_NAME);
verify(mSoftApManager).start();
// reset expectations for mContext due to previously sent AP broadcast
@@ -647,7 +647,6 @@
assertEquals("InitialState", getCurrentState().getName());
// Failed to even create the client interface.
- when(mWificond.createClientInterface()).thenReturn(null);
mWsm.setSupplicantRunning(true);
mLooper.dispatchAll();
assertEquals("InitialState", getCurrentState().getName());
@@ -960,7 +959,7 @@
mWsm.sendMessage(WifiMonitor.SUP_CONNECTION_EVENT);
mLooper.dispatchAll();
- verify(mWifiNative).setupForClientMode();
+ verify(mWifiNative).setupForClientMode(WIFI_IFACE_NAME);
verify(mWifiLastResortWatchdog).clearAllFailureCounts();
}
@@ -2427,7 +2426,7 @@
*/
@Test
public void testSetupForSoftApModeHalFailureIncrementsMetrics() throws Exception {
- when(mWifiNative.setupForSoftApMode())
+ when(mWifiNative.setupForSoftApMode(WIFI_IFACE_NAME))
.thenReturn(Pair.create(WifiNative.SETUP_FAILURE_HAL, null));
SoftApModeConfiguration config = new SoftApModeConfiguration(
@@ -2435,7 +2434,7 @@
mWsm.setHostApRunning(config, true);
mLooper.dispatchAll();
- verify(mWifiNative).setupForSoftApMode();
+ verify(mWifiNative).setupForSoftApMode(WIFI_IFACE_NAME);
verify(mWifiMetrics).incrementNumWifiOnFailureDueToHal();
}
@@ -2444,7 +2443,7 @@
*/
@Test
public void testSetupForSoftApModeWificondFailureIncrementsMetrics() throws Exception {
- when(mWifiNative.setupForSoftApMode())
+ when(mWifiNative.setupForSoftApMode(WIFI_IFACE_NAME))
.thenReturn(Pair.create(WifiNative.SETUP_FAILURE_WIFICOND, null));
SoftApModeConfiguration config = new SoftApModeConfiguration(
@@ -2452,7 +2451,7 @@
mWsm.setHostApRunning(config, true);
mLooper.dispatchAll();
- verify(mWifiNative).setupForSoftApMode();
+ verify(mWifiNative).setupForSoftApMode(WIFI_IFACE_NAME);
verify(mWifiMetrics).incrementNumWifiOnFailureDueToWificond();
}
@@ -2461,7 +2460,7 @@
*/
@Test
public void testSetupForClientModeHalFailureIncrementsMetrics() throws Exception {
- when(mWifiNative.setupForClientMode())
+ when(mWifiNative.setupForClientMode(WIFI_IFACE_NAME))
.thenReturn(Pair.create(WifiNative.SETUP_FAILURE_HAL, null));
mWsm.setSupplicantRunning(true);
@@ -2470,7 +2469,7 @@
mWsm.sendMessage(WifiMonitor.SUP_CONNECTION_EVENT);
mLooper.dispatchAll();
- verify(mWifiNative).setupForClientMode();
+ verify(mWifiNative).setupForClientMode(WIFI_IFACE_NAME);
verify(mWifiMetrics).incrementNumWifiOnFailureDueToHal();
}
@@ -2479,7 +2478,7 @@
*/
@Test
public void testSetupForClientModeWificondFailureIncrementsMetrics() throws Exception {
- when(mWifiNative.setupForClientMode())
+ when(mWifiNative.setupForClientMode(WIFI_IFACE_NAME))
.thenReturn(Pair.create(WifiNative.SETUP_FAILURE_WIFICOND, null));
mWsm.setSupplicantRunning(true);
@@ -2488,7 +2487,7 @@
mWsm.sendMessage(WifiMonitor.SUP_CONNECTION_EVENT);
mLooper.dispatchAll();
- verify(mWifiNative).setupForClientMode();
+ verify(mWifiNative).setupForClientMode(WIFI_IFACE_NAME);
verify(mWifiMetrics).incrementNumWifiOnFailureDueToWificond();
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java
index cca2045..7c17015 100644
--- a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java
@@ -153,7 +153,7 @@
}
/**
- * Verifies that setupDriverForClientMode() calls Wificond.
+ * Verifies that setupDriverForClientMode(TEST_INTERFACE_NAME) calls Wificond.
*/
@Test
public void testSetupDriverForClientMode() throws Exception {
@@ -161,15 +161,16 @@
IClientInterface clientInterface = getMockClientInterface();
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(clientInterface);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(clientInterface);
- IClientInterface returnedClientInterface = mWificondControl.setupDriverForClientMode();
+ IClientInterface returnedClientInterface =
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
assertEquals(clientInterface, returnedClientInterface);
- verify(wificond).createClientInterface();
+ verify(wificond).createClientInterface(TEST_INTERFACE_NAME);
}
/**
- * Verifies that setupDriverForClientMode() calls subscribeScanEvents().
+ * Verifies that setupDriverForClientMode(TEST_INTERFACE_NAME) calls subscribeScanEvents().
*/
@Test
public void testSetupDriverForClientModeCallsScanEventSubscripiton() throws Exception {
@@ -179,19 +180,21 @@
}
/**
- * Verifies that setupDriverForClientMode() returns null when wificond is not started.
+ * Verifies that setupDriverForClientMode(TEST_INTERFACE_NAME) returns null when wificond is
+ * not started.
*/
@Test
public void testSetupDriverForClientModeErrorWhenWificondIsNotStarted() throws Exception {
when(mWifiInjector.makeWificond()).thenReturn(null);
- IClientInterface returnedClientInterface = mWificondControl.setupDriverForClientMode();
+ IClientInterface returnedClientInterface =
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
assertEquals(null, returnedClientInterface);
}
/**
- * Verifies that setupDriverForClientMode() returns null when wificond failed to setup client
- * interface.
+ * Verifies that setupDriverForClientMode(TEST_INTERFACE_NAME) returns null when wificond failed
+ * to setup client interface.
*/
@Test
public void testSetupDriverForClientModeErrorWhenWificondFailedToSetupInterface()
@@ -199,14 +202,15 @@
IWificond wificond = mock(IWificond.class);
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(null);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(null);
- IClientInterface returnedClientInterface = mWificondControl.setupDriverForClientMode();
+ IClientInterface returnedClientInterface =
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
assertEquals(null, returnedClientInterface);
}
/**
- * Verifies that setupDriverForSoftApMode() calls wificond.
+ * Verifies that setupDriverForSoftApMode(TEST_INTERFACE_NAME) calls wificond.
*/
@Test
public void testSetupDriverForSoftApMode() throws Exception {
@@ -214,11 +218,12 @@
IApInterface apInterface = mock(IApInterface.class);
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createApInterface()).thenReturn(apInterface);
+ when(wificond.createApInterface(TEST_INTERFACE_NAME)).thenReturn(apInterface);
- IApInterface returnedApInterface = mWificondControl.setupDriverForSoftApMode();
+ IApInterface returnedApInterface =
+ mWificondControl.setupDriverForSoftApMode(TEST_INTERFACE_NAME);
assertEquals(apInterface, returnedApInterface);
- verify(wificond).createApInterface();
+ verify(wificond).createApInterface(TEST_INTERFACE_NAME);
}
/**
@@ -228,14 +233,15 @@
public void testSetupDriverForSoftApModeErrorWhenWificondIsNotStarted() throws Exception {
when(mWifiInjector.makeWificond()).thenReturn(null);
- IApInterface returnedApInterface = mWificondControl.setupDriverForSoftApMode();
+ IApInterface returnedApInterface =
+ mWificondControl.setupDriverForSoftApMode(TEST_INTERFACE_NAME);
assertEquals(null, returnedApInterface);
}
/**
- * Verifies that setupDriverForSoftApMode() returns null when wificond failed to setup
- * AP interface.
+ * Verifies that setupDriverForSoftApMode(TEST_INTERFACE_NAME) returns null when wificond failed
+ * to setup AP interface.
*/
@Test
public void testSetupDriverForSoftApModeErrorWhenWificondFailedToSetupInterface()
@@ -243,9 +249,10 @@
IWificond wificond = mock(IWificond.class);
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createApInterface()).thenReturn(null);
+ when(wificond.createApInterface(TEST_INTERFACE_NAME)).thenReturn(null);
- IApInterface returnedApInterface = mWificondControl.setupDriverForSoftApMode();
+ IApInterface returnedApInterface =
+ mWificondControl.setupDriverForSoftApMode(TEST_INTERFACE_NAME);
assertEquals(null, returnedApInterface);
}
@@ -258,10 +265,10 @@
IClientInterface clientInterface = getMockClientInterface();
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(clientInterface);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(clientInterface);
when(clientInterface.enableSupplicant()).thenReturn(true);
- mWificondControl.setupDriverForClientMode();
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
assertTrue(mWificondControl.enableSupplicant());
verify(clientInterface).enableSupplicant();
}
@@ -276,10 +283,11 @@
IClientInterface clientInterface = getMockClientInterface();
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(clientInterface);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(clientInterface);
// Configure client interface.
- IClientInterface returnedClientInterface = mWificondControl.setupDriverForClientMode();
+ IClientInterface returnedClientInterface =
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
assertEquals(clientInterface, returnedClientInterface);
// Tear down interfaces.
@@ -298,10 +306,10 @@
IClientInterface clientInterface = getMockClientInterface();
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(clientInterface);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(clientInterface);
when(clientInterface.disableSupplicant()).thenReturn(true);
- mWificondControl.setupDriverForClientMode();
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
assertTrue(mWificondControl.disableSupplicant());
verify(clientInterface).disableSupplicant();
}
@@ -316,10 +324,11 @@
IClientInterface clientInterface = getMockClientInterface();
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(clientInterface);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(clientInterface);
// Configure client interface.
- IClientInterface returnedClientInterface = mWificondControl.setupDriverForClientMode();
+ IClientInterface returnedClientInterface =
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
assertEquals(clientInterface, returnedClientInterface);
// Tear down interfaces.
@@ -375,9 +384,9 @@
IClientInterface clientInterface = getMockClientInterface();
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(clientInterface);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(clientInterface);
- mWificondControl.setupDriverForClientMode();
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
mWificondControl.signalPoll();
verify(clientInterface).signalPoll();
}
@@ -391,10 +400,11 @@
IClientInterface clientInterface = getMockClientInterface();
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(clientInterface);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(clientInterface);
// Configure client interface.
- IClientInterface returnedClientInterface = mWificondControl.setupDriverForClientMode();
+ IClientInterface returnedClientInterface =
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
assertEquals(clientInterface, returnedClientInterface);
// Tear down interfaces.
@@ -413,9 +423,9 @@
IClientInterface clientInterface = getMockClientInterface();
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(clientInterface);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(clientInterface);
- mWificondControl.setupDriverForClientMode();
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
mWificondControl.getTxPacketCounters();
verify(clientInterface).getPacketCounters();
}
@@ -430,10 +440,11 @@
IClientInterface clientInterface = getMockClientInterface();
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(clientInterface);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(clientInterface);
// Configure client interface.
- IClientInterface returnedClientInterface = mWificondControl.setupDriverForClientMode();
+ IClientInterface returnedClientInterface =
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
assertEquals(clientInterface, returnedClientInterface);
// Tear down interfaces.
@@ -453,10 +464,11 @@
IClientInterface clientInterface = getMockClientInterface();
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(clientInterface);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(clientInterface);
// Configure client interface.
- IClientInterface returnedClientInterface = mWificondControl.setupDriverForClientMode();
+ IClientInterface returnedClientInterface =
+ mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME);
assertEquals(clientInterface, returnedClientInterface);
// Tear down interfaces.
@@ -749,11 +761,12 @@
IWifiScannerImpl scanner = mock(IWifiScannerImpl.class);
when(mWifiInjector.makeWificond()).thenReturn(wificond);
- when(wificond.createClientInterface()).thenReturn(clientInterface);
+ when(wificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(clientInterface);
when(clientInterface.getWifiScannerImpl()).thenReturn(scanner);
when(clientInterface.getInterfaceName()).thenReturn(TEST_INTERFACE_NAME);
- assertEquals(clientInterface, mWificondControl.setupDriverForClientMode());
+ assertEquals(
+ clientInterface, mWificondControl.setupDriverForClientMode(TEST_INTERFACE_NAME));
return scanner;
}