Add more logging
This commit is contained in:
1
mobile/proguard-rules.pro
vendored
1
mobile/proguard-rules.pro
vendored
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
# Uncomment this to preserve the line number information for
|
||||||
# debugging stack traces.
|
# debugging stack traces.
|
||||||
|
-keepattributes *Annotation*
|
||||||
-keepattributes SourceFile,LineNumberTable
|
-keepattributes SourceFile,LineNumberTable
|
||||||
-dontobfuscate
|
-dontobfuscate
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import be.mygod.vpnhotspot.net.IpNeighbourMonitor
|
|||||||
import be.mygod.vpnhotspot.net.TetheringManager
|
import be.mygod.vpnhotspot.net.TetheringManager
|
||||||
import be.mygod.vpnhotspot.util.broadcastReceiver
|
import be.mygod.vpnhotspot.util.broadcastReceiver
|
||||||
import be.mygod.vpnhotspot.util.debugLog
|
import be.mygod.vpnhotspot.util.debugLog
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
|
|
||||||
@RequiresApi(26)
|
@RequiresApi(26)
|
||||||
class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
|
class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
|
||||||
@@ -91,6 +92,7 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
|
|||||||
}, app.handler)
|
}, app.handler)
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
}
|
}
|
||||||
return START_STICKY
|
return START_STICKY
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.widget.Toast
|
|||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import be.mygod.vpnhotspot.net.Routing
|
import be.mygod.vpnhotspot.net.Routing
|
||||||
import be.mygod.vpnhotspot.net.UpstreamMonitor
|
import be.mygod.vpnhotspot.net.UpstreamMonitor
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.net.InetAddress
|
import java.net.InetAddress
|
||||||
import java.net.SocketException
|
import java.net.SocketException
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ class LocalOnlyInterfaceManager(val downstream: String, private val owner: InetA
|
|||||||
app.toast(R.string.noisy_su_failure)
|
app.toast(R.string.noisy_su_failure)
|
||||||
} catch (e: SocketException) {
|
} catch (e: SocketException) {
|
||||||
Toast.makeText(app, e.message, Toast.LENGTH_SHORT).show()
|
Toast.makeText(app, e.message, Toast.LENGTH_SHORT).show()
|
||||||
|
Crashlytics.logException(e)
|
||||||
routing = null
|
routing = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.requestPersistentGroupI
|
|||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.setWifiP2pChannels
|
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.setWifiP2pChannels
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.startWps
|
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.startWps
|
||||||
import be.mygod.vpnhotspot.util.*
|
import be.mygod.vpnhotspot.util.*
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.lang.reflect.InvocationTargetException
|
import java.lang.reflect.InvocationTargetException
|
||||||
import java.net.InetAddress
|
import java.net.InetAddress
|
||||||
|
|
||||||
@@ -79,6 +80,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
|||||||
})
|
})
|
||||||
} catch (e: ReflectiveOperationException) {
|
} catch (e: ReflectiveOperationException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
Toast.makeText(this@RepeaterService, e.message, Toast.LENGTH_LONG).show()
|
Toast.makeText(this@RepeaterService, e.message, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,6 +131,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
|||||||
app.pref.registerOnSharedPreferenceChangeListener(this)
|
app.pref.registerOnSharedPreferenceChangeListener(this)
|
||||||
} catch (exc: TypeCastException) {
|
} catch (exc: TypeCastException) {
|
||||||
exc.printStackTrace()
|
exc.printStackTrace()
|
||||||
|
Crashlytics.logException(exc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +150,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
|||||||
if (oc != 0)
|
if (oc != 0)
|
||||||
Toast.makeText(this, getString(R.string.repeater_set_oc_failure, e.message), Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, getString(R.string.repeater_set_oc_failure, e.message), Toast.LENGTH_SHORT).show()
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChannelDisconnected() {
|
override fun onChannelDisconnected() {
|
||||||
@@ -179,7 +183,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
|||||||
it == null -> doStart()
|
it == null -> doStart()
|
||||||
it.isGroupOwner -> if (routingManager == null) doStart(it)
|
it.isGroupOwner -> if (routingManager == null) doStart(it)
|
||||||
else -> {
|
else -> {
|
||||||
Log.i(TAG, "Removing old group ($it)")
|
Crashlytics.log(Log.INFO, TAG, "Removing old group ($it)")
|
||||||
p2pManager.removeGroup(channel, object : WifiP2pManager.ActionListener {
|
p2pManager.removeGroup(channel, object : WifiP2pManager.ActionListener {
|
||||||
override fun onSuccess() = doStart()
|
override fun onSuccess() = doStart()
|
||||||
override fun onFailure(reason: Int) {
|
override fun onFailure(reason: Int) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import be.mygod.vpnhotspot.preference.AlwaysAutoCompleteEditTextPreferenceDialog
|
|||||||
import be.mygod.vpnhotspot.preference.SharedPreferenceDataStore
|
import be.mygod.vpnhotspot.preference.SharedPreferenceDataStore
|
||||||
import be.mygod.vpnhotspot.util.loggerSuStream
|
import be.mygod.vpnhotspot.util.loggerSuStream
|
||||||
import be.mygod.vpnhotspot.util.put
|
import be.mygod.vpnhotspot.util.put
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers
|
import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@@ -53,6 +54,7 @@ class SettingsPreferenceFragment : PreferenceFragmentCompatDividers() {
|
|||||||
Runtime.getRuntime().exec(arrayOf("logcat", "-d")).inputStream.use { it.copyTo(out) }
|
Runtime.getRuntime().exec(arrayOf("logcat", "-d")).inputStream.use { it.copyTo(out) }
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace(writer)
|
e.printStackTrace(writer)
|
||||||
|
Crashlytics.logException(e)
|
||||||
}
|
}
|
||||||
writer.write("\n")
|
writer.write("\n")
|
||||||
writer.flush()
|
writer.flush()
|
||||||
@@ -82,6 +84,7 @@ class SettingsPreferenceFragment : PreferenceFragmentCompatDividers() {
|
|||||||
loggerSuStream(commands.toString())?.use { it.copyTo(out) }
|
loggerSuStream(commands.toString())?.use { it.copyTo(out) }
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace(writer)
|
e.printStackTrace(writer)
|
||||||
|
Crashlytics.logException(e)
|
||||||
writer.flush()
|
writer.flush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,6 +113,7 @@ class SettingsPreferenceFragment : PreferenceFragmentCompatDividers() {
|
|||||||
.map { it.name }.sorted().toList().toTypedArray()
|
.map { it.name }.sorted().toList().toTypedArray()
|
||||||
} catch (e: SocketException) {
|
} catch (e: SocketException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
emptyArray<String>()
|
emptyArray<String>()
|
||||||
}))
|
}))
|
||||||
else -> super.onDisplayPreferenceDialog(preference)
|
else -> super.onDisplayPreferenceDialog(preference)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import be.mygod.vpnhotspot.net.Routing
|
|||||||
import be.mygod.vpnhotspot.net.TetheringManager
|
import be.mygod.vpnhotspot.net.TetheringManager
|
||||||
import be.mygod.vpnhotspot.net.UpstreamMonitor
|
import be.mygod.vpnhotspot.net.UpstreamMonitor
|
||||||
import be.mygod.vpnhotspot.util.broadcastReceiver
|
import be.mygod.vpnhotspot.util.broadcastReceiver
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.net.InetAddress
|
import java.net.InetAddress
|
||||||
import java.net.SocketException
|
import java.net.SocketException
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ class TetheringService : IpNeighbourMonitoringService(), UpstreamMonitor.Callbac
|
|||||||
if (!routing.start()) failed = true
|
if (!routing.start()) failed = true
|
||||||
} catch (e: SocketException) {
|
} catch (e: SocketException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
routings.remove(downstream)
|
routings.remove(downstream)
|
||||||
failed = true
|
failed = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import be.mygod.vpnhotspot.databinding.ListitemInterfaceBinding
|
|||||||
import be.mygod.vpnhotspot.net.TetherType
|
import be.mygod.vpnhotspot.net.TetherType
|
||||||
import be.mygod.vpnhotspot.util.ServiceForegroundConnector
|
import be.mygod.vpnhotspot.util.ServiceForegroundConnector
|
||||||
import be.mygod.vpnhotspot.util.formatAddresses
|
import be.mygod.vpnhotspot.util.formatAddresses
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.net.NetworkInterface
|
import java.net.NetworkInterface
|
||||||
|
|
||||||
@TargetApi(26)
|
@TargetApi(26)
|
||||||
@@ -52,6 +53,7 @@ class LocalOnlyHotspotManager(private val parent: TetheringFragment) : Manager()
|
|||||||
view.context.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))
|
view.context.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))
|
||||||
} catch (exc: ActivityNotFoundException) {
|
} catch (exc: ActivityNotFoundException) {
|
||||||
exc.printStackTrace()
|
exc.printStackTrace()
|
||||||
|
Crashlytics.logException(exc)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
|
|
||||||
object ManageBar : Manager() {
|
object ManageBar : Manager() {
|
||||||
class ViewHolder(view: View) : RecyclerView.ViewHolder(view), View.OnClickListener {
|
class ViewHolder(view: View) : RecyclerView.ViewHolder(view), View.OnClickListener {
|
||||||
@@ -25,8 +26,11 @@ object ManageBar : Manager() {
|
|||||||
try {
|
try {
|
||||||
context.startActivity(Intent()
|
context.startActivity(Intent()
|
||||||
.setClassName("com.android.settings", "com.android.settings.TetherSettings"))
|
.setClassName("com.android.settings", "com.android.settings.TetherSettings"))
|
||||||
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import be.mygod.vpnhotspot.net.wifi.P2pSupplicantConfiguration
|
|||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pDialog
|
import be.mygod.vpnhotspot.net.wifi.WifiP2pDialog
|
||||||
import be.mygod.vpnhotspot.util.ServiceForegroundConnector
|
import be.mygod.vpnhotspot.util.ServiceForegroundConnector
|
||||||
import be.mygod.vpnhotspot.util.formatAddresses
|
import be.mygod.vpnhotspot.util.formatAddresses
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.net.NetworkInterface
|
import java.net.NetworkInterface
|
||||||
import java.net.SocketException
|
import java.net.SocketException
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
|
|||||||
NetworkInterface.getByName(p2pInterface ?: return "")?.formatAddresses() ?: ""
|
NetworkInterface.getByName(p2pInterface ?: return "")?.formatAddresses() ?: ""
|
||||||
} catch (e: SocketException) {
|
} catch (e: SocketException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import be.mygod.vpnhotspot.databinding.ListitemManageTetherBinding
|
|||||||
import be.mygod.vpnhotspot.net.TetherType
|
import be.mygod.vpnhotspot.net.TetherType
|
||||||
import be.mygod.vpnhotspot.net.TetheringManager
|
import be.mygod.vpnhotspot.net.TetheringManager
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiApManager
|
import be.mygod.vpnhotspot.net.wifi.WifiApManager
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.lang.reflect.InvocationTargetException
|
import java.lang.reflect.InvocationTargetException
|
||||||
|
|
||||||
abstract class TetherManager private constructor(protected val parent: TetheringFragment) : Manager(),
|
abstract class TetherManager private constructor(protected val parent: TetheringFragment) : Manager(),
|
||||||
@@ -47,12 +48,14 @@ abstract class TetherManager private constructor(protected val parent: Tethering
|
|||||||
return
|
return
|
||||||
} catch (exc: ActivityNotFoundException) {
|
} catch (exc: ActivityNotFoundException) {
|
||||||
exc.printStackTrace()
|
exc.printStackTrace()
|
||||||
|
Crashlytics.logException(exc)
|
||||||
}
|
}
|
||||||
val started = manager.isStarted
|
val started = manager.isStarted
|
||||||
try {
|
try {
|
||||||
if (started) manager.stop() else manager.start()
|
if (started) manager.stop() else manager.start()
|
||||||
} catch (e: InvocationTargetException) {
|
} catch (e: InvocationTargetException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
var cause: Throwable? = e
|
var cause: Throwable? = e
|
||||||
while (cause != null) {
|
while (cause != null) {
|
||||||
cause = cause.cause
|
cause = cause.cause
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import be.mygod.vpnhotspot.net.TetherType
|
|||||||
import be.mygod.vpnhotspot.net.TetheringManager
|
import be.mygod.vpnhotspot.net.TetheringManager
|
||||||
import be.mygod.vpnhotspot.util.ServiceForegroundConnector
|
import be.mygod.vpnhotspot.util.ServiceForegroundConnector
|
||||||
import be.mygod.vpnhotspot.util.broadcastReceiver
|
import be.mygod.vpnhotspot.util.broadcastReceiver
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.net.NetworkInterface
|
import java.net.NetworkInterface
|
||||||
import java.net.SocketException
|
import java.net.SocketException
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ class TetheringFragment : Fragment(), ServiceConnection {
|
|||||||
NetworkInterface.getNetworkInterfaces().asSequence().associateBy { it.name }
|
NetworkInterface.getNetworkInterfaces().asSequence().associateBy { it.name }
|
||||||
} catch (e: SocketException) {
|
} catch (e: SocketException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
emptyMap()
|
emptyMap()
|
||||||
}
|
}
|
||||||
this@TetheringFragment.enabledTypes =
|
this@TetheringFragment.enabledTypes =
|
||||||
|
|||||||
@@ -4,12 +4,15 @@ import android.util.Log
|
|||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import be.mygod.vpnhotspot.R
|
import be.mygod.vpnhotspot.R
|
||||||
import be.mygod.vpnhotspot.util.thread
|
import be.mygod.vpnhotspot.util.thread
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.io.InterruptedIOException
|
import java.io.InterruptedIOException
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.ScheduledExecutorService
|
import java.util.concurrent.ScheduledExecutorService
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
abstract class IpMonitor : Runnable {
|
abstract class IpMonitor : Runnable {
|
||||||
|
private class MonitorFailure : RuntimeException()
|
||||||
|
private class FlushFailure : RuntimeException()
|
||||||
protected abstract val monitoredObject: String
|
protected abstract val monitoredObject: String
|
||||||
protected abstract fun processLine(line: String)
|
protected abstract fun processLine(line: String)
|
||||||
protected abstract fun processLines(lines: Sequence<String>)
|
protected abstract fun processLines(lines: Sequence<String>)
|
||||||
@@ -27,14 +30,17 @@ abstract class IpMonitor : Runnable {
|
|||||||
this.monitor = monitor
|
this.monitor = monitor
|
||||||
thread("${javaClass.simpleName}-error") {
|
thread("${javaClass.simpleName}-error") {
|
||||||
try {
|
try {
|
||||||
monitor.errorStream.bufferedReader().forEachLine { Log.e(javaClass.simpleName, it) }
|
monitor.errorStream.bufferedReader().forEachLine {
|
||||||
|
Crashlytics.log(Log.ERROR, javaClass.simpleName, it)
|
||||||
|
}
|
||||||
} catch (_: InterruptedIOException) { }
|
} catch (_: InterruptedIOException) { }
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
monitor.inputStream.bufferedReader().forEachLine(this::processLine)
|
monitor.inputStream.bufferedReader().forEachLine(this::processLine)
|
||||||
monitor.waitFor()
|
monitor.waitFor()
|
||||||
if (monitor.exitValue() == 0) return@thread
|
if (monitor.exitValue() == 0) return@thread
|
||||||
Log.w(javaClass.simpleName, "Failed to set up monitor, switching to polling")
|
Crashlytics.log(Log.WARN, javaClass.simpleName, "Failed to set up monitor, switching to polling")
|
||||||
|
Crashlytics.logException(MonitorFailure())
|
||||||
val pool = Executors.newScheduledThreadPool(1)
|
val pool = Executors.newScheduledThreadPool(1)
|
||||||
pool.scheduleAtFixedRate(this, 1, 1, TimeUnit.SECONDS)
|
pool.scheduleAtFixedRate(this, 1, 1, TimeUnit.SECONDS)
|
||||||
this.pool = pool
|
this.pool = pool
|
||||||
@@ -52,7 +58,8 @@ abstract class IpMonitor : Runnable {
|
|||||||
thread("${javaClass.simpleName}-flush-error") {
|
thread("${javaClass.simpleName}-flush-error") {
|
||||||
val err = process.errorStream.bufferedReader().readText()
|
val err = process.errorStream.bufferedReader().readText()
|
||||||
if (err.isNotBlank()) {
|
if (err.isNotBlank()) {
|
||||||
Log.e(javaClass.simpleName, err)
|
Crashlytics.log(Log.ERROR, javaClass.simpleName, err)
|
||||||
|
Crashlytics.logException(FlushFailure())
|
||||||
app.toast(R.string.noisy_su_failure)
|
app.toast(R.string.noisy_su_failure)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package be.mygod.vpnhotspot.net
|
package be.mygod.vpnhotspot.net
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ data class IpNeighbour(val ip: String, val dev: String, val lladdr: String, val
|
|||||||
fun parse(line: String): IpNeighbour? {
|
fun parse(line: String): IpNeighbour? {
|
||||||
val match = parser.matchEntire(line)
|
val match = parser.matchEntire(line)
|
||||||
if (match == null) {
|
if (match == null) {
|
||||||
if (line.isNotEmpty()) Log.w(TAG, line)
|
if (line.isNotEmpty()) Crashlytics.log(Log.WARN, TAG, line)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
val ip = match.groupValues[2]
|
val ip = match.groupValues[2]
|
||||||
@@ -43,7 +44,7 @@ data class IpNeighbour(val ip: String, val dev: String, val lladdr: String, val
|
|||||||
"FAILED" -> State.FAILED
|
"FAILED" -> State.FAILED
|
||||||
"NOARP" -> return null // skip
|
"NOARP" -> return null // skip
|
||||||
else -> {
|
else -> {
|
||||||
Log.w(TAG, "Unknown state encountered: ${match.groupValues[10]}")
|
Crashlytics.log(Log.WARN, TAG, "Unknown state encountered: ${match.groupValues[10]}")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,6 +71,7 @@ data class IpNeighbour(val ip: String, val dev: String, val lladdr: String, val
|
|||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
}
|
}
|
||||||
return arpCache
|
return arpCache
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.support.annotation.RequiresApi
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import com.android.dx.stock.ProxyBuilder
|
import com.android.dx.stock.ProxyBuilder
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Heavily based on:
|
* Heavily based on:
|
||||||
@@ -91,7 +92,7 @@ object TetheringManager {
|
|||||||
val proxy = ProxyBuilder.forClass(classOnStartTetheringCallback)
|
val proxy = ProxyBuilder.forClass(classOnStartTetheringCallback)
|
||||||
.dexCache(app.cacheDir)
|
.dexCache(app.cacheDir)
|
||||||
.handler { proxy, method, args ->
|
.handler { proxy, method, args ->
|
||||||
if (args.isNotEmpty()) Log.w(TAG, "Unexpected args for ${method.name}: $args")
|
if (args.isNotEmpty()) Crashlytics.log(Log.WARN, TAG, "Unexpected args for ${method.name}: $args")
|
||||||
when (method.name) {
|
when (method.name) {
|
||||||
"onTetheringStarted" -> {
|
"onTetheringStarted" -> {
|
||||||
callback.onTetheringStarted()
|
callback.onTetheringStarted()
|
||||||
@@ -102,7 +103,7 @@ object TetheringManager {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
Log.w(TAG, "Unexpected method, calling super: $method")
|
Crashlytics.log(Log.WARN, TAG, "Unexpected method, calling super: $method")
|
||||||
ProxyBuilder.callSuper(proxy, method, args)
|
ProxyBuilder.callSuper(proxy, method, args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.widget.Toast
|
|||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import be.mygod.vpnhotspot.util.loggerSu
|
import be.mygod.vpnhotspot.util.loggerSu
|
||||||
import be.mygod.vpnhotspot.util.noisySu
|
import be.mygod.vpnhotspot.util.noisySu
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class P2pSupplicantConfiguration {
|
class P2pSupplicantConfiguration {
|
||||||
@@ -34,8 +35,9 @@ class P2pSupplicantConfiguration {
|
|||||||
check(result.length in 8..63)
|
check(result.length in 8..63)
|
||||||
result
|
result
|
||||||
} catch (e: RuntimeException) {
|
} catch (e: RuntimeException) {
|
||||||
Log.w(TAG, content)
|
Crashlytics.log(Log.WARN, TAG, content)
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
Toast.makeText(app, e.message, Toast.LENGTH_LONG).show()
|
Toast.makeText(app, e.message, Toast.LENGTH_LONG).show()
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
@@ -61,7 +63,9 @@ class P2pSupplicantConfiguration {
|
|||||||
else -> line // do nothing
|
else -> line // do nothing
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (ssidFound != 1 || pskFound != 1) Log.w(TAG, "Invalid conf ($ssidFound, $pskFound): $content")
|
if (ssidFound != 1 || pskFound != 1) {
|
||||||
|
Crashlytics.log(Log.WARN, TAG, "Invalid conf ($ssidFound, $pskFound): $content")
|
||||||
|
}
|
||||||
if (ssidFound == 0 || pskFound == 0) return false
|
if (ssidFound == 0 || pskFound == 0) return false
|
||||||
// pkill not available on Lollipop. Source: https://android.googlesource.com/platform/system/core/+/master/shell_and_utilities/README.md
|
// pkill not available on Lollipop. Source: https://android.googlesource.com/platform/system/core/+/master/shell_and_utilities/README.md
|
||||||
return noisySu("cat ${tempFile.absolutePath} > /data/misc/wifi/p2p_supplicant.conf",
|
return noisySu("cat ${tempFile.absolutePath} > /data/misc/wifi/p2p_supplicant.conf",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.net.wifi.p2p.WifiP2pGroup
|
|||||||
import android.net.wifi.p2p.WifiP2pManager
|
import android.net.wifi.p2p.WifiP2pManager
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.android.dx.stock.ProxyBuilder
|
import com.android.dx.stock.ProxyBuilder
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.lang.reflect.Proxy
|
import java.lang.reflect.Proxy
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
@@ -88,11 +89,11 @@ object WifiP2pManagerHelper {
|
|||||||
val proxy = Proxy.newProxyInstance(interfacePersistentGroupInfoListener.classLoader,
|
val proxy = Proxy.newProxyInstance(interfacePersistentGroupInfoListener.classLoader,
|
||||||
arrayOf(interfacePersistentGroupInfoListener), { proxy, method, args ->
|
arrayOf(interfacePersistentGroupInfoListener), { proxy, method, args ->
|
||||||
if (method.name == "onPersistentGroupInfoAvailable") {
|
if (method.name == "onPersistentGroupInfoAvailable") {
|
||||||
if (args.size != 1) Log.w(TAG, "Unexpected args: $args")
|
if (args.size != 1) Crashlytics.log(Log.WARN, TAG, "Unexpected args: $args")
|
||||||
listener(getGroupList.invoke(args[0]) as Collection<WifiP2pGroup>)
|
listener(getGroupList.invoke(args[0]) as Collection<WifiP2pGroup>)
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Unexpected method, calling super: $method")
|
Crashlytics.log(Log.WARN, TAG, "Unexpected method, calling super: $method")
|
||||||
ProxyBuilder.callSuper(proxy, method, args)
|
ProxyBuilder.callSuper(proxy, method, args)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,29 +1,34 @@
|
|||||||
package be.mygod.vpnhotspot.util
|
package be.mygod.vpnhotspot.util
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import be.mygod.vpnhotspot.App
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import be.mygod.vpnhotspot.R
|
import be.mygod.vpnhotspot.R
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
private const val NOISYSU_TAG = "NoisySU"
|
private const val NOISYSU_TAG = "NoisySU"
|
||||||
private const val NOISYSU_SUFFIX = "SUCCESS\n"
|
private const val NOISYSU_SUFFIX = "SUCCESS\n"
|
||||||
|
|
||||||
|
private class SuFailure : RuntimeException()
|
||||||
|
|
||||||
fun loggerSuStream(command: String): InputStream? {
|
fun loggerSuStream(command: String): InputStream? {
|
||||||
val process = try {
|
val process = try {
|
||||||
ProcessBuilder("su", "-c", command)
|
ProcessBuilder("su", "-c", command)
|
||||||
.redirectErrorStream(true)
|
.redirectErrorStream(true)
|
||||||
.directory(App.app.deviceContext.cacheDir)
|
.directory(app.deviceContext.cacheDir)
|
||||||
.start()
|
.start()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
thread("LoggerSU-error") {
|
thread("LoggerSU-error") {
|
||||||
val err = process.errorStream.bufferedReader().readText()
|
val err = process.errorStream.bufferedReader().readText()
|
||||||
if (err.isNotBlank()) {
|
if (err.isNotBlank()) {
|
||||||
Log.e(NOISYSU_TAG, err)
|
Crashlytics.log(Log.ERROR, NOISYSU_TAG, err)
|
||||||
App.app.toast(R.string.noisy_su_failure)
|
Crashlytics.logException(SuFailure())
|
||||||
|
app.toast(R.string.noisy_su_failure)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return process.inputStream
|
return process.inputStream
|
||||||
@@ -35,6 +40,7 @@ fun loggerSu(command: String): String? {
|
|||||||
stream.bufferedReader().readText()
|
stream.bufferedReader().readText()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +51,10 @@ ${commands.joinToString("\n") { if (it.startsWith("quiet ")) it.substring(6) els
|
|||||||
echo $NOISYSU_SUFFIX""")
|
echo $NOISYSU_SUFFIX""")
|
||||||
val result = if (out == null) null else out == NOISYSU_SUFFIX
|
val result = if (out == null) null else out == NOISYSU_SUFFIX
|
||||||
out = out?.removeSuffix(NOISYSU_SUFFIX)
|
out = out?.removeSuffix(NOISYSU_SUFFIX)
|
||||||
if (!out.isNullOrBlank()) Log.i(NOISYSU_TAG, out)
|
if (!out.isNullOrBlank()) {
|
||||||
|
Crashlytics.log(Log.INFO, NOISYSU_TAG, out)
|
||||||
|
Crashlytics.logException(SuFailure())
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
fun noisySu(vararg commands: String) = noisySu(commands.asIterable())
|
fun noisySu(vararg commands: String) = noisySu(commands.asIterable())
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ import android.widget.ImageView
|
|||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import be.mygod.vpnhotspot.BuildConfig
|
import be.mygod.vpnhotspot.BuildConfig
|
||||||
import be.mygod.vpnhotspot.R
|
import be.mygod.vpnhotspot.R
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.net.NetworkInterface
|
import java.net.NetworkInterface
|
||||||
import java.net.SocketException
|
import java.net.SocketException
|
||||||
|
|
||||||
fun debugLog(tag: String?, message: String?) {
|
fun debugLog(tag: String?, message: String?) {
|
||||||
if (BuildConfig.DEBUG) Log.d(tag, message)
|
if (BuildConfig.DEBUG) Log.d(tag, message)
|
||||||
|
Crashlytics.log("$tag: $message")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun broadcastReceiver(receiver: (Context, Intent) -> Unit) = object : BroadcastReceiver() {
|
fun broadcastReceiver(receiver: (Context, Intent) -> Unit) = object : BroadcastReceiver() {
|
||||||
@@ -48,6 +50,7 @@ fun NetworkInterface.formatAddresses() =
|
|||||||
hardwareAddress?.joinToString(":") { "%02x".format(it) }
|
hardwareAddress?.joinToString(":") { "%02x".format(it) }
|
||||||
} catch (e: SocketException) {
|
} catch (e: SocketException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Crashlytics.logException(e)
|
||||||
null
|
null
|
||||||
}))
|
}))
|
||||||
.joinToString("\n")
|
.joinToString("\n")
|
||||||
@@ -58,7 +61,10 @@ fun NetworkInterface.formatAddresses() =
|
|||||||
fun thread(name: String? = null, start: Boolean = true, isDaemon: Boolean = false,
|
fun thread(name: String? = null, start: Boolean = true, isDaemon: Boolean = false,
|
||||||
contextClassLoader: ClassLoader? = null, priority: Int = -1, block: () -> Unit): Thread {
|
contextClassLoader: ClassLoader? = null, priority: Int = -1, block: () -> Unit): Thread {
|
||||||
val thread = kotlin.concurrent.thread(false, isDaemon, contextClassLoader, name, priority, block)
|
val thread = kotlin.concurrent.thread(false, isDaemon, contextClassLoader, name, priority, block)
|
||||||
thread.setUncaughtExceptionHandler { _, _ -> app.toast(R.string.noisy_su_failure) }
|
thread.setUncaughtExceptionHandler { _, e ->
|
||||||
|
app.toast(R.string.noisy_su_failure)
|
||||||
|
Crashlytics.logException(e)
|
||||||
|
}
|
||||||
if (start) thread.start()
|
if (start) thread.start()
|
||||||
return thread
|
return thread
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user