Improve debug logging mechanisms
This commit is contained in:
@@ -6,13 +6,19 @@ import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import android.view.View
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.databinding.BaseObservable
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.DebugHelper
|
||||
import be.mygod.vpnhotspot.databinding.ListitemManageBinding
|
||||
import timber.log.Timber
|
||||
|
||||
object ManageBar : Manager() {
|
||||
private const val TAG = "ManageBar"
|
||||
private const val SETTINGS_PACKAGE = "com.android.settings"
|
||||
private const val SETTINGS_1 = "com.android.settings.Settings\$TetherSettingsActivity"
|
||||
private const val SETTINGS_2 = "com.android.settings.TetherSettings"
|
||||
|
||||
object Data : BaseObservable() {
|
||||
/**
|
||||
* It's hard to change tethering rules with Tethering hardware acceleration enabled for now.
|
||||
@@ -38,8 +44,7 @@ object ManageBar : Manager() {
|
||||
|
||||
fun start(context: Context) {
|
||||
try {
|
||||
context.startActivity(Intent()
|
||||
.setClassName("com.android.settings", "com.android.settings.Settings\$TetherSettingsActivity"))
|
||||
context.startActivity(Intent().setClassName(SETTINGS_PACKAGE, SETTINGS_1))
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
startAlternative(context, e)
|
||||
} catch (e: SecurityException) {
|
||||
@@ -49,13 +54,12 @@ object ManageBar : Manager() {
|
||||
|
||||
private fun startAlternative(context: Context, e: RuntimeException) {
|
||||
try {
|
||||
context.startActivity(Intent()
|
||||
.setClassName("com.android.settings", "com.android.settings.TetherSettings"))
|
||||
Timber.w(e)
|
||||
context.startActivity(Intent().setClassName("com.android.settings", SETTINGS_2))
|
||||
DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e.message)))
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Timber.w(e)
|
||||
DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e.message), Pair(SETTINGS_2, e.message)))
|
||||
} catch (e: SecurityException) {
|
||||
Timber.w(e)
|
||||
DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e.message), Pair(SETTINGS_2, e.message)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class TetheringFragment : Fragment(), ServiceConnection {
|
||||
ifaceLookup = try {
|
||||
NetworkInterface.getNetworkInterfaces().asSequence().associateBy { it.name }
|
||||
} catch (e: SocketException) {
|
||||
Timber.w(e)
|
||||
Timber.d(e)
|
||||
emptyMap()
|
||||
}
|
||||
this@TetheringFragment.enabledTypes =
|
||||
|
||||
Reference in New Issue
Block a user