Skip to content

Commit

Permalink
android: fix for app coming to foreground
Browse files Browse the repository at this point in the history
When an app goes to the background, onBlockedStatusChanged is called with true and then called with false when it comes back to the foreground. The function onAvailable isn't called in this case and the connection wasn't being reset. Closes #8850

I noticed the comment that this is used for API versions 24+ but onBlockedStatusChanged was added in 29. I'm not sure if some kind of guard needs to be added or not.
https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback#onBlockedStatusChanged(android.net.Network,%20boolean)
  • Loading branch information
litclimbing committed Feb 3, 2022
1 parent 7308d92 commit ca4a1d8
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -297,6 +297,11 @@ private class DefaultNetworkCallback extends ConnectivityManager.NetworkCallback
public void onAvailable(Network network) {
delegate.enterIdle();
}
@Override
public void onBlockedStatusChanged (Network network, boolean blocked) {
if (!blocked)
delegate.enterIdle();
}
}

/** Respond to network changes. Only used on API levels < 24. */
Expand Down

0 comments on commit ca4a1d8

Please sign in to comment.