1
mirror of https://github.com/revanced/revanced-patcher synced 2025-09-10 05:30:49 +02:00

Compare commits

...

24 Commits

Author SHA1 Message Date
semantic-release-bot
68db95b99b chore: Release v21.1.0-dev.3 [skip ci]
# [21.1.0-dev.3](https://github.com/ReVanced/revanced-patcher/compare/v21.1.0-dev.2...v21.1.0-dev.3) (2025-06-20)

### Bug Fixes

* Encode XML files as UTF-8 to fix compilation of resources ([#339](https://github.com/ReVanced/revanced-patcher/issues/339)) ([4f2ef3c](4f2ef3c47c))
2025-06-20 14:44:18 +00:00
Pg
4f2ef3c47c fix: Encode XML files as UTF-8 to fix compilation of resources (#339)
Co-authored-by: kitadai31 <90122968+kitadai31@users.noreply.github.com>
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2025-06-20 16:41:53 +02:00
semantic-release-bot
062ae14936 chore: Release v21.1.0-dev.2 [skip ci]
# [21.1.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v21.1.0-dev.1...v21.1.0-dev.2) (2025-06-20)

### Bug Fixes

* Add back missing log by naming logger correctly ([#332](https://github.com/ReVanced/revanced-patcher/issues/332)) ([e4e66b0](e4e66b0d8b))
* Support UTF-8 chars when compiling instructions in Smali in non UTF-8 environments ([#331](https://github.com/ReVanced/revanced-patcher/issues/331)) ([bb8771b](bb8771bb8b))

### Features

* Use option name as key for simplicity and consistency ([754b02e](754b02e4ca))

### Performance Improvements

* Use a buffered writer to reduce IO overhead ([#347](https://github.com/ReVanced/revanced-patcher/issues/347)) ([99f4318](99f431897e))
2025-06-20 13:28:31 +00:00
Pg
99f431897e perf: Use a buffered writer to reduce IO overhead (#347) 2025-06-20 15:26:10 +02:00
oSumAtrIX
d80abbcd17 docs: Correct API usage of fingerprints 2025-03-10 13:52:09 +01:00
oSumAtrIX
509ecc81e1 docs: Correct API usage of fingerprints 2025-03-10 13:47:55 +01:00
kitadai31
e4e66b0d8b fix: Add back missing log by naming logger correctly (#332) 2025-01-20 00:40:26 +01:00
Vologhat
bb8771bb8b fix: Support UTF-8 chars when compiling instructions in Smali in non UTF-8 environments (#331) 2025-01-07 01:30:21 +01:00
oSumAtrIX
754b02e4ca feat: Use option name as key for simplicity and consistency 2024-12-24 16:47:48 +01:00
oSumAtrIX
fe5fb736cb build: Bump dependencies 2024-12-17 04:20:28 +01:00
semantic-release-bot
fc505a8726 chore: Release v21.1.0-dev.1 [skip ci]
# [21.1.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v21.0.0...v21.1.0-dev.1) (2024-12-07)

### Features

* Add identity hash code to unnamed patches ([88a3252](88a3252574))
2024-12-07 05:20:15 +00:00
oSumAtrIX
88a3252574 feat: Add identity hash code to unnamed patches 2024-12-07 06:19:08 +01:00
semantic-release-bot
ead701bdaf chore: Release v21.0.0 [skip ci]
# [21.0.0](https://github.com/ReVanced/revanced-patcher/compare/v20.0.2...v21.0.0) (2024-11-05)

### Bug Fixes

* Match fingerprint before delegating the match property ([5d996de](5d996def4d))
* Merge extension only when patch executes ([#315](https://github.com/ReVanced/revanced-patcher/issues/315)) ([aa472eb](aa472eb985))

### Features

* Improve Fingerprint API ([#316](https://github.com/ReVanced/revanced-patcher/issues/316)) ([0abf1c6](0abf1c6c02))
* Improve various APIs  ([#317](https://github.com/ReVanced/revanced-patcher/issues/317)) ([b824978](b8249789df))
* Move fingerprint match members to fingerprint for ease of access by using context receivers ([0746c22](0746c22743))

### Performance Improvements

* Use smallest lookup map for strings ([1358d3f](1358d3fa10))

### BREAKING CHANGES

* Various APIs have been changed.
* Many APIs have been changed.
2024-11-05 18:18:41 +00:00
oSumAtrIX
0581dcf931 chore: Merge branch dev to main 2024-11-05 19:16:28 +01:00
semantic-release-bot
62191e3c4a chore: Release v21.0.0-dev.4 [skip ci]
# [21.0.0-dev.4](https://github.com/ReVanced/revanced-patcher/compare/v21.0.0-dev.3...v21.0.0-dev.4) (2024-11-05)

### Performance Improvements

* Use smallest lookup map for strings ([1358d3f](1358d3fa10))
2024-11-05 13:41:06 +00:00
oSumAtrIX
1358d3fa10 perf: Use smallest lookup map for strings 2024-11-05 14:39:18 +01:00
semantic-release-bot
6712f0ea72 chore: Release v21.0.0-dev.3 [skip ci]
# [21.0.0-dev.3](https://github.com/ReVanced/revanced-patcher/compare/v21.0.0-dev.2...v21.0.0-dev.3) (2024-11-05)

### Features

* Move fingerprint match members to fingerprint for ease of access by using context receivers ([0746c22](0746c22743))
2024-11-05 13:25:22 +00:00
oSumAtrIX
0746c22743 feat: Move fingerprint match members to fingerprint for ease of access by using context receivers 2024-11-05 14:23:19 +01:00
semantic-release-bot
7f55868e6f chore: Release v21.0.0-dev.2 [skip ci]
# [21.0.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v21.0.0-dev.1...v21.0.0-dev.2) (2024-11-01)

### Bug Fixes

* Match fingerprint before delegating the match property ([5d996de](5d996def4d))
2024-11-01 01:49:47 +00:00
oSumAtrIX
5d996def4d fix: Match fingerprint before delegating the match property 2024-11-01 02:47:57 +01:00
semantic-release-bot
49f4570164 chore: Release v21.0.0-dev.1 [skip ci]
# [21.0.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v20.0.2...v21.0.0-dev.1) (2024-10-27)

### Bug Fixes

* Merge extension only when patch executes ([#315](https://github.com/ReVanced/revanced-patcher/issues/315)) ([aa472eb](aa472eb985))

### Features

* Improve Fingerprint API ([#316](https://github.com/ReVanced/revanced-patcher/issues/316)) ([0abf1c6](0abf1c6c02))
* Improve various APIs  ([#317](https://github.com/ReVanced/revanced-patcher/issues/317)) ([b824978](b8249789df))

### BREAKING CHANGES

* Various APIs have been changed.
* Many APIs have been changed.
2024-10-27 15:08:13 +00:00
oSumAtrIX
b8249789df feat: Improve various APIs (#317)
Some APIs have been slightly changed, and API docs have been added.

BREAKING CHANGE: Various APIs have been changed.
2024-10-27 16:06:25 +01:00
oSumAtrIX
0abf1c6c02 feat: Improve Fingerprint API (#316)
Fingerprints can now be matched easily without adding them to a patch first.

BREAKING CHANGE: Many APIs have been changed.
2024-10-27 16:04:30 +01:00
oSumAtrIX
aa472eb985 fix: Merge extension only when patch executes (#315) 2024-10-27 16:00:30 +01:00
25 changed files with 933 additions and 577 deletions

View File

@@ -1,3 +1,101 @@
# [21.1.0-dev.3](https://github.com/ReVanced/revanced-patcher/compare/v21.1.0-dev.2...v21.1.0-dev.3) (2025-06-20)
### Bug Fixes
* Encode XML files as UTF-8 to fix compilation of resources ([#339](https://github.com/ReVanced/revanced-patcher/issues/339)) ([4f2ef3c](https://github.com/ReVanced/revanced-patcher/commit/4f2ef3c47cea76a26c464cfb45d4bb57fe7198b5))
# [21.1.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v21.1.0-dev.1...v21.1.0-dev.2) (2025-06-20)
### Bug Fixes
* Add back missing log by naming logger correctly ([#332](https://github.com/ReVanced/revanced-patcher/issues/332)) ([e4e66b0](https://github.com/ReVanced/revanced-patcher/commit/e4e66b0d8bb0986b79fb150b9c15da35b8e11561))
* Support UTF-8 chars when compiling instructions in Smali in non UTF-8 environments ([#331](https://github.com/ReVanced/revanced-patcher/issues/331)) ([bb8771b](https://github.com/ReVanced/revanced-patcher/commit/bb8771bb8b8ab1724d957e56f4de88c02684d87b))
### Features
* Use option name as key for simplicity and consistency ([754b02e](https://github.com/ReVanced/revanced-patcher/commit/754b02e4ca66ec10764d5205c6643f2d86d0c6a2))
### Performance Improvements
* Use a buffered writer to reduce IO overhead ([#347](https://github.com/ReVanced/revanced-patcher/issues/347)) ([99f4318](https://github.com/ReVanced/revanced-patcher/commit/99f431897eb9e607987fd5d09b879d7eda442f3e))
# [21.1.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v21.0.0...v21.1.0-dev.1) (2024-12-07)
### Features
* Add identity hash code to unnamed patches ([88a3252](https://github.com/ReVanced/revanced-patcher/commit/88a325257494939a79fb30dd51d60c5c52546755))
# [21.0.0](https://github.com/ReVanced/revanced-patcher/compare/v20.0.2...v21.0.0) (2024-11-05)
### Bug Fixes
* Match fingerprint before delegating the match property ([5d996de](https://github.com/ReVanced/revanced-patcher/commit/5d996def4d3de4e2bfc34562e5a6c7d89a8cddf0))
* Merge extension only when patch executes ([#315](https://github.com/ReVanced/revanced-patcher/issues/315)) ([aa472eb](https://github.com/ReVanced/revanced-patcher/commit/aa472eb9857145b53b49f843406a9764fbb7e5ce))
### Features
* Improve Fingerprint API ([#316](https://github.com/ReVanced/revanced-patcher/issues/316)) ([0abf1c6](https://github.com/ReVanced/revanced-patcher/commit/0abf1c6c0279708fdef5cb66b141d07d17682693))
* Improve various APIs ([#317](https://github.com/ReVanced/revanced-patcher/issues/317)) ([b824978](https://github.com/ReVanced/revanced-patcher/commit/b8249789df8b90129f7b7ad0e523a8d0ceaab848))
* Move fingerprint match members to fingerprint for ease of access by using context receivers ([0746c22](https://github.com/ReVanced/revanced-patcher/commit/0746c22743a9561bae2284d234b151f2f8511ca5))
### Performance Improvements
* Use smallest lookup map for strings ([1358d3f](https://github.com/ReVanced/revanced-patcher/commit/1358d3fa10cb8ba011b6b89cfe3684ecf9849d2f))
### BREAKING CHANGES
* Various APIs have been changed.
* Many APIs have been changed.
# [21.0.0-dev.4](https://github.com/ReVanced/revanced-patcher/compare/v21.0.0-dev.3...v21.0.0-dev.4) (2024-11-05)
### Performance Improvements
* Use smallest lookup map for strings ([1358d3f](https://github.com/ReVanced/revanced-patcher/commit/1358d3fa10cb8ba011b6b89cfe3684ecf9849d2f))
# [21.0.0-dev.3](https://github.com/ReVanced/revanced-patcher/compare/v21.0.0-dev.2...v21.0.0-dev.3) (2024-11-05)
### Features
* Move fingerprint match members to fingerprint for ease of access by using context receivers ([0746c22](https://github.com/ReVanced/revanced-patcher/commit/0746c22743a9561bae2284d234b151f2f8511ca5))
# [21.0.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v21.0.0-dev.1...v21.0.0-dev.2) (2024-11-01)
### Bug Fixes
* Match fingerprint before delegating the match property ([5d996de](https://github.com/ReVanced/revanced-patcher/commit/5d996def4d3de4e2bfc34562e5a6c7d89a8cddf0))
# [21.0.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v20.0.2...v21.0.0-dev.1) (2024-10-27)
### Bug Fixes
* Merge extension only when patch executes ([#315](https://github.com/ReVanced/revanced-patcher/issues/315)) ([aa472eb](https://github.com/ReVanced/revanced-patcher/commit/aa472eb9857145b53b49f843406a9764fbb7e5ce))
### Features
* Improve Fingerprint API ([#316](https://github.com/ReVanced/revanced-patcher/issues/316)) ([0abf1c6](https://github.com/ReVanced/revanced-patcher/commit/0abf1c6c0279708fdef5cb66b141d07d17682693))
* Improve various APIs ([#317](https://github.com/ReVanced/revanced-patcher/issues/317)) ([b824978](https://github.com/ReVanced/revanced-patcher/commit/b8249789df8b90129f7b7ad0e523a8d0ceaab848))
### BREAKING CHANGES
* Various APIs have been changed.
* Many APIs have been changed.
## [20.0.2](https://github.com/ReVanced/revanced-patcher/compare/v20.0.1...v20.0.2) (2024-10-17) ## [20.0.2](https://github.com/ReVanced/revanced-patcher/compare/v20.0.1...v20.0.2) (2024-10-17)

View File

@@ -1,7 +1,22 @@
public final class app/revanced/patcher/Fingerprint { public final class app/revanced/patcher/Fingerprint {
public final fun getMatch ()Lapp/revanced/patcher/Match; public final fun getClassDef (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;
public final fun match (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Z public final fun getClassDefOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;
public final fun match (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;)Z public final fun getMethod (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
public final fun getMethodOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
public final fun getOriginalClassDef (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lcom/android/tools/smali/dexlib2/iface/ClassDef;
public final fun getOriginalClassDefOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lcom/android/tools/smali/dexlib2/iface/ClassDef;
public final fun getOriginalMethod (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lcom/android/tools/smali/dexlib2/iface/Method;
public final fun getOriginalMethodOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lcom/android/tools/smali/dexlib2/iface/Method;
public final fun getPatternMatch (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/Match$PatternMatch;
public final fun getPatternMatchOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/Match$PatternMatch;
public final fun getStringMatches (Lapp/revanced/patcher/patch/BytecodePatchContext;)Ljava/util/List;
public final fun getStringMatchesOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Ljava/util/List;
public final fun match (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Lapp/revanced/patcher/Match;
public final fun match (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;)Lapp/revanced/patcher/Match;
public final fun match (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Lapp/revanced/patcher/Match;
public final fun matchOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Lapp/revanced/patcher/Match;
public final fun matchOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;)Lapp/revanced/patcher/Match;
public final fun matchOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Lapp/revanced/patcher/Match;
} }
public final class app/revanced/patcher/FingerprintBuilder { public final class app/revanced/patcher/FingerprintBuilder {
@@ -18,32 +33,27 @@ public final class app/revanced/patcher/FingerprintBuilder {
public final class app/revanced/patcher/FingerprintKt { public final class app/revanced/patcher/FingerprintKt {
public static final fun fingerprint (ILkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/Fingerprint; public static final fun fingerprint (ILkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/Fingerprint;
public static final fun fingerprint (Lapp/revanced/patcher/patch/BytecodePatchBuilder;ILkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/patch/BytecodePatchBuilder$InvokedFingerprint;
public static synthetic fun fingerprint$default (ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/Fingerprint; public static synthetic fun fingerprint$default (ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/Fingerprint;
public static synthetic fun fingerprint$default (Lapp/revanced/patcher/patch/BytecodePatchBuilder;ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/patch/BytecodePatchBuilder$InvokedFingerprint;
} }
public abstract interface annotation class app/revanced/patcher/InternalApi : java/lang/annotation/Annotation { public abstract interface annotation class app/revanced/patcher/InternalApi : java/lang/annotation/Annotation {
} }
public final class app/revanced/patcher/Match { public final class app/revanced/patcher/Match {
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lapp/revanced/patcher/Match$PatternMatch;Ljava/util/List;Lapp/revanced/patcher/patch/BytecodePatchContext;)V public final fun getClassDef ()Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;
public final fun getClassDef ()Lcom/android/tools/smali/dexlib2/iface/ClassDef; public final fun getMethod ()Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
public final fun getMethod ()Lcom/android/tools/smali/dexlib2/iface/Method; public final fun getOriginalClassDef ()Lcom/android/tools/smali/dexlib2/iface/ClassDef;
public final fun getMutableClass ()Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass; public final fun getOriginalMethod ()Lcom/android/tools/smali/dexlib2/iface/Method;
public final fun getMutableMethod ()Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
public final fun getPatternMatch ()Lapp/revanced/patcher/Match$PatternMatch; public final fun getPatternMatch ()Lapp/revanced/patcher/Match$PatternMatch;
public final fun getStringMatches ()Ljava/util/List; public final fun getStringMatches ()Ljava/util/List;
} }
public final class app/revanced/patcher/Match$PatternMatch { public final class app/revanced/patcher/Match$PatternMatch {
public fun <init> (II)V
public final fun getEndIndex ()I public final fun getEndIndex ()I
public final fun getStartIndex ()I public final fun getStartIndex ()I
} }
public final class app/revanced/patcher/Match$StringMatch { public final class app/revanced/patcher/Match$StringMatch {
public fun <init> (Ljava/lang/String;I)V
public final fun getIndex ()I public final fun getIndex ()I
public final fun getString ()Ljava/lang/String; public final fun getString ()Ljava/lang/String;
} }
@@ -63,8 +73,10 @@ public final class app/revanced/patcher/Patcher : java/io/Closeable {
} }
public final class app/revanced/patcher/PatcherConfig { public final class app/revanced/patcher/PatcherConfig {
public fun <init> (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;Z)V public fun <init> (Ljava/io/File;Ljava/io/File;Ljava/io/File;Ljava/lang/String;)V
public synthetic fun <init> (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (Ljava/io/File;Ljava/io/File;Ljava/io/File;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;)V
public synthetic fun <init> (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
} }
public final class app/revanced/patcher/PatcherContext : java/io/Closeable { public final class app/revanced/patcher/PatcherContext : java/io/Closeable {
@@ -135,40 +147,36 @@ public final class app/revanced/patcher/extensions/InstructionExtensions {
} }
public final class app/revanced/patcher/patch/BytecodePatch : app/revanced/patcher/patch/Patch { public final class app/revanced/patcher/patch/BytecodePatch : app/revanced/patcher/patch/Patch {
public final fun getExtension ()Ljava/io/InputStream; public final fun getExtensionInputStream ()Ljava/util/function/Supplier;
public final fun getFingerprints ()Ljava/util/Set;
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
} }
public final class app/revanced/patcher/patch/BytecodePatchBuilder : app/revanced/patcher/patch/PatchBuilder { public final class app/revanced/patcher/patch/BytecodePatchBuilder : app/revanced/patcher/patch/PatchBuilder {
public synthetic fun build$revanced_patcher ()Lapp/revanced/patcher/patch/Patch; public synthetic fun build$revanced_patcher ()Lapp/revanced/patcher/patch/Patch;
public final fun extendWith (Ljava/lang/String;)Lapp/revanced/patcher/patch/BytecodePatchBuilder; public final fun extendWith (Ljava/lang/String;)Lapp/revanced/patcher/patch/BytecodePatchBuilder;
public final fun getExtension ()Ljava/io/InputStream; public final fun getExtensionInputStream ()Ljava/util/function/Supplier;
public final fun invoke (Lapp/revanced/patcher/Fingerprint;)Lapp/revanced/patcher/patch/BytecodePatchBuilder$InvokedFingerprint; public final fun setExtensionInputStream (Ljava/util/function/Supplier;)V
public final fun setExtension (Ljava/io/InputStream;)V
}
public final class app/revanced/patcher/patch/BytecodePatchBuilder$InvokedFingerprint {
public final fun getValue (Ljava/lang/Void;Lkotlin/reflect/KProperty;)Lapp/revanced/patcher/Match;
} }
public final class app/revanced/patcher/patch/BytecodePatchContext : app/revanced/patcher/patch/PatchContext, java/io/Closeable { public final class app/revanced/patcher/patch/BytecodePatchContext : app/revanced/patcher/patch/PatchContext, java/io/Closeable {
public final fun classBy (Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/util/proxy/ClassProxy; public final fun classBy (Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/util/proxy/ClassProxy;
public final fun classByType (Ljava/lang/String;)Lapp/revanced/patcher/util/proxy/ClassProxy;
public fun close ()V public fun close ()V
public synthetic fun get ()Ljava/lang/Object; public synthetic fun get ()Ljava/lang/Object;
public fun get ()Ljava/util/Set; public fun get ()Ljava/util/Set;
public final fun getClasses ()Lapp/revanced/patcher/util/ProxyClassList; public final fun getClasses ()Lapp/revanced/patcher/util/ProxyClassList;
public final fun navigate (Lcom/android/tools/smali/dexlib2/iface/Method;)Lapp/revanced/patcher/util/MethodNavigator; public final fun navigate (Lcom/android/tools/smali/dexlib2/iface/reference/MethodReference;)Lapp/revanced/patcher/util/MethodNavigator;
public final fun proxy (Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Lapp/revanced/patcher/util/proxy/ClassProxy; public final fun proxy (Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Lapp/revanced/patcher/util/proxy/ClassProxy;
} }
public final class app/revanced/patcher/patch/Option { public final class app/revanced/patcher/patch/Option {
public fun <init> (Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/reflect/KType;Lkotlin/jvm/functions/Function2;)V public fun <init> (Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/reflect/KType;Lkotlin/jvm/functions/Function2;)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/reflect/KType;Lkotlin/jvm/functions/Function2;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/reflect/KType;Lkotlin/jvm/functions/Function2;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;ZLkotlin/reflect/KType;Lkotlin/jvm/functions/Function2;)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;ZLkotlin/reflect/KType;Lkotlin/jvm/functions/Function2;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getDefault ()Ljava/lang/Object; public final fun getDefault ()Ljava/lang/Object;
public final fun getDescription ()Ljava/lang/String; public final fun getDescription ()Ljava/lang/String;
public final fun getKey ()Ljava/lang/String; public final fun getKey ()Ljava/lang/String;
public final fun getName ()Ljava/lang/String;
public final fun getRequired ()Z public final fun getRequired ()Z
public final fun getTitle ()Ljava/lang/String; public final fun getTitle ()Ljava/lang/String;
public final fun getType ()Lkotlin/reflect/KType; public final fun getType ()Lkotlin/reflect/KType;
@@ -286,7 +294,7 @@ public final class app/revanced/patcher/patch/Options : java/util/Map, kotlin/jv
} }
public abstract class app/revanced/patcher/patch/Patch { public abstract class app/revanced/patcher/patch/Patch {
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;ZLjava/util/Set;Ljava/util/Set;Ljava/util/Set;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;ZLjava/util/Set;Ljava/util/Set;Ljava/util/Set;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun execute (Lapp/revanced/patcher/patch/PatchContext;)V public final fun execute (Lapp/revanced/patcher/patch/PatchContext;)V
public final fun finalize (Lapp/revanced/patcher/patch/PatchContext;)V public final fun finalize (Lapp/revanced/patcher/patch/PatchContext;)V
public final fun getCompatiblePackages ()Ljava/util/Set; public final fun getCompatiblePackages ()Ljava/util/Set;
@@ -303,13 +311,13 @@ public abstract class app/revanced/patcher/patch/PatchBuilder {
public final fun compatibleWith ([Ljava/lang/String;)V public final fun compatibleWith ([Ljava/lang/String;)V
public final fun compatibleWith ([Lkotlin/Pair;)V public final fun compatibleWith ([Lkotlin/Pair;)V
public final fun dependsOn ([Lapp/revanced/patcher/patch/Patch;)V public final fun dependsOn ([Lapp/revanced/patcher/patch/Patch;)V
public final fun execute (Lkotlin/jvm/functions/Function2;)V public final fun execute (Lkotlin/jvm/functions/Function1;)V
public final fun finalize (Lkotlin/jvm/functions/Function2;)V public final fun finalize (Lkotlin/jvm/functions/Function1;)V
protected final fun getCompatiblePackages ()Ljava/util/Set; protected final fun getCompatiblePackages ()Ljava/util/Set;
protected final fun getDependencies ()Ljava/util/Set; protected final fun getDependencies ()Ljava/util/Set;
protected final fun getDescription ()Ljava/lang/String; protected final fun getDescription ()Ljava/lang/String;
protected final fun getExecutionBlock ()Lkotlin/jvm/functions/Function2; protected final fun getExecutionBlock ()Lkotlin/jvm/functions/Function1;
protected final fun getFinalizeBlock ()Lkotlin/jvm/functions/Function2; protected final fun getFinalizeBlock ()Lkotlin/jvm/functions/Function1;
protected final fun getName ()Ljava/lang/String; protected final fun getName ()Ljava/lang/String;
protected final fun getOptions ()Ljava/util/Set; protected final fun getOptions ()Ljava/util/Set;
protected final fun getUse ()Z protected final fun getUse ()Z
@@ -317,8 +325,8 @@ public abstract class app/revanced/patcher/patch/PatchBuilder {
public final fun invoke (Ljava/lang/String;[Ljava/lang/String;)Lkotlin/Pair; public final fun invoke (Ljava/lang/String;[Ljava/lang/String;)Lkotlin/Pair;
protected final fun setCompatiblePackages (Ljava/util/Set;)V protected final fun setCompatiblePackages (Ljava/util/Set;)V
protected final fun setDependencies (Ljava/util/Set;)V protected final fun setDependencies (Ljava/util/Set;)V
protected final fun setExecutionBlock (Lkotlin/jvm/functions/Function2;)V protected final fun setExecutionBlock (Lkotlin/jvm/functions/Function1;)V
protected final fun setFinalizeBlock (Lkotlin/jvm/functions/Function2;)V protected final fun setFinalizeBlock (Lkotlin/jvm/functions/Function1;)V
} }
public abstract interface class app/revanced/patcher/patch/PatchContext : java/util/function/Supplier { public abstract interface class app/revanced/patcher/patch/PatchContext : java/util/function/Supplier {
@@ -395,18 +403,13 @@ public final class app/revanced/patcher/patch/ResourcePatchBuilder : app/revance
} }
public final class app/revanced/patcher/patch/ResourcePatchContext : app/revanced/patcher/patch/PatchContext { public final class app/revanced/patcher/patch/ResourcePatchContext : app/revanced/patcher/patch/PatchContext {
public final fun delete (Ljava/lang/String;)Z
public final fun document (Ljava/io/InputStream;)Lapp/revanced/patcher/util/Document;
public final fun document (Ljava/lang/String;)Lapp/revanced/patcher/util/Document;
public fun get ()Lapp/revanced/patcher/PatcherResult$PatchedResources; public fun get ()Lapp/revanced/patcher/PatcherResult$PatchedResources;
public synthetic fun get ()Ljava/lang/Object; public synthetic fun get ()Ljava/lang/Object;
public final fun get (Ljava/lang/String;Z)Ljava/io/File; public final fun get (Ljava/lang/String;Z)Ljava/io/File;
public static synthetic fun get$default (Lapp/revanced/patcher/patch/ResourcePatchContext;Ljava/lang/String;ZILjava/lang/Object;)Ljava/io/File; public static synthetic fun get$default (Lapp/revanced/patcher/patch/ResourcePatchContext;Ljava/lang/String;ZILjava/lang/Object;)Ljava/io/File;
public final fun getDocument ()Lapp/revanced/patcher/patch/ResourcePatchContext$DocumentOperatable;
public final fun stageDelete (Lkotlin/jvm/functions/Function1;)Z
}
public final class app/revanced/patcher/patch/ResourcePatchContext$DocumentOperatable {
public fun <init> (Lapp/revanced/patcher/patch/ResourcePatchContext;)V
public final fun get (Ljava/io/InputStream;)Lapp/revanced/patcher/util/Document;
public final fun get (Ljava/lang/String;)Lapp/revanced/patcher/util/Document;
} }
public final class app/revanced/patcher/util/Document : java/io/Closeable, org/w3c/dom/Document { public final class app/revanced/patcher/util/Document : java/io/Closeable, org/w3c/dom/Document {
@@ -482,11 +485,12 @@ public final class app/revanced/patcher/util/Document : java/io/Closeable, org/w
} }
public final class app/revanced/patcher/util/MethodNavigator { public final class app/revanced/patcher/util/MethodNavigator {
public final fun at (ILkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/util/MethodNavigator; public final fun getValue (Ljava/lang/Void;Lkotlin/reflect/KProperty;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
public final fun at ([I)Lapp/revanced/patcher/util/MethodNavigator; public final fun original ()Lcom/android/tools/smali/dexlib2/iface/Method;
public static synthetic fun at$default (Lapp/revanced/patcher/util/MethodNavigator;ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/util/MethodNavigator; public final fun stop ()Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
public final fun immutable ()Lcom/android/tools/smali/dexlib2/iface/Method; public final fun to (ILkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/util/MethodNavigator;
public final fun mutable ()Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod; public final fun to ([I)Lapp/revanced/patcher/util/MethodNavigator;
public static synthetic fun to$default (Lapp/revanced/patcher/util/MethodNavigator;ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/util/MethodNavigator;
} }
public final class app/revanced/patcher/util/ProxyClassList : java/util/List, kotlin/jvm/internal/markers/KMutableList { public final class app/revanced/patcher/util/ProxyClassList : java/util/List, kotlin/jvm/internal/markers/KMutableList {

View File

@@ -56,6 +56,8 @@ dependencies {
kotlin { kotlin {
compilerOptions { compilerOptions {
jvmTarget.set(JvmTarget.JVM_11) jvmTarget.set(JvmTarget.JVM_11)
freeCompilerArgs = listOf("-Xcontext-receivers")
} }
} }

View File

@@ -89,9 +89,9 @@ val patcherResult = Patcher(PatcherConfig(apkFile = File("some.apk"))).use { pat
runBlocking { runBlocking {
patcher().collect { patchResult -> patcher().collect { patchResult ->
if (patchResult.exception != null) if (patchResult.exception != null)
logger.info("\"${patchResult.patch}\" failed:\n${patchResult.exception}") logger.info { "\"${patchResult.patch}\" failed:\n${patchResult.exception}" }
else else
logger.info("\"${patchResult.patch}\" succeeded") logger.info { "\"${patchResult.patch}\" succeeded" }
} }
} }

View File

@@ -72,6 +72,10 @@ To start developing patches with ReVanced Patcher, you must prepare a developmen
Throughout the documentation, [ReVanced Patches](https://github.com/revanced/revanced-patches) will be used as an example project. Throughout the documentation, [ReVanced Patches](https://github.com/revanced/revanced-patches) will be used as an example project.
> [!NOTE]
> To start a fresh project,
> you can use the [ReVanced Patches template](https://github.com/revanced/revanced-patches-template).
1. Clone the repository 1. Clone the repository
```bash ```bash

File diff suppressed because it is too large Load Diff

View File

@@ -76,23 +76,23 @@ val disableAdsPatch = bytecodePatch(
) { ) {
compatibleWith("com.some.app"("1.0.0")) compatibleWith("com.some.app"("1.0.0"))
// Resource patch disables ads by patching resource files. // Patches can depend on other patches, executing them first.
dependsOn(disableAdsResourcePatch) dependsOn(disableAdsResourcePatch)
// Precompiled DEX file to be merged into the patched app. // Merge precompiled DEX files into the patched app, before the patch is executed.
extendWith("disable-ads.rve") extendWith("disable-ads.rve")
// Fingerprint to find the method to patch.
val showAdsMatch by showAdsFingerprint {
// More about fingerprints on the next page of the documentation.
}
// Business logic of the patch to disable ads in the app. // Business logic of the patch to disable ads in the app.
execute { execute {
// Fingerprint to find the method to patch.
val showAdsFingerprint = fingerprint {
// More about fingerprints on the next page of the documentation.
}
// In the method that shows ads, // In the method that shows ads,
// call DisableAdsPatch.shouldDisableAds() from the extension (precompiled DEX file) // call DisableAdsPatch.shouldDisableAds() from the extension (precompiled DEX file)
// to enable or disable ads. // to enable or disable ads.
showAdsMatch.mutableMethod.addInstructions( showAdsFingerprint.method.addInstructions(
0, 0,
""" """
invoke-static {}, LDisableAdsPatch;->shouldDisableAds()Z invoke-static {}, LDisableAdsPatch;->shouldDisableAds()Z
@@ -122,10 +122,10 @@ To define an option, use the available `option` functions:
```kt ```kt
val patch = bytecodePatch(name = "Patch") { val patch = bytecodePatch(name = "Patch") {
// Add an inbuilt option and delegate it to a property. // Add an inbuilt option and delegate it to a property.
val value by stringOption(key = "option") val value by stringOption(name = "Inbuilt option")
// Add an option with a custom type and delegate it to a property. // Add an option with a custom type and delegate it to a property.
val string by option<String>(key = "string") val string by option<String>(name = "String option")
execute { execute {
println(value) println(value)
@@ -139,20 +139,20 @@ Options of a patch can be set after loading the patches with `PatchLoader` by ob
```kt ```kt
loadPatchesJar(patches).apply { loadPatchesJar(patches).apply {
// Type is checked at runtime. // Type is checked at runtime.
first { it.name == "Patch" }.options["option"] = "Value" first { it.name == "Patch" }.options["Option"] = "Value"
} }
``` ```
The type of an option can be obtained from the `type` property of the option: The type of an option can be obtained from the `type` property of the option:
```kt ```kt
option.type // The KType of the option. option.type // The KType of the option. Captures the full type information of the option.
``` ```
Options can be declared outside of a patch and added to a patch manually: Options can be declared outside a patch and added to a patch manually:
```kt ```kt
val option = stringOption(key = "option") val option = stringOption(name = "Option")
bytecodePatch(name = "Patch") { bytecodePatch(name = "Patch") {
val value by option() val value by option()
@@ -184,10 +184,8 @@ and use it in a patch:
val patch = bytecodePatch(name = "Complex patch") { val patch = bytecodePatch(name = "Complex patch") {
extendWith("complex-patch.rve") extendWith("complex-patch.rve")
val match by methodFingerprint()
execute { execute {
match.mutableMethod.addInstructions(0, "invoke-static { }, LComplexPatch;->doSomething()V") fingerprint.method.addInstructions(0, "invoke-static { }, LComplexPatch;->doSomething()V")
} }
} }
``` ```
@@ -251,10 +249,10 @@ The same order is followed for multiple patches depending on the patch.
- A patch can declare compatibility with specific packages and versions, - A patch can declare compatibility with specific packages and versions,
but patches can still be executed on any package or version. but patches can still be executed on any package or version.
It is recommended that compatibility is specified to present known compatible packages and versions. It is recommended that compatibility is specified to present known compatible packages and versions.
- If `compatibleWith` is not used, the patch is treated as compatible with any package - If `compatibleWith` is not used, the patch is treated as compatible with any package
- If a package is specified with no versions, the patch is compatible with any version of the package - If a package is specified with no versions, the patch is compatible with any version of the package
- If an empty array of versions is specified, the patch is not compatible with any version of the package. - If an empty array of versions is specified, the patch is not compatible with any version of the package.
This is useful for declaring incompatibility with a specific package. This is useful for declaring incompatibility with a specific package.
- A patch can raise a `PatchException` at any time of execution to indicate that the patch failed to execute. - A patch can raise a `PatchException` at any time of execution to indicate that the patch failed to execute.
## ⏭️ What's next ## ⏭️ What's next

View File

@@ -96,21 +96,21 @@ Example of patches:
@Surpress("unused") @Surpress("unused")
val bytecodePatch = bytecodePatch { val bytecodePatch = bytecodePatch {
execute { execute {
// TODO // More about this on the next page of the documentation.
} }
} }
@Surpress("unused") @Surpress("unused")
val rawResourcePatch = rawResourcePatch { val rawResourcePatch = rawResourcePatch {
execute { execute {
// TODO // More about this on the next page of the documentation.
} }
} }
@Surpress("unused") @Surpress("unused")
val resourcePatch = resourcePatch { val resourcePatch = resourcePatch {
execute { execute {
// TODO // More about this on the next page of the documentation.
} }
} }
``` ```

View File

@@ -4,18 +4,107 @@ A handful of APIs are available to make patch development easier and more effici
## 📙 Overview ## 📙 Overview
1. 👹 Mutate classes with `context.proxy(ClassDef)` 1. 👹 Create mutable replacements of classes with `proxy(ClassDef)`
2. 🔍 Find and proxy existing classes with `classBy(Predicate)` and `classByType(String)` 2. 🔍 Find and create mutable replaces with `classBy(Predicate)`
3. 🏃‍ Easily access referenced methods recursively by index with `MethodNavigator` 3. 🏃‍ Navigate method calls recursively by index with `navigate(Method)`
4. 🔨 Make use of extension functions from `BytecodeUtils` and `ResourceUtils` with certain applications 4. 💾 Read and write resource files with `get(String, Boolean)` and `delete(String)`
(Available in ReVanced Patches) 5. 📃 Read and write DOM files using `document(String)` and `document(InputStream)`
5. 💾 Read and write (decoded) resources with `ResourcePatchContext.get(Path, Boolean)`
6. 📃 Read and write DOM files using `ResourcePatchContext.document`
### 🧰 APIs ### 🧰 APIs
> [!WARNING] #### 👹 `proxy(ClassDef)`
> This section is still under construction and may be incomplete.
By default, the classes are immutable, meaning they cannot be modified.
To make a class mutable, use the `proxy(ClassDef)` function.
This function creates a lazy mutable copy of the class definition.
Accessing the property will replace the original class definition with the mutable copy,
thus allowing you to make changes to the class. Subsequent accesses will return the same mutable copy.
```kt
execute {
val mutableClass = proxy(classDef)
mutableClass.methods.add(Method())
}
```
#### 🔍 `classBy(Predicate)`
The `classBy(Predicate)` function is an alternative to finding and creating mutable classes by a predicate.
It automatically proxies the class definition, making it mutable.
```kt
execute {
// Alternative to proxy(classes.find { it.name == "Lcom/example/MyClass;" })?.classDef
val classDef = classBy { it.name == "Lcom/example/MyClass;" }?.classDef
}
```
#### 🏃‍ `navigate(Method).at(index)`
The `navigate(Method)` function allows you to navigate method calls recursively by index.
```kt
execute {
// Sequentially navigate to the instructions at index 1 within 'someMethod'.
val method = navigate(someMethod).to(1).original() // original() returns the original immutable method.
// Further navigate to the second occurrence where the instruction's opcode is 'INVOKEVIRTUAL'.
// stop() returns the mutable copy of the method.
val method = navigate(someMethod).to(2) { instruction -> instruction.opcode == Opcode.INVOKEVIRTUAL }.stop()
// Alternatively, to stop(), you can delegate the method to a variable.
val method by navigate(someMethod).to(1)
// You can chain multiple calls to at() to navigate deeper into the method.
val method by navigate(someMethod).to(1).to(2, 3, 4).to(5)
}
```
#### 💾 `get(String, Boolean)` and `delete(String)`
The `get(String, Boolean)` function returns a `File` object that can be used to read and write resource files.
```kt
execute {
val file = get("res/values/strings.xml")
val content = file.readText()
file.writeText(content)
}
```
The `delete` function can mark files for deletion when the APK is rebuilt.
```kt
execute {
delete("res/values/strings.xml")
}
```
#### 📃 `document(String)` and `document(InputStream)`
The `document` function is used to read and write DOM files.
```kt
execute {
document("res/values/strings.xml").use { document ->
val element = doc.createElement("string").apply {
textContent = "Hello, World!"
}
document.documentElement.appendChild(element)
}
}
```
You can also read documents from an `InputStream`:
```kt
execute {
val inputStream = classLoader.getResourceAsStream("some.xml")
document(inputStream).use { document ->
// ...
}
}
```
## 🎉 Afterword ## 🎉 Afterword
@@ -23,5 +112,6 @@ ReVanced Patcher is a powerful library to patch Android applications, offering a
that outlive app updates. Patches make up ReVanced; without you, the community of patch developers, that outlive app updates. Patches make up ReVanced; without you, the community of patch developers,
ReVanced would not be what it is today. We hope that this documentation has been helpful to you ReVanced would not be what it is today. We hope that this documentation has been helpful to you
and are excited to see what you will create with ReVanced Patcher. If you have any questions or need help, and are excited to see what you will create with ReVanced Patcher. If you have any questions or need help,
talk to us on one of our platforms linked on [revanced.app](https://revanced.app) or open an issue in case of a bug or feature request, talk to us on one of our platforms linked on [revanced.app](https://revanced.app) or open an issue in case of a bug or
feature request,
ReVanced ReVanced

View File

@@ -1,3 +1,3 @@
org.gradle.parallel = true org.gradle.parallel = true
org.gradle.caching = true org.gradle.caching = true
version = 20.0.2 version = 21.1.0-dev.3

View File

@@ -1,14 +1,14 @@
[versions] [versions]
android = "4.1.1.4" android = "4.1.1.4"
apktool-lib = "2.9.3" apktool-lib = "2.10.1.1"
binary-compatibility-validator = "0.15.1" binary-compatibility-validator = "0.15.1"
kotlin = "2.0.0" kotlin = "2.0.20"
kotlinx-coroutines-core = "1.8.1" kotlinx-coroutines-core = "1.8.1"
mockk = "1.13.10" mockk = "1.13.10"
multidexlib2 = "3.0.3.r3" multidexlib2 = "3.0.3.r3"
# Tracking https://github.com/google/smali/issues/64. # Tracking https://github.com/google/smali/issues/64.
#noinspection GradleDependency #noinspection GradleDependency
smali = "3.0.5" smali = "3.0.8"
xpp3 = "1.1.4c" xpp3 = "1.1.4c"
[libraries] [libraries]

File diff suppressed because it is too large Load Diff

View File

@@ -91,19 +91,15 @@ class Patcher(private val config: PatcherConfig) : Closeable {
}.also { executedPatches[this] = it } }.also { executedPatches[this] = it }
} }
// Prevent from decoding the app manifest twice if it is not needed. // Prevent decoding the app manifest twice if it is not needed.
if (config.resourceMode != ResourcePatchContext.ResourceMode.NONE) { if (config.resourceMode != ResourcePatchContext.ResourceMode.NONE) {
context.resourceContext.decodeResources(config.resourceMode) context.resourceContext.decodeResources(config.resourceMode)
} }
logger.info("Merging extensions") logger.info("Initializing lookup maps")
with(context.bytecodeContext) { // Accessing the lazy lookup maps to initialize them.
context.executablePatches.mergeExtensions() context.bytecodeContext.lookupMaps
// Initialize lookup maps.
lookupMaps
}
logger.info("Executing patches") logger.info("Executing patches")

View File

@@ -12,17 +12,32 @@ import java.util.logging.Logger
* @param temporaryFilesPath A path to a folder to store temporary files in. * @param temporaryFilesPath A path to a folder to store temporary files in.
* @param aaptBinaryPath A path to a custom aapt binary. * @param aaptBinaryPath A path to a custom aapt binary.
* @param frameworkFileDirectory A path to the directory to cache the framework file in. * @param frameworkFileDirectory A path to the directory to cache the framework file in.
* @param multithreadingDexFileWriter Whether to use multiple threads for writing dex files.
* This has impact on memory usage and performance.
*/ */
class PatcherConfig( class PatcherConfig(
internal val apkFile: File, internal val apkFile: File,
private val temporaryFilesPath: File = File("revanced-temporary-files"), private val temporaryFilesPath: File = File("revanced-temporary-files"),
aaptBinaryPath: String? = null, aaptBinaryPath: File? = null,
frameworkFileDirectory: String? = null, frameworkFileDirectory: String? = null,
@Deprecated("This is going to be removed in the future because it is not needed anymore.")
internal val multithreadingDexFileWriter: Boolean = false,
) { ) {
/**
* The configuration for the patcher.
*
* @param apkFile The apk file to patch.
* @param temporaryFilesPath A path to a folder to store temporary files in.
* @param aaptBinaryPath A path to a custom aapt binary.
* @param frameworkFileDirectory A path to the directory to cache the framework file in.
*/
@Deprecated(
"Use the constructor with a File for aaptBinaryPath instead.",
ReplaceWith("PatcherConfig(apkFile, temporaryFilesPath, aaptBinaryPath?.let { File(it) }, frameworkFileDirectory)"),
)
constructor(
apkFile: File,
temporaryFilesPath: File = File("revanced-temporary-files"),
aaptBinaryPath: String? = null,
frameworkFileDirectory: String? = null,
) : this(apkFile, temporaryFilesPath, aaptBinaryPath?.let { File(it) }, frameworkFileDirectory)
private val logger = Logger.getLogger(PatcherConfig::class.java.name) private val logger = Logger.getLogger(PatcherConfig::class.java.name)
/** /**
@@ -37,8 +52,7 @@ class PatcherConfig(
*/ */
internal val resourceConfig = internal val resourceConfig =
Config.getDefaultConfig().apply { Config.getDefaultConfig().apply {
useAapt2 = true aaptBinary = aaptBinaryPath
aaptPath = aaptBinaryPath ?: ""
frameworkDirectory = frameworkFileDirectory frameworkDirectory = frameworkFileDirectory
} }

View File

@@ -29,12 +29,12 @@ class PatcherResult internal constructor(
* @param resourcesApk The compiled resources.apk file. * @param resourcesApk The compiled resources.apk file.
* @param otherResources The directory containing other resources files. * @param otherResources The directory containing other resources files.
* @param doNotCompress List of files that should not be compressed. * @param doNotCompress List of files that should not be compressed.
* @param deleteResources List of predicates about resources that should be deleted. * @param deleteResources List of resources that should be deleted.
*/ */
class PatchedResources internal constructor( class PatchedResources internal constructor(
val resourcesApk: File?, val resourcesApk: File?,
val otherResources: File?, val otherResources: File?,
val doNotCompress: Set<String>, val doNotCompress: Set<String>,
val deleteResources: Set<(String) -> Boolean>, val deleteResources: Set<String>,
) )
} }

View File

@@ -14,6 +14,7 @@ import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.DexFile import com.android.tools.smali.dexlib2.iface.DexFile
import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.iface.reference.StringReference import com.android.tools.smali.dexlib2.iface.reference.StringReference
import lanchon.multidexlib2.BasicDexFileNamer import lanchon.multidexlib2.BasicDexFileNamer
import lanchon.multidexlib2.DexIO import lanchon.multidexlib2.DexIO
@@ -33,7 +34,7 @@ import java.util.logging.Logger
class BytecodePatchContext internal constructor(private val config: PatcherConfig) : class BytecodePatchContext internal constructor(private val config: PatcherConfig) :
PatchContext<Set<PatcherResult.PatchedDexFile>>, PatchContext<Set<PatcherResult.PatchedDexFile>>,
Closeable { Closeable {
private val logger = Logger.getLogger(BytecodePatchContext::class.java.name) private val logger = Logger.getLogger(this::class.java.name)
/** /**
* [Opcodes] of the supplied [PatcherConfig.apkFile]. * [Opcodes] of the supplied [PatcherConfig.apkFile].
@@ -59,53 +60,38 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
internal val lookupMaps by lazy { LookupMaps(classes) } internal val lookupMaps by lazy { LookupMaps(classes) }
/** /**
* Merge the extensions for this set of patches. * Merge the extension of [bytecodePatch] into the [BytecodePatchContext].
* If no extension is present, the function will return early.
*
* @param bytecodePatch The [BytecodePatch] to merge the extension of.
*/ */
internal fun Set<Patch<*>>.mergeExtensions() { internal fun mergeExtension(bytecodePatch: BytecodePatch) {
// Lookup map to check if a class exists by its type quickly. bytecodePatch.extensionInputStream?.get()?.use { extensionStream ->
val classesByType = mutableMapOf<String, ClassDef>().apply { RawDexIO.readRawDexFile(extensionStream, 0, null).classes.forEach { classDef ->
classes.forEach { classDef -> put(classDef.type, classDef) } val existingClass = lookupMaps.classesByType[classDef.type] ?: run {
} logger.fine { "Adding class \"$classDef\"" }
forEachRecursively { patch -> classes += classDef
if (patch !is BytecodePatch) return@forEachRecursively lookupMaps.classesByType[classDef.type] = classDef
patch.extension?.use { extensionStream -> return@forEach
RawDexIO.readRawDexFile(extensionStream, 0, null).classes.forEach { classDef -> }
val existingClass = classesByType[classDef.type] ?: run {
logger.fine("Adding class \"$classDef\"")
classes += classDef logger.fine { "Class \"$classDef\" exists already. Adding missing methods and fields." }
classesByType[classDef.type] = classDef
return@forEach existingClass.merge(classDef, this@BytecodePatchContext).let { mergedClass ->
// If the class was merged, replace the original class with the merged class.
if (mergedClass === existingClass) {
return@let
} }
logger.fine("Class \"$classDef\" exists already. Adding missing methods and fields.") classes -= existingClass
classes += mergedClass
existingClass.merge(classDef, this@BytecodePatchContext).let { mergedClass ->
// If the class was merged, replace the original class with the merged class.
if (mergedClass === existingClass) {
return@let
}
classes -= existingClass
classes += mergedClass
}
} }
} }
} } ?: logger.fine("No extension to merge")
} }
/**
* Find a class by its type using a contains check.
*
* @param type The type of the class.
* @return A proxy for the first class that matches the type.
*/
@Deprecated("Use classBy { type in it.type } instead.", ReplaceWith("classBy { type in it.type }"))
fun classByType(type: String) = classBy { type in it.type }
/** /**
* Find a class with a predicate. * Find a class with a predicate.
* *
@@ -122,9 +108,9 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
* *
* @return A proxy for the class. * @return A proxy for the class.
*/ */
fun proxy(classDef: ClassDef) = this@BytecodePatchContext.classes.proxyPool.find { fun proxy(classDef: ClassDef) = classes.proxyPool.find {
it.immutableClass.type == classDef.type it.immutableClass.type == classDef.type
} ?: ClassProxy(classDef).also { this@BytecodePatchContext.classes.proxyPool.add(it) } } ?: ClassProxy(classDef).also { classes.proxyPool.add(it) }
/** /**
* Navigate a method. * Navigate a method.
@@ -133,7 +119,7 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
* *
* @return A [MethodNavigator] for the method. * @return A [MethodNavigator] for the method.
*/ */
fun navigate(method: Method) = MethodNavigator(this@BytecodePatchContext, method) fun navigate(method: MethodReference) = MethodNavigator(method)
/** /**
* Compile bytecode from the [BytecodePatchContext]. * Compile bytecode from the [BytecodePatchContext].
@@ -154,7 +140,7 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
}.apply { }.apply {
MultiDexIO.writeDexFile( MultiDexIO.writeDexFile(
true, true,
if (config.multithreadingDexFileWriter) -1 else 1, -1,
this, this,
BasicDexFileNamer(), BasicDexFileNamer(),
object : DexFile { object : DexFile {
@@ -164,7 +150,7 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
override fun getOpcodes() = this@BytecodePatchContext.opcodes override fun getOpcodes() = this@BytecodePatchContext.opcodes
}, },
DexIO.DEFAULT_MAX_DEX_POOL_SIZE, DexIO.DEFAULT_MAX_DEX_POOL_SIZE,
) { _, entryName, _ -> logger.info("Compiled $entryName") } ) { _, entryName, _ -> logger.info { "Compiled $entryName" } }
}.listFiles(FileFilter { it.isFile })!!.map { }.listFiles(FileFilter { it.isFile })!!.map {
PatcherResult.PatchedDexFile(it.name, it.inputStream()) PatcherResult.PatchedDexFile(it.name, it.inputStream())
}.toSet() }.toSet()
@@ -185,6 +171,11 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
*/ */
internal val methodsByStrings = MethodClassPairsLookupMap() internal val methodsByStrings = MethodClassPairsLookupMap()
// Lookup map for fast checking if a class exists by its type.
val classesByType = mutableMapOf<String, ClassDef>().apply {
classes.forEach { classDef -> put(classDef.type, classDef) }
}
init { init {
classes.forEach { classDef -> classes.forEach { classDef ->
classDef.methods.forEach { method -> classDef.methods.forEach { method ->
@@ -207,30 +198,9 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
} }
} }
internal companion object {
/**
* Appends a string based on the parameter reference types of this method.
*/
internal fun StringBuilder.appendParameters(parameters: Iterable<CharSequence>) {
// Maximum parameters to use in the signature key.
// Some apps have methods with an incredible number of parameters (over 100 parameters have been seen).
// To keep the signature map from becoming needlessly bloated,
// group together in the same map entry all methods with the same access/return and 5 or more parameters.
// The value of 5 was chosen based on local performance testing and is not set in stone.
val maxSignatureParameters = 5
// Must append a unique value before the parameters to distinguish this key includes the parameters.
// If this is not appended, then methods with no parameters
// will collide with different keys that specify access/return but omit the parameters.
append("p:")
parameters.forEachIndexed { index, parameter ->
if (index >= maxSignatureParameters) return
append(parameter.first())
}
}
}
override fun close() { override fun close() {
methodsByStrings.clear() methodsByStrings.clear()
classesByType.clear()
} }
} }

View File

@@ -20,16 +20,51 @@ import kotlin.reflect.typeOf
* @constructor Create a new [Option]. * @constructor Create a new [Option].
*/ */
@Suppress("MemberVisibilityCanBePrivate", "unused") @Suppress("MemberVisibilityCanBePrivate", "unused")
class Option<T> @PublishedApi internal constructor( class Option<T>
@PublishedApi
@Deprecated("Use the constructor with the name instead of a key instead.")
internal constructor(
@Deprecated("Use the name property instead.")
val key: String, val key: String,
val default: T? = null, val default: T? = null,
val values: Map<String, T?>? = null, val values: Map<String, T?>? = null,
@Deprecated("Use the name property instead.")
val title: String? = null, val title: String? = null,
val description: String? = null, val description: String? = null,
val required: Boolean = false, val required: Boolean = false,
val type: KType, val type: KType,
val validator: Option<T>.(T?) -> Boolean = { true }, val validator: Option<T>.(T?) -> Boolean = { true },
) { ) {
/**
* The name.
*/
val name = key
/**
* An option.
*
* @param T The value type of the option.
* @param name The name.
* @param default The default value.
* @param values Eligible option values mapped to a human-readable name.
* @param description A description.
* @param required Whether the option is required.
* @param type The type of the option value (to handle type erasure).
* @param validator The function to validate the option value.
*
* @constructor Create a new [Option].
*/
@PublishedApi
internal constructor(
name: String,
default: T? = null,
values: Map<String, T?>? = null,
description: String? = null,
required: Boolean = false,
type: KType,
validator: Option<T>.(T?) -> Boolean = { true },
) : this(name, default, values, name, description, required, type, validator)
/** /**
* The value of the [Option]. * The value of the [Option].
*/ */
@@ -109,7 +144,7 @@ class Option<T> @PublishedApi internal constructor(
class Options internal constructor( class Options internal constructor(
private val options: Map<String, Option<*>>, private val options: Map<String, Option<*>>,
) : Map<String, Option<*>> by options { ) : Map<String, Option<*>> by options {
internal constructor(options: Set<Option<*>>) : this(options.associateBy { it.key }) internal constructor(options: Set<Option<*>>) : this(options.associateBy { it.name })
/** /**
* Set an option's value. * Set an option's value.
@@ -856,14 +891,14 @@ sealed class OptionException(errorMessage: String) : Exception(errorMessage, nul
* *
* @param value The value that failed validation. * @param value The value that failed validation.
*/ */
class ValueValidationException(value: Any?, option: Option<*>) : OptionException("The option value \"$value\" failed validation for ${option.key}") class ValueValidationException(value: Any?, option: Option<*>) : OptionException("The option value \"$value\" failed validation for ${option.name}")
/** /**
* An exception thrown when a value is required but null was passed. * An exception thrown when a value is required but null was passed.
* *
* @param option The [Option] that requires a value. * @param option The [Option] that requires a value.
*/ */
class ValueRequiredException(option: Option<*>) : OptionException("The option ${option.key} requires a value, but the value was null") class ValueRequiredException(option: Option<*>) : OptionException("The option ${option.name} requires a value, but the value was null")
/** /**
* An exception thrown when a [Option] is not found. * An exception thrown when a [Option] is not found.

View File

@@ -2,7 +2,6 @@
package app.revanced.patcher.patch package app.revanced.patcher.patch
import app.revanced.patcher.Fingerprint
import app.revanced.patcher.Patcher import app.revanced.patcher.Patcher
import app.revanced.patcher.PatcherContext import app.revanced.patcher.PatcherContext
import dalvik.system.DexClassLoader import dalvik.system.DexClassLoader
@@ -14,8 +13,8 @@ import java.lang.reflect.Member
import java.lang.reflect.Method import java.lang.reflect.Method
import java.lang.reflect.Modifier import java.lang.reflect.Modifier
import java.net.URLClassLoader import java.net.URLClassLoader
import java.util.function.Supplier
import java.util.jar.JarFile import java.util.jar.JarFile
import kotlin.reflect.KProperty
typealias PackageName = String typealias PackageName = String
typealias VersionName = String typealias VersionName = String
@@ -46,10 +45,10 @@ sealed class Patch<C : PatchContext<*>>(
val dependencies: Set<Patch<*>>, val dependencies: Set<Patch<*>>,
val compatiblePackages: Set<Package>?, val compatiblePackages: Set<Package>?,
options: Set<Option<*>>, options: Set<Option<*>>,
private val executeBlock: Patch<C>.(C) -> Unit, private val executeBlock: (C) -> Unit,
// Must be internal and nullable, so that Patcher.invoke can check, // Must be internal and nullable, so that Patcher.invoke can check,
// if a patch has a finalizing block in order to not emit it twice. // if a patch has a finalizing block in order to not emit it twice.
internal var finalizeBlock: (Patch<C>.(C) -> Unit)?, internal var finalizeBlock: ((C) -> Unit)?,
) { ) {
/** /**
* The options of the patch. * The options of the patch.
@@ -57,38 +56,39 @@ sealed class Patch<C : PatchContext<*>>(
val options = Options(options) val options = Options(options)
/** /**
* Runs the execution block of the patch. * Calls the execution block of the patch.
* Called by [Patcher]. * This function is called by [Patcher.invoke].
* *
* @param context The [PatcherContext] to get the [PatchContext] from to execute the patch with. * @param context The [PatcherContext] to get the [PatchContext] from to execute the patch with.
*/ */
internal abstract fun execute(context: PatcherContext) internal abstract fun execute(context: PatcherContext)
/** /**
* Runs the execution block of the patch. * Calls the execution block of the patch.
* *
* @param context The [PatchContext] to execute the patch with. * @param context The [PatchContext] to execute the patch with.
*/ */
fun execute(context: C) = executeBlock(context) fun execute(context: C) = executeBlock(context)
/** /**
* Runs the finalizing block of the patch. * Calls the finalizing block of the patch.
* Called by [Patcher]. * This function is called by [Patcher.invoke].
* *
* @param context The [PatcherContext] to get the [PatchContext] from to finalize the patch with. * @param context The [PatcherContext] to get the [PatchContext] from to finalize the patch with.
*/ */
internal abstract fun finalize(context: PatcherContext) internal abstract fun finalize(context: PatcherContext)
/** /**
* Runs the finalizing block of the patch. * Calls the finalizing block of the patch.
* *
* @param context The [PatchContext] to finalize the patch with. * @param context The [PatchContext] to finalize the patch with.
*/ */
fun finalize(context: C) { fun finalize(context: C) {
finalizeBlock?.invoke(this, context) finalizeBlock?.invoke(context)
} }
override fun toString() = name ?: "Patch" override fun toString() = name ?:
"Patch@${System.identityHashCode(this)}"
} }
internal fun Patch<*>.anyRecursively( internal fun Patch<*>.anyRecursively(
@@ -127,8 +127,7 @@ internal fun Iterable<Patch<*>>.forEachRecursively(
* If null, the patch is compatible with all packages. * If null, the patch is compatible with all packages.
* @param dependencies Other patches this patch depends on. * @param dependencies Other patches this patch depends on.
* @param options The options of the patch. * @param options The options of the patch.
* @param fingerprints The fingerprints that are resolved before the patch is executed. * @property extensionInputStream Getter for the extension input stream of the patch.
* @property extension An input stream of the extension resource this patch uses.
* An extension is a precompiled DEX file that is merged into the patched app before this patch is executed. * An extension is a precompiled DEX file that is merged into the patched app before this patch is executed.
* @param executeBlock The execution block of the patch. * @param executeBlock The execution block of the patch.
* @param finalizeBlock The finalizing block of the patch. Called after all patches have been executed, * @param finalizeBlock The finalizing block of the patch. Called after all patches have been executed,
@@ -143,10 +142,9 @@ class BytecodePatch internal constructor(
compatiblePackages: Set<Package>?, compatiblePackages: Set<Package>?,
dependencies: Set<Patch<*>>, dependencies: Set<Patch<*>>,
options: Set<Option<*>>, options: Set<Option<*>>,
val fingerprints: Set<Fingerprint>, val extensionInputStream: Supplier<InputStream>?,
val extension: InputStream?, executeBlock: (BytecodePatchContext) -> Unit,
executeBlock: Patch<BytecodePatchContext>.(BytecodePatchContext) -> Unit, finalizeBlock: ((BytecodePatchContext) -> Unit)?,
finalizeBlock: (Patch<BytecodePatchContext>.(BytecodePatchContext) -> Unit)?,
) : Patch<BytecodePatchContext>( ) : Patch<BytecodePatchContext>(
name, name,
description, description,
@@ -158,14 +156,13 @@ class BytecodePatch internal constructor(
finalizeBlock, finalizeBlock,
) { ) {
override fun execute(context: PatcherContext) = with(context.bytecodeContext) { override fun execute(context: PatcherContext) = with(context.bytecodeContext) {
fingerprints.forEach { it.match(this) } mergeExtension(this@BytecodePatch)
execute(this) execute(this)
} }
override fun finalize(context: PatcherContext) = finalize(context.bytecodeContext) override fun finalize(context: PatcherContext) = finalize(context.bytecodeContext)
override fun toString() = name ?: "BytecodePatch" override fun toString() = name ?: "Bytecode${super.toString()}"
} }
/** /**
@@ -192,8 +189,8 @@ class RawResourcePatch internal constructor(
compatiblePackages: Set<Package>?, compatiblePackages: Set<Package>?,
dependencies: Set<Patch<*>>, dependencies: Set<Patch<*>>,
options: Set<Option<*>>, options: Set<Option<*>>,
executeBlock: Patch<ResourcePatchContext>.(ResourcePatchContext) -> Unit, executeBlock: (ResourcePatchContext) -> Unit,
finalizeBlock: (Patch<ResourcePatchContext>.(ResourcePatchContext) -> Unit)?, finalizeBlock: ((ResourcePatchContext) -> Unit)?,
) : Patch<ResourcePatchContext>( ) : Patch<ResourcePatchContext>(
name, name,
description, description,
@@ -208,7 +205,7 @@ class RawResourcePatch internal constructor(
override fun finalize(context: PatcherContext) = finalize(context.resourceContext) override fun finalize(context: PatcherContext) = finalize(context.resourceContext)
override fun toString() = name ?: "RawResourcePatch" override fun toString() = name ?: "RawResource${super.toString()}"
} }
/** /**
@@ -235,8 +232,8 @@ class ResourcePatch internal constructor(
compatiblePackages: Set<Package>?, compatiblePackages: Set<Package>?,
dependencies: Set<Patch<*>>, dependencies: Set<Patch<*>>,
options: Set<Option<*>>, options: Set<Option<*>>,
executeBlock: Patch<ResourcePatchContext>.(ResourcePatchContext) -> Unit, executeBlock: (ResourcePatchContext) -> Unit,
finalizeBlock: (Patch<ResourcePatchContext>.(ResourcePatchContext) -> Unit)?, finalizeBlock: ((ResourcePatchContext) -> Unit)?,
) : Patch<ResourcePatchContext>( ) : Patch<ResourcePatchContext>(
name, name,
description, description,
@@ -251,7 +248,7 @@ class ResourcePatch internal constructor(
override fun finalize(context: PatcherContext) = finalize(context.resourceContext) override fun finalize(context: PatcherContext) = finalize(context.resourceContext)
override fun toString() = name ?: "ResourcePatch" override fun toString() = name ?: "Resource${super.toString()}"
} }
/** /**
@@ -281,8 +278,8 @@ sealed class PatchBuilder<C : PatchContext<*>>(
protected var dependencies = mutableSetOf<Patch<*>>() protected var dependencies = mutableSetOf<Patch<*>>()
protected val options = mutableSetOf<Option<*>>() protected val options = mutableSetOf<Option<*>>()
protected var executionBlock: (Patch<C>.(C) -> Unit) = { } protected var executionBlock: ((C) -> Unit) = { }
protected var finalizeBlock: (Patch<C>.(C) -> Unit)? = null protected var finalizeBlock: ((C) -> Unit)? = null
/** /**
* Add an option to the patch. * Add an option to the patch.
@@ -341,7 +338,7 @@ sealed class PatchBuilder<C : PatchContext<*>>(
* *
* @param block The execution block of the patch. * @param block The execution block of the patch.
*/ */
fun execute(block: Patch<C>.(C) -> Unit) { fun execute(block: C.() -> Unit) {
executionBlock = block executionBlock = block
} }
@@ -350,7 +347,7 @@ sealed class PatchBuilder<C : PatchContext<*>>(
* *
* @param block The finalizing block of the patch. * @param block The finalizing block of the patch.
*/ */
fun finalize(block: Patch<C>.(C) -> Unit) { fun finalize(block: C.() -> Unit) {
finalizeBlock = block finalizeBlock = block
} }
@@ -379,8 +376,7 @@ private fun <B : PatchBuilder<*>> B.buildPatch(block: B.() -> Unit = {}) = apply
* If null, the patch is named "Patch" and will not be loaded by [PatchLoader]. * If null, the patch is named "Patch" and will not be loaded by [PatchLoader].
* @param description The description of the patch. * @param description The description of the patch.
* @param use Weather or not the patch should be used. * @param use Weather or not the patch should be used.
* @property fingerprints The fingerprints that are resolved before the patch is executed. * @property extensionInputStream Getter for the extension input stream of the patch.
* @property extension An input stream of the extension resource this patch uses.
* An extension is a precompiled DEX file that is merged into the patched app before this patch is executed. * An extension is a precompiled DEX file that is merged into the patched app before this patch is executed.
* *
* @constructor Create a new [BytecodePatchBuilder] builder. * @constructor Create a new [BytecodePatchBuilder] builder.
@@ -390,27 +386,9 @@ class BytecodePatchBuilder internal constructor(
description: String?, description: String?,
use: Boolean, use: Boolean,
) : PatchBuilder<BytecodePatchContext>(name, description, use) { ) : PatchBuilder<BytecodePatchContext>(name, description, use) {
private val fingerprints = mutableSetOf<Fingerprint>()
/**
* Add the fingerprint to the patch.
*
* @return A wrapper for the fingerprint with the ability to delegate the match to the fingerprint.
*/
operator fun Fingerprint.invoke() = InvokedFingerprint(also { fingerprints.add(it) })
class InvokedFingerprint internal constructor(private val fingerprint: Fingerprint) {
// The reason getValue isn't extending the Fingerprint class is
// because delegating makes only sense if the fingerprint was previously added to the patch by invoking it.
// It may be likely to forget invoking it. By wrapping the fingerprint into this class,
// the compiler will throw an error if the fingerprint was not invoked if attempting to delegate the match.
operator fun getValue(nothing: Nothing?, property: KProperty<*>) = fingerprint.match
?: throw PatchException("No fingerprint match to delegate to \"${property.name}\".")
}
// Must be internal for the inlined function "extendWith". // Must be internal for the inlined function "extendWith".
@PublishedApi @PublishedApi
internal var extension: InputStream? = null internal var extensionInputStream: Supplier<InputStream>? = null
// Inlining is necessary to get the class loader that loaded the patch // Inlining is necessary to get the class loader that loaded the patch
// to load the extension from the resources. // to load the extension from the resources.
@@ -421,8 +399,11 @@ class BytecodePatchBuilder internal constructor(
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun extendWith(extension: String) = apply { inline fun extendWith(extension: String) = apply {
this.extension = object {}.javaClass.classLoader.getResourceAsStream(extension) val classLoader = object {}.javaClass.classLoader
?: throw PatchException("Extension \"$extension\" not found")
extensionInputStream = Supplier {
classLoader.getResourceAsStream(extension) ?: throw PatchException("Extension \"$extension\" not found")
}
} }
override fun build() = BytecodePatch( override fun build() = BytecodePatch(
@@ -432,8 +413,7 @@ class BytecodePatchBuilder internal constructor(
compatiblePackages, compatiblePackages,
dependencies, dependencies,
options, options,
fingerprints, extensionInputStream,
extension,
executionBlock, executionBlock,
finalizeBlock, finalizeBlock,
) )

View File

@@ -10,9 +10,9 @@ import brut.androlib.ApkDecoder
import brut.androlib.apk.UsesFramework import brut.androlib.apk.UsesFramework
import brut.androlib.res.Framework import brut.androlib.res.Framework
import brut.androlib.res.ResourcesDecoder import brut.androlib.res.ResourcesDecoder
import brut.androlib.res.decoder.AndroidManifestPullStreamDecoder
import brut.androlib.res.decoder.AndroidManifestResourceParser import brut.androlib.res.decoder.AndroidManifestResourceParser
import brut.androlib.res.decoder.XmlPullStreamDecoder import brut.androlib.res.xml.ResXmlUtils
import brut.androlib.res.xml.ResXmlPatcher
import brut.directory.ExtFile import brut.directory.ExtFile
import java.io.InputStream import java.io.InputStream
import java.io.OutputStream import java.io.OutputStream
@@ -32,78 +32,81 @@ class ResourcePatchContext internal constructor(
private val logger = Logger.getLogger(ResourcePatchContext::class.java.name) private val logger = Logger.getLogger(ResourcePatchContext::class.java.name)
/** /**
* Read and write documents in the [PatcherConfig.apkFiles]. * Read a document from an [InputStream].
*/ */
val document = DocumentOperatable() fun document(inputStream: InputStream) = Document(inputStream)
/** /**
* Predicate to delete resources from [PatcherConfig.apkFiles]. * Read and write documents in the [PatcherConfig.apkFiles].
*/ */
private val deleteResources = mutableSetOf<(String) -> Boolean>() fun document(path: String) = Document(get(path))
/**
* Set of resources from [PatcherConfig.apkFiles] to delete.
*/
private val deleteResources = mutableSetOf<String>()
/** /**
* Decode resources of [PatcherConfig.apkFile]. * Decode resources of [PatcherConfig.apkFile].
* *
* @param mode The [ResourceMode] to use. * @param mode The [ResourceMode] to use.
*/ */
internal fun decodeResources(mode: ResourceMode) = internal fun decodeResources(mode: ResourceMode) = with(packageMetadata.apkInfo) {
with(packageMetadata.apkInfo) { config.initializeTemporaryFilesDirectories()
config.initializeTemporaryFilesDirectories()
// Needed to decode resources. // Needed to decode resources.
val resourcesDecoder = ResourcesDecoder(config.resourceConfig, this) val resourcesDecoder = ResourcesDecoder(config.resourceConfig, this)
if (mode == ResourceMode.FULL) { if (mode == ResourceMode.FULL) {
logger.info("Decoding resources") logger.info("Decoding resources")
resourcesDecoder.decodeResources(config.apkFiles) resourcesDecoder.decodeResources(config.apkFiles)
resourcesDecoder.decodeManifest(config.apkFiles) resourcesDecoder.decodeManifest(config.apkFiles)
// Needed to record uncompressed files. // Needed to record uncompressed files.
val apkDecoder = ApkDecoder(config.resourceConfig, this) ApkDecoder(this, config.resourceConfig).recordUncompressedFiles(resourcesDecoder.resFileMapping)
apkDecoder.recordUncompressedFiles(resourcesDecoder.resFileMapping)
usesFramework = usesFramework =
UsesFramework().apply { UsesFramework().apply {
ids = resourcesDecoder.resTable.listFramePackages().map { it.id } ids = resourcesDecoder.resTable.listFramePackages().map { it.id }
}
} else {
logger.info("Decoding app manifest")
// Decode manually instead of using resourceDecoder.decodeManifest
// because it does not support decoding to an OutputStream.
XmlPullStreamDecoder(
AndroidManifestResourceParser(resourcesDecoder.resTable),
resourcesDecoder.resXmlSerializer,
).decodeManifest(
apkFile.directory.getFileInput("AndroidManifest.xml"),
// Older Android versions do not support OutputStream.nullOutputStream()
object : OutputStream() {
override fun write(b: Int) { // Do nothing.
}
},
)
// Get the package name and version from the manifest using the XmlPullStreamDecoder.
// XmlPullStreamDecoder.decodeManifest() sets metadata.apkInfo.
packageMetadata.let { metadata ->
metadata.packageName = resourcesDecoder.resTable.packageRenamed
versionInfo.let {
metadata.packageVersion = it.versionName ?: it.versionCode
}
/*
The ResTable if flagged as sparse if the main package is not loaded, which is the case here,
because ResourcesDecoder.decodeResources loads the main package
and not XmlPullStreamDecoder.decodeManifest.
See ARSCDecoder.readTableType for more info.
Set this to false again to prevent the ResTable from being flagged as sparse falsely.
*/
metadata.apkInfo.sparseResources = false
} }
} else {
logger.info("Decoding app manifest")
// Decode manually instead of using resourceDecoder.decodeManifest
// because it does not support decoding to an OutputStream.
AndroidManifestPullStreamDecoder(
AndroidManifestResourceParser(resourcesDecoder.resTable),
resourcesDecoder.newXmlSerializer(),
).decode(
apkFile.directory.getFileInput("AndroidManifest.xml"),
// Older Android versions do not support OutputStream.nullOutputStream()
object : OutputStream() {
override fun write(b: Int) { // Do nothing.
}
},
)
// Get the package name and version from the manifest using the XmlPullStreamDecoder.
// AndroidManifestPullStreamDecoder.decode() sets metadata.apkInfo.
packageMetadata.let { metadata ->
metadata.packageName = resourcesDecoder.resTable.packageRenamed
versionInfo.let {
metadata.packageVersion = it.versionName ?: it.versionCode
}
/*
The ResTable if flagged as sparse if the main package is not loaded, which is the case here,
because ResourcesDecoder.decodeResources loads the main package
and not AndroidManifestPullStreamDecoder.decode.
See ARSCDecoder.readTableType for more info.
Set this to false again to prevent the ResTable from being flagged as sparse falsely.
*/
metadata.apkInfo.sparseResources = false
} }
} }
}
/** /**
* Compile resources in [PatcherConfig.apkFiles]. * Compile resources in [PatcherConfig.apkFiles].
@@ -125,10 +128,10 @@ class ResourcePatchContext internal constructor(
AaptInvoker( AaptInvoker(
config.resourceConfig, config.resourceConfig,
packageMetadata.apkInfo, packageMetadata.apkInfo,
).invokeAapt( ).invoke(
resources.resolve("resources.apk"), resources.resolve("resources.apk"),
config.apkFiles.resolve("AndroidManifest.xml").also { config.apkFiles.resolve("AndroidManifest.xml").also {
ResXmlPatcher.fixingPublicAttrsInProviderAttributes(it) ResXmlUtils.fixingPublicAttrsInProviderAttributes(it)
}, },
config.apkFiles.resolve("res"), config.apkFiles.resolve("res"),
null, null,
@@ -201,11 +204,11 @@ class ResourcePatchContext internal constructor(
} }
/** /**
* Stage a file to be deleted from [PatcherConfig.apkFile]. * Mark a file for deletion when the APK is rebuilt.
* *
* @param shouldDelete The predicate to stage the file for deletion given its name. * @param name The name of the file to delete.
*/ */
fun stageDelete(shouldDelete: (String) -> Boolean) = deleteResources.add(shouldDelete) fun delete(name: String) = deleteResources.add(name)
/** /**
* How to handle resources decoding and compiling. * How to handle resources decoding and compiling.
@@ -227,10 +230,4 @@ class ResourcePatchContext internal constructor(
*/ */
NONE, NONE,
} }
inner class DocumentOperatable {
operator fun get(inputStream: InputStream) = Document(inputStream)
operator fun get(path: String) = Document(this@ResourcePatchContext[path])
}
} }

View File

@@ -60,7 +60,7 @@ internal object ClassMerger {
if (missingMethods.isEmpty()) return this if (missingMethods.isEmpty()) return this
logger.fine("Found ${missingMethods.size} missing methods") logger.fine { "Found ${missingMethods.size} missing methods" }
return asMutableClass().apply { return asMutableClass().apply {
methods.addAll(missingMethods.map { it.toMutable() }) methods.addAll(missingMethods.map { it.toMutable() })
@@ -80,7 +80,7 @@ internal object ClassMerger {
if (missingFields.isEmpty()) return this if (missingFields.isEmpty()) return this
logger.fine("Found ${missingFields.size} missing fields") logger.fine { "Found ${missingFields.size} missing fields" }
return asMutableClass().apply { return asMutableClass().apply {
fields.addAll(missingFields.map { it.toMutable() }) fields.addAll(missingFields.map { it.toMutable() })
@@ -100,7 +100,7 @@ internal object ClassMerger {
context.traverseClassHierarchy(this) { context.traverseClassHierarchy(this) {
if (accessFlags.isPublic()) return@traverseClassHierarchy if (accessFlags.isPublic()) return@traverseClassHierarchy
logger.fine("Publicizing ${this.type}") logger.fine { "Publicizing ${this.type}" }
accessFlags = accessFlags.toPublic() accessFlags = accessFlags.toPublic()
} }
@@ -124,7 +124,7 @@ internal object ClassMerger {
if (brokenFields.isEmpty()) return this if (brokenFields.isEmpty()) return this
logger.fine("Found ${brokenFields.size} broken fields") logger.fine { "Found ${brokenFields.size} broken fields" }
/** /**
* Make a field public. * Make a field public.
@@ -153,7 +153,7 @@ internal object ClassMerger {
if (brokenMethods.isEmpty()) return this if (brokenMethods.isEmpty()) return this
logger.fine("Found ${brokenMethods.size} methods") logger.fine { "Found ${brokenMethods.size} methods" }
/** /**
* Make a method public. * Make a method public.

View File

@@ -4,7 +4,9 @@ import org.w3c.dom.Document
import java.io.Closeable import java.io.Closeable
import java.io.File import java.io.File
import java.io.InputStream import java.io.InputStream
import java.io.StringWriter
import javax.xml.parsers.DocumentBuilderFactory import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.transform.OutputKeys
import javax.xml.transform.TransformerFactory import javax.xml.transform.TransformerFactory
import javax.xml.transform.dom.DOMSource import javax.xml.transform.dom.DOMSource
import javax.xml.transform.stream.StreamResult import javax.xml.transform.stream.StreamResult
@@ -34,15 +36,20 @@ class Document internal constructor(
readerCount.remove(it) readerCount.remove(it)
} }
it.outputStream().use { stream -> it.outputStream().buffered().use { stream ->
TransformerFactory.newInstance() val transformer = TransformerFactory.newInstance().newTransformer()
.newTransformer() // Set to UTF-16 but encode as UTF-8 to prevent surrogate pairs from being escaped to broken numeric character references.
.transform(DOMSource(this), StreamResult(stream)) if (isAndroid) {
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-16")
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes")
}
transformer.transform(DOMSource(this), StreamResult(stream))
} }
} }
} }
private companion object { private companion object {
private val readerCount = mutableMapOf<File, Int>() private val readerCount = mutableMapOf<File, Int>()
private val isAndroid = System.getProperty("java.runtime.name").equals("Android Runtime")
} }
} }

View File

@@ -12,11 +12,11 @@ import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.util.MethodUtil import com.android.tools.smali.dexlib2.util.MethodUtil
import kotlin.reflect.KProperty
/** /**
* A navigator for methods. * A navigator for methods.
* *
* @param context The [BytecodePatchContext] to use.
* @param startMethod The [Method] to start navigating from. * @param startMethod The [Method] to start navigating from.
* *
* @constructor Creates a new [MethodNavigator]. * @constructor Creates a new [MethodNavigator].
@@ -24,12 +24,16 @@ import com.android.tools.smali.dexlib2.util.MethodUtil
* @throws NavigateException If the method does not have an implementation. * @throws NavigateException If the method does not have an implementation.
* @throws NavigateException If the instruction at the specified index is not a method reference. * @throws NavigateException If the instruction at the specified index is not a method reference.
*/ */
class MethodNavigator internal constructor(private val context: BytecodePatchContext, private var startMethod: MethodReference) { context(BytecodePatchContext)
class MethodNavigator internal constructor(
private var startMethod: MethodReference,
) {
private var lastNavigatedMethodReference = startMethod private var lastNavigatedMethodReference = startMethod
private val lastNavigatedMethodInstructions get() = with(immutable()) { private val lastNavigatedMethodInstructions
instructionsOrNull ?: throw NavigateException("Method $definingClass.$name does not have an implementation.") get() = with(original()) {
} instructionsOrNull ?: throw NavigateException("Method $this does not have an implementation.")
}
/** /**
* Navigate to the method at the specified index. * Navigate to the method at the specified index.
@@ -38,7 +42,7 @@ class MethodNavigator internal constructor(private val context: BytecodePatchCon
* *
* @return This [MethodNavigator]. * @return This [MethodNavigator].
*/ */
fun at(vararg index: Int): MethodNavigator { fun to(vararg index: Int): MethodNavigator {
index.forEach { index.forEach {
lastNavigatedMethodReference = lastNavigatedMethodInstructions.getMethodReferenceAt(it) lastNavigatedMethodReference = lastNavigatedMethodInstructions.getMethodReferenceAt(it)
} }
@@ -52,7 +56,7 @@ class MethodNavigator internal constructor(private val context: BytecodePatchCon
* @param index The index of the method to navigate to. * @param index The index of the method to navigate to.
* @param predicate The predicate to match. * @param predicate The predicate to match.
*/ */
fun at(index: Int = 0, predicate: (Instruction) -> Boolean): MethodNavigator { fun to(index: Int = 0, predicate: (Instruction) -> Boolean): MethodNavigator {
lastNavigatedMethodReference = lastNavigatedMethodInstructions.asSequence() lastNavigatedMethodReference = lastNavigatedMethodInstructions.asSequence()
.filter(predicate).asIterable().getMethodReferenceAt(index) .filter(predicate).asIterable().getMethodReferenceAt(index)
@@ -76,15 +80,22 @@ class MethodNavigator internal constructor(private val context: BytecodePatchCon
* *
* @return The last navigated method mutably. * @return The last navigated method mutably.
*/ */
fun mutable() = context.classBy(matchesCurrentMethodReferenceDefiningClass)!!.mutableClass.firstMethodBySignature fun stop() = classBy(matchesCurrentMethodReferenceDefiningClass)!!.mutableClass.firstMethodBySignature
as MutableMethod as MutableMethod
/**
* Get the last navigated method mutably.
*
* @return The last navigated method mutably.
*/
operator fun getValue(nothing: Nothing?, property: KProperty<*>) = stop()
/** /**
* Get the last navigated method immutably. * Get the last navigated method immutably.
* *
* @return The last navigated method immutably. * @return The last navigated method immutably.
*/ */
fun immutable() = context.classes.first(matchesCurrentMethodReferenceDefiningClass).firstMethodBySignature fun original(): Method = classes.first(matchesCurrentMethodReferenceDefiningClass).firstMethodBySignature
/** /**
* Predicate to match the class defining the current method reference. * Predicate to match the class defining the current method reference.
@@ -96,9 +107,10 @@ class MethodNavigator internal constructor(private val context: BytecodePatchCon
/** /**
* Find the first [lastNavigatedMethodReference] in the class. * Find the first [lastNavigatedMethodReference] in the class.
*/ */
private val ClassDef.firstMethodBySignature get() = methods.first { private val ClassDef.firstMethodBySignature
MethodUtil.methodSignaturesMatch(it, lastNavigatedMethodReference) get() = methods.first {
} MethodUtil.methodSignaturesMatch(it, lastNavigatedMethodReference)
}
/** /**
* An exception thrown when navigating fails. * An exception thrown when navigating fails.

View File

@@ -50,7 +50,7 @@ class InlineSmaliCompiler {
registers, registers,
instructions, instructions,
) )
val reader = InputStreamReader(input.byteInputStream()) val reader = InputStreamReader(input.byteInputStream(), Charsets.UTF_8)
val lexer: LexerErrorInterface = smaliFlexLexer(reader, 15) val lexer: LexerErrorInterface = smaliFlexLexer(reader, 15)
val tokens = CommonTokenStream(lexer as TokenSource) val tokens = CommonTokenStream(lexer as TokenSource)
val parser = smaliParser(tokens) val parser = smaliParser(tokens)

View File

@@ -5,18 +5,15 @@ import app.revanced.patcher.patch.BytecodePatchContext.LookupMaps
import app.revanced.patcher.util.ProxyClassList import app.revanced.patcher.util.ProxyClassList
import com.android.tools.smali.dexlib2.immutable.ImmutableClassDef import com.android.tools.smali.dexlib2.immutable.ImmutableClassDef
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import io.mockk.every import io.mockk.*
import io.mockk.just
import io.mockk.mockk
import io.mockk.runs
import kotlinx.coroutines.flow.toList import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertAll
import java.util.logging.Logger import java.util.logging.Logger
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertNull import kotlin.test.assertNotNull
import kotlin.test.assertTrue import kotlin.test.assertTrue
internal object PatcherTest { internal object PatcherTest {
@@ -151,19 +148,15 @@ internal object PatcherTest {
@Test @Test
fun `throws if unmatched fingerprint match is delegated`() { fun `throws if unmatched fingerprint match is delegated`() {
val patch = bytecodePatch { val patch = bytecodePatch {
// Fingerprint can never match.
val match by fingerprint { }
// Manually add the fingerprint.
app.revanced.patcher.fingerprint { }()
execute { execute {
// Fingerprint can never match.
val fingerprint = fingerprint { }
// Throws, because the fingerprint can't be matched. // Throws, because the fingerprint can't be matched.
match.patternMatch fingerprint.patternMatch
} }
} }
assertEquals(2, patch.fingerprints.size)
assertTrue( assertTrue(
patch().exception != null, patch().exception != null,
"Expected an exception because the fingerprint can't match.", "Expected an exception because the fingerprint can't match.",
@@ -172,44 +165,6 @@ internal object PatcherTest {
@Test @Test
fun `matches fingerprint`() { fun `matches fingerprint`() {
mockClassWithMethod()
val patches = setOf(bytecodePatch { fingerprint { this returns "V" } })
assertNull(
patches.first().fingerprints.first().match,
"Expected fingerprint to be matched before execution.",
)
patches()
assertDoesNotThrow("Expected fingerprint to be matched.") {
assertEquals(
"V",
patches.first().fingerprints.first().match!!.method.returnType,
"Expected fingerprint to be matched.",
)
}
}
private operator fun Set<Patch<*>>.invoke(): List<PatchResult> {
every { patcher.context.executablePatches } returns toMutableSet()
every { patcher.context.bytecodeContext.lookupMaps } returns LookupMaps(patcher.context.bytecodeContext.classes)
every { with(patcher.context.bytecodeContext) { any<Set<Patch<*>>>().mergeExtensions() } } just runs
return runBlocking { patcher().toList() }
}
private operator fun Patch<*>.invoke() = setOf(this)().first()
private fun Any.setPrivateField(field: String, value: Any) {
this::class.java.getDeclaredField(field).apply {
this.isAccessible = true
set(this@setPrivateField, value)
}
}
private fun mockClassWithMethod() {
every { patcher.context.bytecodeContext.classes } returns ProxyClassList( every { patcher.context.bytecodeContext.classes } returns ProxyClassList(
mutableListOf( mutableListOf(
ImmutableClassDef( ImmutableClassDef(
@@ -235,6 +190,47 @@ internal object PatcherTest {
), ),
), ),
) )
val fingerprint = fingerprint { returns("V") }
val fingerprint2 = fingerprint { returns("V") }
val fingerprint3 = fingerprint { returns("V") }
val patches = setOf(
bytecodePatch {
execute {
fingerprint.match(classes.first().methods.first())
fingerprint2.match(classes.first())
fingerprint3.originalClassDef
}
},
)
patches()
with(patcher.context.bytecodeContext) {
assertAll(
"Expected fingerprints to match.",
{ assertNotNull(fingerprint.originalClassDefOrNull) },
{ assertNotNull(fingerprint2.originalClassDefOrNull) },
{ assertNotNull(fingerprint3.originalClassDefOrNull) },
)
}
}
private operator fun Set<Patch<*>>.invoke(): List<PatchResult> {
every { patcher.context.executablePatches } returns toMutableSet()
every { patcher.context.bytecodeContext.lookupMaps } returns LookupMaps(patcher.context.bytecodeContext.classes) every { patcher.context.bytecodeContext.lookupMaps } returns LookupMaps(patcher.context.bytecodeContext.classes)
every { with(patcher.context.bytecodeContext) { mergeExtension(any<BytecodePatch>()) } } just runs
return runBlocking { patcher().toList() }
}
private operator fun Patch<*>.invoke() = setOf(this)().first()
private fun Any.setPrivateField(field: String, value: Any) {
this::class.java.getDeclaredField(field).apply {
this.isAccessible = true
set(this@setPrivateField, value)
}
} }
} }

View File

@@ -1,6 +1,5 @@
package app.revanced.patcher.patch package app.revanced.patcher.patch
import app.revanced.patcher.fingerprint
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
@@ -24,23 +23,6 @@ internal object PatchTest {
assertEquals("compatible.package", patch.compatiblePackages!!.first().first) assertEquals("compatible.package", patch.compatiblePackages!!.first().first)
} }
@Test
fun `can create patch with fingerprints`() {
val externalFingerprint = fingerprint {}
val patch = bytecodePatch(name = "Test") {
val externalFingerprintMatch by externalFingerprint()
val internalFingerprintMatch by fingerprint {}
execute {
externalFingerprintMatch.method
internalFingerprintMatch.method
}
}
assertEquals(2, patch.fingerprints.size)
}
@Test @Test
fun `can create patch with dependencies`() { fun `can create patch with dependencies`() {
val patch = bytecodePatch(name = "Test") { val patch = bytecodePatch(name = "Test") {