Should fix missing incoming call notification caused by Service started before app

This commit is contained in:
Sylvain Berfini 2022-08-22 12:51:18 +02:00
parent 04e8c3566b
commit 7c267dad25
2 changed files with 11 additions and 1 deletions

View file

@ -46,8 +46,12 @@ class CoreService : CoreService() {
coreContext.notificationsManager.startForeground(this, true)
}
coreContext.checkIfForegroundServiceNotificationCanBeRemovedAfterDelay(5000)
} else {
ensureCoreExists(applicationContext, pushReceived = false, service = this, useAutoStartDescription = false)
}
coreContext.notificationsManager.serviceCreated(this)
return super.onStartCommand(intent, flags, startId)
}
@ -73,7 +77,7 @@ class CoreService : CoreService() {
Log.i("[Service] Task removed, stopping Core")
coreContext.stop()
} else {
Log.w("[Service] Task removed but Core in not in background, skipping")
Log.w("[Service] Task removed but Core is not in background, skipping")
}
} else {
Log.i("[Service] Task removed but we were asked to keep the service alive, so doing nothing")

View file

@ -411,7 +411,13 @@ class NotificationsManager(private val context: Context) {
}
}
fun serviceCreated(createdService: CoreService) {
Log.i("[Notifications Manager] Service has been created, keeping it around")
service = createdService
}
fun serviceDestroyed() {
Log.i("[Notifications Manager] Service has been destroyed")
stopForegroundNotification()
service = null
}