Add default p2p group if nothing is found

Fixes #61.
This commit is contained in:
Mygod
2019-01-18 11:22:59 +08:00
parent 3d9ec9121a
commit 6a8dbd7775
2 changed files with 25 additions and 3 deletions

View File

@@ -49,6 +49,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
}
}
val supported get() = p2pManager != null
var persistentSupported = false
}
enum class Status {
@@ -192,7 +193,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
val device = binder.thisDevice ?: return
try {
p2pManager.requestPersistentGroupInfo(channel) {
Timber.d(it.toString())
if (it.isNotEmpty()) persistentSupported = true
val ownedGroups = it.filter { it.isGroupOwner && it.owner.deviceAddress == device.deviceAddress }
val main = ownedGroups.minBy { it.netId }
// do not replace current group if it's better