mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 12:05:30 +00:00
Minor changes
This commit is contained in:
parent
8b28baabd7
commit
7e01f9c95e
@ -9,7 +9,11 @@ import dalvik.system.DexClassLoader;
|
||||
|
||||
public class DynamicClassLoader extends DexClassLoader {
|
||||
|
||||
private ClassLoader base = Object.class.getClassLoader();
|
||||
private static final ClassLoader base = Object.class.getClassLoader();
|
||||
|
||||
public DynamicClassLoader(File apk) {
|
||||
super(apk.getPath(), apk.getParent(), null, base);
|
||||
}
|
||||
|
||||
public DynamicClassLoader(File apk, ClassLoader parent) {
|
||||
super(apk.getPath(), apk.getParent(), null, parent);
|
||||
@ -18,7 +22,7 @@ public class DynamicClassLoader extends DexClassLoader {
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
// First check if already loaded
|
||||
Class cls = findLoadedClass(name);
|
||||
Class<?> cls = findLoadedClass(name);
|
||||
if (cls != null)
|
||||
return cls;
|
||||
|
||||
|
@ -264,8 +264,7 @@ fun Context.startEndToLeftRight(start: Int, end: Int): Pair<Int, Int> {
|
||||
|
||||
fun Context.openUrl(url: String) = Utils.openLink(this, url.toUri())
|
||||
|
||||
@Suppress("FunctionName")
|
||||
inline fun <reified T> T.DynamicClassLoader(apk: File) =
|
||||
inline fun <reified T> T.createClassLoader(apk: File) =
|
||||
DynamicClassLoader(apk, T::class.java.classLoader)
|
||||
|
||||
fun Context.unwrap(): Context {
|
||||
|
@ -12,7 +12,7 @@ import com.topjohnwu.magisk.arch.ContextExecutor
|
||||
import com.topjohnwu.magisk.arch.ViewEventWithScope
|
||||
import com.topjohnwu.magisk.core.Const
|
||||
import com.topjohnwu.magisk.data.repository.NetworkService
|
||||
import com.topjohnwu.magisk.ktx.DynamicClassLoader
|
||||
import com.topjohnwu.magisk.ktx.createClassLoader
|
||||
import com.topjohnwu.magisk.ktx.writeTo
|
||||
import com.topjohnwu.magisk.view.MagiskDialog
|
||||
import com.topjohnwu.signing.CryptoUtils
|
||||
@ -67,7 +67,7 @@ class CheckSafetyNetEvent(
|
||||
private suspend fun attest(context: Context, onError: suspend (Exception) -> Unit) {
|
||||
val helper: SafetyNetHelper
|
||||
try {
|
||||
val loader = DynamicClassLoader(apk)
|
||||
val loader = createClassLoader(apk)
|
||||
|
||||
// Scan through the dex and find our helper class
|
||||
var clazz: Class<*>? = null
|
||||
|
@ -7,10 +7,7 @@ import java.io.File;
|
||||
class InjectedClassLoader extends DynamicClassLoader {
|
||||
|
||||
InjectedClassLoader(File apk) {
|
||||
super(apk,
|
||||
/* Use the base classloader as we do not want stub
|
||||
* APK classes accessible from the main app */
|
||||
Object.class.getClassLoader());
|
||||
super(apk);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user