Target R
This commit is contained in:
@@ -15,12 +15,12 @@ android {
|
|||||||
sourceCompatibility = javaVersion
|
sourceCompatibility = javaVersion
|
||||||
targetCompatibility = javaVersion
|
targetCompatibility = javaVersion
|
||||||
}
|
}
|
||||||
compileSdkVersion(29)
|
compileSdkVersion("android-R")
|
||||||
kotlinOptions.jvmTarget = javaVersion.toString()
|
kotlinOptions.jvmTarget = javaVersion.toString()
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "be.mygod.vpnhotspot"
|
applicationId = "be.mygod.vpnhotspot"
|
||||||
minSdkVersion(21)
|
minSdkVersion(21)
|
||||||
targetSdkVersion(29)
|
targetSdkVersion("R")
|
||||||
resConfigs(listOf("it", "ru", "zh-rCN", "zh-rTW"))
|
resConfigs(listOf("it", "ru", "zh-rCN", "zh-rTW"))
|
||||||
versionCode = 224
|
versionCode = 224
|
||||||
versionName = "2.9.1"
|
versionName = "2.9.1"
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import be.mygod.vpnhotspot.App.Companion.app
|
|||||||
import be.mygod.vpnhotspot.net.monitor.TetherTimeoutMonitor
|
import be.mygod.vpnhotspot.net.monitor.TetherTimeoutMonitor
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper
|
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.deletePersistentGroup
|
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.deletePersistentGroup
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.netId
|
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.requestPersistentGroupInfo
|
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.requestPersistentGroupInfo
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.setWifiP2pChannels
|
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.setWifiP2pChannels
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.startWps
|
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.startWps
|
||||||
@@ -235,11 +234,11 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
|
|||||||
p2pManager.requestPersistentGroupInfo(channel) {
|
p2pManager.requestPersistentGroupInfo(channel) {
|
||||||
if (it.isNotEmpty()) persistentSupported = true
|
if (it.isNotEmpty()) persistentSupported = true
|
||||||
val ownedGroups = it.filter { it.isGroupOwner && it.owner.deviceAddress == device.deviceAddress }
|
val ownedGroups = it.filter { it.isGroupOwner && it.owner.deviceAddress == device.deviceAddress }
|
||||||
val main = ownedGroups.minBy { it.netId }
|
val main = ownedGroups.minBy { it.networkId }
|
||||||
// do not replace current group if it's better
|
// do not replace current group if it's better
|
||||||
if (binder.group?.passphrase == null) binder.group = main
|
if (binder.group?.passphrase == null) binder.group = main
|
||||||
if (main != null) ownedGroups.filter { it.netId != main.netId }.forEach {
|
if (main != null) ownedGroups.filter { it.networkId != main.networkId }.forEach {
|
||||||
p2pManager.deletePersistentGroup(channel, it.netId, object : WifiP2pManager.ActionListener {
|
p2pManager.deletePersistentGroup(channel, it.networkId, object : WifiP2pManager.ActionListener {
|
||||||
override fun onSuccess() = Timber.i("Removed redundant owned group: $it")
|
override fun onSuccess() = Timber.i("Removed redundant owned group: $it")
|
||||||
override fun onFailure(reason: Int) = SmartSnackbar.make(
|
override fun onFailure(reason: Int) = SmartSnackbar.make(
|
||||||
formatReason(R.string.repeater_clean_pog_failure, reason)).show()
|
formatReason(R.string.repeater_clean_pog_failure, reason)).show()
|
||||||
|
|||||||
@@ -102,14 +102,4 @@ object WifiP2pManagerHelper {
|
|||||||
}
|
}
|
||||||
requestPersistentGroupInfo.invoke(this, c, proxy)
|
requestPersistentGroupInfo.invoke(this, c, proxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Available since Android 4.2.
|
|
||||||
*
|
|
||||||
* Source: https://android.googlesource.com/platform/frameworks/base/+/android-4.2_r1/wifi/java/android/net/wifi/p2p/WifiP2pGroup.java#253
|
|
||||||
*/
|
|
||||||
private val getNetworkId by lazy @SuppressLint("DiscouragedPrivateApi") {
|
|
||||||
WifiP2pGroup::class.java.getDeclaredMethod("getNetworkId")
|
|
||||||
}
|
|
||||||
val WifiP2pGroup.netId get() = getNetworkId.invoke(this) as Int
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user