From a093fe3e3aaf9017e7048c19a994b337a052a198 Mon Sep 17 00:00:00 2001 From: MohitMali Date: Wed, 30 Nov 2022 10:39:18 +0530 Subject: [PATCH] improved wifi detection --- .../org/kiwix/kiwixmobile/core/utils/ConnectivityReporter.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ConnectivityReporter.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ConnectivityReporter.kt index 55753f155..f001cb335 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ConnectivityReporter.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ConnectivityReporter.kt @@ -18,6 +18,7 @@ package org.kiwix.kiwixmobile.core.utils +import android.net.wifi.SupplicantState.COMPLETED import android.net.wifi.WifiManager import java.lang.reflect.InvocationTargetException import java.lang.reflect.Method @@ -25,7 +26,8 @@ import javax.inject.Inject class ConnectivityReporter @Inject constructor(private val wifiManager: WifiManager) { - fun checkWifi(): Boolean = wifiManager.isWifiEnabled && wifiManager.connectionInfo.networkId != -1 + fun checkWifi(): Boolean = + wifiManager.isWifiEnabled && wifiManager.connectionInfo.supplicantState == COMPLETED fun checkTethering(): Boolean = try { val method: Method = wifiManager.javaClass.getDeclaredMethod("isWifiApEnabled")