Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Oct 22, 2024
1 parent 5eae45a commit 164b978
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 45 deletions.
5 changes: 2 additions & 3 deletions mobile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,12 @@ dependencies {
implementation("androidx.preference:preference:1.2.1")
implementation("androidx.room:room-ktx:$roomVersion")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("be.mygod.librootkotlinx:librootkotlinx:1.2.0")
implementation("be.mygod.librootkotlinx:librootkotlinx:1.2.1")
implementation("com.android.billingclient:billing-ktx:7.1.1")
implementation("com.google.android.gms:play-services-base:18.5.0") // fix for GoogleApiActivity crash @ 18.1.0+
implementation("com.google.android.gms:play-services-oss-licenses:17.1.0")
implementation("com.google.android.material:material:1.12.0")
implementation("com.google.firebase:firebase-analytics:22.1.2")
implementation("com.google.firebase:firebase-crashlytics:19.2.0")
implementation("com.google.firebase:firebase-crashlytics:19.2.1")
implementation("com.google.zxing:core:3.5.3")
implementation("com.jakewharton.timber:timber:5.0.1")
implementation("com.joaomgcd:taskerpluginlibrary:0.4.10")
Expand Down
4 changes: 3 additions & 1 deletion mobile/src/main/java/be/mygod/vpnhotspot/BootReceiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class BootReceiver : BroadcastReceiver() {
private const val FILENAME = "bootconfig"
private val configFile by lazy { File(app.deviceStorage.noBackupFilesDir, FILENAME) }
private val config: Config? get() = try {
DataInputStream(configFile.inputStream()).use { it.readBytes().toParcelable() }
DataInputStream(configFile.inputStream()).use {
it.readBytes().toParcelable(Config::class.java.classLoader)
}
} catch (_: FileNotFoundException) {
null
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
}
android.R.id.paste -> try {
app.clipboard.primaryClip?.getItemAt(0)?.text?.apply {
Base64.decode(toString(), BASE64_FLAGS).toParcelable<SoftApConfigurationCompat>()?.let { config ->
Base64.decode(toString(), BASE64_FLAGS).toParcelable<SoftApConfigurationCompat>(
SoftApConfigurationCompat::class.java.classLoader)?.let { config ->
val newUnderlying = config.underlying
if (newUnderlying != null) {
arg.configuration.underlying?.let { check(it.javaClass == newUnderlying.javaClass) }
Expand Down
44 changes: 4 additions & 40 deletions mobile/src/main/java/be/mygod/vpnhotspot/root/RootManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package be.mygod.vpnhotspot.root

import android.annotation.SuppressLint
import android.os.Parcelable
import android.os.RemoteException
import android.util.Log
import be.mygod.librootkotlinx.AppProcess
import be.mygod.librootkotlinx.Logger
import be.mygod.librootkotlinx.ParcelableByteArray
import be.mygod.librootkotlinx.ParcelableString
import be.mygod.librootkotlinx.ParcelableThrowable
import be.mygod.librootkotlinx.RootCommandChannel
import be.mygod.librootkotlinx.RootServer
import be.mygod.librootkotlinx.RootSession
Expand All @@ -26,14 +24,10 @@ import kotlinx.coroutines.channels.produce
import kotlinx.coroutines.launch
import kotlinx.parcelize.Parcelize
import timber.log.Timber
import java.io.ByteArrayOutputStream
import java.io.NotSerializableException
import java.io.ObjectInputStream
import java.io.ObjectOutputStream

object RootManager : RootSession(), Logger {
@Parcelize
data class LoggedThrowable(val priority: Int, val t: Parcelable) : Parcelable
data class LoggedThrowable(val priority: Int, val t: ParcelableThrowable) : Parcelable
@Parcelize
class RootInit : RootCommandChannel<LoggedThrowable> {
override fun create(scope: CoroutineScope): ReceiveChannel<LoggedThrowable> {
Expand Down Expand Up @@ -61,15 +55,7 @@ object RootManager : RootSession(), Logger {
UnblockCentral.needInit = false
val channel = Channel<Pair<Int, Throwable>>(Channel.CONFLATED) { it.second.printStackTrace(System.err) }
return scope.produce {
channel.consumeEach { (priority, t) ->
send(LoggedThrowable(priority, if (t is Parcelable) t else try {
ParcelableByteArray(ByteArrayOutputStream().apply {
ObjectOutputStream(this).use { it.writeObject(t) }
}.toByteArray())
} catch (_: NotSerializableException) {
ParcelableString(t.stackTraceToString())
}))
}
channel.consumeEach { (priority, t) -> send(LoggedThrowable(priority, ParcelableThrowable(t))) }
}.also {
logThrowable = { priority, t ->
channel.trySend(priority to t).exceptionOrNull()?.printStackTrace(System.err)
Expand All @@ -83,17 +69,6 @@ object RootManager : RootSession(), Logger {
override fun i(m: String?, t: Throwable?) = Timber.i(t, m)
override fun w(m: String?, t: Throwable?) = Timber.w(t, m)

private fun initException(targetClass: Class<*>, message: String): Throwable {
@Suppress("NAME_SHADOWING")
var targetClass = targetClass
while (true) {
try {
// try to find a message constructor
return targetClass.getDeclaredConstructor(String::class.java).newInstance(message) as Throwable
} catch (_: ReflectiveOperationException) { }
targetClass = targetClass.superclass
}
}
override suspend fun initServer(server: RootServer) {
Logger.me = this
AppProcess.shouldRelocateHeuristics.let {
Expand All @@ -103,18 +78,7 @@ object RootManager : RootSession(), Logger {
val throwables = server.create(RootInit(), GlobalScope)
GlobalScope.launch {
try {
throwables.consumeEach { (priority, p) ->
Timber.tag("RootRemote").log(priority, when (p) {
is Throwable -> RemoteException().initCause(p)
is ParcelableByteArray -> RemoteException().initCause(
ObjectInputStream(p.value.inputStream()).readObject() as Throwable)
is ParcelableString -> {
val name = p.value.split(':', limit = 2)[0]
RemoteException(name).initCause(initException(Class.forName(name), p.value))
}
else -> RuntimeException("Unknown parcel received $p")
})
}
throwables.consumeEach { (priority, p) -> Timber.tag("RootRemote").log(priority, p.unwrap()) }
} catch (_: CancellationException) { }
}
}
Expand Down

0 comments on commit 164b978

Please sign in to comment.