summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chalard Jean <jchalard@google.com> 2021-04-01 06:23:55 +0000
committer Chalard Jean <jchalard@google.com> 2021-04-01 06:27:46 +0000
commitea4d25a7504466362317d99deb9d9b20014e2e69 (patch)
tree92baf7f90a728387e97505efc28bcd3973e09dec
parent67b816def653cc4b81f836f858340231abb970fc (diff)
Fix testLegacyLockdownVpn flaky
When WiFi disconnects, the VPN disconnects immediately. The broadcast can therefore be sent before the broadcast receiver is registered, which causes the receiver to not see the broadcast. The puzzling part is that CONNECTIVITY_ACTION is a sticky broadcast, so one would expect the broadcast to still be received, even if the registration is done after the broadcast is sent. The reason this doesn't happen is that the context used by the test is a BroadcastInterceptingContext, which does not treat sticky broadcasts as sticky. Bug: 184115648 Test: atest --iterations 1000 'ConnectivityServiceTest#testLegacyLockdownVpn' Change-Id: Ib44c92839d25951cc7d2db0f923e1b104690e1e0
-rw-r--r--tests/net/java/com/android/server/ConnectivityServiceTest.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java
index 14c72f1445a9..ad934204c4bd 100644
--- a/tests/net/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java
@@ -8133,12 +8133,12 @@ public class ConnectivityServiceTest {
assertExtraInfoFromCmPresent(mWiFiNetworkAgent);
b1 = expectConnectivityAction(TYPE_WIFI, DetailedState.DISCONNECTED);
+ b2 = expectConnectivityAction(TYPE_VPN, DetailedState.DISCONNECTED);
mWiFiNetworkAgent.disconnect();
callback.expectCallback(CallbackEntry.LOST, mWiFiNetworkAgent);
systemDefaultCallback.expectCallback(CallbackEntry.LOST, mWiFiNetworkAgent);
b1.expectBroadcast();
callback.expectCapabilitiesThat(mMockVpn, nc -> !nc.hasTransport(TRANSPORT_WIFI));
- b2 = expectConnectivityAction(TYPE_VPN, DetailedState.DISCONNECTED);
mMockVpn.expectStopVpnRunnerPrivileged();
callback.expectCallback(CallbackEntry.LOST, mMockVpn);
b2.expectBroadcast();