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.receivers.ReceiverStatusStore
import info.nightscout.androidaps.utils.*
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.utils.wizard.BolusWizard
import info.nightscout.androidaps.utils.wizard.QuickWizard
@ -46,7 +45,6 @@ import java.util.concurrent.TimeUnit
import java.util.stream.Collectors
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.collections.ArrayList
import kotlin.math.abs
import kotlin.math.min
@ -89,6 +87,7 @@ class DataHandlerMobile @Inject constructor(
.observeOn(aapsSchedulers.io)
.subscribe({
aapsLogger.debug(LTag.WEAR, "Pong received from ${it.sourceNodeId}")
fabricPrivacy.logCustom("WearOS_${it.apiLevel}")
}, fabricPrivacy::logException)
disposable += rxBus
.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.utils.DefaultValueHelper
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.utils.wizard.QuickWizard
import info.nightscout.shared.logging.AAPSLogger
@ -35,6 +36,7 @@ import javax.inject.Inject
class DataLayerListenerServiceMobile : WearableListenerService() {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var iobCobCalculator: IobCobCalculator
@Inject lateinit var rh: ResourceHelper
@ -125,17 +127,21 @@ class DataLayerListenerServiceMobile : WearableListenerService() {
private var transcriptionNodeId: String? = null
private fun updateTranscriptionCapability() {
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)
transcriptionNodeId = bestNode?.id
wearPlugin.connectedDevice = bestNode?.displayName ?: "---"
rxBus.send(EventWearUpdateGui())
aapsLogger.debug(LTag.WEAR, "Selected node: ${bestNode?.displayName} $transcriptionNodeId")
rxBus.send(EventMobileToWear(EventData.ActionPing(System.currentTimeMillis())))
rxBus.send(EventData.ActionResendData("WatchUpdaterService"))
try {
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)
transcriptionNodeId = bestNode?.id
wearPlugin.connectedDevice = bestNode?.displayName ?: "---"
rxBus.send(EventWearUpdateGui())
aapsLogger.debug(LTag.WEAR, "Selected node: ${bestNode?.displayName} $transcriptionNodeId")
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

View file

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

View file

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