update to newest patcher v22

This commit is contained in:
oSumAtrIX
2026-01-28 16:27:40 +01:00
parent b02c81de07
commit 00487cf27c
9 changed files with 34 additions and 28 deletions

View File

@@ -1,7 +1,7 @@
package app.revanced.library
import app.revanced.library.ApkSigner.newPrivateKeyCertificatePair
import app.revanced.patcher.PatcherResult
import app.revanced.patcher.PatchesResult
import com.android.tools.build.apkzlib.zip.AlignmentRules
import com.android.tools.build.apkzlib.zip.StoredEntry
import com.android.tools.build.apkzlib.zip.ZFile
@@ -38,7 +38,7 @@ object ApkUtils {
)
/**
* Applies the [PatcherResult] to the given [apkFile].
* Applies the [PatchesResult] to the given [apkFile].
*
* The order of operation is as follows:
* 1. Write patched dex files.
@@ -50,7 +50,7 @@ object ApkUtils {
*
* @param apkFile The file to apply the patched files to.
*/
fun PatcherResult.applyTo(apkFile: File) {
fun PatchesResult.applyTo(apkFile: File) {
ZFile.openReadWrite(apkFile, zFileOptions).use { targetApkZFile ->
dexFiles.forEach { dexFile ->
targetApkZFile.add(dexFile.name, dexFile.stream)

View File

@@ -18,7 +18,7 @@ private val logger = Logger.getLogger("Options")
*
* @param options The options to set. The key is the patch name and the value is a map of option keys to option values.
*/
fun Set<Patch<*>>.setOptions(options: PatchesOptions) = filter { it.name != null }.forEach { patch ->
fun Set<Patch>.setOptions(options: PatchesOptions) = filter { it.name != null }.forEach { patch ->
options[patch.name]?.forEach setOption@{ (optionKey, optionValue) ->
if (optionKey !in patch.options) {
return@setOption logger.warning(

View File

@@ -17,7 +17,7 @@ typealias PackageNameMap = Map<PackageName, VersionMap>
* @param countUnusedPatches Whether to count patches that are not used.
* @return A map of package names to a map of versions to their count.
*/
fun Set<Patch<*>>.mostCommonCompatibleVersions(
fun Set<Patch>.mostCommonCompatibleVersions(
packageNames: Set<String>? = null,
countUnusedPatches: Boolean = false,
): PackageNameMap = buildMap {

View File

@@ -16,7 +16,7 @@ import kotlinx.serialization.json.encodeToStream
import kotlinx.serialization.serializer
import java.io.OutputStream
private class PatchSerializer : KSerializer<Patch<*>> {
private class PatchSerializer : KSerializer<Patch> {
override val descriptor = buildClassSerialDescriptor("Patch") {
element<String?>("name")
element<String?>("description")
@@ -29,7 +29,7 @@ private class PatchSerializer : KSerializer<Patch<*>> {
override fun deserialize(decoder: Decoder) = throw NotImplementedError("Deserialization is unsupported")
@OptIn(ExperimentalSerializationApi::class)
override fun serialize(encoder: Encoder, value: Patch<*>) {
override fun serialize(encoder: Encoder, value: Patch) {
encoder.encodeStructure(descriptor) {
encodeNullableSerializableElement(
descriptor,
@@ -108,7 +108,7 @@ private val patchSerializer by lazy { Json }
* @param prettyPrint Whether to pretty print the JSON.
*/
@OptIn(ExperimentalSerializationApi::class)
fun Set<Patch<*>>.serializeTo(
fun Set<Patch>.serializeTo(
outputStream: OutputStream,
prettyPrint: Boolean = true,
) = if (prettyPrint) {