Export debug information
This commit is contained in:
@@ -2,6 +2,7 @@ package be.mygod.vpnhotspot
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.support.customtabs.CustomTabsIntent
|
||||
import android.support.v4.content.ContextCompat
|
||||
@@ -10,6 +11,8 @@ import android.widget.Toast
|
||||
import be.mygod.vpnhotspot.net.Routing
|
||||
import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers
|
||||
import java.io.IOException
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
|
||||
class SettingsPreferenceFragment : PreferenceFragmentCompatDividers() {
|
||||
private val customTabsIntent by lazy {
|
||||
@@ -24,16 +27,27 @@ class SettingsPreferenceFragment : PreferenceFragmentCompatDividers() {
|
||||
true
|
||||
}
|
||||
findPreference("misc.logcat").setOnPreferenceClickListener {
|
||||
try {
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
.setType("text/plain")
|
||||
.putExtra(Intent.EXTRA_TEXT, Runtime.getRuntime().exec(arrayOf("logcat", "-d"))
|
||||
.inputStream.bufferedReader().readText())
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.abc_shareactionprovider_share_with)))
|
||||
} catch (e: IOException) {
|
||||
fun handle(e: IOException): String {
|
||||
Toast.makeText(context, e.message, Toast.LENGTH_SHORT).show()
|
||||
e.printStackTrace()
|
||||
val writer = StringWriter()
|
||||
e.printStackTrace(PrintWriter(writer))
|
||||
return writer.toString()
|
||||
}
|
||||
val logcat = try {
|
||||
Runtime.getRuntime().exec(arrayOf("logcat", "-d")).inputStream.bufferedReader().readText()
|
||||
} catch (e: IOException) {
|
||||
handle(e)
|
||||
}
|
||||
val debug = try {
|
||||
Routing.dump()
|
||||
} catch (e: IOException) {
|
||||
handle(e)
|
||||
}
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
.setType("text/plain")
|
||||
.putExtra(Intent.EXTRA_TEXT,
|
||||
"${BuildConfig.VERSION_CODE} running on ${Build.VERSION.SDK_INT}\n$logcat\n$debug")
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.abc_shareactionprovider_share_with)))
|
||||
true
|
||||
}
|
||||
findPreference("misc.source").setOnPreferenceClickListener {
|
||||
|
||||
@@ -4,6 +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.loggerSu
|
||||
import be.mygod.vpnhotspot.noisySu
|
||||
import java.io.IOException
|
||||
import java.net.Inet4Address
|
||||
@@ -28,6 +29,17 @@ class Routing(val upstream: String?, val downstream: String, ownerAddress: InetA
|
||||
"$IPTABLES -F vpnhotspot_fwd",
|
||||
"$IPTABLES -X vpnhotspot_fwd",
|
||||
"quiet while ip rule del priority 17900; do done")
|
||||
|
||||
fun dump() = loggerSu("""
|
||||
|echo iptables
|
||||
|iptables-save
|
||||
|echo
|
||||
|echo iptables -t nat
|
||||
|iptables-save -t nat
|
||||
|echo
|
||||
|echo ip rule
|
||||
|ip rule
|
||||
""".trimMargin())
|
||||
}
|
||||
|
||||
class InterfaceNotFoundException : IOException() {
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<string name="settings_service_dns">备用 DNS 服务器[:端口]</string>
|
||||
<string name="settings_service_clean">清理/重新应用路由规则</string>
|
||||
<string name="settings_misc">杂项</string>
|
||||
<string name="settings_misc_logcat">导出日志</string>
|
||||
<string name="settings_misc_logcat">导出调试信息</string>
|
||||
<string name="settings_misc_logcat_summary">这种非常有用哇</string>
|
||||
<string name="settings_misc_source">查看 GitHub 上的源码</string>
|
||||
<string name="settings_misc_source_summary">Star, 提交 issues, 合作</string>
|
||||
@@ -63,5 +63,5 @@
|
||||
|
||||
<string name="exception_interface_not_found">错误:未找到下游接口</string>
|
||||
<string name="root_unavailable">似乎没有 root</string>
|
||||
<string name="noisy_su_failure">发生异常,详情请查看日志。</string>
|
||||
<string name="noisy_su_failure">发生异常,详情请查看调试信息。</string>
|
||||
</resources>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<string name="settings_service_dns">Fallback DNS server[:port]</string>
|
||||
<string name="settings_service_clean">Clean/reapply routing rules</string>
|
||||
<string name="settings_misc">Misc</string>
|
||||
<string name="settings_misc_logcat">Export logcat</string>
|
||||
<string name="settings_misc_logcat">Export debug information</string>
|
||||
<string name="settings_misc_logcat_summary">Such useful very wow</string>
|
||||
<string name="settings_misc_source">View on GitHub</string>
|
||||
<string name="settings_misc_source_summary">Star, submit issues and contribute</string>
|
||||
@@ -67,5 +67,5 @@
|
||||
|
||||
<string name="exception_interface_not_found">Fatal: Downstream interface not found</string>
|
||||
<string name="root_unavailable">Root unavailable</string>
|
||||
<string name="noisy_su_failure">Something went wrong, please check logcat.</string>
|
||||
<string name="noisy_su_failure">Something went wrong, please check the debug information.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user