Merge pull request #7565 from nextcloud/hardenConnectionCheck

getActiveNetwork might be null
This commit is contained in:
Andy Scherzinger 2020-11-30 13:13:10 +01:00 committed by GitHub
commit dc0337476d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -118,7 +118,11 @@ class ConnectivityServiceImpl implements ConnectivityService {
NetworkCapabilities networkCapabilities = platformConnectivityManager.getNetworkCapabilities(
platformConnectivityManager.getActiveNetwork());
isMetered = !networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
if (networkCapabilities != null) {
isMetered = !networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
} else {
isMetered = ConnectivityManagerCompat.isActiveNetworkMetered(platformConnectivityManager);
}
} else {
isMetered = ConnectivityManagerCompat.isActiveNetworkMetered(platformConnectivityManager);
}