From 022058ec7490b53339cf684c759e7269f447ac95 Mon Sep 17 00:00:00 2001 From: Hui Yu Date: Fri, 19 Apr 2019 16:39:11 -0700 Subject: [PATCH] Make sure app_idle_constants is set during setup. Set app_idle_constants in NetPolicyTestsPreparer is not always successful(suspect timing issue). Set app_idle_constants in AbstractRestrictBackgroundNetworkTestCase again to make sure. Bug: 115393390 Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests#testAppIdleMetered_whenCharging Change-Id: I41148bc7eea0825537133f0471ceefeb5b05d763 --- .../AbstractRestrictBackgroundNetworkTestCase.java | 9 ++++++++- .../src/com/android/cts/net/NetPolicyTestsPreparer.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) 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 4e4d1f6075..bff02db038 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 @@ -153,7 +153,14 @@ abstract class AbstractRestrictBackgroundNetworkTestCase extends Instrumentation Log.i(TAG, "Apps status on " + getName() + ":\n" + "\ttest app: uid=" + mMyUid + ", state=" + getProcessStateByUid(mMyUid) + "\n" + "\tapp2: uid=" + mUid + ", state=" + getProcessStateByUid(mUid)); - executeShellCommand("settings get global app_idle_constants"); + + // app_idle_constants set in NetPolicyTestsPreparer.setUp() is not always sucessful (suspect + // timing issue), here we set it again to make sure. + final String appIdleConstants = "parole_duration=0,stable_charging_threshold=0"; + executeShellCommand("settings put global app_idle_constants " + appIdleConstants); + final String currentConstants = + executeShellCommand("settings get global app_idle_constants"); + assertEquals(appIdleConstants, currentConstants); } @Override diff --git a/tests/cts/hostside/src/com/android/cts/net/NetPolicyTestsPreparer.java b/tests/cts/hostside/src/com/android/cts/net/NetPolicyTestsPreparer.java index ca14c27c20..bc2ee2cf7a 100644 --- a/tests/cts/hostside/src/com/android/cts/net/NetPolicyTestsPreparer.java +++ b/tests/cts/hostside/src/com/android/cts/net/NetPolicyTestsPreparer.java @@ -48,7 +48,7 @@ public class NetPolicyTestsPreparer implements ITargetPreparer, ITargetCleaner { } private void setAppIdleConstants(String appIdleConstants) throws DeviceNotAvailableException { - executeCmd("settings put global app_idle_constants " + appIdleConstants); + executeCmd("settings put global app_idle_constants \"" + appIdleConstants + "\""); } private String getAppIdleConstants() throws DeviceNotAvailableException {