Add a hidden API to query appstandby constants.
This will allow the tests to query the value for
appstandby constants that are last known to
the AppStandbyController.
Bug: 221176951
Test: atest ./tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: I286e3d6346570ff613db3b3c6e50cc1bfb225e2e
diff --git a/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java b/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
index 2bc4128..c31efde 100644
--- a/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
+++ b/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
@@ -2329,10 +2329,14 @@
}
private void updateFlagWithDelay(DeviceConfigStateHelper deviceConfigStateHelper,
- String key, String value) throws Exception {
+ String key, String value) {
deviceConfigStateHelper.set(key, value);
- // TODO (221176951): Add a way to check the value of the flag in AppStandbyController
- SystemClock.sleep(1_000);
+ SystemUtil.runWithShellPermissionIdentity(() -> {
+ final String actualValue = PollingCheck.waitFor(DEFAULT_TIMEOUT_MS,
+ () -> mUsageStatsManager.getAppStandbyConstant(key),
+ result -> value.equals(result));
+ assertEquals("Error changing the value of " + key, value, actualValue);
+ });
}
private Notification buildNotification(String channelId, int notificationId,