android: fix for app coming to foreground

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)
This commit is contained in:
litclimbing 2022-02-03 16:56:43 -07:00 committed by GitHub
parent 7308d92034
commit ca4a1d8ca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -297,6 +297,11 @@ public final class AndroidChannelBuilder extends ForwardingChannelBuilder<Androi
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. */