Prevent connection quality to exceed 100%

This commit is contained in:
Theo van Elsberg 2021-10-04 22:36:38 +02:00
parent 25b991a924
commit 0546976cbb

View file

@ -627,11 +627,14 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
} }
override fun connectionSuccessRatio(): Float { override fun connectionSuccessRatio(): Float {
val attempts = connectionAttempts if (connectionAttempts == 0) {
if (attempts == 0) {
return 0.0F return 0.0F
} }
return successfulConnections.toFloat() / attempts.toFloat() else if (connectionAttempts <= successfulConnections) {
// Prevent bogus quality > 1 during initialisation
return 1.0F
}
return successfulConnections.toFloat() / connectionAttempts.toFloat()
} }
override fun reset() { override fun reset() {