mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-12 08:58:51 -04:00
improved wifi detection
This commit is contained in:
parent
62dc918eff
commit
a093fe3e3a
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.utils
|
package org.kiwix.kiwixmobile.core.utils
|
||||||
|
|
||||||
|
import android.net.wifi.SupplicantState.COMPLETED
|
||||||
import android.net.wifi.WifiManager
|
import android.net.wifi.WifiManager
|
||||||
import java.lang.reflect.InvocationTargetException
|
import java.lang.reflect.InvocationTargetException
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
@ -25,7 +26,8 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
class ConnectivityReporter @Inject constructor(private val wifiManager: WifiManager) {
|
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 {
|
fun checkTethering(): Boolean = try {
|
||||||
val method: Method = wifiManager.javaClass.getDeclaredMethod("isWifiApEnabled")
|
val method: Method = wifiManager.javaClass.getDeclaredMethod("isWifiApEnabled")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user