mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-03 00:05:43 +00:00
Hide annoying stack traces when hidden
This commit is contained in:
parent
4c1ea0e421
commit
a328e2bf3c
4
app/proguard-rules.pro
vendored
4
app/proguard-rules.pro
vendored
@ -31,6 +31,10 @@
|
|||||||
|
|
||||||
# Stub
|
# Stub
|
||||||
-keep class com.topjohnwu.magisk.core.App { <init>(java.lang.Object); }
|
-keep class com.topjohnwu.magisk.core.App { <init>(java.lang.Object); }
|
||||||
|
-keepclassmembers class androidx.appcompat.app.AppCompatDelegateImpl {
|
||||||
|
boolean mActivityHandlesUiModeChecked;
|
||||||
|
boolean mActivityHandlesUiMode;
|
||||||
|
}
|
||||||
|
|
||||||
# Strip Timber verbose and debug logging
|
# Strip Timber verbose and debug logging
|
||||||
-assumenosideeffects class timber.log.Timber$Tree {
|
-assumenosideeffects class timber.log.Timber$Tree {
|
||||||
|
@ -7,6 +7,7 @@ import android.content.Intent
|
|||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.CallSuper
|
import androidx.annotation.CallSuper
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@ -16,6 +17,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
import com.topjohnwu.magisk.core.utils.currentLocale
|
import com.topjohnwu.magisk.core.utils.currentLocale
|
||||||
import com.topjohnwu.magisk.core.wrap
|
import com.topjohnwu.magisk.core.wrap
|
||||||
|
import com.topjohnwu.magisk.ktx.reflectField
|
||||||
import com.topjohnwu.magisk.ktx.set
|
import com.topjohnwu.magisk.ktx.set
|
||||||
import com.topjohnwu.magisk.utils.Utils
|
import com.topjohnwu.magisk.utils.Utils
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
@ -43,6 +45,15 @@ abstract class BaseActivity : AppCompatActivity() {
|
|||||||
super.attachBaseContext(base.wrap(true))
|
super.attachBaseContext(base.wrap(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
// Overwrite private members to avoid nasty "false" stack traces being logged
|
||||||
|
val delegate = delegate
|
||||||
|
val clz = delegate.javaClass
|
||||||
|
clz.reflectField("mActivityHandlesUiModeChecked").set(delegate, true)
|
||||||
|
clz.reflectField("mActivityHandlesUiMode").set(delegate, false)
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
fun withPermission(permission: String, builder: PermissionRequestBuilder.() -> Unit) {
|
fun withPermission(permission: String, builder: PermissionRequestBuilder.() -> Unit) {
|
||||||
val request = PermissionRequestBuilder().apply(builder).build()
|
val request = PermissionRequestBuilder().apply(builder).build()
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import timber.log.Timber
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
|
import java.lang.reflect.Field
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.zip.ZipEntry
|
import java.util.zip.ZipEntry
|
||||||
@ -48,3 +49,6 @@ fun <K, V> MutableMap<K, V>.synchronized() = Collections.synchronizedMap(this)
|
|||||||
|
|
||||||
fun SimpleDateFormat.parseOrNull(date: String) =
|
fun SimpleDateFormat.parseOrNull(date: String) =
|
||||||
runCatching { parse(date) }.onFailure { Timber.e(it) }.getOrNull()
|
runCatching { parse(date) }.onFailure { Timber.e(it) }.getOrNull()
|
||||||
|
|
||||||
|
fun Class<*>.reflectField(name: String): Field =
|
||||||
|
getDeclaredField(name).apply { isAccessible = true }
|
||||||
|
@ -13,6 +13,7 @@ import com.topjohnwu.magisk.arch.ViewEventWithScope
|
|||||||
import com.topjohnwu.magisk.core.Const
|
import com.topjohnwu.magisk.core.Const
|
||||||
import com.topjohnwu.magisk.data.repository.NetworkService
|
import com.topjohnwu.magisk.data.repository.NetworkService
|
||||||
import com.topjohnwu.magisk.ktx.createClassLoader
|
import com.topjohnwu.magisk.ktx.createClassLoader
|
||||||
|
import com.topjohnwu.magisk.ktx.reflectField
|
||||||
import com.topjohnwu.magisk.ktx.writeTo
|
import com.topjohnwu.magisk.ktx.writeTo
|
||||||
import com.topjohnwu.magisk.view.MagiskDialog
|
import com.topjohnwu.magisk.view.MagiskDialog
|
||||||
import com.topjohnwu.signing.CryptoUtils
|
import com.topjohnwu.signing.CryptoUtils
|
||||||
@ -31,7 +32,6 @@ import timber.log.Timber
|
|||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.lang.reflect.Field
|
|
||||||
import java.lang.reflect.InvocationHandler
|
import java.lang.reflect.InvocationHandler
|
||||||
import java.security.GeneralSecurityException
|
import java.security.GeneralSecurityException
|
||||||
import java.security.SecureRandom
|
import java.security.SecureRandom
|
||||||
@ -100,14 +100,11 @@ class CheckSafetyNetEvent(
|
|||||||
helper.attest(nonce)
|
helper.attest(nonce)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Class<*>.field(name: String): Field =
|
|
||||||
getDeclaredField(name).apply { isAccessible = true }
|
|
||||||
|
|
||||||
// All of these fields are whitelisted
|
// All of these fields are whitelisted
|
||||||
private fun BaseDexClassLoader.getDexFiles(): List<DexFile> {
|
private fun BaseDexClassLoader.getDexFiles(): List<DexFile> {
|
||||||
val pathList = BaseDexClassLoader::class.java.field("pathList").get(this)
|
val pathList = BaseDexClassLoader::class.java.reflectField("pathList").get(this)
|
||||||
val dexElements = pathList.javaClass.field("dexElements").get(pathList) as Array<*>
|
val dexElements = pathList.javaClass.reflectField("dexElements").get(pathList) as Array<*>
|
||||||
val fileField = dexElements.javaClass.componentType.field("dexFile")
|
val fileField = dexElements.javaClass.componentType.reflectField("dexFile")
|
||||||
return dexElements.map { fileField.get(it) as DexFile }
|
return dexElements.map { fileField.get(it) as DexFile }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user