Merge branch 'master' into v2.4
This commit is contained in:
@@ -14,7 +14,6 @@ import android.os.Handler
|
|||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.core.os.BuildCompat
|
|
||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
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
|
||||||
@@ -140,7 +139,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
|||||||
WifiP2pManager.NO_SERVICE_REQUESTS -> getString(R.string.repeater_failure_reason_no_service_requests)
|
WifiP2pManager.NO_SERVICE_REQUESTS -> getString(R.string.repeater_failure_reason_no_service_requests)
|
||||||
WifiP2pManagerHelper.UNSUPPORTED -> getString(R.string.repeater_failure_reason_unsupported_operation)
|
WifiP2pManagerHelper.UNSUPPORTED -> getString(R.string.repeater_failure_reason_unsupported_operation)
|
||||||
else -> getString(R.string.failure_reason_unknown, reason)
|
else -> getString(R.string.failure_reason_unknown, reason)
|
||||||
}).also { if (BuildCompat.isAtLeastQ()) Timber.w(RuntimeException(it)) }
|
})
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ abstract class IpMonitor : Runnable {
|
|||||||
companion object {
|
companion object {
|
||||||
const val KEY = "service.ipMonitor"
|
const val KEY = "service.ipMonitor"
|
||||||
// https://android.googlesource.com/platform/external/iproute2/+/7f7a711/lib/libnetlink.c#493
|
// https://android.googlesource.com/platform/external/iproute2/+/7f7a711/lib/libnetlink.c#493
|
||||||
private const val MAGIC_SUFFIX = "Dump was interrupted and may be inconsistent."
|
private val errorMatcher = "Dump (was interrupted and may be inconsistent.|terminated)$".toRegex()
|
||||||
private val currentMode get() = Mode.valueOf(app.pref.getString(KEY, Mode.Poll.toString()) ?: "")
|
private val currentMode get() = Mode.valueOf(app.pref.getString(KEY, Mode.Poll.toString()) ?: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ abstract class IpMonitor : Runnable {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
process.inputStream.bufferedReader().forEachLine {
|
process.inputStream.bufferedReader().forEachLine {
|
||||||
if (it.endsWith(MAGIC_SUFFIX)) {
|
if (errorMatcher.matches(it)) {
|
||||||
Timber.w(it)
|
Timber.w(it)
|
||||||
process.destroy() // move on to next mode
|
process.destroy() // move on to next mode
|
||||||
} else processLine(it)
|
} else processLine(it)
|
||||||
@@ -103,7 +103,7 @@ abstract class IpMonitor : Runnable {
|
|||||||
}
|
}
|
||||||
process.inputStream.bufferedReader().useLines {
|
process.inputStream.bufferedReader().useLines {
|
||||||
processLines(it.map { line ->
|
processLines(it.map { line ->
|
||||||
if (line.endsWith(MAGIC_SUFFIX)) throw IOException(line)
|
if (errorMatcher.matches(line)) throw IOException(line)
|
||||||
line
|
line
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ abstract class IpMonitor : Runnable {
|
|||||||
RootSession.use {
|
RootSession.use {
|
||||||
val result = it.execQuiet(command)
|
val result = it.execQuiet(command)
|
||||||
RootSession.checkOutput(command, result, false)
|
RootSession.checkOutput(command, result, false)
|
||||||
if (result.out.any { it.endsWith(MAGIC_SUFFIX) }) throw IOException(result.out.joinToString("\n"))
|
if (result.out.any { errorMatcher.matches(it) }) throw IOException(result.out.joinToString("\n"))
|
||||||
processLines(result.out.asSequence())
|
processLines(result.out.asSequence())
|
||||||
}
|
}
|
||||||
} catch (e: RuntimeException) {
|
} catch (e: RuntimeException) {
|
||||||
|
|||||||
Reference in New Issue
Block a user