aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/pacien/tincapp/context/App.kt
diff options
context:
space:
mode:
authorpacien2020-12-08 16:10:42 +0100
committerpacien2020-12-08 16:10:42 +0100
commitb1f98caca2f6960f7abb3ef7f7c27b903e1ef929 (patch)
tree71857113b01a354dbbd06e988d5fb9896aa9c6d5 /app/src/main/java/org/pacien/tincapp/context/App.kt
parent69445bffe7a17055ac47a41df5d33fe09b9aff3c (diff)
downloadtincapp-b1f98caca2f6960f7abb3ef7f7c27b903e1ef929.tar.gz
app: add configuration directory migrator
This adds an automatic configuration migrator which moves the configuration files previously located on the external public-ish directory to the private app storage, so that existing users can seamlessly transition to the next version. The cache directory containing the logs is cleared instead of being migrated, because those files are considered disposable. GitHub: related to #103
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/context/App.kt')
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/App.kt9
1 files changed, 6 insertions, 3 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/context/App.kt b/app/src/main/java/org/pacien/tincapp/context/App.kt
index 4d8d5d0..d825d78 100644
--- a/app/src/main/java/org/pacien/tincapp/context/App.kt
+++ b/app/src/main/java/org/pacien/tincapp/context/App.kt
@@ -28,6 +28,7 @@ import android.os.Handler
28import androidx.annotation.StringRes 28import androidx.annotation.StringRes
29import org.pacien.tincapp.BuildConfig 29import org.pacien.tincapp.BuildConfig
30import org.pacien.tincapp.R 30import org.pacien.tincapp.R
31import org.slf4j.Logger
31import org.slf4j.LoggerFactory 32import org.slf4j.LoggerFactory
32 33
33/** 34/**
@@ -39,15 +40,17 @@ class App : Application() {
39 appContext = applicationContext 40 appContext = applicationContext
40 handler = Handler() 41 handler = Handler()
41 AppLogger.configure() 42 AppLogger.configure()
42 setupCrashHandler()
43 43
44 val logger = LoggerFactory.getLogger(this.javaClass) 44 val logger = LoggerFactory.getLogger(this.javaClass)
45 setupCrashHandler(logger)
46
45 logger.info("Starting tinc app {} ({} build), running on {} ({})", 47 logger.info("Starting tinc app {} ({} build), running on {} ({})",
46 BuildConfig.VERSION_NAME, BuildConfig.BUILD_TYPE, Build.VERSION.CODENAME, Build.VERSION.RELEASE) 48 BuildConfig.VERSION_NAME, BuildConfig.BUILD_TYPE, Build.VERSION.CODENAME, Build.VERSION.RELEASE)
49
50 ConfigurationDirectoryMigrator().migrate()
47 } 51 }
48 52
49 private fun setupCrashHandler() { 53 private fun setupCrashHandler(logger: Logger) {
50 val logger = LoggerFactory.getLogger(this.javaClass)
51 val systemCrashHandler = Thread.getDefaultUncaughtExceptionHandler()!! 54 val systemCrashHandler = Thread.getDefaultUncaughtExceptionHandler()!!
52 val crashRecorder = CrashRecorder(logger, systemCrashHandler) 55 val crashRecorder = CrashRecorder(logger, systemCrashHandler)
53 Thread.setDefaultUncaughtExceptionHandler(crashRecorder) 56 Thread.setDefaultUncaughtExceptionHandler(crashRecorder)