Fix deprecations
This commit is contained in:
@@ -6,7 +6,6 @@ import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.observe
|
||||
import be.mygod.vpnhotspot.client.ClientViewModel
|
||||
import be.mygod.vpnhotspot.client.ClientsFragment
|
||||
import be.mygod.vpnhotspot.databinding.ActivityMainBinding
|
||||
|
||||
@@ -143,7 +143,7 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
|
||||
// WifiP2pServiceImpl only removes self address
|
||||
Build.VERSION.SDK_INT >= 29 && address == MacAddressCompat.ANY_ADDRESS || address == ownerAddress
|
||||
}
|
||||
val main = ownedGroups.minBy { it.networkId }
|
||||
val main = ownedGroups.minByOrNull { it.networkId }
|
||||
// do not replace current group if it's better
|
||||
if (binder.group?.passphrase == null) binder.group = main
|
||||
return if (main != null) ownedGroups.filter { it.networkId != main.networkId } else emptyList()
|
||||
|
||||
@@ -52,10 +52,10 @@ open class Client(val mac: MacAddressCompat, val iface: String) {
|
||||
val titleSelectable = record.map { it.nickname.isEmpty() }
|
||||
val description = record.map { record ->
|
||||
SpannableStringBuilder().apply {
|
||||
if (record.nickname.isNotEmpty()) appendln(macIface)
|
||||
if (record.nickname.isNotEmpty()) appendLine(macIface)
|
||||
ip.entries.forEach { (ip, state) ->
|
||||
append(makeIpSpan(ip))
|
||||
appendln(app.getText(when (state) {
|
||||
appendLine(app.getText(when (state) {
|
||||
IpNeighbour.State.INCOMPLETE -> R.string.connected_state_incomplete
|
||||
IpNeighbour.State.VALID -> R.string.connected_state_valid
|
||||
IpNeighbour.State.FAILED -> R.string.connected_state_failed
|
||||
|
||||
@@ -20,7 +20,6 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.findViewTreeLifecycleOwner
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.observe
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
|
||||
@@ -52,24 +52,24 @@ class Routing(private val caller: Any, private val downstream: String) : IpNeigh
|
||||
const val IP6TABLES = "ip6tables -w"
|
||||
|
||||
fun appendCleanCommands(commands: BufferedWriter) {
|
||||
commands.appendln("$IPTABLES -t nat -F PREROUTING")
|
||||
commands.appendln("while $IPTABLES -D FORWARD -j vpnhotspot_fwd; do done")
|
||||
commands.appendln("$IPTABLES -F vpnhotspot_fwd")
|
||||
commands.appendln("$IPTABLES -X vpnhotspot_fwd")
|
||||
commands.appendln("$IPTABLES -F vpnhotspot_acl")
|
||||
commands.appendln("$IPTABLES -X vpnhotspot_acl")
|
||||
commands.appendln("while $IPTABLES -t nat -D POSTROUTING -j vpnhotspot_masquerade; do done")
|
||||
commands.appendln("$IPTABLES -t nat -F vpnhotspot_masquerade")
|
||||
commands.appendln("$IPTABLES -t nat -X vpnhotspot_masquerade")
|
||||
commands.appendln("while $IP6TABLES -D INPUT -j vpnhotspot_filter; do done")
|
||||
commands.appendln("while $IP6TABLES -D FORWARD -j vpnhotspot_filter; do done")
|
||||
commands.appendln("while $IP6TABLES -D OUTPUT -j vpnhotspot_filter; do done")
|
||||
commands.appendln("$IP6TABLES -F vpnhotspot_filter")
|
||||
commands.appendln("$IP6TABLES -X vpnhotspot_filter")
|
||||
commands.appendln("while $IP rule del priority $RULE_PRIORITY_DNS; do done")
|
||||
commands.appendln("while $IP rule del priority $RULE_PRIORITY_UPSTREAM; do done")
|
||||
commands.appendln("while $IP rule del priority $RULE_PRIORITY_UPSTREAM_FALLBACK; do done")
|
||||
commands.appendln("while $IP rule del priority $RULE_PRIORITY_UPSTREAM_DISABLE_SYSTEM; do done")
|
||||
commands.appendLine("$IPTABLES -t nat -F PREROUTING")
|
||||
commands.appendLine("while $IPTABLES -D FORWARD -j vpnhotspot_fwd; do done")
|
||||
commands.appendLine("$IPTABLES -F vpnhotspot_fwd")
|
||||
commands.appendLine("$IPTABLES -X vpnhotspot_fwd")
|
||||
commands.appendLine("$IPTABLES -F vpnhotspot_acl")
|
||||
commands.appendLine("$IPTABLES -X vpnhotspot_acl")
|
||||
commands.appendLine("while $IPTABLES -t nat -D POSTROUTING -j vpnhotspot_masquerade; do done")
|
||||
commands.appendLine("$IPTABLES -t nat -F vpnhotspot_masquerade")
|
||||
commands.appendLine("$IPTABLES -t nat -X vpnhotspot_masquerade")
|
||||
commands.appendLine("while $IP6TABLES -D INPUT -j vpnhotspot_filter; do done")
|
||||
commands.appendLine("while $IP6TABLES -D FORWARD -j vpnhotspot_filter; do done")
|
||||
commands.appendLine("while $IP6TABLES -D OUTPUT -j vpnhotspot_filter; do done")
|
||||
commands.appendLine("$IP6TABLES -F vpnhotspot_filter")
|
||||
commands.appendLine("$IP6TABLES -X vpnhotspot_filter")
|
||||
commands.appendLine("while $IP rule del priority $RULE_PRIORITY_DNS; do done")
|
||||
commands.appendLine("while $IP rule del priority $RULE_PRIORITY_UPSTREAM; do done")
|
||||
commands.appendLine("while $IP rule del priority $RULE_PRIORITY_UPSTREAM_FALLBACK; do done")
|
||||
commands.appendLine("while $IP rule del priority $RULE_PRIORITY_UPSTREAM_DISABLE_SYSTEM; do done")
|
||||
}
|
||||
|
||||
suspend fun clean() {
|
||||
|
||||
@@ -219,7 +219,8 @@ data class SoftApConfigurationCompat(
|
||||
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK
|
||||
}
|
||||
android.net.wifi.WifiConfiguration.KeyMgmt.SAE -> SoftApConfiguration.SECURITY_TYPE_WPA3_SAE
|
||||
else -> android.net.wifi.WifiConfiguration.KeyMgmt.strings.getOrElse(selected) { "?" }.let {
|
||||
else -> android.net.wifi.WifiConfiguration.KeyMgmt.strings
|
||||
.getOrElse<String>(selected) { "?" }.let {
|
||||
throw IllegalArgumentException("Unrecognized key management $it ($selected)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ data class Dump(val path: String, val cacheDir: File = app.deviceStorage.codeCac
|
||||
process.outputStream.bufferedWriter().use { commands ->
|
||||
// https://android.googlesource.com/platform/external/iptables/+/android-7.0.0_r1/iptables/Android.mk#34
|
||||
val iptablesSave = if (Build.VERSION.SDK_INT < 24) File(cacheDir, "iptables-save").absolutePath.also {
|
||||
commands.appendln("ln -sf /system/bin/iptables $it")
|
||||
commands.appendLine("ln -sf /system/bin/iptables $it")
|
||||
} else "iptables-save"
|
||||
val ip6tablesSave = if (Build.VERSION.SDK_INT < 24) File(cacheDir, "ip6tables-save").absolutePath.also {
|
||||
commands.appendln("ln -sf /system/bin/ip6tables $it")
|
||||
commands.appendLine("ln -sf /system/bin/ip6tables $it")
|
||||
} else "ip6tables-save"
|
||||
commands.appendln("""
|
||||
commands.appendLine("""
|
||||
|echo dumpsys ${Context.WIFI_P2P_SERVICE}
|
||||
|dumpsys ${Context.WIFI_P2P_SERVICE}
|
||||
|echo
|
||||
|
||||
@@ -92,11 +92,11 @@ fun makeMacSpan(mac: String) = if (app.hasTouch) SpannableString(mac).apply {
|
||||
|
||||
fun NetworkInterface.formatAddresses(macOnly: Boolean = false) = SpannableStringBuilder().apply {
|
||||
try {
|
||||
hardwareAddress?.let { appendln(makeMacSpan(MacAddressCompat.bytesToString(it))) }
|
||||
hardwareAddress?.let { appendLine(makeMacSpan(MacAddressCompat.bytesToString(it))) }
|
||||
} catch (_: SocketException) { }
|
||||
if (!macOnly) for (address in interfaceAddresses) {
|
||||
append(makeIpSpan(address.address))
|
||||
appendln("/${address.networkPrefixLength}")
|
||||
appendLine("/${address.networkPrefixLength}")
|
||||
}
|
||||
}.trimEnd()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user