Wear: log API level

This commit is contained in:
Milos Kozak 2022-05-05 23:05:48 +02:00
parent 3d9b08e5c2
commit 4eb05b01a8
4 changed files with 20 additions and 16 deletions

View file

@ -28,7 +28,6 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProv
import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.receivers.ReceiverStatusStore import info.nightscout.androidaps.receivers.ReceiverStatusStore
import info.nightscout.androidaps.utils.* import info.nightscout.androidaps.utils.*
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.utils.wizard.BolusWizard import info.nightscout.androidaps.utils.wizard.BolusWizard
import info.nightscout.androidaps.utils.wizard.QuickWizard import info.nightscout.androidaps.utils.wizard.QuickWizard
@ -46,7 +45,6 @@ import java.util.concurrent.TimeUnit
import java.util.stream.Collectors import java.util.stream.Collectors
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.collections.ArrayList
import kotlin.math.abs import kotlin.math.abs
import kotlin.math.min import kotlin.math.min
@ -89,6 +87,7 @@ class DataHandlerMobile @Inject constructor(
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ .subscribe({
aapsLogger.debug(LTag.WEAR, "Pong received from ${it.sourceNodeId}") aapsLogger.debug(LTag.WEAR, "Pong received from ${it.sourceNodeId}")
fabricPrivacy.logCustom("WearOS_${it.apiLevel}")
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus
.toObservable(EventData.CancelBolus::class.java) .toObservable(EventData.CancelBolus::class.java)

View file

@ -20,6 +20,7 @@ import info.nightscout.androidaps.plugins.general.wear.events.EventWearUpdateGui
import info.nightscout.androidaps.receivers.ReceiverStatusStore import info.nightscout.androidaps.receivers.ReceiverStatusStore
import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.utils.wizard.QuickWizard import info.nightscout.androidaps.utils.wizard.QuickWizard
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
@ -35,6 +36,7 @@ import javax.inject.Inject
class DataLayerListenerServiceMobile : WearableListenerService() { class DataLayerListenerServiceMobile : WearableListenerService() {
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var iobCobCalculator: IobCobCalculator @Inject lateinit var iobCobCalculator: IobCobCalculator
@Inject lateinit var rh: ResourceHelper @Inject lateinit var rh: ResourceHelper
@ -125,17 +127,21 @@ class DataLayerListenerServiceMobile : WearableListenerService() {
private var transcriptionNodeId: String? = null private var transcriptionNodeId: String? = null
private fun updateTranscriptionCapability() { private fun updateTranscriptionCapability() {
val capabilityInfo: CapabilityInfo = Tasks.await( try {
capabilityClient.getCapability(WEAR_CAPABILITY, CapabilityClient.FILTER_REACHABLE) val capabilityInfo: CapabilityInfo = Tasks.await(
) capabilityClient.getCapability(WEAR_CAPABILITY, CapabilityClient.FILTER_REACHABLE)
aapsLogger.debug(LTag.WEAR, "Nodes: ${capabilityInfo.nodes.joinToString(", ") { it.displayName + "(" + it.id + ")" }}") )
val bestNode = pickBestNodeId(capabilityInfo.nodes) aapsLogger.debug(LTag.WEAR, "Nodes: ${capabilityInfo.nodes.joinToString(", ") { it.displayName + "(" + it.id + ")" }}")
transcriptionNodeId = bestNode?.id val bestNode = pickBestNodeId(capabilityInfo.nodes)
wearPlugin.connectedDevice = bestNode?.displayName ?: "---" transcriptionNodeId = bestNode?.id
rxBus.send(EventWearUpdateGui()) wearPlugin.connectedDevice = bestNode?.displayName ?: "---"
aapsLogger.debug(LTag.WEAR, "Selected node: ${bestNode?.displayName} $transcriptionNodeId") rxBus.send(EventWearUpdateGui())
rxBus.send(EventMobileToWear(EventData.ActionPing(System.currentTimeMillis()))) aapsLogger.debug(LTag.WEAR, "Selected node: ${bestNode?.displayName} $transcriptionNodeId")
rxBus.send(EventData.ActionResendData("WatchUpdaterService")) rxBus.send(EventMobileToWear(EventData.ActionPing(System.currentTimeMillis())))
rxBus.send(EventData.ActionResendData("WatchUpdaterService"))
} catch (e: Exception) {
fabricPrivacy.logCustom("WearOS_unsupported")
}
} }
// Find a nearby node or pick one arbitrarily // Find a nearby node or pick one arbitrarily

View file

@ -19,7 +19,7 @@ sealed class EventData : Event() {
// Mobile <- Wear // Mobile <- Wear
@Serializable @Serializable
data class ActionPong(val timeStamp: Long) : EventData() data class ActionPong(val timeStamp: Long, val apiLevel: Int) : EventData()
@Serializable @Serializable
data class Error(val timeStamp: Long) : EventData() // ignored data class Error(val timeStamp: Long) : EventData() // ignored

View file

@ -57,7 +57,7 @@ class DataHandlerWear @Inject constructor(
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe { .subscribe {
aapsLogger.debug(LTag.WEAR, "Ping received from ${it.sourceNodeId}") aapsLogger.debug(LTag.WEAR, "Ping received from ${it.sourceNodeId}")
rxBus.send(EventWearToMobile(EventData.ActionPong(System.currentTimeMillis()))) rxBus.send(EventWearToMobile(EventData.ActionPong(System.currentTimeMillis(), Build.VERSION.SDK_INT)))
} }
disposable += rxBus disposable += rxBus
.toObservable(EventData.ConfirmAction::class.java) .toObservable(EventData.ConfirmAction::class.java)
@ -115,7 +115,6 @@ class DataHandlerWear @Inject constructor(
.subscribe { .subscribe {
aapsLogger.debug(LTag.WEAR, "Bolus progress received from ${it.sourceNodeId}") aapsLogger.debug(LTag.WEAR, "Bolus progress received from ${it.sourceNodeId}")
handleBolusProgress(it) handleBolusProgress(it)
rxBus.send(EventWearToMobile(EventData.ActionPong(System.currentTimeMillis())))
} }
disposable += rxBus disposable += rxBus
.toObservable(EventData.Status::class.java) .toObservable(EventData.Status::class.java)