mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 05:35:39 +03:00
Test also for connected networks
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
bdf90f0a1c
commit
e20f69dd7f
1 changed files with 4 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue