summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-05-15 01:46:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-05-15 01:46:29 +0000
commitd0b1c6de370037885cf0da1eb202efff23c746b4 (patch)
tree5977fb4718e251c1abb60ce5d9c9534990a24961 /tests
parent877c3bc1d9089708b6e3afad255fc295ad58014e (diff)
parentf4b0992881304e897a039e41e17c8b8d48a031fd (diff)
Merge "SupplicantStaIfaceHal: Don't trigger onDeath for remote exception" into pi-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java39
1 files changed, 31 insertions, 8 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
index 04af83263..b4ea5af34 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
@@ -1401,6 +1401,37 @@ public class SupplicantStaIfaceHalTest {
}
/**
+ * When wpa_supplicant is dead, we could end up getting a remote exception on a hwbinder call
+ * and then the death notification.
+ */
+ @Test
+ public void testHandleRemoteExceptonAndDeathNotification() throws Exception {
+ executeAndValidateInitializationSequence();
+ assertTrue(mDut.registerDeathHandler(mSupplicantHalDeathHandler));
+ assertTrue(mDut.isInitializationComplete());
+
+ // Throw remote exception on hwbinder call.
+ when(mISupplicantStaIfaceMock.setPowerSave(anyBoolean()))
+ .thenThrow(new RemoteException());
+ assertFalse(mDut.setPowerSave(WLAN0_IFACE_NAME, true));
+ verify(mISupplicantStaIfaceMock).setPowerSave(true);
+
+ // Check that remote exception cleared all internal state.
+ assertFalse(mDut.isInitializationComplete());
+
+ // Ensure that futher calls fail because the remote exception clears any state.
+ assertFalse(mDut.setPowerSave(WLAN0_IFACE_NAME, true));
+ //.. No call to ISupplicantStaIface object
+
+ // Now trigger a death notification and ensure it's handled.
+ assertNotNull(mSupplicantDeathCaptor.getValue());
+ mSupplicantDeathCaptor.getValue().serviceDied(5L);
+
+ // External death notification fires only once!
+ verify(mSupplicantHalDeathHandler).onDeath();
+ }
+
+ /**
* Tests the setting of log level.
*/
@Test
@@ -1590,10 +1621,6 @@ public class SupplicantStaIfaceHalTest {
.getInterface(any(ISupplicant.IfaceInfo.class),
any(ISupplicant.getInterfaceCallback.class));
}
- if (causeRemoteException) {
- mInOrder.verify(mWifiMonitor).broadcastSupplicantDisconnectionEvent(
- eq(WLAN0_IFACE_NAME));
- }
if (!causeRemoteException && !getZeroInterfaces && !getNullInterface) {
mInOrder.verify(mISupplicantStaIfaceMock)
.registerCallback(any(ISupplicantStaIfaceCallback.class));
@@ -1654,10 +1681,6 @@ public class SupplicantStaIfaceHalTest {
.addInterface(any(ISupplicant.IfaceInfo.class),
any(android.hardware.wifi.supplicant.V1_1.ISupplicant
.addInterfaceCallback.class));
- if (causeRemoteException) {
- mInOrder.verify(mWifiMonitor).broadcastSupplicantDisconnectionEvent(
- eq(WLAN0_IFACE_NAME));
- }
if (!causeRemoteException && !getNullInterface) {
mInOrder.verify(mISupplicantStaIfaceMockV1_1)
.registerCallback_1_1(