mirror of
https://github.com/ReVanced/revanced-library.git
synced 2026-01-29 22:21:03 +00:00
update to newest patcher v22
This commit is contained in:
@@ -26,7 +26,7 @@ public final class app/revanced/library/ApkSigner$Signer {
|
||||
|
||||
public final class app/revanced/library/ApkUtils {
|
||||
public static final field INSTANCE Lapp/revanced/library/ApkUtils;
|
||||
public final fun applyTo (Lapp/revanced/patcher/PatcherResult;Ljava/io/File;)V
|
||||
public final fun applyTo (Lapp/revanced/patcher/PatchesResult;Ljava/io/File;)V
|
||||
public final fun signApk (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Lapp/revanced/library/ApkUtils$KeyStoreDetails;)V
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public final class app/revanced/library/ApkSigner$Signer {
|
||||
|
||||
public final class app/revanced/library/ApkUtils {
|
||||
public static final field INSTANCE Lapp/revanced/library/ApkUtils;
|
||||
public final fun applyTo (Lapp/revanced/patcher/PatcherResult;Ljava/io/File;)V
|
||||
public final fun applyTo (Lapp/revanced/patcher/PatchesResult;Ljava/io/File;)V
|
||||
public final fun signApk (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Lapp/revanced/library/ApkUtils$KeyStoreDetails;)V
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,13 @@ kotlin {
|
||||
implementation(libs.revanced.patcher)
|
||||
}
|
||||
}
|
||||
|
||||
compilerOptions {
|
||||
freeCompilerArgs.addAll(
|
||||
"-Xexplicit-backing-fields",
|
||||
"-Xcontext-parameters",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
|
||||
@@ -4,7 +4,7 @@ binary-compatibility-validator = "0.18.1"
|
||||
core-ktx = "1.17.0"
|
||||
guava = "33.5.0-jre"
|
||||
jadb = "1.2.1.1"
|
||||
kotlin = "2.2.21"
|
||||
kotlin = "2.3.0"
|
||||
kotlinx-coroutines = "1.10.2"
|
||||
kotlinx-serialization = "1.9.0"
|
||||
libsu = "5.2.2"
|
||||
@@ -25,7 +25,7 @@ kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serializa
|
||||
libsu-core = { module = "com.github.topjohnwu.libsu:core", version.ref = "libsu" }
|
||||
libsu-nio = { module = "com.github.topjohnwu.libsu:nio", version.ref = "libsu" }
|
||||
libsu-service = { module = "com.github.topjohnwu.libsu:service", version.ref = "libsu" }
|
||||
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }
|
||||
revanced-patcher = { module = "app.revanced:patcher", version.ref = "revanced-patcher" }
|
||||
bouncycastle-bcpkix = { module = "org.bouncycastle:bcpkix-jdk18on", version.ref = "bouncy-castle" }
|
||||
bouncycastle-pgp = { module = "org.bouncycastle:bcpg-jdk18on", version.ref = "bouncy-castle" }
|
||||
sigstore-java = { module = "dev.sigstore:sigstore-java", version.ref = "sigstore" }
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -50,19 +50,18 @@ internal class MostCommonCompatibleVersionsTest {
|
||||
|
||||
@Test
|
||||
fun `common versions correctly ordered for each package`() {
|
||||
fun assertEqualsExpected(compatiblePackageNames: Set<String>?) =
|
||||
assertEqualsVersions(
|
||||
expected =
|
||||
mapOf(
|
||||
"some.package" to linkedMapOf("a" to 3, "b" to 2, "c" to 1),
|
||||
"some.other.package" to linkedMapOf("b" to 3, "c" to 2, "d" to 1),
|
||||
"some.other.other.package" to linkedMapOf("a" to 1, "b" to 1),
|
||||
"some.other.other.other.package" to linkedMapOf(),
|
||||
),
|
||||
patches,
|
||||
compatiblePackageNames,
|
||||
countUnusedPatches = true,
|
||||
)
|
||||
fun assertEqualsExpected(compatiblePackageNames: Set<String>?) = assertEqualsVersions(
|
||||
expected =
|
||||
mapOf(
|
||||
"some.package" to linkedMapOf("a" to 3, "b" to 2, "c" to 1),
|
||||
"some.other.package" to linkedMapOf("b" to 3, "c" to 2, "d" to 1),
|
||||
"some.other.other.package" to linkedMapOf("a" to 1, "b" to 1),
|
||||
"some.other.other.other.package" to linkedMapOf(),
|
||||
),
|
||||
patches,
|
||||
compatiblePackageNames,
|
||||
countUnusedPatches = true,
|
||||
)
|
||||
|
||||
assertEqualsExpected(
|
||||
compatiblePackageNames =
|
||||
@@ -112,7 +111,7 @@ internal class MostCommonCompatibleVersionsTest {
|
||||
|
||||
@Test
|
||||
fun `return null because no patches were supplied`() {
|
||||
assertEqualsVersion(null, emptySet<BytecodePatch>(), "some.package")
|
||||
assertEqualsVersion(null, emptySet(), "some.package")
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -135,7 +134,7 @@ internal class MostCommonCompatibleVersionsTest {
|
||||
|
||||
private fun assertEqualsVersions(
|
||||
expected: PackageNameMap,
|
||||
patches: Set<Patch<*>>,
|
||||
patches: Set<Patch>,
|
||||
compatiblePackageNames: Set<String>?,
|
||||
countUnusedPatches: Boolean = false,
|
||||
) = assertEquals(
|
||||
@@ -145,7 +144,7 @@ internal class MostCommonCompatibleVersionsTest {
|
||||
|
||||
private fun assertEqualsVersion(
|
||||
expected: String?,
|
||||
patches: Set<Patch<*>>,
|
||||
patches: Set<Patch>,
|
||||
compatiblePackageName: String,
|
||||
) {
|
||||
assertEquals(
|
||||
|
||||
Reference in New Issue
Block a user