Respect bounds for heartbeat intervals when learning from timeouts

Without this it can happen that we learn the interval too close to 0 which causes us to assume that we are always disconnected breaking Mcs network functionality

Change-Id: I0dee59d1365a8e10941dd346bfcd7af19d79d523
This commit is contained in:
Torsten Grote 2021-10-13 13:38:45 -03:00 committed by Marvin W
parent 00a06d4b94
commit 222b03f7ee

View File

@ -125,13 +125,16 @@ data class GcmPrefs(
Log.d("GmsGcmPrefs", "learnTimeout: $pref")
when (pref) {
PREF_NETWORK_MOBILE, PREF_NETWORK_ROAMING -> setSettings(context, Gcm.getContentUri(context)) {
put(Gcm.LEARNT_MOBILE, (learntMobileInterval * 0.95).toInt())
val newInterval = (learntMobileInterval * 0.95).toInt()
put(Gcm.LEARNT_MOBILE, max(MIN_INTERVAL, min(newInterval, MAX_INTERVAL)))
}
PREF_NETWORK_WIFI -> setSettings(context, Gcm.getContentUri(context)) {
put(Gcm.LEARNT_WIFI, (learntWifiInterval * 0.95).toInt())
val newInterval = (learntWifiInterval * 0.95).toInt()
put(Gcm.LEARNT_WIFI, max(MIN_INTERVAL, min(newInterval, MAX_INTERVAL)))
}
else -> setSettings(context, Gcm.getContentUri(context)) {
put(Gcm.LEARNT_OTHER, (learntOtherInterval * 0.95).toInt())
val newInterval = (learntOtherInterval * 0.95).toInt()
put(Gcm.LEARNT_OTHER, max(MIN_INTERVAL, min(newInterval, MAX_INTERVAL)))
}
}
}