Set operating channel unconditionally
This commit is contained in:
@@ -24,6 +24,7 @@ import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.netId
|
||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.requestPersistentGroupInfo
|
||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.setWifiP2pChannels
|
||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.startWps
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.net.InetAddress
|
||||
import java.net.SocketException
|
||||
|
||||
@@ -150,11 +151,8 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, VpnMonitor.Ca
|
||||
|
||||
override fun onBind(intent: Intent) = binder
|
||||
|
||||
private fun setOperatingChannel(init: Boolean = false) {
|
||||
val oc = app.operatingChannel
|
||||
if (!init || oc > 0) {
|
||||
private fun setOperatingChannel(oc: Int = app.operatingChannel) = try {
|
||||
// we don't care about listening channel
|
||||
debugLog(TAG, "Setting OC to $oc")
|
||||
p2pManager.setWifiP2pChannels(channel, 0, oc, object : WifiP2pManager.ActionListener {
|
||||
override fun onSuccess() { }
|
||||
override fun onFailure(reason: Int) {
|
||||
@@ -162,12 +160,15 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, VpnMonitor.Ca
|
||||
Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (e: InvocationTargetException) {
|
||||
if (oc != 0)
|
||||
Toast.makeText(this, getString(R.string.repeater_set_oc_failure, e.message), Toast.LENGTH_SHORT).show()
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
override fun onChannelDisconnected() {
|
||||
channel = p2pManager.initialize(this, Looper.getMainLooper(), this)
|
||||
setOperatingChannel(true)
|
||||
setOperatingChannel()
|
||||
binder.requestGroupUpdate()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user