fooddelivery: warm up AppInit when tracking starts in a cold process
- Commit
3b77acab0676c222790fba470c9ee62337502e41- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-07 20:00 UTC (29 days ago)
- Parents
69c1965
Symptom: if the system restarted OrderTrackingService after killing the app process (it returns START_REDELIVER_INTENT), live tracking never resumed: the placeholder notification stayed forever and the order was never polled again. Root cause: pollLoop's first step is AppInit.awaitReady(), which only completes after AppInit.start() runs. start() was only called from MainActivity and OrderLookupIntent; a service restarted into a cold process runs neither, so the await hung forever. The module's own AGENTS.md requires tracking to survive the app being killed. Fix: call the idempotent AppInit.start(this) from the service's onCreate, the same cold-process pattern OrderLookupIntent already uses, so the token/trust-bundle warm-up always runs before polling. Verification: TrackingServiceTest still exercises the service end to end (its manual AppInit.start is now redundant but harmless; AppInit readiness is process-global and cannot be un-completed in the same test JVM, so a cold-start regression test is not feasible there). Full module test run follows in the final verification.
Diff
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/notifications/OrderTrackingService.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/notifications/OrderTrackingService.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/notifications/OrderTrackingService.ktindex 1cabbadf7a..593b02f9f5 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/notifications/OrderTrackingService.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/notifications/OrderTrackingService.kt@@ -35,6 +35,16 @@ class OrderTrackingService : Service() { private var pollJob: Job? = null private var trackedOrderId: Int = -1 + override fun onCreate() {+ super.onCreate()+ // This service can be (re)started by the system into a cold process where+ // MainActivity never runs (START_REDELIVER_INTENT after a kill). AppInit.start+ // is normally MainActivity's job, and pollLoop awaits it -- without this call+ // that await never completes and tracking hangs on the placeholder forever.+ // start() is idempotent, so the warm-process path is unaffected.+ AppInit.start(this)+ }+ override fun onBind(intent: Intent?): IBinder? = null override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {