Implement periodic checks for wear

This commit is contained in:
darken
2022-09-14 18:00:18 +02:00
committed by Matthias Urhahn
parent 87ca90f6cc
commit ca2e4fec79
10 changed files with 174 additions and 17 deletions
@@ -65,7 +65,7 @@ class OverviewFragmentVM @Inject constructor(
}
val shouldStartMonitor = when (generalSettings.monitorMode.value) {
MonitorMode.PERIODICALLY, MonitorMode.MANUAL -> false
MonitorMode.MANUAL -> false
MonitorMode.AUTOMATIC -> bluetoothManager.connectedDevices().first().isNotEmpty()
MonitorMode.ALWAYS -> true
}
@@ -127,10 +127,10 @@ class MonitorWorker @AssistedInject constructor(
.flatMapLatest { (monitorMode, devices) ->
log(TAG) { "Monitor mode: $monitorMode" }
when (monitorMode) {
MonitorMode.PERIODICALLY, MonitorMode.MANUAL -> flow<Unit> {
// Cancel worker, ui scans manually
workerScope.coroutineContext.cancelChildren()
}
MonitorMode.MANUAL -> flow<Unit> {
// Cancel worker, ui scans manually
workerScope.coroutineContext.cancelChildren()
}
MonitorMode.ALWAYS -> emptyFlow()
MonitorMode.AUTOMATIC -> flow {
val mainAddress = generalSettings.mainDeviceAddress.value