Merge "Add isAllowlistedExceptIdle method to check target package is under it" into sc-v2-dev am: 2a15391ab9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15837567

Change-Id: If22040ef91b5c6389c87f870b4b49bd5a5adf749
This commit is contained in:
Wesley Wang
2021-09-17 20:43:06 +00:00
committed by Automerger Merge Worker
2 changed files with 22 additions and 0 deletions

View File

@@ -109,6 +109,18 @@ public class PowerAllowlistBackend {
return false; return false;
} }
/**
* Check if target package is in allow list except idle app
*/
public boolean isAllowlistedExceptIdle(String pkg) {
try {
return mDeviceIdleService.isPowerSaveWhitelistExceptIdleApp(pkg);
} catch (RemoteException e) {
Log.w(TAG, "Unable to reach IDeviceIdleController", e);
return true;
}
}
/** /**
* *
* @param pkgs a list of packageName * @param pkgs a list of packageName

View File

@@ -151,4 +151,14 @@ public class PowerAllowlistBackendTest {
assertThat(mPowerAllowlistBackend.isSysAllowlisted(PACKAGE_TWO)).isFalse(); assertThat(mPowerAllowlistBackend.isSysAllowlisted(PACKAGE_TWO)).isFalse();
assertThat(mPowerAllowlistBackend.isAllowlisted(PACKAGE_ONE)).isFalse(); assertThat(mPowerAllowlistBackend.isAllowlisted(PACKAGE_ONE)).isFalse();
} }
@Test
public void testIsPowerSaveWhitelistExceptIdleApp() throws Exception {
doReturn(true).when(mDeviceIdleService)
.isPowerSaveWhitelistExceptIdleApp(PACKAGE_ONE);
mPowerAllowlistBackend.refreshList();
assertThat(mPowerAllowlistBackend.isAllowlistedExceptIdle(PACKAGE_ONE)).isTrue();
}
} }