Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/src/main/java/eu/darken/bluemusic/App.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.darken.bluemusic

import android.app.Application
import android.os.Looper
import dagger.hilt.android.HiltAndroidApp
import eu.darken.bluemusic.common.coroutine.AppScope
import eu.darken.bluemusic.common.coroutine.DispatcherProvider
Expand Down Expand Up @@ -40,10 +41,13 @@ class App : Application() {
curriculumVitae.updateAppLaunch()
}

var foregroundExceptionHandled = false
val oldHandler = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler { thread, throwable ->
if (throwable.isForegroundServiceTimingException()) {
if (throwable.isForegroundServiceTimingException() && !foregroundExceptionHandled) {
foregroundExceptionHandled = true
log(TAG, WARN) { "Suppressed foreground service timing exception: ${throwable.asLog()}" }
Looper.loop()
return@setDefaultUncaughtExceptionHandler
}
log(TAG, ERROR) { "UNCAUGHT EXCEPTION: ${throwable.asLog()}" }
Expand Down