mirror of
https://github.com/ReVanced/revanced-library.git
synced 2026-01-18 08:53:57 +00:00
Compare commits
9 Commits
v1.1.5-dev
...
v1.2.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d39995f48 | ||
|
|
1dc8e2e2eb | ||
|
|
6555fcdffe | ||
|
|
8b89993505 | ||
|
|
5896968358 | ||
|
|
cd73bd39ce | ||
|
|
77416b6bf4 | ||
|
|
4227a57fc7 | ||
|
|
cc3de84d25 |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,3 +1,24 @@
|
|||||||
|
# [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.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)
|
## [1.1.4](https://github.com/ReVanced/revanced-library/compare/v1.1.3...v1.1.4) (2023-10-12)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
org.gradle.parallel = true
|
org.gradle.parallel = true
|
||||||
org.gradle.caching = true
|
org.gradle.caching = true
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 1.1.5-dev.1
|
version = 1.2.0-dev.2
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ apksig = "8.1.2"
|
|||||||
bcpkix-jdk18on = "1.76"
|
bcpkix-jdk18on = "1.76"
|
||||||
jackson-module-kotlin = "2.14.3"
|
jackson-module-kotlin = "2.14.3"
|
||||||
jadb = "1.2.1"
|
jadb = "1.2.1"
|
||||||
kotlin-reflect = "1.9.0"
|
kotlin-reflect = "1.9.10"
|
||||||
kotlin-test = "1.8.20-RC"
|
kotlin-test = "1.8.20-RC"
|
||||||
revanced-patcher = "18.0.0"
|
revanced-patcher = "19.0.0"
|
||||||
binary-compatibility-validator = "0.13.2"
|
binary-compatibility-validator = "0.13.2"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
|||||||
@@ -30,7 +30,16 @@ object Options {
|
|||||||
.map { patch ->
|
.map { patch ->
|
||||||
Patch(
|
Patch(
|
||||||
patch.name!!,
|
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.
|
// See https://github.com/revanced/revanced-patches/pull/2434/commits/60e550550b7641705e81aa72acfc4faaebb225e7.
|
||||||
@@ -71,7 +80,7 @@ object Options {
|
|||||||
try {
|
try {
|
||||||
patch.options[option] = value
|
patch.options[option] = value
|
||||||
} catch (e: PatchOptionException) {
|
} catch (e: PatchOptionException) {
|
||||||
logger.severe(e.toString())
|
logger.warning("Could not set option value for the ${patch.name} patch: ${e.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ import java.util.logging.SimpleFormatter
|
|||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
object Logger {
|
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("")
|
private val rootLogger = java.util.logging.Logger.getLogger("")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,7 +72,9 @@ object Logger {
|
|||||||
removeAllHandlers()
|
removeAllHandlers()
|
||||||
|
|
||||||
val publishHandler = handler@{ log: String, level: Level, loggerName: String? ->
|
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 {
|
log.toByteArray().let {
|
||||||
if (level.intValue() > Level.WARNING.intValue())
|
if (level.intValue() > Level.WARNING.intValue())
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package app.revanced.library
|
|||||||
import app.revanced.library.Options.setOptions
|
import app.revanced.library.Options.setOptions
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.options.types.BooleanPatchOption.Companion.booleanPatchOption
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patcher.patch.options.types.StringPatchOption.Companion.stringPatchOption
|
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.MethodOrderer
|
||||||
import org.junit.jupiter.api.Order
|
import org.junit.jupiter.api.Order
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
@@ -35,9 +36,10 @@ internal object PatchOptionsTest {
|
|||||||
private const val CHANGED_JSON =
|
private const val CHANGED_JSON =
|
||||||
"[{\"patchName\":\"PatchOptionsTestPatch\",\"options\":[{\"key\":\"key1\",\"value\":\"test\"},{\"key\":\"key2\",\"value\":false}]}]"
|
"[{\"patchName\":\"PatchOptionsTestPatch\",\"options\":[{\"key\":\"key1\",\"value\":\"test\"},{\"key\":\"key2\",\"value\":false}]}]"
|
||||||
|
|
||||||
object PatchOptionsTestPatch : BytecodePatch(name = "PatchOptionsTestPatch") {
|
@Patch("PatchOptionsTestPatch")
|
||||||
var option1 by stringPatchOption("key1", null, "title1", "description1")
|
object PatchOptionsTestPatch : BytecodePatch() {
|
||||||
var option2 by booleanPatchOption("key2", true, "title2", "description2")
|
var option1 by stringPatchOption("key1", null, null, "title1", "description1")
|
||||||
|
var option2 by booleanPatchOption("key2", true, null, "title2", "description2")
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package app.revanced.library
|
|||||||
import app.revanced.patcher.PatchSet
|
import app.revanced.patcher.PatchSet
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.Patch
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
@@ -42,9 +43,16 @@ internal object PatchUtilsTest {
|
|||||||
expected: String?, patches: PatchSet, compatiblePackageName: String
|
expected: String?, patches: PatchSet, compatiblePackageName: String
|
||||||
) = assertEquals(expected, PatchUtils.getMostCommonCompatibleVersion(patches, compatiblePackageName))
|
) = assertEquals(expected, PatchUtils.getMostCommonCompatibleVersion(patches, compatiblePackageName))
|
||||||
|
|
||||||
private fun newPatch(packageName: String, vararg versions: String) = object : BytecodePatch(
|
private fun newPatch(packageName: String, vararg versions: String) = object : BytecodePatch() {
|
||||||
compatiblePackages = setOf(CompatiblePackage(packageName, versions.toSet()))
|
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) {}
|
override fun execute(context: BytecodeContext) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user