Support specifying network interface

Fix #15.
This commit is contained in:
Mygod
2018-06-02 07:29:46 +08:00
parent 8e335fec1b
commit da9bf4867e
14 changed files with 326 additions and 173 deletions

View File

@@ -177,7 +177,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
p2pManager.requestGroupInfo(channel, {
when {
it == null -> doStart()
it.isGroupOwner -> doStart(it)
it.isGroupOwner -> if (routingManager == null) doStart(it)
else -> {
Log.i(TAG, "Removing old group ($it)")
p2pManager.removeGroup(channel, object : WifiP2pManager.ActionListener {
@@ -220,6 +220,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
*/
private fun doStart(group: WifiP2pGroup, ownerAddress: InetAddress? = null) {
this.group = group
check(routingManager == null)
routingManager = LocalOnlyInterfaceManager(group.`interface`!!, ownerAddress)
status = Status.ACTIVE
showNotification(group)