summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-03-21 16:34:37 -0700
committerRoshan Pius <rpius@google.com>2017-03-27 10:15:21 -0700
commit790a767cc340069ce4d8f76410889199c1beaf01 (patch)
treef1c79b5786f3661fe6a422652e0500feede9a362 /tests
parent8aebfed96d10c3ef93ece3974e602b36c3e81f4a (diff)
WifiStateMachine: Handle vendor HAL death
The handling is similar to wificond binder death handling. We go back to initial state on the vendor HAL death. Also fixed couple of nits: 1. Fixed the vendor Hal test failures due to mockito change. 2. Renamed the log event handler variable (fixing a previous sed). Bug: 34859006 Test: Unit tests Test: Crashed the vendor HAL manually and verified WSM returned to Initial State Change-Id: Ia2c8249ca5b6857af09f8e996900881ac8a844ec
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java29
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java17
2 files changed, 45 insertions, 1 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index cc8535318..ad441f54d 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -1383,6 +1383,35 @@ public class WifiStateMachineTest {
assertFalse("WpsRunningState".equals(getCurrentState().getName()));
}
+ @Test
+ public void handleVendorHalDeath() throws Exception {
+ ArgumentCaptor<WifiNative.VendorHalDeathEventHandler> deathHandlerCapturer =
+ ArgumentCaptor.forClass(WifiNative.VendorHalDeathEventHandler.class);
+ when(mWifiNative.initializeVendorHal(deathHandlerCapturer.capture())).thenReturn(true);
+
+ // Trigger initialize to capture the death handler registration.
+ mLooper.startAutoDispatch();
+ assertTrue(mWsm.syncInitialize(mWsmAsyncChannel));
+ mLooper.stopAutoDispatch();
+
+ verify(mWifiNative).initializeVendorHal(any(WifiNative.VendorHalDeathEventHandler.class));
+ WifiNative.VendorHalDeathEventHandler deathHandler = deathHandlerCapturer.getValue();
+
+ mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE);
+ mLooper.dispatchAll();
+
+ // We should not be in initial state now.
+ assertFalse("InitialState".equals(getCurrentState().getName()));
+
+ // Now trigger the death notification.
+ mLooper.startAutoDispatch();
+ deathHandler.onDeath();
+ mLooper.stopAutoDispatch();
+
+ // We should back to initial state after vendor HAL death.
+ assertTrue("InitialState".equals(getCurrentState().getName()));
+ }
+
private void setupMocksForWpsNetworkMigration() {
int newNetworkId = 5;
// Now trigger the network connection event for adding the WPS network.
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
index 36fe7d2df..15fc55f66 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
@@ -103,6 +103,8 @@ public class WifiVendorHalTest {
private IWifiRttController mIWifiRttController;
private IWifiStaIfaceEventCallback mIWifiStaIfaceEventCallback;
private IWifiChipEventCallback mIWifiChipEventCallback;
+ @Mock
+ private WifiNative.VendorHalDeathEventHandler mVendorHalDeathHandler;
/**
* Identity function to supply a type to its argument, which is a lambda
@@ -172,7 +174,7 @@ public class WifiVendorHalTest {
mWifiVendorHal = new WifiVendorHal(mHalDeviceManager, mWifiStateMachineHandlerThread);
// Initialize the vendor HAL to capture the registered callback.
- mWifiVendorHal.initialize();
+ mWifiVendorHal.initialize(mVendorHalDeathHandler);
ArgumentCaptor<WifiVendorHal.HalDeviceManagerStatusListener> hdmCallbackCaptor =
ArgumentCaptor.forClass(WifiVendorHal.HalDeviceManagerStatusListener.class);
verify(mHalDeviceManager).registerStatusListener(hdmCallbackCaptor.capture(), any());
@@ -1729,6 +1731,19 @@ public class WifiVendorHalTest {
new WifiDebugRingBufferStatus(), NativeUtil.byteArrayToArrayList(errorData));
}
+ /**
+ * Test the handling of Vendor HAL death.
+ */
+ @Test
+ public void testVendorHalDeath() {
+ // Invoke the HAL device manager status callback with ready set to false to indicate the
+ // death of the HAL.
+ when(mHalDeviceManager.isReady()).thenReturn(false);
+ mHalDeviceManagerStatusCallbacks.onStatusChanged();
+
+ verify(mVendorHalDeathHandler).onDeath();
+ }
+
private void startBgScan(WifiNative.ScanEventHandler eventHandler) throws Exception {
when(mIWifiStaIface.startBackgroundScan(
anyInt(), any(StaBackgroundScanParameters.class))).thenReturn(mWifiStatusSuccess);