Commit 226583f0 by olly Committed by Oliver Woodman

Reintroduce isConnected check for download requirements

PiperOrigin-RevId: 314925639
parent ee0c6224
......@@ -156,7 +156,10 @@ public final class Requirements implements Parcelable {
ConnectivityManager connectivityManager =
(ConnectivityManager)
Assertions.checkNotNull(context.getSystemService(Context.CONNECTIVITY_SERVICE));
if (!isInternetConnectivityValidated(connectivityManager)) {
@Nullable NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if (networkInfo == null
|| !networkInfo.isConnected()
|| !isInternetConnectivityValidated(connectivityManager)) {
return requirements & (NETWORK | NETWORK_UNMETERED);
}
......@@ -197,11 +200,10 @@ public final class Requirements implements Parcelable {
private static boolean isInternetConnectivityValidated(ConnectivityManager connectivityManager) {
// It's possible to check NetworkCapabilities.NET_CAPABILITY_VALIDATED from API level 23, but
// RequirementsWatcher only fires an event to re-check the requirements when NetworkCapabilities
// change from API level 24. We use the legacy path for API level 23 here to keep in sync.
// change from API level 24. We assume that network capability is validated for API level 23 to
// keep in sync.
if (Util.SDK_INT < 24) {
// Legacy path.
@Nullable NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
return networkInfo != null && networkInfo.isConnected();
return true;
}
@Nullable Network activeNetwork = connectivityManager.getActiveNetwork();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment