Fix metered-constraint job scheduler CTS test
The test was incurring false positives in the case of the job running
even when the metered-network constraint didn't hold. We now have a
test that verifies the negative: that the job fails to run, as expected,
when the device is connected via an unmetered network.
Along the way, we made setup/teardown of the wifi state more robust;
there was some flakiness arising from the previous handling.
Fix 62545908
Test: bit CtsJobSchedulerTestCases:.ConnectivityConstraintTest
Change-Id: I40269728aea5c7fef314d36a4b163dfa7d9eafa3
diff --git a/tests/JobScheduler/src/android/jobscheduler/MockJobService.java b/tests/JobScheduler/src/android/jobscheduler/MockJobService.java
index 0ca3ecc..94aee20 100644
--- a/tests/JobScheduler/src/android/jobscheduler/MockJobService.java
+++ b/tests/JobScheduler/src/android/jobscheduler/MockJobService.java
@@ -360,7 +360,11 @@
* @return True if the latch timed out waiting on an execution.
*/
public boolean awaitTimeout() throws InterruptedException {
- return !mLatch.await(DEFAULT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ return awaitTimeout(DEFAULT_TIMEOUT_MILLIS);
+ }
+
+ public boolean awaitTimeout(long timeoutMillis) throws InterruptedException {
+ return !mLatch.await(timeoutMillis, TimeUnit.MILLISECONDS);
}
public boolean awaitWaitingForStop() throws InterruptedException {