Temporary Wi-Fi hotspot for bypassing tethering limits (#18)

* First draft of temporary hotspot
* Refactor with LocalOnlyInterfaceManager
* Refactor LocalOnlyHotspotService
* Localize
* Update strict summary
This commit is contained in:
Mygod
2018-05-02 17:53:06 -07:00
committed by GitHub
parent 0a47cfdf1c
commit 2fe7703d6d
15 changed files with 420 additions and 185 deletions

View File

@@ -1,13 +1,10 @@
package be.mygod.vpnhotspot.net.wifi
import android.content.Context
import android.net.wifi.WifiConfiguration
import android.net.wifi.WifiManager
import be.mygod.vpnhotspot.App.Companion.app
@Deprecated("No longer usable since API 26.")
object WifiApManager {
private val wifi = app.getSystemService(Context.WIFI_SERVICE) as WifiManager
private val setWifiApEnabled = WifiManager::class.java.getDeclaredMethod("setWifiApEnabled",
WifiConfiguration::class.java, Boolean::class.java)
/**
@@ -23,12 +20,14 @@ object WifiApManager {
private fun WifiManager.setWifiApEnabled(wifiConfig: WifiConfiguration?, enabled: Boolean) =
setWifiApEnabled.invoke(this, wifiConfig, enabled) as Boolean
@Deprecated("No longer usable since API 26.")
fun start(wifiConfig: WifiConfiguration? = null) {
wifi.isWifiEnabled = false
wifi.setWifiApEnabled(wifiConfig, true)
app.wifi.isWifiEnabled = false
app.wifi.setWifiApEnabled(wifiConfig, true)
}
@Deprecated("No longer usable since API 26.")
fun stop() {
wifi.setWifiApEnabled(null, false)
wifi.isWifiEnabled = true
app.wifi.setWifiApEnabled(null, false)
app.wifi.isWifiEnabled = true
}
}