summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-02-13 16:29:19 -0800
committerRoshan Pius <rpius@google.com>2018-07-20 09:46:40 -0700
commit2dae9a53ed772d193c9e9a39cd6cc6d0ded1b568 (patch)
tree2e399764011c9541d4d8f657de3ed6fea84fcc19 /tests
parentf67983967623524bc785cac8ac3e294fb9183746 (diff)
SupplicantStaIfaceHal: Backwards compatibility for start/stop
We fall back to the older mechanism of letting init system (controlled via property) start/stop supplicant for devices running older version of wpa_supplicant. Since this check needs to be done before the ISupplicant object is retrieved, refactored the isV1_1() helper method to use the manifest to get this data. Bug: 72394251 Test: Unit tests Test: Device boots up & connects to wifi networks. Test: Manually tested the new path by hacking the supplicant manifest version 1.0 locally Change-Id: I6eba3e65bbce2fd89882beace9110365c3ae85b8
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java69
1 files changed, 66 insertions, 3 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
index 33490869b..c28f8708e 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
@@ -101,6 +101,7 @@ public class SupplicantStaIfaceHalTest {
mISupplicantStaIfaceMockV1_1;
private @Mock Context mContext;
private @Mock WifiMonitor mWifiMonitor;
+ private @Mock PropertyService mPropertyService;
private @Mock SupplicantStaNetworkHal mSupplicantStaNetworkMock;
private @Mock WifiNative.SupplicantDeathEventHandler mSupplicantHalDeathHandler;
SupplicantStatus mStatusSuccess;
@@ -124,8 +125,9 @@ public class SupplicantStaIfaceHalTest {
private InOrder mInOrder;
private class SupplicantStaIfaceHalSpy extends SupplicantStaIfaceHal {
- SupplicantStaIfaceHalSpy(Context context, WifiMonitor monitor) {
- super(context, monitor);
+ SupplicantStaIfaceHalSpy(Context context, WifiMonitor monitor,
+ PropertyService propertyService) {
+ super(context, monitor, propertyService);
}
@Override
@@ -177,13 +179,15 @@ public class SupplicantStaIfaceHalTest {
mIfaceInfoList.add(mStaIface1);
mIfaceInfoList.add(mP2pIface);
+ when(mServiceManagerMock.getTransport(anyString(), anyString()))
+ .thenReturn(IServiceManager.Transport.EMPTY);
when(mServiceManagerMock.linkToDeath(any(IHwBinder.DeathRecipient.class),
anyLong())).thenReturn(true);
when(mServiceManagerMock.registerForNotifications(anyString(), anyString(),
any(IServiceNotification.Stub.class))).thenReturn(true);
when(mISupplicantMock.linkToDeath(any(IHwBinder.DeathRecipient.class),
anyLong())).thenReturn(true);
- mDut = new SupplicantStaIfaceHalSpy(mContext, mWifiMonitor);
+ mDut = new SupplicantStaIfaceHalSpy(mContext, mWifiMonitor, mPropertyService);
}
/**
@@ -237,6 +241,8 @@ public class SupplicantStaIfaceHalTest {
*/
@Test
public void testInitialize_successV1_1() throws Exception {
+ when(mServiceManagerMock.getTransport(anyString(), anyString()))
+ .thenReturn(IServiceManager.Transport.HWBINDER);
mISupplicantMockV1_1 = mock(android.hardware.wifi.supplicant.V1_1.ISupplicant.class);
executeAndValidateInitializationSequenceV1_1(false, false);
}
@@ -247,6 +253,8 @@ public class SupplicantStaIfaceHalTest {
*/
@Test
public void testInitialize_remoteExceptionFailureV1_1() throws Exception {
+ when(mServiceManagerMock.getTransport(anyString(), anyString()))
+ .thenReturn(IServiceManager.Transport.HWBINDER);
mISupplicantMockV1_1 = mock(android.hardware.wifi.supplicant.V1_1.ISupplicant.class);
executeAndValidateInitializationSequenceV1_1(true, false);
}
@@ -257,6 +265,8 @@ public class SupplicantStaIfaceHalTest {
*/
@Test
public void testInitialize_nullInterfaceFailureV1_1() throws Exception {
+ when(mServiceManagerMock.getTransport(anyString(), anyString()))
+ .thenReturn(IServiceManager.Transport.HWBINDER);
mISupplicantMockV1_1 = mock(android.hardware.wifi.supplicant.V1_1.ISupplicant.class);
executeAndValidateInitializationSequenceV1_1(false, true);
}
@@ -284,6 +294,8 @@ public class SupplicantStaIfaceHalTest {
*/
@Test
public void testDuplicateSetupIfaceV1_1_Fails() throws Exception {
+ when(mServiceManagerMock.getTransport(anyString(), anyString()))
+ .thenReturn(IServiceManager.Transport.HWBINDER);
mISupplicantMockV1_1 = mock(android.hardware.wifi.supplicant.V1_1.ISupplicant.class);
executeAndValidateInitializationSequenceV1_1(false, false);
@@ -1542,6 +1554,57 @@ public class SupplicantStaIfaceHalTest {
verify(mISupplicantStaIfaceMock, never()).setCountryCode(any(byte[].class));
}
+ /**
+ * Tests the start daemon for V1_0 service.
+ */
+ @Test
+ public void testStartDaemonV1_0() throws Exception {
+ executeAndValidateInitializationSequence();
+ assertTrue(mDut.startDaemon());
+ verify(mPropertyService).set(
+ SupplicantStaIfaceHal.INIT_START_PROPERTY, SupplicantStaIfaceHal.INIT_SERVICE_NAME);
+ }
+
+ /**
+ * Tests the start daemon for V1_1 service.
+ */
+ @Test
+ public void testStartDaemonV1_1() throws Exception {
+ when(mServiceManagerMock.getTransport(anyString(), anyString()))
+ .thenReturn(IServiceManager.Transport.HWBINDER);
+ mISupplicantMockV1_1 = mock(android.hardware.wifi.supplicant.V1_1.ISupplicant.class);
+
+ executeAndValidateInitializationSequenceV1_1(false, false);
+ assertTrue(mDut.startDaemon());
+ verify(mPropertyService, never()).set(any(), any());
+ }
+
+ /**
+ * Tests the terminate for V1_0 service.
+ */
+ @Test
+ public void testTerminateV1_0() throws Exception {
+ executeAndValidateInitializationSequence();
+ mDut.terminate();
+ verify(mPropertyService).set(
+ SupplicantStaIfaceHal.INIT_STOP_PROPERTY, SupplicantStaIfaceHal.INIT_SERVICE_NAME);
+ }
+
+ /**
+ * Tests the start daemon for V1_1 service.
+ */
+ @Test
+ public void testTerminateV1_1() throws Exception {
+ when(mServiceManagerMock.getTransport(anyString(), anyString()))
+ .thenReturn(IServiceManager.Transport.HWBINDER);
+ mISupplicantMockV1_1 = mock(android.hardware.wifi.supplicant.V1_1.ISupplicant.class);
+
+ executeAndValidateInitializationSequenceV1_1(false, false);
+ mDut.terminate();
+ verify(mPropertyService, never()).set(any(), any());
+ verify(mISupplicantMockV1_1).terminate();
+ }
+
private WifiConfiguration createTestWifiConfiguration() {
WifiConfiguration config = new WifiConfiguration();
config.networkId = SUPPLICANT_NETWORK_ID;