@@ -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
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.net.wifi.p2p.WifiP2pGroup
|
||||
import android.os.Build
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.DebugHelper
|
||||
import be.mygod.vpnhotspot.RepeaterService
|
||||
import be.mygod.vpnhotspot.util.RootSession
|
||||
import java.io.File
|
||||
|
||||
@@ -51,6 +52,7 @@ class P2pSupplicantConfiguration(private val group: WifiP2pGroup, ownerAddress:
|
||||
it.checkOutput(command, shell, false, false)
|
||||
val parser = Parser(shell.out)
|
||||
try {
|
||||
val bssid = group.owner.deviceAddress ?: ownerAddress
|
||||
while (parser.next()) {
|
||||
if (parser.trimmed.startsWith("network={")) {
|
||||
val block = NetworkBlock()
|
||||
@@ -65,8 +67,7 @@ class P2pSupplicantConfiguration(private val group: WifiP2pGroup, ownerAddress:
|
||||
check(block.pskLine == null && block.psk == null)
|
||||
block.psk = match.groupValues[5].apply { check(length in 8..63) }
|
||||
block.pskLine = block.size
|
||||
} else if (match.groups[2] != null &&
|
||||
match.groupValues[2].equals(group.owner.deviceAddress ?: ownerAddress, true)) {
|
||||
} else if (match.groups[2] != null && match.groupValues[2].equals(bssid, true)) {
|
||||
block.bssidMatches = true
|
||||
}
|
||||
}
|
||||
@@ -80,6 +81,26 @@ class P2pSupplicantConfiguration(private val group: WifiP2pGroup, ownerAddress:
|
||||
}
|
||||
} else result.add(parser.line)
|
||||
}
|
||||
if (target == null && !RepeaterService.persistentSupported) {
|
||||
result.add("")
|
||||
result.add(NetworkBlock().apply {
|
||||
// generate a basic network block, it is likely that vendor is going to add more stuff here
|
||||
add("network={")
|
||||
ssidLine = size
|
||||
add("")
|
||||
add("\tbssid=$bssid")
|
||||
pskLine = size
|
||||
add("")
|
||||
add("\tproto=RSN")
|
||||
add("\tkey_mgmt=WPA-PSK")
|
||||
add("\tpairwise=CCMP")
|
||||
add("\tauth_alg=OPEN")
|
||||
add("\tmode=3")
|
||||
add("\tdisabled=2")
|
||||
add("}")
|
||||
target = this
|
||||
})
|
||||
}
|
||||
Triple(result, target!!, shell.err.isNotEmpty())
|
||||
} catch (e: RuntimeException) {
|
||||
DebugHelper.setString(TAG, parser.lines.joinToString("\n"))
|
||||
|
||||
Reference in New Issue
Block a user