mirror of
https://github.com/ReVanced/revanced-library.git
synced 2026-01-12 14:26:17 +00:00
Compare commits
45 Commits
v1.0.1
...
v1.2.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d39995f48 | ||
|
|
1dc8e2e2eb | ||
|
|
6555fcdffe | ||
|
|
8b89993505 | ||
|
|
5896968358 | ||
|
|
cd73bd39ce | ||
|
|
77416b6bf4 | ||
|
|
4227a57fc7 | ||
|
|
cc3de84d25 | ||
|
|
0545341f9a | ||
|
|
035870e08d | ||
|
|
b58ea35f6a | ||
|
|
3f61394f0a | ||
|
|
9536413fa3 | ||
|
|
7b1ca25a6c | ||
|
|
79640bcb8c | ||
|
|
aea1d69157 | ||
|
|
7a6977aff2 | ||
|
|
c221ab1482 | ||
|
|
fda3eca74f | ||
|
|
d2e367e901 | ||
|
|
3e460805bc | ||
|
|
6019320d9e | ||
|
|
0dc83c3e0a | ||
|
|
dc0c9f6cc9 | ||
|
|
33f48f1f3f | ||
|
|
9de5348351 | ||
|
|
adfb41c737 | ||
|
|
5024ea3313 | ||
|
|
c61d90462f | ||
|
|
8263175a8e | ||
|
|
17694e2d8a | ||
|
|
e232577e33 | ||
|
|
771c9d7165 | ||
|
|
13823b74db | ||
|
|
fbe5c39227 | ||
|
|
c6e85466ed | ||
|
|
2ec24dbb70 | ||
|
|
9fd895cb56 | ||
|
|
c3f297b65d | ||
|
|
ef38d8b4bf | ||
|
|
59ab008030 | ||
|
|
892e0835c6 | ||
|
|
fc61954e5d | ||
|
|
5993f7e568 |
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# Make sure the release step uses its own credentials:
|
||||
# https://github.com/cycjimmy/semantic-release-action#private-packages
|
||||
|
||||
2
.github/workflows/pull_request.yml
vendored
2
.github/workflows/pull_request.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Open pull request
|
||||
uses: repo-sync/pull-request@v2
|
||||
with:
|
||||
|
||||
103
CHANGELOG.md
103
CHANGELOG.md
@@ -1,3 +1,106 @@
|
||||
# [1.2.0-dev.2](https://github.com/ReVanced/revanced-library/compare/v1.2.0-dev.1...v1.2.0-dev.2) (2023-11-03)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Log warnings when compiling resources ([1dc8e2e](https://github.com/ReVanced/revanced-library/commit/1dc8e2e2eb76bcade9167be0c4b4a628ff114f63))
|
||||
|
||||
# [1.2.0-dev.1](https://github.com/ReVanced/revanced-library/compare/v1.1.5...v1.2.0-dev.1) (2023-10-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Catch exceptions when serializing invalid patch options ([cd73bd3](https://github.com/ReVanced/revanced-library/commit/cd73bd39ce7be5963a3c84ec43409b87c327579b))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Use better log messages when handling exceptions ([5896968](https://github.com/ReVanced/revanced-library/commit/58969683582e70f36d6ed169b41c37928a2cf602))
|
||||
|
||||
## [1.1.5](https://github.com/ReVanced/revanced-library/compare/v1.1.4...v1.1.5) (2023-10-23)
|
||||
|
||||
## [1.1.5-dev.1](https://github.com/ReVanced/revanced-library/compare/v1.1.4...v1.1.5-dev.1) (2023-10-23)
|
||||
|
||||
## [1.1.4](https://github.com/ReVanced/revanced-library/compare/v1.1.3...v1.1.4) (2023-10-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Ask for root permissions before trying to use them ([aea1d69](https://github.com/ReVanced/revanced-library/commit/aea1d6915766d9757075ee459955aa335d906bab))
|
||||
* Execute ADB commands sequentially to fix mounting issues ([#12](https://github.com/ReVanced/revanced-library/issues/12)) ([fda3eca](https://github.com/ReVanced/revanced-library/commit/fda3eca74f30b968d8ee816d63a3dcf493e026de))
|
||||
|
||||
## [1.1.4-dev.2](https://github.com/ReVanced/revanced-library/compare/v1.1.4-dev.1...v1.1.4-dev.2) (2023-10-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Ask for root permissions before trying to use them ([aea1d69](https://github.com/ReVanced/revanced-library/commit/aea1d6915766d9757075ee459955aa335d906bab))
|
||||
|
||||
## [1.1.4-dev.1](https://github.com/ReVanced/revanced-library/compare/v1.1.3...v1.1.4-dev.1) (2023-10-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Execute ADB commands sequentially to fix mounting issues ([#12](https://github.com/ReVanced/revanced-library/issues/12)) ([fda3eca](https://github.com/ReVanced/revanced-library/commit/fda3eca74f30b968d8ee816d63a3dcf493e026de))
|
||||
|
||||
## [1.1.3](https://github.com/ReVanced/revanced-library/compare/v1.1.2...v1.1.3) (2023-10-09)
|
||||
|
||||
## [1.1.3-dev.2](https://github.com/ReVanced/revanced-library/compare/v1.1.3-dev.1...v1.1.3-dev.2) (2023-10-09)
|
||||
|
||||
## [1.1.3-dev.1](https://github.com/ReVanced/revanced-library/compare/v1.1.2...v1.1.3-dev.1) (2023-10-09)
|
||||
|
||||
## [1.1.2](https://github.com/ReVanced/revanced-library/compare/v1.1.1...v1.1.2) (2023-10-05)
|
||||
|
||||
## [1.1.2-dev.1](https://github.com/ReVanced/revanced-library/compare/v1.1.1...v1.1.2-dev.1) (2023-10-05)
|
||||
|
||||
## [1.1.1](https://github.com/ReVanced/revanced-library/compare/v1.1.0...v1.1.1) (2023-10-04)
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* Use maps to set options ([13823b7](https://github.com/ReVanced/revanced-library/commit/13823b74db1de3a104b5022b6bf0db0ef945f47b))
|
||||
|
||||
## [1.1.1-dev.1](https://github.com/ReVanced/revanced-library/compare/v1.1.0...v1.1.1-dev.1) (2023-10-04)
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* Use maps to set options ([13823b7](https://github.com/ReVanced/revanced-library/commit/13823b74db1de3a104b5022b6bf0db0ef945f47b))
|
||||
|
||||
# [1.1.0](https://github.com/ReVanced/revanced-library/compare/v1.0.1...v1.1.0) (2023-10-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Only load the keystore once per instantiation ([5993f7e](https://github.com/ReVanced/revanced-library/commit/5993f7e568543c777bee51a140c34fa8953a178a))
|
||||
* Use correct function name casing ([ef38d8b](https://github.com/ReVanced/revanced-library/commit/ef38d8b4bfe3a79c25fb40588c6217c09574770f))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Increase the key size to 4096 ([892e083](https://github.com/ReVanced/revanced-library/commit/892e0835c6b2da0836bd6ba1d8603db1848cc2d9))
|
||||
|
||||
# [1.1.0-dev.2](https://github.com/ReVanced/revanced-library/compare/v1.1.0-dev.1...v1.1.0-dev.2) (2023-09-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Use correct function name casing ([ef38d8b](https://github.com/ReVanced/revanced-library/commit/ef38d8b4bfe3a79c25fb40588c6217c09574770f))
|
||||
|
||||
# [1.1.0-dev.1](https://github.com/ReVanced/revanced-library/compare/v1.0.2-dev.1...v1.1.0-dev.1) (2023-09-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Increase the key size to 4096 ([892e083](https://github.com/ReVanced/revanced-library/commit/892e0835c6b2da0836bd6ba1d8603db1848cc2d9))
|
||||
|
||||
## [1.0.2-dev.1](https://github.com/ReVanced/revanced-library/compare/v1.0.1...v1.0.2-dev.1) (2023-09-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Only load the keystore once per instantiation ([5993f7e](https://github.com/ReVanced/revanced-library/commit/5993f7e568543c777bee51a140c34fa8953a178a))
|
||||
|
||||
## [1.0.1](https://github.com/ReVanced/revanced-library/compare/v1.0.0...v1.0.1) (2023-09-24)
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ public final class app/revanced/library/ApkSigner {
|
||||
public static final field INSTANCE Lapp/revanced/library/ApkSigner;
|
||||
public final fun newApkSignerBuilder (Lapp/revanced/library/ApkSigner$PrivateKeyCertificatePair;Ljava/lang/String;Ljava/lang/String;)Lcom/android/apksig/ApkSigner$Builder;
|
||||
public final fun newApkSignerBuilder (Ljava/security/KeyStore;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/android/apksig/ApkSigner$Builder;
|
||||
public final fun newKeyStore (Ljava/io/OutputStream;Ljava/lang/String;Ljava/util/List;)V
|
||||
public final fun newKeyStore (Ljava/util/List;)Ljava/security/KeyStore;
|
||||
public final fun newKeystore (Ljava/io/OutputStream;Ljava/lang/String;Ljava/util/List;)V
|
||||
public final fun newPrivateKeyCertificatePair (Ljava/lang/String;Ljava/util/Date;)Lapp/revanced/library/ApkSigner$PrivateKeyCertificatePair;
|
||||
public static synthetic fun newPrivateKeyCertificatePair$default (Lapp/revanced/library/ApkSigner;Ljava/lang/String;Ljava/util/Date;ILjava/lang/Object;)Lapp/revanced/library/ApkSigner$PrivateKeyCertificatePair;
|
||||
public final fun readKeyCertificatePair (Ljava/security/KeyStore;Ljava/lang/String;Ljava/lang/String;)Lapp/revanced/library/ApkSigner$PrivateKeyCertificatePair;
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
plugins {
|
||||
kotlin("jvm") version "1.9.0"
|
||||
kotlin("jvm") version "1.9.10"
|
||||
alias(libs.plugins.binary.compatibility.validator)
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
group = "app.revanced"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven { url = uri("https://jitpack.io") }
|
||||
google()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.revanced.patcher)
|
||||
implementation(libs.kotlin.reflect)
|
||||
@@ -34,17 +41,6 @@ java {
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = "GitHubPackages"
|
||||
url = uri("https://maven.pkg.github.com/revanced/revanced-library")
|
||||
credentials {
|
||||
username = System.getenv("GITHUB_ACTOR")
|
||||
password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
}
|
||||
}
|
||||
publications {
|
||||
create<MavenPublication>("gpr") {
|
||||
from(components["java"])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
org.gradle.parallel = true
|
||||
org.gradle.caching = true
|
||||
kotlin.code.style = official
|
||||
version = 1.0.1
|
||||
version = 1.2.0-dev.2
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
[versions]
|
||||
apksig = "8.1.1"
|
||||
apksig = "8.1.2"
|
||||
bcpkix-jdk18on = "1.76"
|
||||
jackson-module-kotlin = "2.14.3"
|
||||
jadb = "2531a28109"
|
||||
kotlin-reflect = "1.9.0"
|
||||
jadb = "1.2.1"
|
||||
kotlin-reflect = "1.9.10"
|
||||
kotlin-test = "1.8.20-RC"
|
||||
revanced-patcher = "15.0.1"
|
||||
revanced-patcher = "19.0.0"
|
||||
binary-compatibility-validator = "0.13.2"
|
||||
|
||||
[libraries]
|
||||
apksig = { module = "com.android.tools.build:apksig", version.ref = "apksig" }
|
||||
bcpkix-jdk18on = { module = "org.bouncycastle:bcpkix-jdk18on", version.ref = "bcpkix-jdk18on" }
|
||||
jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson-module-kotlin" }
|
||||
jadb = { module = "com.github.revanced:jadb", version.ref = "jadb" }
|
||||
jadb = { module = "app.revanced:jadb", version.ref = "jadb" }
|
||||
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin-reflect" }
|
||||
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin-test" }
|
||||
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }
|
||||
|
||||
@@ -1,23 +1 @@
|
||||
val githubUsername: String = providers.gradleProperty("gpr.user").orNull ?: System.getenv("GITHUB_ACTOR")
|
||||
val githubPassword: String = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GITHUB_TOKEN")
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
google()
|
||||
maven { url = uri("https://jitpack.io") }
|
||||
listOf("revanced-patcher", "jadb").forEach { repo ->
|
||||
maven {
|
||||
url = uri("https://maven.pkg.github.com/revanced/$repo")
|
||||
credentials {
|
||||
username = githubUsername
|
||||
password = githubPassword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "revanced-library"
|
||||
@@ -45,7 +45,7 @@ object ApkSigner {
|
||||
|
||||
// Generate a new key pair.
|
||||
val keyPair = KeyPairGenerator.getInstance("RSA").apply {
|
||||
initialize(2048)
|
||||
initialize(4096)
|
||||
}.generateKeyPair()
|
||||
|
||||
var serialNumber: BigInteger
|
||||
@@ -116,8 +116,9 @@ object ApkSigner {
|
||||
logger.fine("Creating keystore")
|
||||
|
||||
return KeyStore.getInstance("BKS", BouncyCastleProvider.PROVIDER_NAME).apply {
|
||||
load(null)
|
||||
|
||||
entries.forEach { entry ->
|
||||
load(null)
|
||||
// Add all entries to the keystore.
|
||||
setKeyEntry(
|
||||
entry.alias,
|
||||
@@ -136,7 +137,7 @@ object ApkSigner {
|
||||
* @param keyStorePassword The password for the keystore.
|
||||
* @param entries The entries to add to the keystore.
|
||||
*/
|
||||
fun newKeystore(
|
||||
fun newKeyStore(
|
||||
keyStoreOutputStream: OutputStream,
|
||||
keyStorePassword: String,
|
||||
entries: List<KeyStoreEntry>
|
||||
|
||||
@@ -30,7 +30,16 @@ object Options {
|
||||
.map { patch ->
|
||||
Patch(
|
||||
patch.name!!,
|
||||
patch.options.values.map { option -> Option(option.key, option.value) }
|
||||
patch.options.values.map { option ->
|
||||
val optionValue = try {
|
||||
option.value
|
||||
} catch (e: PatchOptionException) {
|
||||
logger.warning("Using default option value for the ${patch.name} patch: ${e.message}")
|
||||
option.default
|
||||
}
|
||||
|
||||
Option(option.key, optionValue)
|
||||
}
|
||||
)
|
||||
}
|
||||
// See https://github.com/revanced/revanced-patches/pull/2434/commits/60e550550b7641705e81aa72acfc4faaebb225e7.
|
||||
@@ -61,15 +70,17 @@ object Options {
|
||||
filter { it.options.any() }.let { patches ->
|
||||
if (patches.isEmpty()) return
|
||||
|
||||
val patchOptions = deserialize(json)
|
||||
val jsonPatches = deserialize(json).associate {
|
||||
it.patchName to it.options.associate { option -> option.key to option.value }
|
||||
}
|
||||
|
||||
patches.forEach patch@{ patch ->
|
||||
patchOptions.find { option -> option.patchName == patch.name!! }?.let {
|
||||
it.options.forEach { option ->
|
||||
patches.forEach { patch ->
|
||||
jsonPatches[patch.name]?.let { jsonPatchOptions ->
|
||||
jsonPatchOptions.forEach { (option, value) ->
|
||||
try {
|
||||
patch.options[option.key] = option.value
|
||||
patch.options[option] = value
|
||||
} catch (e: PatchOptionException) {
|
||||
logger.severe(e.toString())
|
||||
logger.warning("Could not set option value for the ${patch.name} patch: ${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,14 +84,14 @@ sealed class AdbManager private constructor(deviceSerial: String? = null) {
|
||||
|
||||
device.push(apk.file, TMP_PATH)
|
||||
|
||||
device.run("$CREATE_DIR $INSTALLATION_PATH")
|
||||
device.run(INSTALL_PATCHED_APK, packageName)
|
||||
device.run("$CREATE_DIR $INSTALLATION_PATH").waitFor()
|
||||
device.run(INSTALL_PATCHED_APK, packageName).waitFor()
|
||||
|
||||
device.createFile(TMP_PATH, MOUNT_SCRIPT.applyReplacement(packageName))
|
||||
|
||||
device.run(INSTALL_MOUNT, packageName)
|
||||
device.run(UMOUNT, packageName) // Sanity check.
|
||||
device.run(MOUNT_PATH, packageName)
|
||||
device.run(INSTALL_MOUNT, packageName).waitFor()
|
||||
device.run(UMOUNT, packageName).waitFor() // Sanity check.
|
||||
device.run(MOUNT_PATH, packageName).waitFor()
|
||||
device.run(RESTART, packageName)
|
||||
device.run(DELETE, TMP_PATH)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package app.revanced.library.adb
|
||||
|
||||
import se.vidstige.jadb.JadbDevice
|
||||
import se.vidstige.jadb.RemoteFile
|
||||
import se.vidstige.jadb.ShellProcess
|
||||
import se.vidstige.jadb.ShellProcessBuilder
|
||||
import java.io.File
|
||||
|
||||
@@ -16,19 +15,14 @@ internal fun JadbDevice.buildCommand(command: String, su: Boolean = true): Shell
|
||||
return shellProcessBuilder(cmd, *args.toTypedArray())
|
||||
}
|
||||
|
||||
internal fun JadbDevice.run(command: String, su: Boolean = true): ShellProcess {
|
||||
return this.buildCommand(command, su).start()!!
|
||||
}
|
||||
internal fun JadbDevice.run(command: String, su: Boolean = true) =
|
||||
this.buildCommand(command, su).start()
|
||||
|
||||
internal fun JadbDevice.hasSu() =
|
||||
this.startCommand("su -h", false).waitFor() == 0
|
||||
this.run("whoami", true).waitFor() == 0
|
||||
|
||||
internal fun JadbDevice.push(file: File, targetFilePath: String) =
|
||||
push(file, RemoteFile(targetFilePath))
|
||||
|
||||
internal fun JadbDevice.createFile(targetFile: String, content: String) =
|
||||
push(content.byteInputStream(), System.currentTimeMillis(), 644, RemoteFile(targetFile))
|
||||
|
||||
|
||||
private fun JadbDevice.startCommand(command: String, su: Boolean) =
|
||||
shellProcessBuilder(if (su) "su -c '$command'" else command).start()
|
||||
push(content.byteInputStream(), System.currentTimeMillis(), 644, RemoteFile(targetFile))
|
||||
@@ -7,6 +7,14 @@ import java.util.logging.SimpleFormatter
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
object Logger {
|
||||
/**
|
||||
* Rules for allowed loggers.
|
||||
*/
|
||||
private val allowedLoggersRules = arrayOf<String.() -> Boolean>(
|
||||
{ startsWith("app.revanced") }, // ReVanced loggers.
|
||||
{ this == "" } // Logs warnings when compiling resources (Logger in class brut.util.OS).
|
||||
)
|
||||
|
||||
private val rootLogger = java.util.logging.Logger.getLogger("")
|
||||
|
||||
/**
|
||||
@@ -64,7 +72,9 @@ object Logger {
|
||||
removeAllHandlers()
|
||||
|
||||
val publishHandler = handler@{ log: String, level: Level, loggerName: String? ->
|
||||
if (loggerName?.startsWith("app.revanced") != true) return@handler
|
||||
loggerName?.let { name ->
|
||||
if (allowedLoggersRules.none { it(name) }) return@handler
|
||||
}
|
||||
|
||||
log.toByteArray().let {
|
||||
if (level.intValue() > Level.WARNING.intValue())
|
||||
|
||||
@@ -3,8 +3,9 @@ package app.revanced.library
|
||||
import app.revanced.library.Options.setOptions
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.options.types.BooleanPatchOption.Companion.booleanPatchOption
|
||||
import app.revanced.patcher.patch.options.types.StringPatchOption.Companion.stringPatchOption
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.booleanPatchOption
|
||||
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption
|
||||
import org.junit.jupiter.api.MethodOrderer
|
||||
import org.junit.jupiter.api.Order
|
||||
import org.junit.jupiter.api.Test
|
||||
@@ -35,9 +36,10 @@ internal object PatchOptionsTest {
|
||||
private const val CHANGED_JSON =
|
||||
"[{\"patchName\":\"PatchOptionsTestPatch\",\"options\":[{\"key\":\"key1\",\"value\":\"test\"},{\"key\":\"key2\",\"value\":false}]}]"
|
||||
|
||||
object PatchOptionsTestPatch : BytecodePatch(name = "PatchOptionsTestPatch") {
|
||||
var option1 by stringPatchOption("key1", null, "title1", "description1")
|
||||
var option2 by booleanPatchOption("key2", true, "title2", "description2")
|
||||
@Patch("PatchOptionsTestPatch")
|
||||
object PatchOptionsTestPatch : BytecodePatch() {
|
||||
var option1 by stringPatchOption("key1", null, null, "title1", "description1")
|
||||
var option2 by booleanPatchOption("key2", true, null, "title2", "description2")
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
// Do nothing
|
||||
|
||||
@@ -3,6 +3,7 @@ package app.revanced.library
|
||||
import app.revanced.patcher.PatchSet
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -42,9 +43,16 @@ internal object PatchUtilsTest {
|
||||
expected: String?, patches: PatchSet, compatiblePackageName: String
|
||||
) = assertEquals(expected, PatchUtils.getMostCommonCompatibleVersion(patches, compatiblePackageName))
|
||||
|
||||
private fun newPatch(packageName: String, vararg versions: String) = object : BytecodePatch(
|
||||
compatiblePackages = setOf(CompatiblePackage(packageName, versions.toSet()))
|
||||
) {
|
||||
private fun newPatch(packageName: String, vararg versions: String) = object : BytecodePatch() {
|
||||
init {
|
||||
// Set the compatible packages field to the supplied package name and versions reflectively,
|
||||
// because the setter is private but needed for testing.
|
||||
val compatiblePackagesField = Patch::class.java.getDeclaredField("compatiblePackages")
|
||||
|
||||
compatiblePackagesField.isAccessible = true
|
||||
compatiblePackagesField.set(this, setOf(CompatiblePackage(packageName, versions.toSet())))
|
||||
}
|
||||
|
||||
override fun execute(context: BytecodeContext) {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user