mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-14 18:26:11 -04:00
Improve final headphones checks and fix IllegalStateException if data changes between the final two checks.
This commit is contained in:
@@ -174,8 +174,14 @@ class TroubleShooterFragmentVM @Inject constructor(
|
||||
run {
|
||||
progress("Checking all closeby headphones.")
|
||||
|
||||
var otherDevices = withTimeoutOrNull(STEP_TIME) {
|
||||
podMonitor.devices.take(10).toList().flatten()
|
||||
val otherDevices = withTimeoutOrNull(STEP_TIME) {
|
||||
val start = System.currentTimeMillis()
|
||||
podMonitor.devices
|
||||
.take(10)
|
||||
.takeWhile { System.currentTimeMillis() - start < STEP_TIME - 1000 }
|
||||
.toList()
|
||||
.flatten()
|
||||
.distinctBy { it.address }
|
||||
} ?: emptyList()
|
||||
|
||||
if (otherDevices.isEmpty()) {
|
||||
@@ -189,18 +195,6 @@ class TroubleShooterFragmentVM @Inject constructor(
|
||||
generalSettings.mainDeviceAddress.value = null
|
||||
generalSettings.minimumSignalQuality.value = 0.25f
|
||||
|
||||
otherDevices = withTimeoutOrNull(STEP_TIME) {
|
||||
withTimeoutOrNull(STEP_TIME) {
|
||||
val start = System.currentTimeMillis()
|
||||
podMonitor.devices
|
||||
.take(10)
|
||||
.takeWhile { System.currentTimeMillis() - start < STEP_TIME - 1000 }
|
||||
.toList()
|
||||
.flatten()
|
||||
.distinctBy { it.address }
|
||||
} ?: emptyList()
|
||||
} ?: emptyList()
|
||||
|
||||
progress("Setting headphone with strongest signal as yours.")
|
||||
|
||||
generalSettings.mainDeviceModel.value = otherDevices.maxBy { it.signalQuality }.model
|
||||
|
||||
Reference in New Issue
Block a user