Added delayed check for removing auto start foreground service app if registration process is quicker than the start of the Service
This commit is contained in:
parent
f78be7e306
commit
5ddc3f7ff0
2 changed files with 15 additions and 0 deletions
|
@ -612,6 +612,20 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
}
|
||||
}
|
||||
|
||||
fun checkIfForegroundServiceNotificationCanBeRemovedAfterDelay(delayInMs: Long) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Default) {
|
||||
delay(delayInMs)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (core.defaultAccount != null && core.defaultAccount?.state == RegistrationState.Ok) {
|
||||
Log.i("[Context] Default account is registered, cancel foreground service notification if possible")
|
||||
notificationsManager.stopForegroundNotificationIfPossible()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Start call related activities */
|
||||
|
||||
private fun onIncomingReceived() {
|
||||
|
|
|
@ -37,6 +37,7 @@ class CoreService : CoreService() {
|
|||
if (intent?.extras?.get("StartForeground") == true) {
|
||||
Log.i("[Service] Starting as foreground due to device boot or app update")
|
||||
coreContext.notificationsManager.startForeground(this, true)
|
||||
coreContext.checkIfForegroundServiceNotificationCanBeRemovedAfterDelay(5000)
|
||||
} else if (corePreferences.keepServiceAlive) {
|
||||
Log.i("[Service] Starting as foreground to keep app alive in background")
|
||||
coreContext.notificationsManager.startForeground(this, false)
|
||||
|
|
Loading…
Reference in a new issue