uel.log for Start and Exit AAPS

This commit is contained in:
Philoul 2021-04-10 11:35:38 +02:00
parent 5a143b5444
commit c728f8689b
8 changed files with 36 additions and 15 deletions

View file

@ -32,6 +32,8 @@ import info.nightscout.androidaps.activities.PreferencesActivity
import info.nightscout.androidaps.activities.ProfileHelperActivity
import info.nightscout.androidaps.activities.SingleFragmentActivity
import info.nightscout.androidaps.activities.StatsActivity
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.databinding.ActivityMainBinding
import info.nightscout.androidaps.events.EventAppExit
import info.nightscout.androidaps.events.EventPreferenceChange
@ -41,6 +43,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
@ -87,6 +90,7 @@ class MainActivity : NoSplashAppCompatActivity() {
@Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var signatureVerifierPlugin: SignatureVerifierPlugin
@Inject lateinit var config: Config
@Inject lateinit var uel: UserEntryLogger
private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
private var pluginPreferencesMenuItem: MenuItem? = null
@ -316,6 +320,7 @@ class MainActivity : NoSplashAppCompatActivity() {
R.id.nav_exit -> {
aapsLogger.debug(LTag.CORE, "Exiting")
uel.log(Action.EXIT_AAPS, Sources.Aaps)
rxBus.send(EventAppExit())
finish()
System.runFinalization()

View file

@ -11,6 +11,7 @@ import dagger.android.AndroidInjector
import dagger.android.DaggerApplication
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
import info.nightscout.androidaps.database.transactions.VersionChangeTransaction
import info.nightscout.androidaps.db.CompatDBHelper
@ -20,6 +21,7 @@ import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
@ -54,6 +56,7 @@ class MainApp : DaggerApplication() {
@Inject lateinit var repository: AppRepository
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var staticInjector: StaticInjector// TODO avoid , here fake only to initialize
@Inject lateinit var uel: UserEntryLogger
override fun onCreate() {
super.onCreate()
@ -85,6 +88,7 @@ class MainApp : DaggerApplication() {
configBuilderPlugin.initialize()
keepAliveManager.setAlarm(this)
doMigrations()
uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps)
}
private fun doMigrations() {

View file

@ -94,6 +94,8 @@ class Translator @Inject internal constructor(
Action.OTP_RESET -> resourceHelper.gs(R.string.uel_otp_reset)
Action.EXPORT_CSV -> resourceHelper.gs(R.string.uel_export_csv)
Action.STOP_SMS -> resourceHelper.gs(R.string.uel_stop_sms)
Action.START_AAPS -> resourceHelper.gs(R.string.uel_start_aaps)
Action.EXIT_AAPS -> resourceHelper.gs(R.string.uel_exit_aaps)
Action.UNKNOWN -> resourceHelper.gs(R.string.unknown)
}
@ -263,6 +265,7 @@ class Translator @Inject internal constructor(
Sources.ConfigBuilder -> TODO()
Sources.Overview -> TODO()
Sources.Stats -> TODO()
Sources.Aaps -> TODO()
*/
Sources.Automation -> resourceHelper.gs(R.string.automation)
Sources.Loop -> resourceHelper.gs(R.string.loop)

View file

@ -79,6 +79,8 @@ class UserEntryMapper {
STOP_SMS (UserEntry.Action.STOP_SMS),
FOOD (UserEntry.Action.FOOD),
EXPORT_CSV (UserEntry.Action.EXPORT_CSV),
START_AAPS (UserEntry.Action.START_AAPS),
EXIT_AAPS (UserEntry.Action.EXIT_AAPS),
UNKNOWN (UserEntry.Action.UNKNOWN)
;
}
@ -141,6 +143,7 @@ class UserEntryMapper {
ConfigBuilder (UserEntry.Sources.ConfigBuilder),
Overview (UserEntry.Sources.Overview),
Stats (UserEntry.Sources.Stats),
Aaps (UserEntry.Sources.Aaps),
Unknown(UserEntry.Sources.Unknown)
;
}

View file

@ -28,13 +28,13 @@ class UserEntryPresentationHelper @Inject constructor(
fun colorId(colorGroup: ColorGroup): Int = when (colorGroup) {
ColorGroup.InsulinTreatment -> R.color.iob
ColorGroup.BasalTreatment -> R.color.basal
ColorGroup.CarbTreatment -> R.color.carbs
ColorGroup.TT -> R.color.tempTargetConfirmation
ColorGroup.Profile -> R.color.white
ColorGroup.Loop -> R.color.loopClosed
ColorGroup.Careportal -> R.color.high
ColorGroup.Pump -> R.color.loopDisconnected
ColorGroup.Aaps -> R.color.defaulttext
ColorGroup.CarbTreatment -> R.color.carbs
ColorGroup.TT -> R.color.tempTargetConfirmation
ColorGroup.Profile -> R.color.white
ColorGroup.Loop -> R.color.loopClosed
ColorGroup.Careportal -> R.color.high
ColorGroup.Pump -> R.color.loopDisconnected
ColorGroup.Aaps -> R.color.defaulttext
else -> R.color.defaulttext
}
@ -89,14 +89,15 @@ class UserEntryPresentationHelper @Inject constructor(
Sources.OmnipodDash -> R.drawable.ic_pod_128
Sources.MDI -> R.drawable.ic_ict
Sources.VirtualPump -> R.drawable.ic_virtual_pump
Sources.SMS -> R.drawable.ic_sms
Sources.Treatments -> R.drawable.ic_treatments
Sources.Wear -> R.drawable.ic_watch
Sources.Food -> R.drawable.ic_food
Sources.Stats -> R.drawable.ic_cp_stats
Sources.ConfigBuilder -> R.drawable.ic_generic_icon
Sources.Overview -> R.drawable.ic_generic_icon
Sources.Unknown -> R.drawable.ic_generic_icon
Sources.SMS -> R.drawable.ic_sms
Sources.Treatments -> R.drawable.ic_treatments
Sources.Wear -> R.drawable.ic_watch
Sources.Food -> R.drawable.ic_food
Sources.Stats -> R.drawable.ic_cp_stats
Sources.ConfigBuilder -> R.drawable.ic_cogs
Sources.Overview -> R.drawable.ic_notif_aaps
Sources.Aaps -> R.drawable.ic_notif_aaps
Sources.Unknown -> R.drawable.ic_generic_icon
}
fun actionToColoredString(action: Action): Spanned = when (action) {

View file

@ -477,6 +477,8 @@
<string name="uel_otp_reset">OTP RESET</string>
<string name="uel_stop_sms">STOP SMS</string>
<string name="uel_export_csv">EXPORT USER ENTRIES</string>
<string name="uel_start_aaps">START AAPS</string>
<string name="uel_exit_aaps">EXIT AAPS</string>
<string name="uel_unknown">UNKNOWN</string>
<string name="ue_formated_string">Formated string</string>
<string name="ue_source">Source</string>

View file

@ -94,6 +94,8 @@ data class UserEntry(
STOP_SMS (ColorGroup.Aaps),
FOOD (ColorGroup.CarbTreatment),
EXPORT_CSV (ColorGroup.Aaps),
START_AAPS (ColorGroup.Aaps),
EXIT_AAPS (ColorGroup.Aaps),
UNKNOWN (ColorGroup.Aaps)
;
@ -160,6 +162,7 @@ data class UserEntry(
ConfigBuilder, //From ConfigBuilder Plugin
Overview, //From OverViewPlugin
Stats, //From Stat Activity
Aaps, // MainApp
Unknown //if necessary
;