From 06dc6df2705ca7fed9f83f82e8ad897d67910e99 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 11 Oct 2019 03:58:04 -0400 Subject: [PATCH] Allow dalvik runtime to load snet --- .../main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt index a35207f61..2cee4cbd8 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt @@ -9,7 +9,6 @@ import com.topjohnwu.magisk.base.BaseActivity import com.topjohnwu.magisk.base.BaseFragment import com.topjohnwu.magisk.data.repository.MagiskRepository import com.topjohnwu.magisk.databinding.FragmentMagiskBinding -import com.topjohnwu.magisk.extensions.inject import com.topjohnwu.magisk.extensions.openUrl import com.topjohnwu.magisk.extensions.subscribeK import com.topjohnwu.magisk.extensions.writeTo @@ -21,6 +20,7 @@ import com.topjohnwu.magisk.view.dialogs.* import com.topjohnwu.superuser.Shell import dalvik.system.DexFile import io.reactivex.Completable +import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import java.io.File import java.lang.reflect.InvocationHandler @@ -33,6 +33,7 @@ class HomeFragment : BaseFragment(), private val magiskRepo: MagiskRepository by inject() private val EXT_APK by lazy { File("${activity.filesDir.parent}/snet", "snet.jar") } + private val EXT_DEX by lazy { File(EXT_APK.parent, "snet.dex") } override fun onResponse(responseCode: Int) = viewModel.finishSafetyNetCheck(responseCode) @@ -94,7 +95,7 @@ class HomeFragment : BaseFragment(), private fun updateSafetyNet(dieOnError: Boolean) { Completable.fromAction { val loader = DynamicClassLoader(EXT_APK) - val dex = DexFile.loadDex(EXT_APK.path, EXT_APK.parent, 0) + val dex = DexFile.loadDex(EXT_APK.path, EXT_DEX.path, 0) // Scan through the dex and find our helper class var helperClass: Class<*>? = null