Refresh isConnectionNecessary on network block changes.

This commit is contained in:
Clark
2023-06-27 11:41:25 -04:00
committed by Nicholas
parent b6589637fa
commit c08f1355db
2 changed files with 8 additions and 2 deletions

View File

@@ -88,9 +88,9 @@ class IncomingMessageObserver(private val context: Application) {
private val lock: ReentrantLock = ReentrantLock()
private val connectionNecessarySemaphore = Semaphore(0)
private val networkConnectionListener = NetworkConnectionListener(context) { isNetworkAvailable ->
private val networkConnectionListener = NetworkConnectionListener(context) { isNetworkUnavailable ->
lock.withLock {
if (isNetworkAvailable()) {
if (isNetworkUnavailable()) {
Log.w(TAG, "Lost network connection. Shutting down our websocket connections and resetting the drained state.")
decryptionDrained = false
disconnect()

View File

@@ -38,6 +38,12 @@ class NetworkConnectionListener(private val context: Context, private val onNetw
onNetworkLost { true }
}
override fun onBlockedStatusChanged(network: Network, blocked: Boolean) {
super.onBlockedStatusChanged(network, blocked)
Log.d(TAG, "ConnectivityManager.NetworkCallback onBlockedStatusChanged()")
onNetworkLost { blocked }
}
override fun onAvailable(network: Network) {
super.onAvailable(network)
Log.d(TAG, "ConnectivityManager.NetworkCallback onAvailable()")