fix: apply correct patch if patch names are same (#535)

This commit is contained in:
d4rkk3y 2022-11-25 00:14:04 +07:00 committed by GitHub
parent 795a1c78df
commit 922f474b59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ import app.revanced.manager.flutter.utils.zip.ZipFile
import app.revanced.manager.flutter.utils.zip.structures.ZipEntry import app.revanced.manager.flutter.utils.zip.structures.ZipEntry
import app.revanced.patcher.Patcher import app.revanced.patcher.Patcher
import app.revanced.patcher.PatcherOptions import app.revanced.patcher.PatcherOptions
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
import app.revanced.patcher.extensions.PatchExtensions.patchName import app.revanced.patcher.extensions.PatchExtensions.patchName
import app.revanced.patcher.logging.Logger import app.revanced.patcher.logging.Logger
import app.revanced.patcher.util.patch.PatchBundle import app.revanced.patcher.util.patch.PatchBundle
@ -99,20 +100,6 @@ class MainActivity : FlutterActivity() {
Thread { Thread {
try { try {
val patches = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CUPCAKE) {
PatchBundle.Dex(
patchBundleFilePath,
DexClassLoader(
patchBundleFilePath,
cacheDirPath,
null,
javaClass.classLoader
)
).loadPatches().filter { patch -> selectedPatches.any { it == patch.patchName } }
} else {
TODO("VERSION.SDK_INT < CUPCAKE")
}
handler.post { handler.post {
installerChannel.invokeMethod( installerChannel.invokeMethod(
"update", "update",
@ -177,6 +164,22 @@ class MainActivity : FlutterActivity() {
) )
} }
val patches = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CUPCAKE) {
PatchBundle.Dex(
patchBundleFilePath,
DexClassLoader(
patchBundleFilePath,
cacheDirPath,
null,
javaClass.classLoader
)
).loadPatches().filter { patch ->
patch.compatiblePackages!!.any { it.name == patcher.context.packageMetadata.packageName } &&
selectedPatches.any { it == patch.patchName }
}
} else {
TODO("VERSION.SDK_INT < CUPCAKE")
}
patcher.addPatches(patches) patcher.addPatches(patches)
patcher.executePatches().forEach { (patch, res) -> patcher.executePatches().forEach { (patch, res) ->
if (res.isSuccess) { if (res.isSuccess) {
@ -308,6 +311,7 @@ class MainActivity : FlutterActivity() {
} }
} }
override fun trace(_msg: String) { /* unused */ } override fun trace(_msg: String) { /* unused */
}
} }
} }