move logs, eng_mode to AAPS directory
This commit is contained in:
parent
5867ff8b93
commit
596012ab10
7 changed files with 35 additions and 15 deletions
|
@ -52,7 +52,8 @@
|
||||||
android:name="com.google.android.gms.car.application"
|
android:name="com.google.android.gms.car.application"
|
||||||
android:resource="@xml/automotive_app_desc" />
|
android:resource="@xml/automotive_app_desc" />
|
||||||
|
|
||||||
<activity android:name=".MainActivity">
|
<activity android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
@ -60,7 +61,8 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".activities.PreferencesActivity" />
|
<activity android:name=".activities.PreferencesActivity" />
|
||||||
<activity android:name=".plugins.general.overview.activities.QuickWizardListActivity">
|
<activity android:name=".plugins.general.overview.activities.QuickWizardListActivity"
|
||||||
|
android:exported="false">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity" />
|
<action android:name="info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity" />
|
||||||
|
|
||||||
|
@ -115,11 +117,11 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<!-- Receiver keepalive, scheduled every 30 min -->
|
<!-- Receiver keep alive, scheduled every 30 min -->
|
||||||
<receiver android:name=".receivers.KeepAliveReceiver" />
|
<receiver android:name=".receivers.KeepAliveReceiver" />
|
||||||
|
|
||||||
<!-- Receive ignore 5m, 15m, 30m requests for carb notifications -->
|
<!-- Receive ignore 5m, 15m, 30m requests for carb notifications -->
|
||||||
<receiver android:name=".plugins.aps.loop.CarbSuggestionReceiver"></receiver>
|
<receiver android:name=".plugins.aps.loop.CarbSuggestionReceiver" />
|
||||||
|
|
||||||
<!-- Auto start -->
|
<!-- Auto start -->
|
||||||
<receiver
|
<receiver
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- Create a file appender for a log in the application's data directory -->
|
<!-- Create a file appender for a log in the application's data directory -->
|
||||||
<property name="EXT_FILES_DIR" scope="context"
|
<property name="EXT_FILES_DIR" scope="context"
|
||||||
value="${EXT_DIR:-/sdcard}/Android/data/${PACKAGE_NAME}/files" />
|
value="${EXT_DIR:-/sdcard}/AAPS/logs/${PACKAGE_NAME}" />
|
||||||
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>${EXT_FILES_DIR}/AndroidAPS.log</file>
|
<file>${EXT_FILES_DIR}/AndroidAPS.log</file>
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
|
|
@ -63,7 +63,9 @@ class MaintenanceFragment : DaggerFragment() {
|
||||||
binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() }
|
binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() }
|
||||||
binding.logDelete.setOnClickListener {
|
binding.logDelete.setOnClickListener {
|
||||||
uel.log(Action.DELETE_LOGS, Sources.Maintenance)
|
uel.log(Action.DELETE_LOGS, Sources.Maintenance)
|
||||||
maintenancePlugin.deleteLogs()
|
Thread {
|
||||||
|
maintenancePlugin.deleteLogs(5)
|
||||||
|
}.start()
|
||||||
}
|
}
|
||||||
binding.navResetdb.setOnClickListener {
|
binding.navResetdb.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
|
|
|
@ -35,6 +35,7 @@ class MaintenancePlugin @Inject constructor(
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
private val buildHelper: BuildHelper,
|
private val buildHelper: BuildHelper,
|
||||||
private val config: Config,
|
private val config: Config,
|
||||||
|
private val fileListProvider: PrefFileListProvider,
|
||||||
private val loggerUtils: LoggerUtils
|
private val loggerUtils: LoggerUtils
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
|
@ -53,7 +54,7 @@ class MaintenancePlugin @Inject constructor(
|
||||||
val recipient = sp.getString(R.string.key_maintenance_logs_email, "logs@androidaps.org")
|
val recipient = sp.getString(R.string.key_maintenance_logs_email, "logs@androidaps.org")
|
||||||
val amount = sp.getInt(R.string.key_maintenance_logs_amount, 2)
|
val amount = sp.getInt(R.string.key_maintenance_logs_amount, 2)
|
||||||
val logs = getLogFiles(amount)
|
val logs = getLogFiles(amount)
|
||||||
val zipDir = context.getExternalFilesDir("exports")
|
val zipDir = fileListProvider.ensureExportDirExists()
|
||||||
val zipFile = File(zipDir, constructName())
|
val zipFile = File(zipDir, constructName())
|
||||||
aapsLogger.debug("zipFile: ${zipFile.absolutePath}")
|
aapsLogger.debug("zipFile: ${zipFile.absolutePath}")
|
||||||
val zip = zipLogs(zipFile, logs)
|
val zip = zipLogs(zipFile, logs)
|
||||||
|
@ -65,14 +66,14 @@ class MaintenancePlugin @Inject constructor(
|
||||||
|
|
||||||
//todo replace this with a call on startup of the application, specifically to remove
|
//todo replace this with a call on startup of the application, specifically to remove
|
||||||
// unnecessary garbage from the log exports
|
// unnecessary garbage from the log exports
|
||||||
fun deleteLogs() {
|
fun deleteLogs(keep: Int) {
|
||||||
val logDir = File(loggerUtils.logDirectory)
|
val logDir = File(loggerUtils.logDirectory)
|
||||||
val files = logDir.listFiles { _: File?, name: String ->
|
val files = logDir.listFiles { _: File?, name: String ->
|
||||||
(name.startsWith("AndroidAPS") && name.endsWith(".zip"))
|
(name.startsWith("AndroidAPS") && name.endsWith(".zip"))
|
||||||
}
|
}
|
||||||
Arrays.sort(files) { f1: File, f2: File -> f1.name.compareTo(f2.name) }
|
Arrays.sort(files) { f1: File, f2: File -> f1.name.compareTo(f2.name) }
|
||||||
var delFiles = listOf(*files)
|
var delFiles = listOf(*files)
|
||||||
val amount = sp.getInt(R.string.key_logshipper_amount, 5)
|
val amount = sp.getInt(R.string.key_logshipper_amount, keep)
|
||||||
val keepIndex = amount - 1
|
val keepIndex = amount - 1
|
||||||
if (keepIndex < delFiles.size) {
|
if (keepIndex < delFiles.size) {
|
||||||
delFiles = delFiles.subList(keepIndex, delFiles.size)
|
delFiles = delFiles.subList(keepIndex, delFiles.size)
|
||||||
|
@ -80,7 +81,7 @@ class MaintenancePlugin @Inject constructor(
|
||||||
file.delete()
|
file.delete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val exportDir = File(loggerUtils.logDirectory, "exports")
|
val exportDir = fileListProvider.ensureExportDirExists()
|
||||||
if (exportDir.exists()) {
|
if (exportDir.exists()) {
|
||||||
val expFiles = exportDir.listFiles()
|
val expFiles = exportDir.listFiles()
|
||||||
for (file in expFiles) {
|
for (file in expFiles) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration
|
import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
|
@ -72,6 +73,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@Inject lateinit var maintenancePlugin: MaintenancePlugin
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||||
|
@ -93,6 +95,8 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
|
||||||
localAlertUtils.checkStaleBGAlert()
|
localAlertUtils.checkStaleBGAlert()
|
||||||
checkPump()
|
checkPump()
|
||||||
checkAPS()
|
checkAPS()
|
||||||
|
maintenancePlugin.deleteLogs(30)
|
||||||
|
|
||||||
return Result.success()
|
return Result.success()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,20 +2,22 @@ package info.nightscout.androidaps.utils.buildHelper
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig
|
import info.nightscout.androidaps.BuildConfig
|
||||||
import info.nightscout.androidaps.interfaces.Config
|
import info.nightscout.androidaps.interfaces.Config
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.LoggerUtils
|
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class BuildHelper @Inject constructor(private val config: Config, loggerUtils: LoggerUtils) {
|
class BuildHelper @Inject constructor(
|
||||||
|
private val config: Config,
|
||||||
|
fileListProvider: PrefFileListProvider
|
||||||
|
) {
|
||||||
|
|
||||||
private var devBranch = false
|
private var devBranch = false
|
||||||
private var engineeringMode = false
|
private var engineeringMode = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val extFilesDir = loggerUtils.logDirectory
|
val engineeringModeSemaphore = File(fileListProvider.ensureExtraDirExists(), "engineering__mode")
|
||||||
val engineeringModeSemaphore = File(extFilesDir, "engineering__mode")
|
|
||||||
|
|
||||||
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile
|
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile
|
||||||
devBranch = BuildConfig.VERSION.contains("-") || BuildConfig.VERSION.matches(Regex(".*[a-zA-Z]+.*"))
|
devBranch = BuildConfig.VERSION.contains("-") || BuildConfig.VERSION.matches(Regex(".*[a-zA-Z]+.*"))
|
||||||
|
|
|
@ -32,6 +32,7 @@ class PrefFileListProvider @Inject constructor(
|
||||||
private val path = File(Environment.getExternalStorageDirectory().toString())
|
private val path = File(Environment.getExternalStorageDirectory().toString())
|
||||||
private val aapsPath = File(path, "AAPS" + File.separator + "preferences")
|
private val aapsPath = File(path, "AAPS" + File.separator + "preferences")
|
||||||
private val exportsPath = File(path, "AAPS" + File.separator + "exports")
|
private val exportsPath = File(path, "AAPS" + File.separator + "exports")
|
||||||
|
private val extraPath = File(path, "AAPS" + File.separator + "extra")
|
||||||
private const val IMPORT_AGE_NOT_YET_OLD_DAYS = 60
|
private const val IMPORT_AGE_NOT_YET_OLD_DAYS = 60
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,13 +91,21 @@ class PrefFileListProvider @Inject constructor(
|
||||||
return File(path, resourceHelper.gs(R.string.app_name) + "Preferences")
|
return File(path, resourceHelper.gs(R.string.app_name) + "Preferences")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ensureExportDirExists() {
|
fun ensureExportDirExists(): File {
|
||||||
if (!aapsPath.exists()) {
|
if (!aapsPath.exists()) {
|
||||||
aapsPath.mkdirs()
|
aapsPath.mkdirs()
|
||||||
}
|
}
|
||||||
if (!exportsPath.exists()) {
|
if (!exportsPath.exists()) {
|
||||||
exportsPath.mkdirs()
|
exportsPath.mkdirs()
|
||||||
}
|
}
|
||||||
|
return exportsPath
|
||||||
|
}
|
||||||
|
|
||||||
|
fun ensureExtraDirExists(): File {
|
||||||
|
if (!extraPath.exists()) {
|
||||||
|
extraPath.mkdirs()
|
||||||
|
}
|
||||||
|
return extraPath
|
||||||
}
|
}
|
||||||
|
|
||||||
fun newExportFile(): File {
|
fun newExportFile(): File {
|
||||||
|
|
Loading…
Reference in a new issue