mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 03:01:50 +01:00
Supporting more network transports (fixes miui) (again)
This commit is contained in:
parent
2c3f8e6b62
commit
bb422743dd
@ -14,6 +14,7 @@ import android.graphics.drawable.Drawable
|
|||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.NetworkCapabilities
|
import android.net.NetworkCapabilities
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
@ -243,15 +244,13 @@ fun Context.isOnline(): Boolean {
|
|||||||
var result = false
|
var result = false
|
||||||
connectivityManager?.let {
|
connectivityManager?.let {
|
||||||
val networkCapabilities = connectivityManager.activeNetwork ?: return false
|
val networkCapabilities = connectivityManager.activeNetwork ?: return false
|
||||||
val actNw =
|
val actNw = connectivityManager.getNetworkCapabilities(networkCapabilities) ?: return false
|
||||||
connectivityManager.getNetworkCapabilities(networkCapabilities) ?: return false
|
val maxTransport = when {
|
||||||
result = when {
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 -> NetworkCapabilities.TRANSPORT_LOWPAN
|
||||||
actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O -> NetworkCapabilities.TRANSPORT_WIFI_AWARE
|
||||||
actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
|
else -> NetworkCapabilities.TRANSPORT_VPN
|
||||||
actNw.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true
|
|
||||||
else -> false
|
|
||||||
}
|
}
|
||||||
|
result = (NetworkCapabilities.TRANSPORT_CELLULAR..maxTransport).any(actNw::hasTransport)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user