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 grpc#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 authored and ejona86 committed Feb 9, 2022
1 parent 81ac88a commit 9537bba
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -293,6 +293,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 9537bba

Please sign in to comment.