diff --git a/build.gradle.kts b/build.gradle.kts index 2920f61a..845e7445 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,7 +25,7 @@ repositories { dependencies { implementation(kotlin("reflect")) - implementation("app.revanced:revanced-patcher:5.1.2") + implementation("app.revanced:revanced-patcher:6.0.0") implementation("info.picocli:picocli:4.6.3") implementation("com.android.tools.build:apksig:7.2.1") implementation("com.github.revanced:jadb:master-SNAPSHOT") // updated fork diff --git a/src/main/kotlin/app/revanced/cli/command/MainCommand.kt b/src/main/kotlin/app/revanced/cli/command/MainCommand.kt index 922020b1..49f9fb4d 100644 --- a/src/main/kotlin/app/revanced/cli/command/MainCommand.kt +++ b/src/main/kotlin/app/revanced/cli/command/MainCommand.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.PatcherOptions import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages import app.revanced.patcher.extensions.PatchExtensions.description import app.revanced.patcher.extensions.PatchExtensions.patchName -import app.revanced.patcher.util.patch.impl.JarPatchBundle +import app.revanced.patcher.util.patch.PatchBundle import app.revanced.utils.OptionsLoader import app.revanced.utils.adb.Adb import picocli.CommandLine.* @@ -131,7 +131,7 @@ internal object MainCommand : Runnable { val outputFile = File(pArgs.outputPath) // the file to write to val allPatches = args.patchArgs!!.patchBundles.flatMap { bundle -> - JarPatchBundle(bundle).loadPatches() + PatchBundle.Jar(bundle).loadPatches() } OptionsLoader.init(args.patchArgs!!.options, allPatches) @@ -148,7 +148,7 @@ internal object MainCommand : Runnable { // prepare adb val adb: Adb? = args.deploy?.let { - Adb(outputFile, patcher.data.packageMetadata.packageName, args.deploy!!, !pArgs.mount) + Adb(outputFile, patcher.context.packageMetadata.packageName, args.deploy!!, !pArgs.mount) } val patchedFile = File(pArgs.cacheDirectory).resolve("${outputFile.nameWithoutExtension}_raw.apk") @@ -209,7 +209,7 @@ internal object MainCommand : Runnable { val adb: Adb? = args.deploy?.let { Adb( File("placeholder_file"), - app.revanced.patcher.Patcher(PatcherOptions(args.inputFile, "")).data.packageMetadata.packageName, + app.revanced.patcher.Patcher(PatcherOptions(args.inputFile, "")).context.packageMetadata.packageName, args.deploy!!, false ) @@ -219,7 +219,8 @@ internal object MainCommand : Runnable { private fun printListOfPatches() { val logged = mutableListOf() - for (patchBundlePath in args.patchArgs?.patchBundles!!) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) { + for (patchBundlePath in args.patchArgs?.patchBundles!!) for (patch in PatchBundle.Jar(patchBundlePath) + .loadPatches()) { if (patch.patchName in logged) continue for (compatiblePackage in patch.compatiblePackages!!) { val packageEntryStr = buildString { diff --git a/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt b/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt index a1b1d401..dfe7b3d5 100644 --- a/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt @@ -2,7 +2,7 @@ package app.revanced.cli.patcher import app.revanced.cli.command.MainCommand.args import app.revanced.cli.command.MainCommand.logger -import app.revanced.patcher.data.Data +import app.revanced.patcher.data.Context import app.revanced.patcher.patch.Patch import app.revanced.utils.filesystem.ZipFileSystemUtils import app.revanced.utils.patcher.addPatchesFiltered @@ -12,7 +12,11 @@ import java.io.File import java.nio.file.Files internal object Patcher { - internal fun start(patcher: app.revanced.patcher.Patcher, output: File, allPatches: List>>) { + internal fun start( + patcher: app.revanced.patcher.Patcher, + output: File, + allPatches: List>> + ) { val inputFile = args.inputFile // merge files like necessary integrations diff --git a/src/main/kotlin/app/revanced/utils/OptionsLoader.kt b/src/main/kotlin/app/revanced/utils/OptionsLoader.kt index fc1f8013..e098da01 100644 --- a/src/main/kotlin/app/revanced/utils/OptionsLoader.kt +++ b/src/main/kotlin/app/revanced/utils/OptionsLoader.kt @@ -2,7 +2,7 @@ package app.revanced.utils import app.revanced.cli.command.MainCommand.logger import app.revanced.patcher.Patcher -import app.revanced.patcher.data.Data +import app.revanced.patcher.data.Context import app.revanced.patcher.extensions.PatchExtensions.options import app.revanced.patcher.extensions.PatchExtensions.patchName import app.revanced.patcher.patch.Patch @@ -12,7 +12,7 @@ import cc.ekblad.toml.serialization.from import cc.ekblad.toml.tomlMapper import java.io.File -private typealias PatchList = List>> +private typealias PatchList = List>> private typealias OptionsMap = MutableMap> object OptionsLoader { diff --git a/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt b/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt index f0a657c2..e2c32fec 100644 --- a/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt @@ -4,18 +4,18 @@ import app.revanced.cli.command.MainCommand import app.revanced.cli.command.MainCommand.args import app.revanced.cli.command.MainCommand.logger import app.revanced.patcher.Patcher -import app.revanced.patcher.data.Data +import app.revanced.patcher.data.Context import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages import app.revanced.patcher.extensions.PatchExtensions.deprecated import app.revanced.patcher.extensions.PatchExtensions.include import app.revanced.patcher.extensions.PatchExtensions.patchName import app.revanced.patcher.patch.Patch -fun Patcher.addPatchesFiltered(allPatches: List>>) { - val packageName = this.data.packageMetadata.packageName - val packageVersion = this.data.packageMetadata.packageVersion +fun Patcher.addPatchesFiltered(allPatches: List>>) { + val packageName = this.context.packageMetadata.packageName + val packageVersion = this.context.packageMetadata.packageVersion - val includedPatches = mutableListOf>>() + val includedPatches = mutableListOf>>() allPatches.forEach patchLoop@{ patch -> val compatiblePackages = patch.compatiblePackages val patchName = patch.patchName @@ -66,7 +66,7 @@ fun Patcher.addPatchesFiltered(allPatches: List>>) { } fun Patcher.applyPatchesVerbose() { - this.applyPatches().forEach { (patch, result) -> + this.executePatches().forEach { (patch, result) -> if (result.isSuccess) { logger.info("$patch succeeded") return@forEach diff --git a/src/main/kotlin/app/revanced/utils/signing/align/zip/structures/ZipEntry.kt b/src/main/kotlin/app/revanced/utils/signing/align/zip/structures/ZipEntry.kt index 9e70f526..480377f6 100644 --- a/src/main/kotlin/app/revanced/utils/signing/align/zip/structures/ZipEntry.kt +++ b/src/main/kotlin/app/revanced/utils/signing/align/zip/structures/ZipEntry.kt @@ -1,10 +1,6 @@ package app.revanced.utils.signing.align.zip.structures -import app.revanced.utils.signing.align.zip.getUShort -import app.revanced.utils.signing.align.zip.putUInt -import app.revanced.utils.signing.align.zip.putUShort -import app.revanced.utils.signing.align.zip.readUIntLE -import app.revanced.utils.signing.align.zip.readUShortLE +import app.revanced.utils.signing.align.zip.* import java.io.DataInput import java.nio.ByteBuffer import java.nio.ByteOrder