mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Reintroduce isConnected check for download requirements
PiperOrigin-RevId: 314925639
This commit is contained in:
parent
ee0c6224af
commit
226583f01c
1 changed files with 7 additions and 5 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue