From 43353038f0eac0e64058a4bcb1bb7afb596760f7 Mon Sep 17 00:00:00 2001 From: Sudheer Shanka Date: Wed, 24 May 2017 17:49:11 -0700 Subject: [PATCH] Try to fix HostsideRestrictBackgroundNetworkTests flakyness. - If the screen is not turned on when the activity is starting, then that process will be in TOP_SLEEPING state and won't have temp access to network connectivity in restricted modes. So, add a wait time after turning the screen on. - Increase the timeout for app standby wait time. Bug: 38384021 Test: cts-tradefed run singleCommand cts-dev -m CtsHostsideNetworkTests -t \ com.android.cts.net.HostsideRestrictBackgroundNetworkTests Change-Id: I54563a0c8b3e783ee9279d667faa5cab529ddc7e --- .../hostside/AbstractRestrictBackgroundNetworkTestCase.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java index f994169d98..c5342bac58 100644 --- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java +++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java @@ -782,7 +782,7 @@ abstract class AbstractRestrictBackgroundNetworkTestCase extends Instrumentation } protected void assertAppIdle(boolean enabled) throws Exception { - assertDelayedShellCommand("am get-inactive " + TEST_APP2_PKG, 10, 2, "Idle=" + enabled); + assertDelayedShellCommand("am get-inactive " + TEST_APP2_PKG, 15, 2, "Idle=" + enabled); } /** @@ -848,6 +848,8 @@ abstract class AbstractRestrictBackgroundNetworkTestCase extends Instrumentation return; } else if (type == TYPE_COMPONENT_ACTIVTIY) { turnScreenOn(); + // Wait for screen-on state to propagate through the system. + SystemClock.sleep(2000); final CountDownLatch latch = new CountDownLatch(1); final Intent launchIntent = getIntentForComponent(type); final Bundle extras = new Bundle();