Make compatible with F-Droid (#42)
* Make compatible with F-Droid * Fix title bar empty
This commit is contained in:
@@ -2,10 +2,9 @@ package be.mygod.vpnhotspot.util
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.util.Log
|
||||
import androidx.core.os.postDelayed
|
||||
import com.crashlytics.android.Crashlytics
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import timber.log.Timber
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
@@ -86,11 +85,11 @@ class RootSession : AutoCloseable {
|
||||
*/
|
||||
fun submit(command: String) {
|
||||
val result = execQuiet(command)
|
||||
if (result.code != 0) Crashlytics.log(Log.VERBOSE, TAG, "$command exited with ${result.code}")
|
||||
if (result.code != 0) Timber.v("$command exited with ${result.code}")
|
||||
var msg = result.err.joinToString("\n").trim()
|
||||
if (msg.isNotEmpty()) Crashlytics.log(Log.VERBOSE, TAG, msg)
|
||||
if (msg.isNotEmpty()) Timber.v(msg)
|
||||
msg = result.out.joinToString("\n").trim()
|
||||
if (msg.isNotEmpty()) Crashlytics.log(Log.VERBOSE, TAG, msg)
|
||||
if (msg.isNotEmpty()) Timber.v(msg)
|
||||
}
|
||||
|
||||
fun execQuiet(command: String, redirect: Boolean = false): Shell.Result {
|
||||
|
||||
@@ -11,7 +11,7 @@ import androidx.databinding.BindingAdapter
|
||||
import be.mygod.vpnhotspot.BuildConfig
|
||||
import be.mygod.vpnhotspot.R
|
||||
import be.mygod.vpnhotspot.widget.SmartSnackbar
|
||||
import com.crashlytics.android.Crashlytics
|
||||
import timber.log.Timber
|
||||
import java.net.InetAddress
|
||||
import java.net.NetworkInterface
|
||||
import java.net.SocketException
|
||||
@@ -28,11 +28,6 @@ fun Long.toPluralInt(): Int {
|
||||
|
||||
fun CharSequence?.onEmpty(otherwise: CharSequence): CharSequence = if (isNullOrEmpty()) otherwise else this!!
|
||||
|
||||
fun debugLog(tag: String?, message: String?) {
|
||||
if (BuildConfig.DEBUG) Log.d(tag, message)
|
||||
Crashlytics.log("$tag: $message")
|
||||
}
|
||||
|
||||
fun broadcastReceiver(receiver: (Context, Intent) -> Unit) = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) = receiver(context, intent)
|
||||
}
|
||||
@@ -58,8 +53,7 @@ fun NetworkInterface.formatAddresses() =
|
||||
listOfNotNull(try {
|
||||
hardwareAddress?.joinToString(":") { "%02x".format(it) }
|
||||
} catch (e: SocketException) {
|
||||
e.printStackTrace()
|
||||
Crashlytics.logException(e)
|
||||
Timber.w(e)
|
||||
null
|
||||
}))
|
||||
.joinToString("\n")
|
||||
@@ -85,7 +79,7 @@ fun thread(name: String? = null, start: Boolean = true, isDaemon: Boolean = fals
|
||||
val thread = kotlin.concurrent.thread(false, isDaemon, contextClassLoader, name, priority, block)
|
||||
thread.setUncaughtExceptionHandler { _, e ->
|
||||
SmartSnackbar.make(R.string.noisy_su_failure).show()
|
||||
Crashlytics.logException(e)
|
||||
Timber.w(e)
|
||||
}
|
||||
if (start) thread.start()
|
||||
return thread
|
||||
|
||||
Reference in New Issue
Block a user