From 6e6bef6a66c76b1538ade009dc41bb0b09df9f5b Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 5 Apr 2019 11:19:25 +0800 Subject: [PATCH 1/2] Handle dump terminated error --- .../java/be/mygod/vpnhotspot/net/monitor/IpMonitor.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/IpMonitor.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/IpMonitor.kt index 6955834a..10029a8c 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/IpMonitor.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/IpMonitor.kt @@ -19,7 +19,7 @@ abstract class IpMonitor : Runnable { companion object { const val KEY = "service.ipMonitor" // 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()) ?: "") } @@ -54,7 +54,7 @@ abstract class IpMonitor : Runnable { } try { process.inputStream.bufferedReader().forEachLine { - if (it.endsWith(MAGIC_SUFFIX)) { + if (errorMatcher.matches(it)) { Timber.w(it) process.destroy() // move on to next mode } else processLine(it) @@ -103,7 +103,7 @@ abstract class IpMonitor : Runnable { } process.inputStream.bufferedReader().useLines { processLines(it.map { line -> - if (line.endsWith(MAGIC_SUFFIX)) throw IOException(line) + if (errorMatcher.matches(line)) throw IOException(line) line }) } @@ -121,7 +121,7 @@ abstract class IpMonitor : Runnable { RootSession.use { val result = it.execQuiet(command) 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()) } } catch (e: RuntimeException) { From c922a944536f17b0a824c02ca9d2462d0e80f89e Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 5 Apr 2019 11:21:43 +0800 Subject: [PATCH 2/2] Remove fixed debug --- mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt index 69fb257d..021caa5d 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt @@ -14,7 +14,6 @@ import android.os.Handler import android.os.Looper import androidx.annotation.StringRes import androidx.core.content.getSystemService -import androidx.core.os.BuildCompat import be.mygod.vpnhotspot.App.Companion.app import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.deletePersistentGroup @@ -150,7 +149,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere WifiP2pManager.NO_SERVICE_REQUESTS -> getString(R.string.repeater_failure_reason_no_service_requests) WifiP2pManagerHelper.UNSUPPORTED -> getString(R.string.repeater_failure_reason_unsupported_operation) else -> getString(R.string.failure_reason_unknown, reason) - }).also { if (BuildCompat.isAtLeastQ()) Timber.w(RuntimeException(it)) } + }) override fun onCreate() { super.onCreate()