From 8abb431b7974b77a55dfc0769e83cc4dd92185b8 Mon Sep 17 00:00:00 2001 From: Mygod Date: Tue, 3 Apr 2018 22:28:21 -0700 Subject: [PATCH] Add dumpsys wifip2p to debug info --- .../vpnhotspot/SettingsPreferenceFragment.kt | 25 ++++++++++++++++++- .../java/be/mygod/vpnhotspot/net/Routing.kt | 25 ------------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt index d0a54453..7c3506e3 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt @@ -1,5 +1,6 @@ package be.mygod.vpnhotspot +import android.content.Context import android.content.Intent import android.net.Uri import android.os.Build @@ -48,8 +49,30 @@ class SettingsPreferenceFragment : PreferenceFragmentCompatDividers() { } writer.write("\n") writer.flush() + val commands = StringBuilder() + // https://android.googlesource.com/platform/external/iptables/+/android-7.0.0_r1/iptables/Android.mk#34 + val iptablesSave = if (Build.VERSION.SDK_INT >= 24) "iptables-save" else { + commands.appendln("ln -sf /system/bin/iptables ./iptables-save") + "./iptables-save" + } + commands.append(""" + |echo logcat-su + |logcat -d + |echo + |echo dumpsys ${Context.WIFI_P2P_SERVICE} + |dumpsys ${Context.WIFI_P2P_SERVICE} + |echo + |echo iptables + |$iptablesSave + |echo + |echo iptables -t nat + |$iptablesSave -t nat + |echo + |echo ip rule + |ip rule + """.trimMargin()) try { - Routing.dump()?.use { it.copyTo(out) } + loggerSuStream(commands.toString())?.use { it.copyTo(out) } } catch (e: IOException) { e.printStackTrace(writer) writer.flush() diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt index 3927ce75..49d550a6 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt @@ -4,9 +4,7 @@ import android.os.Build import be.mygod.vpnhotspot.App.Companion.app import be.mygod.vpnhotspot.R import be.mygod.vpnhotspot.debugLog -import be.mygod.vpnhotspot.loggerSuStream import be.mygod.vpnhotspot.noisySu -import java.io.InputStream import java.net.Inet4Address import java.net.InetAddress import java.net.NetworkInterface @@ -32,29 +30,6 @@ class Routing(val upstream: String?, val downstream: String, ownerAddress: InetA "$IPTABLES -t nat -F vpnhotspot_masquerade", "$IPTABLES -t nat -X vpnhotspot_masquerade", "quiet while ip rule del priority 17900; do done") - - fun dump(): InputStream? { - val commands = StringBuilder() - // https://android.googlesource.com/platform/external/iptables/+/android-7.0.0_r1/iptables/Android.mk#34 - val iptablesSave = if (Build.VERSION.SDK_INT >= 24) "iptables-save" else { - commands.appendln("ln -sf /system/bin/iptables ./iptables-save") - "./iptables-save" - } - commands.append(""" - |echo logcat-su - |logcat -d - |echo - |echo iptables - |$iptablesSave - |echo - |echo iptables -t nat - |$iptablesSave -t nat - |echo - |echo ip rule - |ip rule - """.trimMargin()) - return loggerSuStream(commands.toString()) - } } class InterfaceNotFoundException : SocketException() {