Adaptively change duration to wait before showing offline indicator
Adaptively change duration to wait before showing offline indicator. If the device has been recently online, then we wait a long time before showing an offline indicator. This gives device sufficient time to switch over to a different network. If the device has not been recently online (e.g., at the app startup or when app is brought to foreground), we wait shorter time of 2 seconds before invoking the offline indicator callback. This shorter duration is sufficient to catch racing issues related to Android API callbacks, i.e., 2 seconds is sufficient that we receive connection change callback from Android when app is brought to foreground. Having the 2 different timeouts ensures that we respond faster when needed while reducing the false positives when the device is taking too long to switch the network. This approach may still lead to indicator being temporarily wrong in some niche edge cases, but eventually (at most 10 seconds) the snackbar would be correct. Change-Id: I6ef350c86973d8449be54930d1e1972706eb5c92 Bug: 1084740 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2303983 Commit-Queue: Tarun Bansal <tbansal@chromium.org> Reviewed-by:Theresa <twellington@chromium.org> Cr-Commit-Position: refs/heads/master@{#791112}
Showing
Please register or sign in to comment