mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-15 10:46:12 -04:00
50 lines
1.5 KiB
Kotlin
50 lines
1.5 KiB
Kotlin
package eu.darken.cap
|
|
|
|
import android.app.Application
|
|
import androidx.hilt.work.HiltWorkerFactory
|
|
import androidx.work.Configuration
|
|
import com.getkeepsafe.relinker.ReLinker
|
|
import dagger.hilt.android.HiltAndroidApp
|
|
import eu.darken.cap.common.coroutine.AppScope
|
|
import eu.darken.cap.common.debug.bugreporting.BugReporter
|
|
import eu.darken.cap.common.debug.logging.*
|
|
import eu.darken.cap.monitor.core.worker.MonitorControl
|
|
import kotlinx.coroutines.CoroutineScope
|
|
import kotlinx.coroutines.launch
|
|
import javax.inject.Inject
|
|
|
|
@HiltAndroidApp
|
|
open class App : Application(), Configuration.Provider {
|
|
|
|
@Inject lateinit var workerFactory: HiltWorkerFactory
|
|
@Inject lateinit var bugReporter: BugReporter
|
|
@Inject lateinit var monitorControl: MonitorControl
|
|
@Inject @AppScope lateinit var appScope: CoroutineScope
|
|
|
|
override fun onCreate() {
|
|
super.onCreate()
|
|
if (BuildConfig.DEBUG) Logging.install(LogCatLogger())
|
|
|
|
ReLinker
|
|
.log { message -> log(TAG) { "ReLinker: $message" } }
|
|
.loadLibrary(this, "bugsnag-plugin-android-anr")
|
|
|
|
bugReporter.setup()
|
|
|
|
log(TAG) { "onCreate() done! ${Exception().asLog()}" }
|
|
|
|
appScope.launch {
|
|
monitorControl.startMonitor(forceStart = true)
|
|
}
|
|
}
|
|
|
|
override fun getWorkManagerConfiguration(): Configuration = Configuration.Builder()
|
|
.setMinimumLoggingLevel(android.util.Log.VERBOSE)
|
|
.setWorkerFactory(workerFactory)
|
|
.build()
|
|
|
|
companion object {
|
|
internal val TAG = logTag("CAP")
|
|
}
|
|
}
|