mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 19:38:08 +00:00
Fixed background mode advanced setting switch not starting the service & notification
This commit is contained in:
parent
b4696502aa
commit
204f21d801
2 changed files with 8 additions and 5 deletions
|
|
@ -34,13 +34,13 @@ class CoreService : CoreService() {
|
|||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
if (intent?.extras?.get("StartForeground") == true) {
|
||||
if (corePreferences.keepServiceAlive) {
|
||||
Log.i("[Service] Starting as foreground to keep app alive in background")
|
||||
coreContext.notificationsManager.startForeground(this, false)
|
||||
} else 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)
|
||||
}
|
||||
return super.onStartCommand(intent, flags, startId)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,7 +252,10 @@ class NotificationsManager(private val context: Context) {
|
|||
if (coreService != null) {
|
||||
startForeground(coreService, useAutoStartDescription = false)
|
||||
} else {
|
||||
Log.e("[Notifications Manager] Can't start service as foreground, no service!")
|
||||
Log.w("[Notifications Manager] Can't start service as foreground without a service, starting it now")
|
||||
val intent = Intent()
|
||||
intent.setClass(coreContext.context, CoreService::class.java)
|
||||
coreContext.context.startService(intent)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue