summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/WifiNative.java50
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java8
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java21
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java4
4 files changed, 51 insertions, 32 deletions
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index c5e5fc77e..11242a755 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -238,40 +238,56 @@ public class WifiNative {
}
/**
- * Setup driver for client mode via wificond.
+ * Setup wifi native for Client mode operations.
+ *
+ * 1. Starts the Wifi HAL and configures it in client/STA mode.
+ * 2. Setup Wificond to operate in client mode and retrieve the handle to use for client
+ * operations.
+ *
* @return An IClientInterface as wificond client interface binder handler.
* Returns null on failure.
*/
- public IClientInterface setupDriverForClientMode() {
- IClientInterface clientInterface = mWificondControl.setupDriverForClientMode();
+ public IClientInterface setupForClientMode() {
if (!startHal(true)) {
// TODO(b/34859006): Handle failures.
Log.e(TAG, "Failed to start HAL for client mode");
}
- return clientInterface;
+ return mWificondControl.setupDriverForClientMode();
}
/**
- * Setup driver for softAp mode via wificond.
- * @return An IApInterface as wificond Ap interface binder handler.
- * Returns null on failure.
- */
- public IApInterface setupDriverForSoftApMode() {
- IApInterface apInterface = mWificondControl.setupDriverForSoftApMode();
-
+ * Setup wifi native for AP mode operations.
+ *
+ * 1. Starts the Wifi HAL and configures it in AP mode.
+ * 2. Setup Wificond to operate in AP mode and retrieve the handle to use for ap operations.
+ *
+ * @return An IApInterface as wificond Ap interface binder handler.
+ * Returns null on failure.
+ */
+ public IApInterface setupForSoftApMode() {
if (!startHal(false)) {
// TODO(b/34859006): Handle failures.
Log.e(TAG, "Failed to start HAL for AP mode");
}
- return apInterface;
+ return mWificondControl.setupDriverForSoftApMode();
}
/**
- * Teardown all interfaces configured in wificond.
- * @return Returns true on success.
- */
- public boolean tearDownInterfaces() {
- return mWificondControl.tearDownInterfaces();
+ * Teardown all mode configurations in wifi native.
+ *
+ * 1. Tears down all the interfaces from Wificond.
+ * 2. Stops the Wifi HAL.
+ *
+ * @return Returns true on success.
+ */
+ public boolean tearDown() {
+ if (!mWificondControl.tearDownInterfaces()) {
+ // TODO(b/34859006): Handle failures.
+ Log.e(TAG, "Failed to teardown interfaces from Wificond");
+ return false;
+ }
+ stopHal();
+ return true;
}
/**
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index c25fa3cc2..4b5fb2544 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -3962,9 +3962,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
mWifiMonitor.stopAllMonitoring();
mDeathRecipient.unlinkToDeath();
- mWifiNative.tearDownInterfaces();
-
- mWifiNative.stopHal();
+ mWifiNative.tearDown();
}
@Override
@@ -3978,7 +3976,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
logStateAndMessage(message, this);
switch (message.what) {
case CMD_START_SUPPLICANT:
- mClientInterface = mWifiNative.setupDriverForClientMode();
+ mClientInterface = mWifiNative.setupForClientMode();
if (mClientInterface == null
|| !mDeathRecipient.linkToDeath(mClientInterface.asBinder())) {
setWifiState(WifiManager.WIFI_STATE_UNKNOWN);
@@ -6600,7 +6598,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
throw new RuntimeException("Illegal transition to SoftApState: " + message);
}
- IApInterface apInterface = mWifiNative.setupDriverForSoftApMode();
+ IApInterface apInterface = mWifiNative.setupForSoftApMode();
if (apInterface == null) {
setWifiApState(WIFI_AP_STATE_FAILED,
WifiManager.SAP_START_FAILURE_GENERAL);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
index ef33b656f..a9a32bd40 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.eq;
@@ -157,6 +158,7 @@ public class WifiNativeTest {
wifiNativeConstructor.setAccessible(true);
mWifiNative = spy(wifiNativeConstructor.newInstance("test", true));
mWifiVendorHal = mock(WifiVendorHal.class);
+ when(mWifiVendorHal.startVendorHal(anyBoolean())).thenReturn(true);
mWifiNative.setWifiVendorHal(mWifiVendorHal);
}
@@ -517,10 +519,10 @@ public class WifiNativeTest {
when(wificondControl.setupDriverForClientMode()).thenReturn(clientInterface);
mWifiNative.setWificondControl(wificondControl);
- IClientInterface returnedClientInterface = mWifiNative.setupDriverForClientMode();
+ IClientInterface returnedClientInterface = mWifiNative.setupForClientMode();
assertEquals(clientInterface, returnedClientInterface);
- verify(wificondControl).setupDriverForClientMode();
verify(mWifiNative).startHal(eq(true));
+ verify(wificondControl).setupDriverForClientMode();
}
/**
@@ -535,8 +537,9 @@ public class WifiNativeTest {
when(wificondControl.setupDriverForClientMode()).thenReturn(null);
mWifiNative.setWificondControl(wificondControl);
- IClientInterface returnedClientInterface = mWifiNative.setupDriverForClientMode();
+ IClientInterface returnedClientInterface = mWifiNative.setupForClientMode();
assertEquals(null, returnedClientInterface);
+ verify(mWifiNative).startHal(eq(true));
verify(wificondControl).setupDriverForClientMode();
}
@@ -552,10 +555,10 @@ public class WifiNativeTest {
when(wificondControl.setupDriverForSoftApMode()).thenReturn(apInterface);
mWifiNative.setWificondControl(wificondControl);
- IApInterface returnedApInterface = mWifiNative.setupDriverForSoftApMode();
+ IApInterface returnedApInterface = mWifiNative.setupForSoftApMode();
assertEquals(apInterface, returnedApInterface);
- verify(wificondControl).setupDriverForSoftApMode();
verify(mWifiNative).startHal(eq(false));
+ verify(wificondControl).setupDriverForSoftApMode();
}
/**
@@ -570,8 +573,9 @@ public class WifiNativeTest {
when(wificondControl.setupDriverForSoftApMode()).thenReturn(null);
mWifiNative.setWificondControl(wificondControl);
- IApInterface returnedApInterface = mWifiNative.setupDriverForSoftApMode();
+ IApInterface returnedApInterface = mWifiNative.setupForSoftApMode();
assertEquals(null, returnedApInterface);
+ verify(mWifiNative).startHal(eq(false));
verify(wificondControl).setupDriverForSoftApMode();
}
@@ -607,14 +611,15 @@ public class WifiNativeTest {
* Verifies that tearDownInterfaces() calls underlying WificondControl.
*/
@Test
- public void testTearDownInterfaces() {
+ public void testTearDown() {
WificondControl wificondControl = mock(WificondControl.class);
when(wificondControl.tearDownInterfaces()).thenReturn(true);
mWifiNative.setWificondControl(wificondControl);
- assertTrue(mWifiNative.tearDownInterfaces());
+ assertTrue(mWifiNative.tearDown());
verify(wificondControl).tearDownInterfaces();
+ verify(mWifiVendorHal).stopVendorHal();
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 45874ac80..9ab24c56b 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -367,8 +367,8 @@ public class WifiStateMachineTest {
.thenReturn(mSoftApManager);
when(mWifiInjector.getPasspointManager()).thenReturn(mPasspointManager);
- when(mWifiNative.setupDriverForClientMode()).thenReturn(mClientInterface);
- when(mWifiNative.setupDriverForSoftApMode()).thenReturn(mApInterface);
+ when(mWifiNative.setupForClientMode()).thenReturn(mClientInterface);
+ when(mWifiNative.setupForSoftApMode()).thenReturn(mApInterface);
when(mWifiInjector.getWifiStateTracker()).thenReturn(mWifiStateTracker);
when(mWifiNative.getInterfaceName()).thenReturn("mockWlan");
when(mWifiNative.enableSupplicant()).thenReturn(true);