From a4a49489bd915a05a7baa0c7e8aa6a586adcba74 Mon Sep 17 00:00:00 2001 From: 821938089 <821938089@qq.com> Date: Sun, 10 Jul 2022 17:21:36 +0800 Subject: [PATCH] fix webdav network detect bug --- .../java/io/legado/app/utils/NetworkUtils.kt | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt index c78ed87b4..5b8b4d906 100644 --- a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt +++ b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt @@ -27,22 +27,24 @@ object NetworkUtils { if (Build.VERSION.SDK_INT < 23) { val mWiFiNetworkInfo = connectivityManager.activeNetworkInfo if (mWiFiNetworkInfo != null) { - //移动数据 - return if (mWiFiNetworkInfo.type == ConnectivityManager.TYPE_WIFI) { - //WIFI - true - } else mWiFiNetworkInfo.type == ConnectivityManager.TYPE_MOBILE + // WIFI + return mWiFiNetworkInfo.type == ConnectivityManager.TYPE_WIFI || + // 移动数据 + mWiFiNetworkInfo.type == ConnectivityManager.TYPE_MOBILE || + // 以太网 + mWiFiNetworkInfo.type == ConnectivityManager.TYPE_ETHERNET } } else { val network = connectivityManager.activeNetwork if (network != null) { val nc = connectivityManager.getNetworkCapabilities(network) if (nc != null) { - //移动数据 - return if (nc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) { - //WIFI - true - } else nc.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) + // WIFI + return nc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) || + // 移动数据 + nc.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) || + // 以太网 + nc.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) } } }