fix logcat crash
This commit is contained in:
parent
f28b60751c
commit
05733a72eb
2 changed files with 14 additions and 5 deletions
|
@ -1,8 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.general.maintenance
|
||||
|
||||
import ch.qos.logback.classic.LoggerContext
|
||||
import info.nightscout.androidaps.annotations.OpenForTesting
|
||||
import org.slf4j.LoggerFactory
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
@ -11,7 +9,9 @@ import javax.inject.Singleton
|
|||
*/
|
||||
@OpenForTesting
|
||||
@Singleton
|
||||
class LoggerUtils @Inject constructor() {
|
||||
class LoggerUtils @Inject constructor(
|
||||
val prefFileListProvider: PrefFileListProvider
|
||||
) {
|
||||
|
||||
var suffix = ".log.zip"
|
||||
|
||||
|
@ -21,9 +21,15 @@ class LoggerUtils @Inject constructor() {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
/*
|
||||
This is failing after slf4j update to 2.0.0
|
||||
It would be better to find a way to read the value from xml
|
||||
So far replaced by static value
|
||||
val logDirectory: String
|
||||
get() {
|
||||
val lc = LoggerFactory.getILoggerFactory() as LoggerContext
|
||||
return lc.getProperty("EXT_FILES_DIR")
|
||||
}
|
||||
*/
|
||||
val logDirectory get() = prefFileListProvider.logsPath
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.general.maintenance
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Environment
|
||||
import info.nightscout.androidaps.annotations.OpenForTesting
|
||||
import info.nightscout.androidaps.core.R
|
||||
|
@ -26,7 +27,8 @@ class PrefFileListProvider @Inject constructor(
|
|||
private val config: Config,
|
||||
private val encryptedPrefsFormat: EncryptedPrefsFormat,
|
||||
private val storage: Storage,
|
||||
private val versionCheckerUtils: VersionCheckerUtils
|
||||
private val versionCheckerUtils: VersionCheckerUtils,
|
||||
context: Context
|
||||
) {
|
||||
@Suppress("DEPRECATION")
|
||||
private val path = File(Environment.getExternalStorageDirectory().toString())
|
||||
|
@ -34,6 +36,7 @@ class PrefFileListProvider @Inject constructor(
|
|||
private val exportsPath = File(path, "AAPS" + File.separator + "exports")
|
||||
private val tempPath = File(path, "AAPS" + File.separator + "temp")
|
||||
private val extraPath = File(path, "AAPS" + File.separator + "extra")
|
||||
val logsPath: String = File(path, "AAPS" + File.separator + "logs" + File.separator + context.packageName).absolutePath
|
||||
|
||||
companion object {
|
||||
|
||||
|
@ -85,7 +88,7 @@ class PrefFileListProvider @Inject constructor(
|
|||
return checkMetadata(encryptedPrefsFormat.loadMetadata(contents))
|
||||
}
|
||||
|
||||
fun legacyFile(): File {
|
||||
@Suppress("unused") fun legacyFile(): File {
|
||||
return File(path, rh.gs(R.string.app_name) + "Preferences")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue