Merge "Force the app idle state again after whitelisting it." into rvc-dev am: 2008be86fd am: 886928a5b8 am: 18c0716ca5 am: 949242b819

Original change: https://googleplex-android-review.googlesource.com/c/platform/cts/+/12171299

Change-Id: I7edf8524c8c788f2561129ead0817c6597f0a8e9
This commit is contained in:
Sudheer Shanka
2020-07-17 23:53:55 +00:00
committed by Automerger Merge Worker
2 changed files with 10 additions and 0 deletions

View File

@@ -89,14 +89,19 @@ abstract class AbstractAppIdleTestCase extends AbstractRestrictBackgroundNetwork
assertAppIdle(false); // Sanity check - not idle anymore, since whitelisted
assertBackgroundNetworkAccess(true);
setAppIdleNoAssert(true);
assertAppIdle(false); // app is still whitelisted
removePowerSaveModeWhitelist(TEST_APP2_PKG);
assertAppIdle(true); // Sanity check - idle again, once whitelisted was removed
assertBackgroundNetworkAccess(false);
setAppIdle(true);
addPowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
assertAppIdle(false); // Sanity check - not idle anymore, since whitelisted
assertBackgroundNetworkAccess(true);
setAppIdleNoAssert(true);
assertAppIdle(false); // app is still whitelisted
removePowerSaveModeExceptIdleWhitelist(TEST_APP2_PKG);
assertAppIdle(true); // Sanity check - idle again, once whitelisted was removed
assertBackgroundNetworkAccess(false);

View File

@@ -662,6 +662,11 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
assertAppIdle(enabled); // Sanity check
}
protected void setAppIdleNoAssert(boolean enabled) throws Exception {
Log.i(TAG, "Setting app idle to " + enabled);
executeSilentShellCommand("am set-inactive " + TEST_APP2_PKG + " " + enabled );
}
protected void assertAppIdle(boolean enabled) throws Exception {
try {
assertDelayedShellCommand("am get-inactive " + TEST_APP2_PKG, 15, 2, "Idle=" + enabled);