Prevent runtime exception if we failed to build service notification

This commit is contained in:
Sylvain Berfini 2022-02-10 14:41:39 +01:00
parent 4226dd6d5c
commit a0d0bb0d48

View file

@ -327,6 +327,10 @@ class NotificationsManager(private val context: Context) {
fun startForeground(coreService: CoreService, useAutoStartDescription: Boolean = true) {
if (serviceNotification == null) {
createServiceNotification(useAutoStartDescription)
if (serviceNotification == null) {
Log.e("[Notifications Manager] Failed to create service notification, aborting foreground service!")
return
}
}
currentForegroundServiceNotificationId = SERVICE_NOTIF_ID
Log.i("[Notifications Manager] Starting service as foreground [$currentForegroundServiceNotificationId]")