Modern Apps git

← Modern-Apps.git

findfamily: poll for direct-boot job completion

Commit
8446c2bb9aca5486b5ce0324b360a2173a5076f2
Author
Vayun Mathur <[email protected]>
When
2026-11-17 02:44 UTC (19 days ago)
Parents
e9a7f2e
directBootIdlesWhenMirrorUnseeded slept a fixed 300ms, but the job checks the device-protected mirror on Dispatchers.IO, which takes arbitrarily long on a loaded CI box, so the job was still active at the assert.

Poll until the job is null/completed (20s budget). Product behaviour unchanged.

Verified: TZ=UTC the test green.

Diff

findfamily/src/test/java/com/vayunmathur/findfamily/util/DirectBootAndStoresRealTest.kt
diff --git a/findfamily/src/test/java/com/vayunmathur/findfamily/util/DirectBootAndStoresRealTest.kt b/findfamily/src/test/java/com/vayunmathur/findfamily/util/DirectBootAndStoresRealTest.ktindex 8340d1da86..454cdc5770 100644--- a/findfamily/src/test/java/com/vayunmathur/findfamily/util/DirectBootAndStoresRealTest.kt+++ b/findfamily/src/test/java/com/vayunmathur/findfamily/util/DirectBootAndStoresRealTest.kt@@ -57,9 +57,15 @@ class DirectBootAndStoresRealTest {     @Test fun directBootIdlesWhenMirrorUnseeded() = runBlocking {         spoolFile().delete()         service.startDirectBootTracking()-        delay(300)         // No seeded mirror on a fresh Robolectric install: the job must-        // finish (idle) rather than minting an identity.+        // finish (idle) rather than minting an identity. The job checks the+        // mirror on Dispatchers.IO, which takes arbitrarily long on a+        // loaded box, so poll for completion instead of a fixed 300ms.+        var waitedMs = 0+        while (waitedMs < 20_000) {+            if (service.directBootJob == null || service.directBootJob!!.isCompleted) break+            delay(50); waitedMs += 50+        }         assertTrue(service.directBootJob == null || service.directBootJob!!.isCompleted)     }