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:
@@ -113,7 +113,8 @@ class Routing(val upstream: String?, val downstream: String, ownerAddress: InetA
|
||||
fun start(): Boolean {
|
||||
if (started) return true
|
||||
started = true
|
||||
return noisySu(startScript) == true
|
||||
if (noisySu(startScript) != true) stop()
|
||||
return started
|
||||
}
|
||||
fun stop(): Boolean {
|
||||
if (!started) return true
|
||||
|
||||
@@ -125,7 +125,8 @@ object TetheringManager {
|
||||
stopTethering.invoke(app.connectivity, type)
|
||||
}
|
||||
|
||||
fun getTetheredIfaces(extras: Bundle) = if (Build.VERSION.SDK_INT >= 26)
|
||||
extras.getStringArrayList(EXTRA_ACTIVE_TETHER).toSet() + extras.getStringArrayList(EXTRA_ACTIVE_LOCAL_ONLY)
|
||||
else extras.getStringArrayList(EXTRA_ACTIVE_TETHER_LEGACY).toSet()
|
||||
fun getTetheredIfaces(extras: Bundle) = extras.getStringArrayList(
|
||||
if (Build.VERSION.SDK_INT >= 26) EXTRA_ACTIVE_TETHER else EXTRA_ACTIVE_TETHER_LEGACY)
|
||||
fun getLocalOnlyTetheredIfaces(extras: Bundle) =
|
||||
if (Build.VERSION.SDK_INT >= 26) extras.getStringArrayList(EXTRA_ACTIVE_LOCAL_ONLY) else emptyList<String>()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user