Add delays before checking result of LocationAccessCheck
This should prevent the job from being cancelled before it finishes
Bug: 165768911
Test: atest LocationAccessCheckTest
Change-Id: I50cfd9e920fdf5949f49218af408e6355c2b00be
diff --git a/tests/tests/permission/src/android/permission/cts/LocationAccessCheckTest.java b/tests/tests/permission/src/android/permission/cts/LocationAccessCheckTest.java
index 53b7d18..0c660b1 100644
--- a/tests/tests/permission/src/android/permission/cts/LocationAccessCheckTest.java
+++ b/tests/tests/permission/src/android/permission/cts/LocationAccessCheckTest.java
@@ -111,6 +111,7 @@
private static final long UNEXPECTED_TIMEOUT_MILLIS = 10000;
private static final long EXPECTED_TIMEOUT_MILLIS = 1000;
private static final long LOCATION_ACCESS_TIMEOUT_MILLIS = 15000;
+ private static final long LOCATION_ACCESS_JOB_WAIT_MILLIS = 250;
// Same as in AccessLocationOnCommand
private static final long BACKGROUND_ACCESS_SETTLE_TIME = 11000;
@@ -270,13 +271,14 @@
+ BACKGROUND_ACCESS_SETTLE_TIME;
while (true) {
runLocationCheck();
+ Thread.sleep(LOCATION_ACCESS_JOB_WAIT_MILLIS);
StatusBarNotification notification = getPermissionControllerNotification();
if (notification == null) {
// Sometimes getting a location takes some time, hence not getting a notification
// can be caused by not having gotten a location yet
if (SystemClock.elapsedRealtime() - start < timeout) {
- Thread.sleep(200);
+ Thread.sleep(LOCATION_ACCESS_JOB_WAIT_MILLIS);
continue;
}
@@ -666,6 +668,7 @@
@SecurityTest(minPatchLevel = "2019-12-01")
public void notificationOnlyForAccessesSinceFeatureWasEnabled() throws Throwable {
// Disable the feature and access location in disabled state
+ getNotification(true, true);
disableLocationAccessCheck();
accessLocation();
assertNull(getNotification(true));