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

@@ -0,0 +1,24 @@
package be.mygod.vpnhotspot
import android.app.Service
import be.mygod.vpnhotspot.net.IpNeighbour
import be.mygod.vpnhotspot.net.IpNeighbourMonitor
abstract class IpNeighbourMonitoringService : Service(), IpNeighbourMonitor.Callback {
private var neighbours = emptyList<IpNeighbour>()
protected abstract val activeIfaces: List<String>
override fun onIpNeighbourAvailable(neighbours: Map<String, IpNeighbour>) {
this.neighbours = neighbours.values.toList()
}
override fun postIpNeighbourAvailable() {
val sizeLookup = neighbours.groupBy { it.dev }.mapValues { (_, neighbours) ->
neighbours
.filter { it.state != IpNeighbour.State.FAILED }
.distinctBy { it.lladdr }
.size
}
ServiceNotification.startForeground(this, activeIfaces.associate { Pair(it, sizeLookup[it] ?: 0) })
}
}