Test also for connected networks

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2020-10-29 13:38:35 +01:00
parent bdf90f0a1c
commit e20f69dd7f
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7

View file

@ -111,16 +111,17 @@ class ConnectivityServiceImpl implements ConnectivityService {
if (networkInfo != null) {
boolean isConnected = networkInfo.isConnectedOrConnecting();
boolean isMetered = ConnectivityManagerCompat.isActiveNetworkMetered(platformConnectivityManager);
boolean isWifi = networkInfo.getType() == ConnectivityManager.TYPE_WIFI || isAnyOtherNetworkWifi();
boolean isWifi = networkInfo.getType() == ConnectivityManager.TYPE_WIFI || hasNonCellularConnectivity();
return new Connectivity(isConnected, isMetered, isWifi, null);
} else {
return Connectivity.DISCONNECTED;
}
}
private boolean isAnyOtherNetworkWifi() {
private boolean hasNonCellularConnectivity() {
for (NetworkInfo networkInfo : platformConnectivityManager.getAllNetworkInfo()) {
if (networkInfo.isConnectedOrConnecting() && networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
if (networkInfo.isConnectedOrConnecting() && (networkInfo.getType() == ConnectivityManager.TYPE_WIFI ||
networkInfo.getType() == ConnectivityManager.TYPE_ETHERNET)) {
return true;
}
}