Merge "Force the app idle state again after whitelisting it." into rvc-dev

This commit is contained in:
Sudheer Shanka
2020-07-17 22:48:44 +00:00
committed by Android (Google) Code Review
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);