fix: Catch Hilt DI failure in MonitorService.onCreate()

Wrap super.onCreate() (Hilt injection) in try-catch to prevent

DI failures from crashing the process. The service is already

foreground at this point, so a graceful stopSelf() satisfies the

FGS timeout requirement without killing the app.
This commit is contained in:
darken
2026-03-20 19:17:56 +00:00
committed by Matthias Urhahn
parent 6e9b275936
commit f25718ab2c
@@ -114,7 +114,15 @@ class MonitorService : Service() {
return
}
super.onCreate()
try {
super.onCreate()
} catch (e: Exception) {
log(TAG, WARN) { "Hilt DI failed in onCreate(), stopping service: ${e.asLog()}" }
Bugs.report(tag = TAG, "Hilt DI failed in onCreate()", exception = e)
foregroundStartFailed = true
stopSelf()
return
}
log(TAG, VERBOSE) { "onCreate()" }
// Replace early notification with the full one from injected MonitorNotifications.