From 223cea70213cbc8a6d01ea97475afe5683dbc195 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 9 May 2023 08:16:15 +0200 Subject: [PATCH 1/4] build: use Java SDK 17 for building --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2170654..8b20eb4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: - name: Setup JDK uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'zulu' cache: gradle - name: Setup Node.js From a2052202b23037150df6aadc47f6e91efcd481cf Mon Sep 17 00:00:00 2001 From: badawoll <129878899+badawoll@users.noreply.github.com> Date: Wed, 10 May 2023 23:37:17 +0000 Subject: [PATCH 2/4] feat!: add `classDef` parameter to `MethodFingerprint` (#175) BREAKING CHANGE: This changes the signature of the `customFingerprint` function. --- .../patcher/fingerprint/method/impl/MethodFingerprint.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt b/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt index f3803c0..72a8086 100644 --- a/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt +++ b/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt @@ -31,7 +31,7 @@ abstract class MethodFingerprint( internal val parameters: Iterable? = null, internal val opcodes: Iterable? = null, internal val strings: Iterable? = null, - internal val customFingerprint: ((methodDef: Method) -> Boolean)? = null + internal val customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null ) : Fingerprint { /** * The result of the [MethodFingerprint] the [Method]. @@ -94,7 +94,7 @@ abstract class MethodFingerprint( ) return false @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - if (methodFingerprint.customFingerprint != null && !methodFingerprint.customFingerprint!!(method)) + if (methodFingerprint.customFingerprint != null && !methodFingerprint.customFingerprint!!(method, forClass)) return false val stringsScanResult: StringsScanResult? = From 7f02b8df48907602ec9e34f2dee1f40858769d2a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 10 May 2023 23:38:38 +0000 Subject: [PATCH 3/4] chore(release): 8.0.0-dev.1 [skip ci] # [8.0.0-dev.1](https://github.com/revanced/revanced-patcher/compare/v7.1.1...v8.0.0-dev.1) (2023-05-10) * feat!: add `classDef` parameter to `MethodFingerprint` (#175) ([a205220](https://github.com/revanced/revanced-patcher/commit/a2052202b23037150df6aadc47f6e91efcd481cf)), closes [#175](https://github.com/revanced/revanced-patcher/issues/175) ### BREAKING CHANGES * This changes the signature of the `customFingerprint` function. --- CHANGELOG.md | 10 ++++++++++ gradle.properties | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 821738b..7db641b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# [8.0.0-dev.1](https://github.com/revanced/revanced-patcher/compare/v7.1.1...v8.0.0-dev.1) (2023-05-10) + + +* feat!: add `classDef` parameter to `MethodFingerprint` (#175) ([a205220](https://github.com/revanced/revanced-patcher/commit/a2052202b23037150df6aadc47f6e91efcd481cf)), closes [#175](https://github.com/revanced/revanced-patcher/issues/175) + + +### BREAKING CHANGES + +* This changes the signature of the `customFingerprint` function. + ## [7.1.1](https://github.com/revanced/revanced-patcher/compare/v7.1.0...v7.1.1) (2023-05-07) diff --git a/gradle.properties b/gradle.properties index 6bad5d5..3bec4e1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ kotlin.code.style = official -version = 7.1.1 +version = 8.0.0-dev.1 From 239ea0bcaa7eeba9976b1141081b8508a37ccc0d Mon Sep 17 00:00:00 2001 From: Jim Man <58356745+jimman2003@users.noreply.github.com> Date: Sun, 14 May 2023 02:55:26 +0300 Subject: [PATCH 4/4] refactor: simplify loading patches (#172) --- .../app/revanced/patcher/data/Context.kt | 11 --------- .../patcher/util/patch/PatchBundle.kt | 23 ++++++++----------- .../patcher/util/patch/StringIterator.kt | 10 -------- 3 files changed, 9 insertions(+), 35 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patcher/util/patch/StringIterator.kt diff --git a/src/main/kotlin/app/revanced/patcher/data/Context.kt b/src/main/kotlin/app/revanced/patcher/data/Context.kt index 3aced30..5083a42 100644 --- a/src/main/kotlin/app/revanced/patcher/data/Context.kt +++ b/src/main/kotlin/app/revanced/patcher/data/Context.kt @@ -54,17 +54,6 @@ class BytecodeContext internal constructor(classes: MutableList) : Con } return proxy } - - private companion object { - inline fun Iterable.find(predicate: (T) -> Boolean): T? { - for (element in this) { - if (predicate(element)) { - return element - } - } - return null - } - } } /** diff --git a/src/main/kotlin/app/revanced/patcher/util/patch/PatchBundle.kt b/src/main/kotlin/app/revanced/patcher/util/patch/PatchBundle.kt index f7459d9..97f165b 100644 --- a/src/main/kotlin/app/revanced/patcher/util/patch/PatchBundle.kt +++ b/src/main/kotlin/app/revanced/patcher/util/patch/PatchBundle.kt @@ -41,18 +41,13 @@ sealed class PatchBundle(path: String) : File(path) { arrayOf(this.toURI().toURL()), Thread.currentThread().contextClassLoader // TODO: find out why this is required ), - StringIterator( - JarFile(this) - .entries() - .toList() // TODO: find a cleaner solution than that to filter non class files - .filter { - it.name.endsWith(".class") && !it.name.contains("$") - } - .iterator() - ) { - it.realName.replace('/', '.').replace(".class", "") - } - ) + JarFile(this) + .stream() + .filter {it.name.endsWith(".class") && !it.name.contains("$")} + .map({it -> it.realName.replace('/', '.').replace(".class", "")}).iterator() + ) + + } /** @@ -68,8 +63,8 @@ sealed class PatchBundle(path: String) : File(path) { * Patches will be loaded to the provided [dexClassLoader]. */ fun loadPatches() = loadPatches(dexClassLoader, - StringIterator(DexFileFactory.loadDexFile(path, null).classes.iterator()) { classDef -> + DexFileFactory.loadDexFile(path, null).classes.asSequence().map({ classDef -> classDef.type.substring(1, classDef.length - 1).replace('/', '.') - }) + }).iterator()) } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/util/patch/StringIterator.kt b/src/main/kotlin/app/revanced/patcher/util/patch/StringIterator.kt deleted file mode 100644 index 26c55bd..0000000 --- a/src/main/kotlin/app/revanced/patcher/util/patch/StringIterator.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patcher.util.patch - -internal class StringIterator>( - private val iterator: I, - private val _next: (T) -> String -) : Iterator { - override fun hasNext() = iterator.hasNext() - - override fun next() = _next(iterator.next()) -} \ No newline at end of file