mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-19 09:23:56 +00:00
Compare commits
200 Commits
v11.0.2-de
...
v18.0.0-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
167bd83f4e | ||
|
|
aed1eac315 | ||
|
|
54a2f8f16f | ||
|
|
2ca543ffb9 | ||
|
|
58e7f815a5 | ||
|
|
15b38fc841 | ||
|
|
e2ca50729d | ||
|
|
6192089b71 | ||
|
|
a4212f6bf9 | ||
|
|
124a2e9d3e | ||
|
|
f77624b3b9 | ||
|
|
a76ac04214 | ||
|
|
0447fa9c28 | ||
|
|
54ac1394a9 | ||
|
|
0b04c73ac5 | ||
|
|
079de45238 | ||
|
|
56ce9ec2f9 | ||
|
|
1b52e4b0f9 | ||
|
|
098c2c1efa | ||
|
|
64343e5a7c | ||
|
|
0caf6caeb9 | ||
|
|
55f6c2a9fc | ||
|
|
c6095bc38a | ||
|
|
09cd6aa568 | ||
|
|
ebbaafb78e | ||
|
|
e6de90d300 | ||
|
|
c7922e90d0 | ||
|
|
c1f4c0445a | ||
|
|
caa634fac6 | ||
|
|
f28bfe0dbd | ||
|
|
155e787ff4 | ||
|
|
c38f0ef42a | ||
|
|
4456031459 | ||
|
|
5fb59a227f | ||
|
|
d9fb241d57 | ||
|
|
642c4ea97e | ||
|
|
8c8a251626 | ||
|
|
5953d6cfb5 | ||
|
|
a1962fe600 | ||
|
|
77dbee3d6a | ||
|
|
cb5e39d73e | ||
|
|
38ef2f470a | ||
|
|
129d84e108 | ||
|
|
affeba76b8 | ||
|
|
6059d3ca26 | ||
|
|
444dee5a16 | ||
|
|
d314466ce2 | ||
|
|
fdaf9c21c8 | ||
|
|
06c2b76f11 | ||
|
|
3896b30738 | ||
|
|
2c4b88e1a0 | ||
|
|
dfc7e1596b | ||
|
|
f590436399 | ||
|
|
cbfb9ba02f | ||
|
|
b4cfe80ad5 | ||
|
|
b37906fa35 | ||
|
|
356f1f1553 | ||
|
|
e882af74ee | ||
|
|
46875fb28e | ||
|
|
417c3e4234 | ||
|
|
6d2c28807b | ||
|
|
4d6e08a650 | ||
|
|
5cebc1fd30 | ||
|
|
ac61731dc6 | ||
|
|
9e4ffabd5c | ||
|
|
3f410bd39f | ||
|
|
d51bc32e37 | ||
|
|
b7f6aa94cc | ||
|
|
ff965e6953 | ||
|
|
468d5d7421 | ||
|
|
fc95b28c49 | ||
|
|
69184187d9 | ||
|
|
a802d0df46 | ||
|
|
8de30633ae | ||
|
|
a1fbb7990f | ||
|
|
aa71146b1b | ||
|
|
9fdb8f087f | ||
|
|
670f0153de | ||
|
|
1d7aeca696 | ||
|
|
4e7811ea07 | ||
|
|
e11283744a | ||
|
|
91cdfd53ef | ||
|
|
bc7d6b9941 | ||
|
|
6b1e0a1656 | ||
|
|
72c9eb2129 | ||
|
|
4bc4b0dc01 | ||
|
|
637d48746f | ||
|
|
9a109c129b | ||
|
|
d49e4ee5ea | ||
|
|
30f0ea29a3 | ||
|
|
49930f6565 | ||
|
|
909d89fa8d | ||
|
|
81d1d7f544 | ||
|
|
67b7dff67a | ||
|
|
4b76d19596 | ||
|
|
080fbe9feb | ||
|
|
d3721229bf | ||
|
|
86c1c9c772 | ||
|
|
c299817193 | ||
|
|
fcc1de45ed | ||
|
|
a29931f2ec | ||
|
|
3fc6a139ee | ||
|
|
4dd04975d9 | ||
|
|
3b4db3ddb7 | ||
|
|
c4a7117ee8 | ||
|
|
b4e900fde8 | ||
|
|
9818d730e4 | ||
|
|
11a3378659 | ||
|
|
1bb05f22d3 | ||
|
|
26b70554c4 | ||
|
|
93b29d2e83 | ||
|
|
072986374a | ||
|
|
2c590d212a | ||
|
|
6cc863efb3 | ||
|
|
b832812767 | ||
|
|
c44558cacd | ||
|
|
6d83a720cd | ||
|
|
8d0dd9c448 | ||
|
|
64020eec49 | ||
|
|
4dedfb85cb | ||
|
|
55d694579a | ||
|
|
86db64edff | ||
|
|
983563efb6 | ||
|
|
37abb2db99 | ||
|
|
5ba0b47e60 | ||
|
|
e8f2087a6f | ||
|
|
6ce99f5cdf | ||
|
|
13c0c9cdd3 | ||
|
|
58ffdb60d7 | ||
|
|
ba56a6a2ee | ||
|
|
ccccf5b1d2 | ||
|
|
b507ac0a54 | ||
|
|
e985676c2d | ||
|
|
f7f4ba6c55 | ||
|
|
4292f43814 | ||
|
|
30bd4fd9fe | ||
|
|
76de39369d | ||
|
|
88a703ce36 | ||
|
|
5938f6b7ea | ||
|
|
5c0c0d6c37 | ||
|
|
0f15077225 | ||
|
|
273dd8d388 | ||
|
|
1795f376ef | ||
|
|
e7360a7692 | ||
|
|
e1fc86934f | ||
|
|
6b8977f178 | ||
|
|
12c6c73de0 | ||
|
|
db62a1607b | ||
|
|
58bb879ef5 | ||
|
|
254912438a | ||
|
|
0e48918bcc | ||
|
|
783ccf8529 | ||
|
|
8fb2f2dc1d | ||
|
|
2a8cc283c7 | ||
|
|
433fe3af9f | ||
|
|
c2d89c622e | ||
|
|
02d6ff15fe | ||
|
|
f2cb7ee7df | ||
|
|
a2ac44dcc1 | ||
|
|
3cf9d74efa | ||
|
|
d5f89a903f | ||
|
|
496c2242bc | ||
|
|
98fbff87df | ||
|
|
ddb51a1c45 | ||
|
|
8df1155215 | ||
|
|
53f2a61409 | ||
|
|
746544f9d5 | ||
|
|
c65c3df11c | ||
|
|
b29b8f12b3 | ||
|
|
d6945677c4 | ||
|
|
aedf4aea08 | ||
|
|
dc28d414dc | ||
|
|
9755bab298 | ||
|
|
fae4029cfc | ||
|
|
1790f0d706 | ||
|
|
0ba2c51676 | ||
|
|
03cd97b49c | ||
|
|
16a162c1dd | ||
|
|
c9bbcf2bf2 | ||
|
|
86e1bf6078 | ||
|
|
1bca84ef0b | ||
|
|
e0f8e1b71a | ||
|
|
416d69142f | ||
|
|
426807aeaa | ||
|
|
90cb075a97 | ||
|
|
ac2ca8fbd3 | ||
|
|
69e4a49065 | ||
|
|
a4a030f2b2 | ||
|
|
dcc4ecd237 | ||
|
|
57f3036a96 | ||
|
|
753e55dfc3 | ||
|
|
9d81baf4b4 | ||
|
|
7cb4d4c596 | ||
|
|
2c8565508e | ||
|
|
c7f156e4c9 | ||
|
|
fcef4342e8 | ||
|
|
72783a5e74 | ||
|
|
a379b69eeb | ||
|
|
0a8ccba33e | ||
|
|
519359a9eb |
9
.gitattributes
vendored
Normal file
9
.gitattributes
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#
|
||||||
|
# https://help.github.com/articles/dealing-with-line-endings/
|
||||||
|
#
|
||||||
|
# Linux start script should use lf
|
||||||
|
/gradlew text eol=lf
|
||||||
|
|
||||||
|
# These are Windows script files and should use crlf
|
||||||
|
*.bat text eol=crlf
|
||||||
|
|
||||||
6
.github/workflows/pull_request.yml
vendored
6
.github/workflows/pull_request.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: PR to main
|
name: Open a PR to main
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -7,7 +7,7 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
MESSAGE: merge branch `${{ github.head_ref || github.ref_name }}` to `main`
|
MESSAGE: Merge branch `${{ github.head_ref || github.ref_name }}` to `main`
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pull-request:
|
pull-request:
|
||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Open pull request
|
- name: Open pull request
|
||||||
uses: repo-sync/pull-request@v2
|
uses: repo-sync/pull-request@v2
|
||||||
with:
|
with:
|
||||||
|
|||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
# Make sure the release step uses its own credentials:
|
# Make sure the release step uses its own credentials:
|
||||||
# https://github.com/cycjimmy/semantic-release-action#private-packages
|
# https://github.com/cycjimmy/semantic-release-action#private-packages
|
||||||
@@ -36,7 +36,7 @@ jobs:
|
|||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: ./gradlew clean --no-daemon
|
run: ./gradlew build clean --no-daemon
|
||||||
- name: Setup semantic-release
|
- name: Setup semantic-release
|
||||||
run: npm install
|
run: npm install
|
||||||
- name: Release
|
- name: Release
|
||||||
|
|||||||
@@ -7,7 +7,13 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"@semantic-release/commit-analyzer",
|
[
|
||||||
|
"@semantic-release/commit-analyzer", {
|
||||||
|
"releaseRules": [
|
||||||
|
{ "type": "build", "scope": "Needs bump", "release": "patch" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"@semantic-release/release-notes-generator",
|
"@semantic-release/release-notes-generator",
|
||||||
"@semantic-release/changelog",
|
"@semantic-release/changelog",
|
||||||
"gradle-semantic-release-plugin",
|
"gradle-semantic-release-plugin",
|
||||||
|
|||||||
639
CHANGELOG.md
639
CHANGELOG.md
@@ -1,3 +1,642 @@
|
|||||||
|
# [18.0.0-dev.6](https://github.com/ReVanced/revanced-patcher/compare/v18.0.0-dev.5...v18.0.0-dev.6) (2023-10-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Only allow setting `MethodFingerprint#result` privately ([aed1eac](https://github.com/ReVanced/revanced-patcher/commit/aed1eac3157317acf87f522750cf2f41509606c3))
|
||||||
|
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
* Change data classes to actual classes ([6192089](https://github.com/ReVanced/revanced-patcher/commit/6192089b71bdca15765369f3e607ddd1f8266205))
|
||||||
|
* Convert extension functions to member functions ([e2ca507](https://github.com/ReVanced/revanced-patcher/commit/e2ca50729da7085799c0ff6fc4f7afaf82579738))
|
||||||
|
* Move files to simplify package structure ([124a2e9](https://github.com/ReVanced/revanced-patcher/commit/124a2e9d3efb88f0f038ae306d941e918ad3ad3c))
|
||||||
|
* Remove deprecated classes and members ([a4212f6](https://github.com/ReVanced/revanced-patcher/commit/a4212f6bf952971541c4550e20f6bf57a382e19a))
|
||||||
|
|
||||||
|
|
||||||
|
* refactor!: Remove `Fingerprint` interface ([54a2f8f](https://github.com/ReVanced/revanced-patcher/commit/54a2f8f16fddf2b2ed47eb23717ba3734c4a6c5d))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* The `MethodFingerprint#result` member can now only be set inside `MethodFingerprint`.
|
||||||
|
* The `Fingerprint` interface is no longer present.
|
||||||
|
* Some extension functions are now member functions.
|
||||||
|
* This gets rid of data class members.
|
||||||
|
* Some deprecated classes and members are not present anymore.
|
||||||
|
* Classes and members have changed packages.
|
||||||
|
|
||||||
|
# [18.0.0-dev.5](https://github.com/ReVanced/revanced-patcher/compare/v18.0.0-dev.4...v18.0.0-dev.5) (2023-10-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Do not set patch fields if they are empty ([a76ac04](https://github.com/ReVanced/revanced-patcher/commit/a76ac04214a2ab91e3b2f9dddb13ed52816fe723))
|
||||||
|
|
||||||
|
# [18.0.0-dev.4](https://github.com/ReVanced/revanced-patcher/compare/v18.0.0-dev.3...v18.0.0-dev.4) (2023-10-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Use a map for `PatchOption#values` ([54ac139](https://github.com/ReVanced/revanced-patcher/commit/54ac1394a914d3eed7865ec697e8016834134911))
|
||||||
|
|
||||||
|
# [18.0.0-dev.3](https://github.com/ReVanced/revanced-patcher/compare/v18.0.0-dev.2...v18.0.0-dev.3) (2023-10-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Make `PatchOption#values` nullable ([56ce9ec](https://github.com/ReVanced/revanced-patcher/commit/56ce9ec2f98ff351c3d42df71b49e5c88f07e665))
|
||||||
|
|
||||||
|
# [18.0.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v18.0.0-dev.1...v18.0.0-dev.2) (2023-10-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
* Change `PatchOption` from abstract to open class ([09cd6aa](https://github.com/ReVanced/revanced-patcher/commit/09cd6aa568988dd5241bfa6a2e12b7926a7b0683))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Add function to reset options to their default value ([ebbaafb](https://github.com/ReVanced/revanced-patcher/commit/ebbaafb78e88f34faeafe9ff8532afe29231bd79))
|
||||||
|
* Add function to reset options to their default value ([e6de90d](https://github.com/ReVanced/revanced-patcher/commit/e6de90d300bc9c82ca1696cb898db04c65a1cd5b))
|
||||||
|
* Add getter for default option value ([c7922e9](https://github.com/ReVanced/revanced-patcher/commit/c7922e90d0c6ae83f513611c706ebea33c1a2b63))
|
||||||
|
* Name patch option value validator property correctly ([caa634f](https://github.com/ReVanced/revanced-patcher/commit/caa634fac6d7a717f54e3b015827c8858fd637b9))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This gets rid of the existing basic implementations of the `PatchOptions` type and moves extension functions.
|
||||||
|
* This changes the getter name of the property.
|
||||||
|
|
||||||
|
# [18.0.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v17.0.1-dev.1...v18.0.0-dev.1) (2023-10-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Remove patch annotation processor ([4456031](https://github.com/ReVanced/revanced-patcher/commit/445603145979a6f67823a79f9d6cd140299cff37))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* Various patch constructor signatures have changed.
|
||||||
|
|
||||||
|
## [17.0.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v17.0.0...v17.0.1-dev.1) (2023-10-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* Run the garbage collector after writing dex files ([d9fb241](https://github.com/ReVanced/revanced-patcher/commit/d9fb241d57b0c4340130c0e5900250e66730ea56))
|
||||||
|
|
||||||
|
# [17.0.0](https://github.com/ReVanced/revanced-patcher/compare/v16.0.2...v17.0.0) (2023-10-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Add option to use single threaded writer for dex files ([77dbee3](https://github.com/ReVanced/revanced-patcher/commit/77dbee3d6ae7b8dc77543e036624daa68ae63504))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This commit gets rid of deprecated constructors.
|
||||||
|
|
||||||
|
# [17.0.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v16.0.2...v17.0.0-dev.1) (2023-10-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Add option to use single threaded writer for dex files ([77dbee3](https://github.com/ReVanced/revanced-patcher/commit/77dbee3d6ae7b8dc77543e036624daa68ae63504))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This commit gets rid of deprecated constructors.
|
||||||
|
|
||||||
|
## [16.0.2](https://github.com/ReVanced/revanced-patcher/compare/v16.0.1...v16.0.2) (2023-10-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* Use a map to merge integrations classes ([6059d3c](https://github.com/ReVanced/revanced-patcher/commit/6059d3ca2685cb659023b171b95d4b9d279c6e53))
|
||||||
|
|
||||||
|
## [16.0.2-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v16.0.1...v16.0.2-dev.1) (2023-10-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* Use a map to merge integrations classes ([6059d3c](https://github.com/ReVanced/revanced-patcher/commit/6059d3ca2685cb659023b171b95d4b9d279c6e53))
|
||||||
|
|
||||||
|
## [16.0.1](https://github.com/ReVanced/revanced-patcher/compare/v16.0.0...v16.0.1) (2023-10-05)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Merge integrations when required ([06c2b76](https://github.com/ReVanced/revanced-patcher/commit/06c2b76f11ac1bfe43d51d54d425e7577ecefdf6))
|
||||||
|
|
||||||
|
## [16.0.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v16.0.0...v16.0.1-dev.1) (2023-10-05)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Merge integrations when required ([06c2b76](https://github.com/ReVanced/revanced-patcher/commit/06c2b76f11ac1bfe43d51d54d425e7577ecefdf6))
|
||||||
|
|
||||||
|
# [16.0.0](https://github.com/ReVanced/revanced-patcher/compare/v15.0.3...v16.0.0) (2023-10-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Use correct super class type ([f590436](https://github.com/ReVanced/revanced-patcher/commit/f590436399f6385c51cea54618251b5d823c31f9))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This changes the super classes of some `PatchOptionException` classes
|
||||||
|
|
||||||
|
# [16.0.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v15.0.3...v16.0.0-dev.1) (2023-10-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Use correct super class type ([f590436](https://github.com/ReVanced/revanced-patcher/commit/f590436399f6385c51cea54618251b5d823c31f9))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This changes the super classes of some `PatchOptionException` classes
|
||||||
|
|
||||||
|
## [15.0.3](https://github.com/ReVanced/revanced-patcher/compare/v15.0.2...v15.0.3) (2023-10-01)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Fix SMALI compilation on devices with RTL language ([#242](https://github.com/ReVanced/revanced-patcher/issues/242)) ([356f1f1](https://github.com/ReVanced/revanced-patcher/commit/356f1f155348347a8f318a2e024716ebf4fec99b))
|
||||||
|
|
||||||
|
## [15.0.3-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v15.0.2...v15.0.3-dev.1) (2023-09-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Fix SMALI compilation on devices with RTL language ([#242](https://github.com/ReVanced/revanced-patcher/issues/242)) ([356f1f1](https://github.com/ReVanced/revanced-patcher/commit/356f1f155348347a8f318a2e024716ebf4fec99b))
|
||||||
|
|
||||||
|
## [15.0.2](https://github.com/ReVanced/revanced-patcher/compare/v15.0.1...v15.0.2) (2023-09-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* Do not unnecessary resolve fingeprints twice ([#241](https://github.com/ReVanced/revanced-patcher/issues/241)) ([4d6e08a](https://github.com/ReVanced/revanced-patcher/commit/4d6e08a650dde6ec2e18611c5db1ab92b9a61dd1))
|
||||||
|
|
||||||
|
## [15.0.2-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v15.0.1...v15.0.2-dev.1) (2023-09-26)
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* Do not unnecessary resolve fingeprints twice ([#241](https://github.com/ReVanced/revanced-patcher/issues/241)) ([4d6e08a](https://github.com/ReVanced/revanced-patcher/commit/4d6e08a650dde6ec2e18611c5db1ab92b9a61dd1))
|
||||||
|
|
||||||
|
## [15.0.1](https://github.com/ReVanced/revanced-patcher/compare/v15.0.0...v15.0.1) (2023-09-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Remove log management ([d51bc32](https://github.com/ReVanced/revanced-patcher/commit/d51bc32e37a865194c3825471085b3ccf8c78421))
|
||||||
|
|
||||||
|
## [15.0.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v15.0.0...v15.0.1-dev.1) (2023-09-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Remove log management ([d51bc32](https://github.com/ReVanced/revanced-patcher/commit/d51bc32e37a865194c3825471085b3ccf8c78421))
|
||||||
|
|
||||||
|
# [15.0.0](https://github.com/ReVanced/revanced-patcher/compare/v14.2.2...v15.0.0) (2023-09-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Account for source patch dependency for tests ([6918418](https://github.com/ReVanced/revanced-patcher/commit/69184187d90f126478d2f49415c1e3381217557f))
|
||||||
|
* Always make the generated patch depend on the source patch ([8de3063](https://github.com/ReVanced/revanced-patcher/commit/8de30633ae6eb7acf7f0a351e26d4a6c2fdbdfec))
|
||||||
|
* Catch correct exception ([637d487](https://github.com/ReVanced/revanced-patcher/commit/637d48746ff8694e01c5aead1c75a9a1efeb5ac8))
|
||||||
|
* Delegate `PatchBundleLoader` by mutable set of patches ([9a109c1](https://github.com/ReVanced/revanced-patcher/commit/9a109c129b135a634be1aad4130a06d9e8e96ecd))
|
||||||
|
* Do not resolve the proxied patch to the proxy in the dependency list ([e112837](https://github.com/ReVanced/revanced-patcher/commit/e11283744a21fe2d09435e99d6924462b6aac3b8))
|
||||||
|
* Do not set `CompatiblePackage.versions` if `@CompatiblePackage.versions` is empty ([6b1e0a1](https://github.com/ReVanced/revanced-patcher/commit/6b1e0a16568124e9f82fb5740353360fa8ec614a))
|
||||||
|
* Filter for patches correctly ([4bc4b0d](https://github.com/ReVanced/revanced-patcher/commit/4bc4b0dc0104073b62528d02a88383cecd7a50e7))
|
||||||
|
* Find dependency in `context.allPatches` ([670f015](https://github.com/ReVanced/revanced-patcher/commit/670f0153de10c6f0db25b08df1c01a2905037f84))
|
||||||
|
* Log the correct patch names ([9fdb8f0](https://github.com/ReVanced/revanced-patcher/commit/9fdb8f087f62babf6081879db65c80db639aa0a7))
|
||||||
|
* Make `CompatiblePackage.versions` a property ([67b7dff](https://github.com/ReVanced/revanced-patcher/commit/67b7dff67a212b4fc30eb4f0cbe58f0ba09fb09a))
|
||||||
|
* Print patch name instead of class name ([4e7811e](https://github.com/ReVanced/revanced-patcher/commit/4e7811ea07762667a1f22526dc176022038f60eb))
|
||||||
|
* Print stack trace of exception ([aa71146](https://github.com/ReVanced/revanced-patcher/commit/aa71146b1bf4ffebcc81a1663e15abae89e97ff0))
|
||||||
|
* Run code-block if `executablePatches` does not yet contain `patch` ([1d7aeca](https://github.com/ReVanced/revanced-patcher/commit/1d7aeca696be873dfaf88eaa6d312949a3b8572b))
|
||||||
|
* Suppress logger when loading patches in `PatchBundleLoader` ([72c9eb2](https://github.com/ReVanced/revanced-patcher/commit/72c9eb212985f99f3390cf1faa10ab547d2dbe7e))
|
||||||
|
* Use correct module name ([080fbe9](https://github.com/ReVanced/revanced-patcher/commit/080fbe9feb9d4ea9ec4e599ecef296eacd803b05))
|
||||||
|
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
* Internalize processor constructor ([a802d0d](https://github.com/ReVanced/revanced-patcher/commit/a802d0df463695976e85d8391762942eb977920b))
|
||||||
|
|
||||||
|
|
||||||
|
* feat Use `Set` as super type for `PatchBundleLoader` ([4b76d19](https://github.com/ReVanced/revanced-patcher/commit/4b76d1959691babf8c99d3d5235df4a4388956f0))
|
||||||
|
* feat!: Add patch annotation processor ([3fc6a13](https://github.com/ReVanced/revanced-patcher/commit/3fc6a139eef67237c116fb4e3e29bf9542d3a981))
|
||||||
|
* feat!: Remove patch annotations ([3b4db3d](https://github.com/ReVanced/revanced-patcher/commit/3b4db3ddb72cdcee8af2f787eadf58eeb37543de))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Add patch annotation processor ([#231](https://github.com/ReVanced/revanced-patcher/issues/231)) ([a29931f](https://github.com/ReVanced/revanced-patcher/commit/a29931f2ec0a666dba209b54855425d9dc2f4462))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This gets rid of the public constructor.
|
||||||
|
* `PatchBundleLoader` is not a map anymore
|
||||||
|
* This renames packages and the Maven package.
|
||||||
|
* The manifest for patches has been removed, and the properties have been added to patches. Patches are now `OptionsContainer`. The `@Patch` annotation has been removed in favour of the `@Patch` annotation from the annotation processor.
|
||||||
|
* Patch annotations have been removed. PatcherException is now thrown in various places. PatchBundleLoader is now a map of patches associated by their name. Patches are now instances.
|
||||||
|
|
||||||
|
# [15.0.0-dev.4](https://github.com/ReVanced/revanced-patcher/compare/v15.0.0-dev.3...v15.0.0-dev.4) (2023-09-13)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Account for source patch dependency for tests ([6918418](https://github.com/ReVanced/revanced-patcher/commit/69184187d90f126478d2f49415c1e3381217557f))
|
||||||
|
* Always make the generated patch depend on the source patch ([8de3063](https://github.com/ReVanced/revanced-patcher/commit/8de30633ae6eb7acf7f0a351e26d4a6c2fdbdfec))
|
||||||
|
* Catch correct exception ([637d487](https://github.com/ReVanced/revanced-patcher/commit/637d48746ff8694e01c5aead1c75a9a1efeb5ac8))
|
||||||
|
* Delegate `PatchBundleLoader` by mutable set of patches ([9a109c1](https://github.com/ReVanced/revanced-patcher/commit/9a109c129b135a634be1aad4130a06d9e8e96ecd))
|
||||||
|
* Do not resolve the proxied patch to the proxy in the dependency list ([e112837](https://github.com/ReVanced/revanced-patcher/commit/e11283744a21fe2d09435e99d6924462b6aac3b8))
|
||||||
|
* Do not set `CompatiblePackage.versions` if `@CompatiblePackage.versions` is empty ([6b1e0a1](https://github.com/ReVanced/revanced-patcher/commit/6b1e0a16568124e9f82fb5740353360fa8ec614a))
|
||||||
|
* Filter for patches correctly ([4bc4b0d](https://github.com/ReVanced/revanced-patcher/commit/4bc4b0dc0104073b62528d02a88383cecd7a50e7))
|
||||||
|
* Find dependency in `context.allPatches` ([670f015](https://github.com/ReVanced/revanced-patcher/commit/670f0153de10c6f0db25b08df1c01a2905037f84))
|
||||||
|
* Log the correct patch names ([9fdb8f0](https://github.com/ReVanced/revanced-patcher/commit/9fdb8f087f62babf6081879db65c80db639aa0a7))
|
||||||
|
* Print patch name instead of class name ([4e7811e](https://github.com/ReVanced/revanced-patcher/commit/4e7811ea07762667a1f22526dc176022038f60eb))
|
||||||
|
* Print stack trace of exception ([aa71146](https://github.com/ReVanced/revanced-patcher/commit/aa71146b1bf4ffebcc81a1663e15abae89e97ff0))
|
||||||
|
* Run code-block if `executablePatches` does not yet contain `patch` ([1d7aeca](https://github.com/ReVanced/revanced-patcher/commit/1d7aeca696be873dfaf88eaa6d312949a3b8572b))
|
||||||
|
* Suppress logger when loading patches in `PatchBundleLoader` ([72c9eb2](https://github.com/ReVanced/revanced-patcher/commit/72c9eb212985f99f3390cf1faa10ab547d2dbe7e))
|
||||||
|
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
* Internalize processor constructor ([a802d0d](https://github.com/ReVanced/revanced-patcher/commit/a802d0df463695976e85d8391762942eb977920b))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This gets rid of the public constructor.
|
||||||
|
|
||||||
|
# [15.0.0-dev.3](https://github.com/ReVanced/revanced-patcher/compare/v15.0.0-dev.2...v15.0.0-dev.3) (2023-09-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Make `CompatiblePackage.versions` a property ([67b7dff](https://github.com/ReVanced/revanced-patcher/commit/67b7dff67a212b4fc30eb4f0cbe58f0ba09fb09a))
|
||||||
|
* Use correct module name ([080fbe9](https://github.com/ReVanced/revanced-patcher/commit/080fbe9feb9d4ea9ec4e599ecef296eacd803b05))
|
||||||
|
|
||||||
|
|
||||||
|
* feat Use `Set` as super type for `PatchBundleLoader` ([4b76d19](https://github.com/ReVanced/revanced-patcher/commit/4b76d1959691babf8c99d3d5235df4a4388956f0))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* `PatchBundleLoader` is not a map anymore
|
||||||
|
* This renames packages and the Maven package.
|
||||||
|
|
||||||
|
# [15.0.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v15.0.0-dev.1...v15.0.0-dev.2) (2023-09-06)
|
||||||
|
|
||||||
|
# [15.0.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v14.2.2...v15.0.0-dev.1) (2023-09-04)
|
||||||
|
|
||||||
|
|
||||||
|
* feat!: Add patch annotation processor ([3fc6a13](https://github.com/ReVanced/revanced-patcher/commit/3fc6a139eef67237c116fb4e3e29bf9542d3a981))
|
||||||
|
* feat!: Remove patch annotations ([3b4db3d](https://github.com/ReVanced/revanced-patcher/commit/3b4db3ddb72cdcee8af2f787eadf58eeb37543de))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Add patch annotation processor ([#231](https://github.com/ReVanced/revanced-patcher/issues/231)) ([a29931f](https://github.com/ReVanced/revanced-patcher/commit/a29931f2ec0a666dba209b54855425d9dc2f4462))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* The manifest for patches has been removed, and the properties have been added to patches. Patches are now `OptionsContainer`. The `@Patch` annotation has been removed in favour of the `@Patch` annotation from the annotation processor.
|
||||||
|
* Patch annotations have been removed. PatcherException is now thrown in various places. PatchBundleLoader is now a map of patches associated by their name. Patches are now instances.
|
||||||
|
|
||||||
|
## [14.2.2](https://github.com/ReVanced/revanced-patcher/compare/v14.2.1...v14.2.2) (2023-08-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* allow setting `DexClassLoader.optimizedDirectory` ([11a3378](https://github.com/ReVanced/revanced-patcher/commit/11a337865947a6ac74a63ebb3f3f9bc2610f7771))
|
||||||
|
|
||||||
|
## [14.2.2-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v14.2.1...v14.2.2-dev.1) (2023-08-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* allow setting `DexClassLoader.optimizedDirectory` ([11a3378](https://github.com/ReVanced/revanced-patcher/commit/11a337865947a6ac74a63ebb3f3f9bc2610f7771))
|
||||||
|
|
||||||
|
## [14.2.1](https://github.com/ReVanced/revanced-patcher/compare/v14.2.0...v14.2.1) (2023-08-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* do not flag resource table as sparse when main package is not loaded ([b832812](https://github.com/ReVanced/revanced-patcher/commit/b832812767a06ec6ec232291e6d14c8c2f14118c))
|
||||||
|
|
||||||
|
## [14.2.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v14.2.0...v14.2.1-dev.1) (2023-08-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* do not flag resource table as sparse when main package is not loaded ([b832812](https://github.com/ReVanced/revanced-patcher/commit/b832812767a06ec6ec232291e6d14c8c2f14118c))
|
||||||
|
|
||||||
|
# [14.2.0](https://github.com/ReVanced/revanced-patcher/compare/v14.1.0...v14.2.0) (2023-08-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* load patches in lexicographical order ([e8f2087](https://github.com/ReVanced/revanced-patcher/commit/e8f2087a6ffa6077fb3a6a69e29f3aec72e2fc1b))
|
||||||
|
* log when merging integrations ([983563e](https://github.com/ReVanced/revanced-patcher/commit/983563efb6d7c8d289464b8bf71a016b8a735630))
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* compare types of classes ([55d6945](https://github.com/ReVanced/revanced-patcher/commit/55d694579ac2718b9e2c61ca5f38419c3775ef87))
|
||||||
|
|
||||||
|
# [14.2.0-dev.3](https://github.com/ReVanced/revanced-patcher/compare/v14.2.0-dev.2...v14.2.0-dev.3) (2023-08-26)
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* compare types of classes ([55d6945](https://github.com/ReVanced/revanced-patcher/commit/55d694579ac2718b9e2c61ca5f38419c3775ef87))
|
||||||
|
|
||||||
|
# [14.2.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v14.2.0-dev.1...v14.2.0-dev.2) (2023-08-26)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* log when merging integrations ([983563e](https://github.com/ReVanced/revanced-patcher/commit/983563efb6d7c8d289464b8bf71a016b8a735630))
|
||||||
|
|
||||||
|
# [14.2.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v14.1.0...v14.2.0-dev.1) (2023-08-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* load patches in lexicographical order ([e8f2087](https://github.com/ReVanced/revanced-patcher/commit/e8f2087a6ffa6077fb3a6a69e29f3aec72e2fc1b))
|
||||||
|
|
||||||
|
# [14.1.0](https://github.com/ReVanced/revanced-patcher/compare/v14.0.0...v14.1.0) (2023-08-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* move version properties file to correct package ([e985676](https://github.com/ReVanced/revanced-patcher/commit/e985676c2d8e5d6cb907d371de30428caaa6da43))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* properly make use of logging facade ([ba56a6a](https://github.com/ReVanced/revanced-patcher/commit/ba56a6a2eef503c0d6cdd846ddce2e1474d8ed1a))
|
||||||
|
|
||||||
|
# [14.1.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v14.0.1-dev.1...v14.1.0-dev.1) (2023-08-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* properly make use of logging facade ([ba56a6a](https://github.com/ReVanced/revanced-patcher/commit/ba56a6a2eef503c0d6cdd846ddce2e1474d8ed1a))
|
||||||
|
|
||||||
|
## [14.0.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v14.0.0...v14.0.1-dev.1) (2023-08-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* move version properties file to correct package ([e985676](https://github.com/ReVanced/revanced-patcher/commit/e985676c2d8e5d6cb907d371de30428caaa6da43))
|
||||||
|
|
||||||
|
# [14.0.0](https://github.com/ReVanced/revanced-patcher/compare/v13.0.0...v14.0.0) (2023-08-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* log decoding resources after logging deleting resource cache directory ([db62a16](https://github.com/ReVanced/revanced-patcher/commit/db62a1607b4a9d6256b5f5153decb088d9680553))
|
||||||
|
* only emit closed patches that did not throw an exception with the `@Patch` annotation ([5938f6b](https://github.com/ReVanced/revanced-patcher/commit/5938f6b7ea25103a0a1b56ceebe49139bc80c6f5))
|
||||||
|
* supply the parent classloader to `DexClassLoader` ([0f15077](https://github.com/ReVanced/revanced-patcher/commit/0f15077225600b65200022c1a318e504deb472b9))
|
||||||
|
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
* improve structure and public API ([6b8977f](https://github.com/ReVanced/revanced-patcher/commit/6b8977f17854ef0344d868e6391cb18134eceadc))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* do not log instantiation of ReVanced Patcher ([273dd8d](https://github.com/ReVanced/revanced-patcher/commit/273dd8d388f8e9b7436c6d6145a94c12c1fabe55))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* Various public APIs have been changed. The `Version` annotation has been removed. Patches do not return anything anymore and instead throw `PatchException`. Multiple patch bundles can now be loaded in a single ClassLoader to bypass class loader isolation.
|
||||||
|
|
||||||
|
# [14.0.0-dev.4](https://github.com/ReVanced/revanced-patcher/compare/v14.0.0-dev.3...v14.0.0-dev.4) (2023-08-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* only emit closed patches that did not throw an exception with the `@Patch` annotation ([5938f6b](https://github.com/ReVanced/revanced-patcher/commit/5938f6b7ea25103a0a1b56ceebe49139bc80c6f5))
|
||||||
|
|
||||||
|
# [14.0.0-dev.3](https://github.com/ReVanced/revanced-patcher/compare/v14.0.0-dev.2...v14.0.0-dev.3) (2023-08-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* supply the parent classloader to `DexClassLoader` ([0f15077](https://github.com/ReVanced/revanced-patcher/commit/0f15077225600b65200022c1a318e504deb472b9))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* do not log instantiation of ReVanced Patcher ([273dd8d](https://github.com/ReVanced/revanced-patcher/commit/273dd8d388f8e9b7436c6d6145a94c12c1fabe55))
|
||||||
|
|
||||||
|
# [14.0.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v14.0.0-dev.1...v14.0.0-dev.2) (2023-08-19)
|
||||||
|
|
||||||
|
# [14.0.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v13.0.0...v14.0.0-dev.1) (2023-08-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* log decoding resources after logging deleting resource cache directory ([db62a16](https://github.com/ReVanced/revanced-patcher/commit/db62a1607b4a9d6256b5f5153decb088d9680553))
|
||||||
|
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
* improve structure and public API ([6b8977f](https://github.com/ReVanced/revanced-patcher/commit/6b8977f17854ef0344d868e6391cb18134eceadc))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* Various public APIs have been changed. The `Version` annotation has been removed. Patches do not return anything anymore and instead throw `PatchException`. Multiple patch bundles can now be loaded in a single ClassLoader to bypass class loader isolation.
|
||||||
|
|
||||||
|
# [13.0.0](https://github.com/ReVanced/revanced-patcher/compare/v12.1.1...v13.0.0) (2023-08-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* decode in correct order ([8fb2f2d](https://github.com/ReVanced/revanced-patcher/commit/8fb2f2dc1d3b9b1e9fd13b39485985d2886d52ae))
|
||||||
|
* disable correct loggers ([c2d89c6](https://github.com/ReVanced/revanced-patcher/commit/c2d89c622e06e58e5042e1a00ef67cee8a246e53))
|
||||||
|
* get framework ids to compile resources ([f2cb7ee](https://github.com/ReVanced/revanced-patcher/commit/f2cb7ee7dffa573c31df497cf235a3f5d120f91f))
|
||||||
|
* only enable logging for ReVanced ([783ccf8](https://github.com/ReVanced/revanced-patcher/commit/783ccf8529f5d16aa463982da6977328306232bb))
|
||||||
|
* set package metadata correctly ([02d6ff1](https://github.com/ReVanced/revanced-patcher/commit/02d6ff15fe87c2352de29749610e9d72db8ba418))
|
||||||
|
|
||||||
|
|
||||||
|
* build(Needs bump)!: Bump dependencies ([d5f89a9](https://github.com/ReVanced/revanced-patcher/commit/d5f89a903f019c199bdb27a50287124fc4b4978e))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This bump updates smali, a crucial dependency
|
||||||
|
|
||||||
|
# [13.0.0-dev.3](https://github.com/ReVanced/revanced-patcher/compare/v13.0.0-dev.2...v13.0.0-dev.3) (2023-08-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* decode in correct order ([8fb2f2d](https://github.com/ReVanced/revanced-patcher/commit/8fb2f2dc1d3b9b1e9fd13b39485985d2886d52ae))
|
||||||
|
* only enable logging for ReVanced ([783ccf8](https://github.com/ReVanced/revanced-patcher/commit/783ccf8529f5d16aa463982da6977328306232bb))
|
||||||
|
|
||||||
|
# [13.0.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v13.0.0-dev.1...v13.0.0-dev.2) (2023-08-12)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* disable correct loggers ([c2d89c6](https://github.com/ReVanced/revanced-patcher/commit/c2d89c622e06e58e5042e1a00ef67cee8a246e53))
|
||||||
|
* get framework ids to compile resources ([f2cb7ee](https://github.com/ReVanced/revanced-patcher/commit/f2cb7ee7dffa573c31df497cf235a3f5d120f91f))
|
||||||
|
* set package metadata correctly ([02d6ff1](https://github.com/ReVanced/revanced-patcher/commit/02d6ff15fe87c2352de29749610e9d72db8ba418))
|
||||||
|
|
||||||
|
# [13.0.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v12.1.1...v13.0.0-dev.1) (2023-08-11)
|
||||||
|
|
||||||
|
|
||||||
|
* build(Needs bump)!: Bump dependencies ([d5f89a9](https://github.com/ReVanced/revanced-patcher/commit/d5f89a903f019c199bdb27a50287124fc4b4978e))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This bump updates smali, a crucial dependency
|
||||||
|
|
||||||
|
## [12.1.1](https://github.com/ReVanced/revanced-patcher/compare/v12.1.0...v12.1.1) (2023-08-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* clear method lookup maps before initializing them ([#210](https://github.com/ReVanced/revanced-patcher/issues/210)) ([746544f](https://github.com/ReVanced/revanced-patcher/commit/746544f9d51d1013bb160075709cd26bffd425b3))
|
||||||
|
|
||||||
|
## [12.1.1-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v12.1.1-dev.1...v12.1.1-dev.2) (2023-08-03)
|
||||||
|
|
||||||
|
## [12.1.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v12.1.0...v12.1.1-dev.1) (2023-08-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* clear method lookup maps before initializing them ([#210](https://github.com/ReVanced/revanced-patcher/issues/210)) ([746544f](https://github.com/ReVanced/revanced-patcher/commit/746544f9d51d1013bb160075709cd26bffd425b3))
|
||||||
|
|
||||||
|
# [12.1.0](https://github.com/ReVanced/revanced-patcher/compare/v12.0.0...v12.1.0) (2023-08-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add `MutableMethod.getInstructions` extension function ([fae4029](https://github.com/ReVanced/revanced-patcher/commit/fae4029cfccfad7aa3dd8f7fbef1c63ee26b85b3))
|
||||||
|
|
||||||
|
# [12.1.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v12.1.0-dev.1...v12.1.0-dev.2) (2023-08-03)
|
||||||
|
|
||||||
|
# [12.1.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v12.0.0...v12.1.0-dev.1) (2023-08-01)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add `MutableMethod.getInstructions` extension function ([fae4029](https://github.com/ReVanced/revanced-patcher/commit/fae4029cfccfad7aa3dd8f7fbef1c63ee26b85b3))
|
||||||
|
|
||||||
|
# [12.0.0](https://github.com/ReVanced/revanced-patcher/compare/v11.0.4...v12.0.0) (2023-07-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* correct access flags of `PackageMetadata` ([416d691](https://github.com/ReVanced/revanced-patcher/commit/416d69142f50dab49c9ea3f027e9d53e4777f257))
|
||||||
|
* set resource table via resource decoder ([e0f8e1b](https://github.com/ReVanced/revanced-patcher/commit/e0f8e1b71a295948b610029c89a48f52762396b6))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Deprecate `Version` annotation ([c9bbcf2](https://github.com/ReVanced/revanced-patcher/commit/c9bbcf2bf2b0f50ab9100380a3a66c6346ad42ac))
|
||||||
|
* remove `Path` option ([#202](https://github.com/ReVanced/revanced-patcher/issues/202)) ([69e4a49](https://github.com/ReVanced/revanced-patcher/commit/69e4a490659ebc4fb4bf46148634f4b064ef1713))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This removes the previously available `Path` option
|
||||||
|
|
||||||
|
# [12.0.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v12.0.0-dev.1...v12.0.0-dev.2) (2023-07-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Deprecate `Version` annotation ([400442f](https://github.com/ReVanced/revanced-patcher/commit/400442f70ee56cafd4493b2ce64a294db9836509))
|
||||||
|
|
||||||
|
# [12.0.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v11.0.4...v12.0.0-dev.1) (2023-07-26)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* correct access flags of `PackageMetadata` ([416d691](https://github.com/ReVanced/revanced-patcher/commit/416d69142f50dab49c9ea3f027e9d53e4777f257))
|
||||||
|
* set resource table via resource decoder ([e0f8e1b](https://github.com/ReVanced/revanced-patcher/commit/e0f8e1b71a295948b610029c89a48f52762396b6))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* remove `Path` option ([#202](https://github.com/ReVanced/revanced-patcher/issues/202)) ([69e4a49](https://github.com/ReVanced/revanced-patcher/commit/69e4a490659ebc4fb4bf46148634f4b064ef1713))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* This removes the previously available `Path` option
|
||||||
|
|
||||||
|
## [11.0.4](https://github.com/revanced/revanced-patcher/compare/v11.0.3...v11.0.4) (2023-07-01)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* clear method lookup maps ([#198](https://github.com/revanced/revanced-patcher/issues/198)) ([9d81baf](https://github.com/revanced/revanced-patcher/commit/9d81baf4b4ca7514f8a1009e72218638609a7c7f))
|
||||||
|
|
||||||
|
## [11.0.4-dev.1](https://github.com/revanced/revanced-patcher/compare/v11.0.3...v11.0.4-dev.1) (2023-07-01)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* clear method lookup maps ([#198](https://github.com/revanced/revanced-patcher/issues/198)) ([9d81baf](https://github.com/revanced/revanced-patcher/commit/9d81baf4b4ca7514f8a1009e72218638609a7c7f))
|
||||||
|
|
||||||
|
## [11.0.3](https://github.com/revanced/revanced-patcher/compare/v11.0.2...v11.0.3) (2023-06-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* NPE on method lookup ([#195](https://github.com/revanced/revanced-patcher/issues/195)) ([fcef434](https://github.com/revanced/revanced-patcher/commit/fcef4342e8bde73945e8315aef6337cc8a8d8572))
|
||||||
|
|
||||||
|
## [11.0.3-dev.1](https://github.com/revanced/revanced-patcher/compare/v11.0.2...v11.0.3-dev.1) (2023-06-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* NPE on method lookup ([#195](https://github.com/revanced/revanced-patcher/issues/195)) ([fcef434](https://github.com/revanced/revanced-patcher/commit/fcef4342e8bde73945e8315aef6337cc8a8d8572))
|
||||||
|
|
||||||
|
## [11.0.2](https://github.com/revanced/revanced-patcher/compare/v11.0.1...v11.0.2) (2023-06-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* catch exceptions from closing patches ([d5d6f85](https://github.com/revanced/revanced-patcher/commit/d5d6f85084c03ed9c776632823ca12394a716167))
|
||||||
|
* do not load annotations as patches ([519359a](https://github.com/revanced/revanced-patcher/commit/519359a9eb0e9dfa390c5016e9fe4a7490b8ab18))
|
||||||
|
* only close succeeded patches ([b8151eb](https://github.com/revanced/revanced-patcher/commit/b8151ebccb5b27dd9e06fa63235cf9baeef1c0ee))
|
||||||
|
* use `versionCode` if `versionName` is unavailable ([6e1b647](https://github.com/revanced/revanced-patcher/commit/6e1b6479b677657c226693e9cc6b63f4ef2ee060))
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* resolve fingerprints using method maps ([#185](https://github.com/revanced/revanced-patcher/issues/185)) ([d718134](https://github.com/revanced/revanced-patcher/commit/d718134ab26423e02708e01eba711737f9260ba0))
|
||||||
|
|
||||||
|
## [11.0.2-dev.4](https://github.com/revanced/revanced-patcher/compare/v11.0.2-dev.3...v11.0.2-dev.4) (2023-06-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* do not load annotations as patches ([519359a](https://github.com/revanced/revanced-patcher/commit/519359a9eb0e9dfa390c5016e9fe4a7490b8ab18))
|
||||||
|
|
||||||
## [11.0.2-dev.3](https://github.com/revanced/revanced-patcher/compare/v11.0.2-dev.2...v11.0.2-dev.3) (2023-06-27)
|
## [11.0.2-dev.3](https://github.com/revanced/revanced-patcher/compare/v11.0.2-dev.2...v11.0.2-dev.3) (2023-06-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
769
api/revanced-patcher.api
Normal file
769
api/revanced-patcher.api
Normal file
@@ -0,0 +1,769 @@
|
|||||||
|
public abstract interface class app/revanced/patcher/IntegrationsConsumer {
|
||||||
|
public abstract fun acceptIntegrations (Ljava/util/List;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/PackageMetadata {
|
||||||
|
public final fun getPackageName ()Ljava/lang/String;
|
||||||
|
public final fun getPackageVersion ()Ljava/lang/String;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class app/revanced/patcher/PatchBundleLoader : java/util/Set, kotlin/jvm/internal/markers/KMappedMarker {
|
||||||
|
public synthetic fun <init> (Ljava/lang/ClassLoader;[Ljava/io/File;Lkotlin/jvm/functions/Function1;Ljava/util/Set;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
public fun add (Lapp/revanced/patcher/patch/Patch;)Z
|
||||||
|
public synthetic fun add (Ljava/lang/Object;)Z
|
||||||
|
public fun addAll (Ljava/util/Collection;)Z
|
||||||
|
public fun clear ()V
|
||||||
|
public fun contains (Lapp/revanced/patcher/patch/Patch;)Z
|
||||||
|
public final fun contains (Ljava/lang/Object;)Z
|
||||||
|
public fun containsAll (Ljava/util/Collection;)Z
|
||||||
|
public fun getSize ()I
|
||||||
|
public fun isEmpty ()Z
|
||||||
|
public fun iterator ()Ljava/util/Iterator;
|
||||||
|
public fun remove (Ljava/lang/Object;)Z
|
||||||
|
public fun removeAll (Ljava/util/Collection;)Z
|
||||||
|
public fun retainAll (Ljava/util/Collection;)Z
|
||||||
|
public final fun size ()I
|
||||||
|
public fun toArray ()[Ljava/lang/Object;
|
||||||
|
public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/PatchBundleLoader$Dex : app/revanced/patcher/PatchBundleLoader {
|
||||||
|
public fun <init> ([Ljava/io/File;)V
|
||||||
|
public fun <init> ([Ljava/io/File;Ljava/io/File;)V
|
||||||
|
public synthetic fun <init> ([Ljava/io/File;Ljava/io/File;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/PatchBundleLoader$Jar : app/revanced/patcher/PatchBundleLoader {
|
||||||
|
public fun <init> ([Ljava/io/File;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract interface class app/revanced/patcher/PatchExecutorFunction : java/util/function/Function {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/Patcher : app/revanced/patcher/IntegrationsConsumer, app/revanced/patcher/PatchExecutorFunction, app/revanced/patcher/PatchesConsumer, java/io/Closeable, java/util/function/Supplier {
|
||||||
|
public fun <init> (Lapp/revanced/patcher/PatcherOptions;)V
|
||||||
|
public fun acceptIntegrations (Ljava/util/List;)V
|
||||||
|
public fun acceptPatches (Ljava/util/List;)V
|
||||||
|
public synthetic fun apply (Ljava/lang/Object;)Ljava/lang/Object;
|
||||||
|
public fun apply (Z)Lkotlinx/coroutines/flow/Flow;
|
||||||
|
public fun close ()V
|
||||||
|
public fun get ()Lapp/revanced/patcher/PatcherResult;
|
||||||
|
public synthetic fun get ()Ljava/lang/Object;
|
||||||
|
public final fun getContext ()Lapp/revanced/patcher/PatcherContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/PatcherContext {
|
||||||
|
public final fun getPackageMetadata ()Lapp/revanced/patcher/PackageMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class app/revanced/patcher/PatcherException : java/lang/Exception {
|
||||||
|
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/Throwable;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
public synthetic fun <init> (Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/PatcherException$CircularDependencyException : app/revanced/patcher/PatcherException {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/PatcherOptions {
|
||||||
|
public fun <init> (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;Z)V
|
||||||
|
public synthetic fun <init> (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
public final fun copy (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;Z)Lapp/revanced/patcher/PatcherOptions;
|
||||||
|
public static synthetic fun copy$default (Lapp/revanced/patcher/PatcherOptions;Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Lapp/revanced/patcher/PatcherOptions;
|
||||||
|
public fun equals (Ljava/lang/Object;)Z
|
||||||
|
public fun hashCode ()I
|
||||||
|
public final fun recreateResourceCacheDirectory ()Ljava/io/File;
|
||||||
|
public fun toString ()Ljava/lang/String;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/PatcherResult {
|
||||||
|
public fun <init> (Ljava/util/List;Ljava/io/File;Ljava/util/List;)V
|
||||||
|
public synthetic fun <init> (Ljava/util/List;Ljava/io/File;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
public final fun component1 ()Ljava/util/List;
|
||||||
|
public final fun component2 ()Ljava/io/File;
|
||||||
|
public final fun component3 ()Ljava/util/List;
|
||||||
|
public final fun copy (Ljava/util/List;Ljava/io/File;Ljava/util/List;)Lapp/revanced/patcher/PatcherResult;
|
||||||
|
public static synthetic fun copy$default (Lapp/revanced/patcher/PatcherResult;Ljava/util/List;Ljava/io/File;Ljava/util/List;ILjava/lang/Object;)Lapp/revanced/patcher/PatcherResult;
|
||||||
|
public fun equals (Ljava/lang/Object;)Z
|
||||||
|
public final fun getDexFiles ()Ljava/util/List;
|
||||||
|
public final fun getDoNotCompress ()Ljava/util/List;
|
||||||
|
public final fun getResourceFile ()Ljava/io/File;
|
||||||
|
public fun hashCode ()I
|
||||||
|
public fun toString ()Ljava/lang/String;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/PatcherResult$PatchedDexFile {
|
||||||
|
public fun <init> (Ljava/lang/String;Ljava/io/InputStream;)V
|
||||||
|
public final fun getName ()Ljava/lang/String;
|
||||||
|
public final fun getStream ()Ljava/io/InputStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract interface class app/revanced/patcher/PatchesConsumer {
|
||||||
|
public abstract fun acceptPatches (Ljava/util/List;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/data/BytecodeContext : app/revanced/patcher/data/Context {
|
||||||
|
public final fun findClass (Ljava/lang/String;)Lapp/revanced/patcher/util/proxy/ClassProxy;
|
||||||
|
public final fun findClass (Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/util/proxy/ClassProxy;
|
||||||
|
public synthetic fun get ()Ljava/lang/Object;
|
||||||
|
public fun get ()Ljava/util/List;
|
||||||
|
public final fun getClasses ()Lapp/revanced/patcher/util/ProxyClassList;
|
||||||
|
public final fun proxy (Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Lapp/revanced/patcher/util/proxy/ClassProxy;
|
||||||
|
public final fun toMethodWalker (Lcom/android/tools/smali/dexlib2/iface/Method;)Lapp/revanced/patcher/util/method/MethodWalker;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract interface class app/revanced/patcher/data/Context : java/util/function/Supplier {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/data/ResourceContext : app/revanced/patcher/data/Context, java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker {
|
||||||
|
public fun get ()Ljava/io/File;
|
||||||
|
public synthetic fun get ()Ljava/lang/Object;
|
||||||
|
public final fun get (Ljava/lang/String;)Ljava/io/File;
|
||||||
|
public final fun getXmlEditor ()Lapp/revanced/patcher/data/ResourceContext$XmlFileHolder;
|
||||||
|
public fun iterator ()Ljava/util/Iterator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/data/ResourceContext$XmlFileHolder {
|
||||||
|
public fun <init> (Lapp/revanced/patcher/data/ResourceContext;)V
|
||||||
|
public final fun get (Ljava/io/InputStream;)Lapp/revanced/patcher/util/DomFileEditor;
|
||||||
|
public final fun get (Ljava/lang/String;)Lapp/revanced/patcher/util/DomFileEditor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/extensions/ExtensionsKt {
|
||||||
|
public static final fun newLabel (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;I)Lcom/android/tools/smali/dexlib2/builder/Label;
|
||||||
|
public static final fun or (ILcom/android/tools/smali/dexlib2/AccessFlags;)I
|
||||||
|
public static final fun or (Lcom/android/tools/smali/dexlib2/AccessFlags;I)I
|
||||||
|
public static final fun or (Lcom/android/tools/smali/dexlib2/AccessFlags;Lcom/android/tools/smali/dexlib2/AccessFlags;)I
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/extensions/InstructionExtensions {
|
||||||
|
public static final field INSTANCE Lapp/revanced/patcher/extensions/InstructionExtensions;
|
||||||
|
public final fun addInstruction (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILcom/android/tools/smali/dexlib2/builder/BuilderInstruction;)V
|
||||||
|
public final fun addInstruction (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILjava/lang/String;)V
|
||||||
|
public final fun addInstruction (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Lcom/android/tools/smali/dexlib2/builder/BuilderInstruction;)V
|
||||||
|
public final fun addInstruction (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Ljava/lang/String;)V
|
||||||
|
public final fun addInstructions (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILjava/lang/String;)V
|
||||||
|
public final fun addInstructions (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILjava/util/List;)V
|
||||||
|
public final fun addInstructions (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Ljava/lang/String;)V
|
||||||
|
public final fun addInstructions (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Ljava/util/List;)V
|
||||||
|
public final fun addInstructions (Lcom/android/tools/smali/dexlib2/builder/MutableMethodImplementation;ILjava/util/List;)V
|
||||||
|
public final fun addInstructions (Lcom/android/tools/smali/dexlib2/builder/MutableMethodImplementation;Ljava/util/List;)V
|
||||||
|
public final fun addInstructionsWithLabels (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILjava/lang/String;[Lapp/revanced/patcher/util/smali/ExternalLabel;)V
|
||||||
|
public final fun getInstruction (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;I)Lcom/android/tools/smali/dexlib2/builder/BuilderInstruction;
|
||||||
|
public final fun getInstruction (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;I)Ljava/lang/Object;
|
||||||
|
public final fun getInstruction (Lcom/android/tools/smali/dexlib2/builder/MutableMethodImplementation;I)Lcom/android/tools/smali/dexlib2/builder/BuilderInstruction;
|
||||||
|
public final fun getInstruction (Lcom/android/tools/smali/dexlib2/builder/MutableMethodImplementation;I)Ljava/lang/Object;
|
||||||
|
public final fun getInstructions (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;)Ljava/util/List;
|
||||||
|
public final fun removeInstruction (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;I)V
|
||||||
|
public final fun removeInstructions (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;I)V
|
||||||
|
public final fun removeInstructions (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;II)V
|
||||||
|
public final fun removeInstructions (Lcom/android/tools/smali/dexlib2/builder/MutableMethodImplementation;I)V
|
||||||
|
public final fun removeInstructions (Lcom/android/tools/smali/dexlib2/builder/MutableMethodImplementation;II)V
|
||||||
|
public final fun replaceInstruction (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILcom/android/tools/smali/dexlib2/builder/BuilderInstruction;)V
|
||||||
|
public final fun replaceInstruction (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILjava/lang/String;)V
|
||||||
|
public final fun replaceInstructions (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILjava/lang/String;)V
|
||||||
|
public final fun replaceInstructions (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILjava/util/List;)V
|
||||||
|
public final fun replaceInstructions (Lcom/android/tools/smali/dexlib2/builder/MutableMethodImplementation;ILjava/util/List;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/extensions/MethodFingerprintExtensions {
|
||||||
|
public static final field INSTANCE Lapp/revanced/patcher/extensions/MethodFingerprintExtensions;
|
||||||
|
public final fun getFuzzyPatternScanMethod (Lapp/revanced/patcher/fingerprint/MethodFingerprint;)Lapp/revanced/patcher/fingerprint/annotation/FuzzyPatternScanMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class app/revanced/patcher/fingerprint/MethodFingerprint {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/fingerprint/MethodFingerprint$Companion;
|
||||||
|
public fun <init> ()V
|
||||||
|
public fun <init> (Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;Lkotlin/jvm/functions/Function2;)V
|
||||||
|
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;Lkotlin/jvm/functions/Function2;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
public final fun getResult ()Lapp/revanced/patcher/fingerprint/MethodFingerprintResult;
|
||||||
|
public final fun resolve (Lapp/revanced/patcher/data/BytecodeContext;Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Z
|
||||||
|
public final fun resolve (Lapp/revanced/patcher/data/BytecodeContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Z
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/fingerprint/MethodFingerprint$Companion {
|
||||||
|
public final fun resolve (Ljava/lang/Iterable;Lapp/revanced/patcher/data/BytecodeContext;Ljava/lang/Iterable;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/fingerprint/MethodFingerprintResult {
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lapp/revanced/patcher/fingerprint/MethodFingerprintResult$MethodFingerprintScanResult;Lapp/revanced/patcher/data/BytecodeContext;)V
|
||||||
|
public final fun getClassDef ()Lcom/android/tools/smali/dexlib2/iface/ClassDef;
|
||||||
|
public final fun getMethod ()Lcom/android/tools/smali/dexlib2/iface/Method;
|
||||||
|
public final fun getMutableClass ()Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;
|
||||||
|
public final fun getMutableMethod ()Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
|
||||||
|
public final fun getScanResult ()Lapp/revanced/patcher/fingerprint/MethodFingerprintResult$MethodFingerprintScanResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/fingerprint/MethodFingerprintResult$MethodFingerprintScanResult {
|
||||||
|
public fun <init> (Lapp/revanced/patcher/fingerprint/MethodFingerprintResult$MethodFingerprintScanResult$PatternScanResult;Lapp/revanced/patcher/fingerprint/MethodFingerprintResult$MethodFingerprintScanResult$StringsScanResult;)V
|
||||||
|
public final fun getPatternScanResult ()Lapp/revanced/patcher/fingerprint/MethodFingerprintResult$MethodFingerprintScanResult$PatternScanResult;
|
||||||
|
public final fun getStringsScanResult ()Lapp/revanced/patcher/fingerprint/MethodFingerprintResult$MethodFingerprintScanResult$StringsScanResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/fingerprint/MethodFingerprintResult$MethodFingerprintScanResult$PatternScanResult {
|
||||||
|
public fun <init> (IILjava/util/List;)V
|
||||||
|
public synthetic fun <init> (IILjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
public final fun getEndIndex ()I
|
||||||
|
public final fun getStartIndex ()I
|
||||||
|
public final fun getWarnings ()Ljava/util/List;
|
||||||
|
public final fun setWarnings (Ljava/util/List;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/fingerprint/MethodFingerprintResult$MethodFingerprintScanResult$PatternScanResult$Warning {
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/Opcode;Lcom/android/tools/smali/dexlib2/Opcode;II)V
|
||||||
|
public final fun getCorrectOpcode ()Lcom/android/tools/smali/dexlib2/Opcode;
|
||||||
|
public final fun getInstructionIndex ()I
|
||||||
|
public final fun getPatternIndex ()I
|
||||||
|
public final fun getWrongOpcode ()Lcom/android/tools/smali/dexlib2/Opcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/fingerprint/MethodFingerprintResult$MethodFingerprintScanResult$StringsScanResult {
|
||||||
|
public fun <init> (Ljava/util/List;)V
|
||||||
|
public final fun getMatches ()Ljava/util/List;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/fingerprint/MethodFingerprintResult$MethodFingerprintScanResult$StringsScanResult$StringMatch {
|
||||||
|
public fun <init> (Ljava/lang/String;I)V
|
||||||
|
public final fun getIndex ()I
|
||||||
|
public final fun getString ()Ljava/lang/String;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract interface annotation class app/revanced/patcher/fingerprint/annotation/FuzzyPatternScanMethod : java/lang/annotation/Annotation {
|
||||||
|
public abstract fun threshold ()I
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class app/revanced/patcher/patch/BytecodePatch : app/revanced/patcher/patch/Patch {
|
||||||
|
public fun <init> ()V
|
||||||
|
public fun <init> (Ljava/util/Set;)V
|
||||||
|
public synthetic fun <init> (Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class app/revanced/patcher/patch/Patch {
|
||||||
|
public fun equals (Ljava/lang/Object;)Z
|
||||||
|
public abstract fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||||
|
public final fun getCompatiblePackages ()Ljava/util/Set;
|
||||||
|
public final fun getDependencies ()Ljava/util/Set;
|
||||||
|
public final fun getDescription ()Ljava/lang/String;
|
||||||
|
public final fun getName ()Ljava/lang/String;
|
||||||
|
public final fun getOptions ()Lapp/revanced/patcher/patch/options/PatchOptions;
|
||||||
|
public final fun getRequiresIntegrations ()Z
|
||||||
|
public final fun getUse ()Z
|
||||||
|
public fun hashCode ()I
|
||||||
|
public fun toString ()Ljava/lang/String;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/patch/Patch$CompatiblePackage {
|
||||||
|
public fun <init> (Ljava/lang/String;Ljava/util/Set;)V
|
||||||
|
public synthetic fun <init> (Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
public final fun getName ()Ljava/lang/String;
|
||||||
|
public final fun getVersions ()Ljava/util/Set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/patch/PatchException : java/lang/Exception {
|
||||||
|
public fun <init> (Ljava/lang/String;)V
|
||||||
|
public fun <init> (Ljava/lang/String;Ljava/lang/Throwable;)V
|
||||||
|
public fun <init> (Ljava/lang/Throwable;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/patch/PatchResult {
|
||||||
|
public final fun getException ()Lapp/revanced/patcher/patch/PatchException;
|
||||||
|
public final fun getPatch ()Lapp/revanced/patcher/patch/Patch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class app/revanced/patcher/patch/ResourcePatch : app/revanced/patcher/patch/Patch {
|
||||||
|
public fun <init> ()V
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract interface annotation class app/revanced/patcher/patch/annotation/CompatiblePackage : java/lang/annotation/Annotation {
|
||||||
|
public abstract fun name ()Ljava/lang/String;
|
||||||
|
public abstract fun versions ()[Ljava/lang/String;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract interface annotation class app/revanced/patcher/patch/annotation/Patch : java/lang/annotation/Annotation {
|
||||||
|
public abstract fun compatiblePackages ()[Lapp/revanced/patcher/patch/annotation/CompatiblePackage;
|
||||||
|
public abstract fun dependencies ()[Ljava/lang/Class;
|
||||||
|
public abstract fun description ()Ljava/lang/String;
|
||||||
|
public abstract fun name ()Ljava/lang/String;
|
||||||
|
public abstract fun requiresIntegrations ()Z
|
||||||
|
public abstract fun use ()Z
|
||||||
|
}
|
||||||
|
|
||||||
|
public class app/revanced/patcher/patch/options/PatchOption {
|
||||||
|
public static final field PatchExtensions Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;
|
||||||
|
public fun <init> (Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)V
|
||||||
|
public final fun getDefault ()Ljava/lang/Object;
|
||||||
|
public final fun getDescription ()Ljava/lang/String;
|
||||||
|
public final fun getKey ()Ljava/lang/String;
|
||||||
|
public final fun getRequired ()Z
|
||||||
|
public final fun getTitle ()Ljava/lang/String;
|
||||||
|
public final fun getValidator ()Lkotlin/jvm/functions/Function2;
|
||||||
|
public final fun getValue ()Ljava/lang/Object;
|
||||||
|
public final fun getValue (Ljava/lang/Object;Lkotlin/reflect/KProperty;)Ljava/lang/Object;
|
||||||
|
public final fun getValues ()Ljava/util/Map;
|
||||||
|
public fun reset ()V
|
||||||
|
public final fun setValue (Ljava/lang/Object;)V
|
||||||
|
public final fun setValue (Ljava/lang/Object;Lkotlin/reflect/KProperty;Ljava/lang/Object;)V
|
||||||
|
public fun toString ()Ljava/lang/String;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/patch/options/PatchOption$PatchExtensions {
|
||||||
|
public final fun booleanArrayPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/Boolean;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public static synthetic fun booleanArrayPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/Boolean;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final fun booleanPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Boolean;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public static synthetic fun booleanPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Boolean;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final fun floatArrayPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/Float;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public static synthetic fun floatArrayPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/Float;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final fun floatPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Float;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public static synthetic fun floatPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Float;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final fun intArrayPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/Integer;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public static synthetic fun intArrayPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/Integer;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final fun intPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Integer;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public static synthetic fun intPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Integer;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final fun longArrayPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/Long;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public static synthetic fun longArrayPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/Long;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final fun longPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Long;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public static synthetic fun longPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Long;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final fun stringArrayPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public static synthetic fun stringArrayPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;[Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final fun stringPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public static synthetic fun stringPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class app/revanced/patcher/patch/options/PatchOptionException : java/lang/Exception {
|
||||||
|
public synthetic fun <init> (Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/patch/options/PatchOptionException$InvalidValueTypeException : app/revanced/patcher/patch/options/PatchOptionException {
|
||||||
|
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/patch/options/PatchOptionException$PatchOptionNotFoundException : app/revanced/patcher/patch/options/PatchOptionException {
|
||||||
|
public fun <init> (Ljava/lang/String;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/patch/options/PatchOptionException$ValueRequiredException : app/revanced/patcher/patch/options/PatchOptionException {
|
||||||
|
public fun <init> (Lapp/revanced/patcher/patch/options/PatchOption;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/patch/options/PatchOptionException$ValueValidationException : app/revanced/patcher/patch/options/PatchOptionException {
|
||||||
|
public fun <init> (Ljava/lang/Object;Lapp/revanced/patcher/patch/options/PatchOption;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/patch/options/PatchOptions : java/util/Map, kotlin/jvm/internal/markers/KMutableMap {
|
||||||
|
public fun <init> ()V
|
||||||
|
public fun clear ()V
|
||||||
|
public final fun containsKey (Ljava/lang/Object;)Z
|
||||||
|
public fun containsKey (Ljava/lang/String;)Z
|
||||||
|
public fun containsValue (Lapp/revanced/patcher/patch/options/PatchOption;)Z
|
||||||
|
public final fun containsValue (Ljava/lang/Object;)Z
|
||||||
|
public final fun entrySet ()Ljava/util/Set;
|
||||||
|
public final fun get (Ljava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final synthetic fun get (Ljava/lang/Object;)Ljava/lang/Object;
|
||||||
|
public fun get (Ljava/lang/String;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public fun getEntries ()Ljava/util/Set;
|
||||||
|
public fun getKeys ()Ljava/util/Set;
|
||||||
|
public fun getSize ()I
|
||||||
|
public fun getValues ()Ljava/util/Collection;
|
||||||
|
public fun isEmpty ()Z
|
||||||
|
public final fun keySet ()Ljava/util/Set;
|
||||||
|
public synthetic fun put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
|
||||||
|
public fun put (Ljava/lang/String;Lapp/revanced/patcher/patch/options/PatchOption;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public fun putAll (Ljava/util/Map;)V
|
||||||
|
public final fun register (Lapp/revanced/patcher/patch/options/PatchOption;)V
|
||||||
|
public final fun remove (Ljava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final synthetic fun remove (Ljava/lang/Object;)Ljava/lang/Object;
|
||||||
|
public fun remove (Ljava/lang/String;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final fun set (Ljava/lang/String;Ljava/lang/Object;)V
|
||||||
|
public final fun size ()I
|
||||||
|
public final fun values ()Ljava/util/Collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/DomFileEditor : java/io/Closeable {
|
||||||
|
public fun <init> (Ljava/io/File;)V
|
||||||
|
public fun close ()V
|
||||||
|
public final fun getFile ()Lorg/w3c/dom/Document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/ProxyClassList : java/util/Set, kotlin/jvm/internal/markers/KMutableSet {
|
||||||
|
public final fun add (Lapp/revanced/patcher/util/proxy/ClassProxy;)Z
|
||||||
|
public fun add (Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Z
|
||||||
|
public synthetic fun add (Ljava/lang/Object;)Z
|
||||||
|
public fun addAll (Ljava/util/Collection;)Z
|
||||||
|
public fun clear ()V
|
||||||
|
public fun contains (Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Z
|
||||||
|
public final fun contains (Ljava/lang/Object;)Z
|
||||||
|
public fun containsAll (Ljava/util/Collection;)Z
|
||||||
|
public fun getSize ()I
|
||||||
|
public fun isEmpty ()Z
|
||||||
|
public fun iterator ()Ljava/util/Iterator;
|
||||||
|
public fun remove (Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Z
|
||||||
|
public final fun remove (Ljava/lang/Object;)Z
|
||||||
|
public fun removeAll (Ljava/util/Collection;)Z
|
||||||
|
public fun retainAll (Ljava/util/Collection;)Z
|
||||||
|
public final fun size ()I
|
||||||
|
public fun toArray ()[Ljava/lang/Object;
|
||||||
|
public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/method/MethodWalker {
|
||||||
|
public final fun getMethod ()Lcom/android/tools/smali/dexlib2/iface/Method;
|
||||||
|
public final fun nextMethod (IZ)Lapp/revanced/patcher/util/method/MethodWalker;
|
||||||
|
public static synthetic fun nextMethod$default (Lapp/revanced/patcher/util/method/MethodWalker;IZILjava/lang/Object;)Lapp/revanced/patcher/util/method/MethodWalker;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/ClassProxy {
|
||||||
|
public final fun getImmutableClass ()Lcom/android/tools/smali/dexlib2/iface/ClassDef;
|
||||||
|
public final fun getMutableClass ()Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableAnnotation : com/android/tools/smali/dexlib2/base/BaseAnnotation {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/MutableAnnotation$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/Annotation;)V
|
||||||
|
public fun getElements ()Ljava/util/Set;
|
||||||
|
public fun getType ()Ljava/lang/String;
|
||||||
|
public fun getVisibility ()I
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableAnnotation$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/Annotation;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableAnnotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableAnnotationElement : com/android/tools/smali/dexlib2/base/BaseAnnotationElement {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/MutableAnnotationElement$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/AnnotationElement;)V
|
||||||
|
public fun getName ()Ljava/lang/String;
|
||||||
|
public fun getValue ()Lcom/android/tools/smali/dexlib2/iface/value/EncodedValue;
|
||||||
|
public final fun setName (Ljava/lang/String;)V
|
||||||
|
public final fun setValue (Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableAnnotationElement$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/AnnotationElement;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableAnnotationElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableClass : com/android/tools/smali/dexlib2/base/reference/BaseTypeReference, com/android/tools/smali/dexlib2/iface/ClassDef {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/ClassDef;)V
|
||||||
|
public final fun charAt (I)C
|
||||||
|
public fun get (I)C
|
||||||
|
public fun getAccessFlags ()I
|
||||||
|
public fun getAnnotations ()Ljava/util/Set;
|
||||||
|
public synthetic fun getDirectMethods ()Ljava/lang/Iterable;
|
||||||
|
public fun getDirectMethods ()Ljava/util/Set;
|
||||||
|
public synthetic fun getFields ()Ljava/lang/Iterable;
|
||||||
|
public fun getFields ()Ljava/util/Set;
|
||||||
|
public synthetic fun getInstanceFields ()Ljava/lang/Iterable;
|
||||||
|
public fun getInstanceFields ()Ljava/util/Set;
|
||||||
|
public fun getInterfaces ()Ljava/util/List;
|
||||||
|
public fun getLength ()I
|
||||||
|
public synthetic fun getMethods ()Ljava/lang/Iterable;
|
||||||
|
public fun getMethods ()Ljava/util/Set;
|
||||||
|
public fun getSourceFile ()Ljava/lang/String;
|
||||||
|
public synthetic fun getStaticFields ()Ljava/lang/Iterable;
|
||||||
|
public fun getStaticFields ()Ljava/util/Set;
|
||||||
|
public fun getSuperclass ()Ljava/lang/String;
|
||||||
|
public fun getType ()Ljava/lang/String;
|
||||||
|
public synthetic fun getVirtualMethods ()Ljava/lang/Iterable;
|
||||||
|
public fun getVirtualMethods ()Ljava/util/Set;
|
||||||
|
public final fun length ()I
|
||||||
|
public final fun setAccessFlags (I)V
|
||||||
|
public final fun setSourceFile (Ljava/lang/String;)V
|
||||||
|
public final fun setSuperClass (Ljava/lang/String;)V
|
||||||
|
public final fun setType (Ljava/lang/String;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableClass$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableField : com/android/tools/smali/dexlib2/base/reference/BaseFieldReference, com/android/tools/smali/dexlib2/iface/Field {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/MutableField$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/Field;)V
|
||||||
|
public fun getAccessFlags ()I
|
||||||
|
public fun getAnnotations ()Ljava/util/Set;
|
||||||
|
public fun getDefiningClass ()Ljava/lang/String;
|
||||||
|
public fun getHiddenApiRestrictions ()Ljava/util/Set;
|
||||||
|
public fun getInitialValue ()Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue;
|
||||||
|
public synthetic fun getInitialValue ()Lcom/android/tools/smali/dexlib2/iface/value/EncodedValue;
|
||||||
|
public fun getName ()Ljava/lang/String;
|
||||||
|
public fun getType ()Ljava/lang/String;
|
||||||
|
public final fun setAccessFlags (I)V
|
||||||
|
public final fun setDefiningClass (Ljava/lang/String;)V
|
||||||
|
public final fun setInitialValue (Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue;)V
|
||||||
|
public final fun setName (Ljava/lang/String;)V
|
||||||
|
public final fun setType (Ljava/lang/String;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableField$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/Field;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableMethod : com/android/tools/smali/dexlib2/base/reference/BaseMethodReference, com/android/tools/smali/dexlib2/iface/Method {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/Method;)V
|
||||||
|
public fun getAccessFlags ()I
|
||||||
|
public fun getAnnotations ()Ljava/util/Set;
|
||||||
|
public fun getDefiningClass ()Ljava/lang/String;
|
||||||
|
public fun getHiddenApiRestrictions ()Ljava/util/Set;
|
||||||
|
public fun getImplementation ()Lcom/android/tools/smali/dexlib2/builder/MutableMethodImplementation;
|
||||||
|
public synthetic fun getImplementation ()Lcom/android/tools/smali/dexlib2/iface/MethodImplementation;
|
||||||
|
public fun getName ()Ljava/lang/String;
|
||||||
|
public fun getParameterTypes ()Ljava/util/List;
|
||||||
|
public fun getParameters ()Ljava/util/List;
|
||||||
|
public fun getReturnType ()Ljava/lang/String;
|
||||||
|
public final fun setAccessFlags (I)V
|
||||||
|
public final fun setDefiningClass (Ljava/lang/String;)V
|
||||||
|
public final fun setName (Ljava/lang/String;)V
|
||||||
|
public final fun setReturnType (Ljava/lang/String;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableMethod$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/Method;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableMethodParameter : com/android/tools/smali/dexlib2/base/BaseMethodParameter, com/android/tools/smali/dexlib2/iface/MethodParameter {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethodParameter$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/MethodParameter;)V
|
||||||
|
public final fun charAt (I)C
|
||||||
|
public fun get (I)C
|
||||||
|
public fun getAnnotations ()Ljava/util/Set;
|
||||||
|
public fun getLength ()I
|
||||||
|
public fun getName ()Ljava/lang/String;
|
||||||
|
public fun getSignature ()Ljava/lang/String;
|
||||||
|
public fun getType ()Ljava/lang/String;
|
||||||
|
public final fun length ()I
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/MutableMethodParameter$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/MethodParameter;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethodParameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableAnnotationEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseAnnotationEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableAnnotationEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/AnnotationEncodedValue;)V
|
||||||
|
public fun getElements ()Ljava/util/Set;
|
||||||
|
public fun getType ()Ljava/lang/String;
|
||||||
|
public final fun setType (Ljava/lang/String;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableAnnotationEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/AnnotationEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableAnnotationEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableArrayEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseArrayEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableArrayEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/ArrayEncodedValue;)V
|
||||||
|
public fun getValue ()Ljava/util/List;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableArrayEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/ArrayEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableArrayEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableBooleanEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseBooleanEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableBooleanEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/BooleanEncodedValue;)V
|
||||||
|
public fun getValue ()Z
|
||||||
|
public final fun setValue (Z)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableBooleanEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/BooleanEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableBooleanEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableByteEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseByteEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableByteEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/ByteEncodedValue;)V
|
||||||
|
public fun getValue ()B
|
||||||
|
public final fun setValue (B)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableByteEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/ByteEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableByteEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableCharEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseCharEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableCharEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/CharEncodedValue;)V
|
||||||
|
public fun getValue ()C
|
||||||
|
public final fun setValue (C)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableCharEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/CharEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableCharEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableDoubleEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseDoubleEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableDoubleEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/DoubleEncodedValue;)V
|
||||||
|
public fun getValue ()D
|
||||||
|
public final fun setValue (D)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableDoubleEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/DoubleEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableDoubleEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract interface class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue : com/android/tools/smali/dexlib2/iface/value/EncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue$Companion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/EncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEnumEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseEnumEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEnumEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/EnumEncodedValue;)V
|
||||||
|
public fun getValue ()Lcom/android/tools/smali/dexlib2/iface/reference/FieldReference;
|
||||||
|
public final fun setValue (Lcom/android/tools/smali/dexlib2/iface/reference/FieldReference;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEnumEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/EnumEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEnumEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableFieldEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseFieldEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableFieldEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/FieldEncodedValue;)V
|
||||||
|
public fun getValue ()Lcom/android/tools/smali/dexlib2/iface/reference/FieldReference;
|
||||||
|
public fun getValueType ()I
|
||||||
|
public final fun setValue (Lcom/android/tools/smali/dexlib2/iface/reference/FieldReference;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableFieldEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/FieldEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableFieldEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableFloatEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseFloatEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableFloatEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/FloatEncodedValue;)V
|
||||||
|
public fun getValue ()F
|
||||||
|
public final fun setValue (F)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableFloatEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/FloatEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableFloatEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableIntEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseIntEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableIntEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/IntEncodedValue;)V
|
||||||
|
public fun getValue ()I
|
||||||
|
public final fun setValue (I)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableIntEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/IntEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableIntEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableLongEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseLongEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableLongEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/LongEncodedValue;)V
|
||||||
|
public fun getValue ()J
|
||||||
|
public final fun setValue (J)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableLongEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/LongEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableLongEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseMethodEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/MethodEncodedValue;)V
|
||||||
|
public fun getValue ()Lcom/android/tools/smali/dexlib2/iface/reference/MethodReference;
|
||||||
|
public final fun setValue (Lcom/android/tools/smali/dexlib2/iface/reference/MethodReference;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/MethodEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodHandleEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseMethodHandleEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodHandleEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/MethodHandleEncodedValue;)V
|
||||||
|
public fun getValue ()Lcom/android/tools/smali/dexlib2/iface/reference/MethodHandleReference;
|
||||||
|
public final fun setValue (Lcom/android/tools/smali/dexlib2/iface/reference/MethodHandleReference;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodHandleEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/MethodHandleEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodHandleEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodTypeEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseMethodTypeEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodTypeEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/MethodTypeEncodedValue;)V
|
||||||
|
public fun getValue ()Lcom/android/tools/smali/dexlib2/iface/reference/MethodProtoReference;
|
||||||
|
public final fun setValue (Lcom/android/tools/smali/dexlib2/iface/reference/MethodProtoReference;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodTypeEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/MethodTypeEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableMethodTypeEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableNullEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseNullEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableNullEncodedValue$Companion;
|
||||||
|
public fun <init> ()V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableNullEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/ByteEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableByteEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableShortEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseShortEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableShortEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/ShortEncodedValue;)V
|
||||||
|
public fun getValue ()S
|
||||||
|
public final fun setValue (S)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableShortEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/ShortEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableShortEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableStringEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseStringEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableStringEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/StringEncodedValue;)V
|
||||||
|
public fun getValue ()Ljava/lang/String;
|
||||||
|
public final fun setValue (Ljava/lang/String;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableStringEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/ByteEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableByteEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableTypeEncodedValue : com/android/tools/smali/dexlib2/base/value/BaseTypeEncodedValue, app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableEncodedValue {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableTypeEncodedValue$Companion;
|
||||||
|
public fun <init> (Lcom/android/tools/smali/dexlib2/iface/value/TypeEncodedValue;)V
|
||||||
|
public fun getValue ()Ljava/lang/String;
|
||||||
|
public final fun setValue (Ljava/lang/String;)V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableTypeEncodedValue$Companion {
|
||||||
|
public final fun toMutable (Lcom/android/tools/smali/dexlib2/iface/value/TypeEncodedValue;)Lapp/revanced/patcher/util/proxy/mutableTypes/encodedValue/MutableTypeEncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/smali/ExternalLabel {
|
||||||
|
public fun <init> (Ljava/lang/String;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)V
|
||||||
|
public final fun copy (Ljava/lang/String;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)Lapp/revanced/patcher/util/smali/ExternalLabel;
|
||||||
|
public static synthetic fun copy$default (Lapp/revanced/patcher/util/smali/ExternalLabel;Ljava/lang/String;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;ILjava/lang/Object;)Lapp/revanced/patcher/util/smali/ExternalLabel;
|
||||||
|
public fun equals (Ljava/lang/Object;)Z
|
||||||
|
public fun hashCode ()I
|
||||||
|
public fun toString ()Ljava/lang/String;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/smali/InlineSmaliCompiler {
|
||||||
|
public static final field Companion Lapp/revanced/patcher/util/smali/InlineSmaliCompiler$Companion;
|
||||||
|
public fun <init> ()V
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/smali/InlineSmaliCompiler$Companion {
|
||||||
|
public final fun compile (Ljava/lang/String;Ljava/lang/String;IZ)Ljava/util/List;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patcher/util/smali/InlineSmaliCompilerKt {
|
||||||
|
public static final fun toInstruction (Ljava/lang/String;Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;)Lcom/android/tools/smali/dexlib2/builder/BuilderInstruction;
|
||||||
|
public static synthetic fun toInstruction$default (Ljava/lang/String;Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILjava/lang/Object;)Lcom/android/tools/smali/dexlib2/builder/BuilderInstruction;
|
||||||
|
public static final fun toInstructions (Ljava/lang/String;Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;)Ljava/util/List;
|
||||||
|
public static synthetic fun toInstructions$default (Ljava/lang/String;Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILjava/lang/Object;)Ljava/util/List;
|
||||||
|
}
|
||||||
|
|
||||||
101
build.gradle.kts
101
build.gradle.kts
@@ -1,47 +1,48 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.8.10"
|
kotlin("jvm") version "1.9.10"
|
||||||
|
alias(libs.plugins.binary.compatibility.validator)
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
|
signing
|
||||||
|
java
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "app.revanced"
|
group = "app.revanced"
|
||||||
|
|
||||||
val githubUsername: String = project.findProperty("gpr.user") as? String ?: System.getenv("GITHUB_ACTOR")
|
|
||||||
val githubPassword: String = project.findProperty("gpr.key") as? String ?: System.getenv("GITHUB_TOKEN")
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven {
|
|
||||||
url = uri("https://maven.pkg.github.com/revanced/multidexlib2")
|
|
||||||
credentials {
|
|
||||||
username = githubUsername
|
|
||||||
password = githubPassword
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation("xpp3:xpp3:1.1.4c")
|
|
||||||
implementation("app.revanced:smali:2.5.3-a3836654")
|
|
||||||
implementation("app.revanced:multidexlib2:2.5.3-a3836654")
|
|
||||||
implementation("app.revanced:apktool-lib:2.7.0")
|
|
||||||
|
|
||||||
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.20-RC")
|
|
||||||
testImplementation("org.jetbrains.kotlin:kotlin-test:1.8.20-RC")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
processResources {
|
||||||
|
expand("projectVersion" to project.version)
|
||||||
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
testLogging {
|
testLogging {
|
||||||
events("PASSED", "SKIPPED", "FAILED")
|
events("PASSED", "SKIPPED", "FAILED")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
processResources {
|
}
|
||||||
expand("projectVersion" to project.version)
|
|
||||||
}
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
maven { url = uri("https://jitpack.io") }
|
||||||
|
google()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.kotlinx.coroutines.core)
|
||||||
|
implementation(libs.xpp3)
|
||||||
|
implementation(libs.smali)
|
||||||
|
implementation(libs.multidexlib2)
|
||||||
|
implementation(libs.apktool.lib)
|
||||||
|
implementation(libs.kotlin.reflect)
|
||||||
|
|
||||||
|
compileOnly(libs.android)
|
||||||
|
|
||||||
|
testImplementation(libs.kotlin.test)
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
withJavadocJar()
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,22 +51,36 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
publications {
|
||||||
if (System.getenv("GITHUB_ACTOR") != null)
|
create<MavenPublication>("revanced-patcher-publication") {
|
||||||
maven {
|
from(components["java"])
|
||||||
name = "GitHubPackages"
|
|
||||||
url = uri("https://maven.pkg.github.com/revanced/revanced-patcher")
|
version = project.version.toString()
|
||||||
credentials {
|
|
||||||
username = System.getenv("GITHUB_ACTOR")
|
pom {
|
||||||
password = System.getenv("GITHUB_TOKEN")
|
name = "ReVanced Patcher"
|
||||||
|
description = "Patcher used by ReVanced."
|
||||||
|
url = "https://revanced.app"
|
||||||
|
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name = "GNU General Public License v3.0"
|
||||||
|
url = "https://www.gnu.org/licenses/gpl-3.0.en.html"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id = "ReVanced"
|
||||||
|
name = "ReVanced"
|
||||||
|
email = "contact@revanced.app"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
connection = "scm:git:git://github.com/revanced/revanced-patcher.git"
|
||||||
|
developerConnection = "scm:git:git@github.com:revanced/revanced-patcher.git"
|
||||||
|
url = "https://github.com/revanced/revanced-patcher"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
mavenLocal()
|
|
||||||
}
|
|
||||||
publications {
|
|
||||||
register<MavenPublication>("gpr") {
|
|
||||||
from(components["java"])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,4 @@
|
|||||||
|
org.gradle.parallel = true
|
||||||
|
org.gradle.caching = true
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 11.0.2-dev.3
|
version = 18.0.0-dev.6
|
||||||
|
|||||||
23
gradle/libs.versions.toml
Normal file
23
gradle/libs.versions.toml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
[versions]
|
||||||
|
android = "4.1.1.4"
|
||||||
|
kotlin-reflect = "1.9.0"
|
||||||
|
apktool-lib = "2.9.1"
|
||||||
|
kotlin-test = "1.8.20-RC"
|
||||||
|
kotlinx-coroutines-core = "1.7.3"
|
||||||
|
multidexlib2 = "3.0.3.r3"
|
||||||
|
smali = "3.0.3"
|
||||||
|
xpp3 = "1.1.4c"
|
||||||
|
binary-compatibility-validator = "0.13.2"
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
android = { module = "com.google.android:android", version.ref = "android" }
|
||||||
|
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin-reflect" }
|
||||||
|
apktool-lib = { module = "app.revanced:apktool", version.ref = "apktool-lib" }
|
||||||
|
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin-test" }
|
||||||
|
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" }
|
||||||
|
multidexlib2 = { module = "app.revanced:multidexlib2", version.ref = "multidexlib2" }
|
||||||
|
smali = { module = "com.android.tools.smali:smali", version.ref = "smali" }
|
||||||
|
xpp3 = { module = "xpp3:xpp3", version.ref = "xpp3" }
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
40
gradlew
vendored
40
gradlew
vendored
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright <EFBFBD> 2015-2021 the original authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -32,10 +32,10 @@
|
|||||||
# Busybox and similar reduced shells will NOT work, because this script
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
# requires all of these POSIX shell features:
|
# requires all of these POSIX shell features:
|
||||||
# * functions;
|
# * functions;
|
||||||
# * expansions <EFBFBD>$var<EFBFBD>, <EFBFBD>${var}<EFBFBD>, <EFBFBD>${var:-default}<EFBFBD>, <EFBFBD>${var+SET}<EFBFBD>,
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
# <EFBFBD>${var#prefix}<EFBFBD>, <EFBFBD>${var%suffix}<EFBFBD>, and <EFBFBD>$( cmd )<EFBFBD>;
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
# * compound commands having a testable exit status, especially <EFBFBD>case<EFBFBD>;
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
# * various built-in commands including <EFBFBD>command<EFBFBD>, <EFBFBD>set<EFBFBD>, and <EFBFBD>ulimit<EFBFBD>.
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
#
|
#
|
||||||
# Important for patching:
|
# Important for patching:
|
||||||
#
|
#
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -80,13 +80,10 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -133,22 +130,29 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
# Collect all arguments for the java command;
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
@@ -205,6 +213,12 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
|||||||
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,8 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
rootProject.name = "revanced-patcher"
|
rootProject.name = "revanced-patcher"
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package app.revanced.patcher
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
interface IntegrationsConsumer {
|
||||||
|
fun acceptIntegrations(integrations: List<File>)
|
||||||
|
}
|
||||||
14
src/main/kotlin/app/revanced/patcher/PackageMetadata.kt
Normal file
14
src/main/kotlin/app/revanced/patcher/PackageMetadata.kt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package app.revanced.patcher
|
||||||
|
|
||||||
|
import brut.androlib.apk.ApkInfo
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metadata about a package.
|
||||||
|
*/
|
||||||
|
class PackageMetadata internal constructor(internal val apkInfo: ApkInfo) {
|
||||||
|
lateinit var packageName: String
|
||||||
|
internal set
|
||||||
|
|
||||||
|
lateinit var packageVersion: String
|
||||||
|
internal set
|
||||||
|
}
|
||||||
127
src/main/kotlin/app/revanced/patcher/PatchBundleLoader.kt
Normal file
127
src/main/kotlin/app/revanced/patcher/PatchBundleLoader.kt
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
|
package app.revanced.patcher
|
||||||
|
|
||||||
|
import app.revanced.patcher.patch.Patch
|
||||||
|
import dalvik.system.DexClassLoader
|
||||||
|
import lanchon.multidexlib2.BasicDexFileNamer
|
||||||
|
import lanchon.multidexlib2.MultiDexIO
|
||||||
|
import java.io.File
|
||||||
|
import java.net.URLClassLoader
|
||||||
|
import java.util.jar.JarFile
|
||||||
|
import java.util.logging.Logger
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A set of [Patch]es.
|
||||||
|
*/
|
||||||
|
typealias PatchSet = Set<Patch<*>>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [Patch] class.
|
||||||
|
*/
|
||||||
|
typealias PatchClass = KClass<out Patch<*>>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A loader of [Patch]es from patch bundles.
|
||||||
|
* This will load all [Patch]es from the given patch bundles that have a name.
|
||||||
|
*
|
||||||
|
* @param getBinaryClassNames A function that returns the binary names of all classes in a patch bundle.
|
||||||
|
* @param classLoader The [ClassLoader] to use for loading the classes.
|
||||||
|
* @param patchBundles A set of patches to initialize this instance with.
|
||||||
|
*/
|
||||||
|
sealed class PatchBundleLoader private constructor(
|
||||||
|
classLoader: ClassLoader,
|
||||||
|
patchBundles: Array<out File>,
|
||||||
|
getBinaryClassNames: (patchBundle: File) -> List<String>,
|
||||||
|
// This constructor parameter is unfortunately necessary,
|
||||||
|
// so that a reference to the mutable set is present in the constructor to be able to add patches to it.
|
||||||
|
// because the instance itself is a PatchSet, which is immutable, that is delegated by the parameter.
|
||||||
|
private val patchSet: MutableSet<Patch<*>> = mutableSetOf()
|
||||||
|
) : PatchSet by patchSet {
|
||||||
|
private val logger = Logger.getLogger(PatchBundleLoader::class.java.name)
|
||||||
|
|
||||||
|
init {
|
||||||
|
patchBundles.flatMap(getBinaryClassNames).asSequence().map {
|
||||||
|
classLoader.loadClass(it)
|
||||||
|
}.filter {
|
||||||
|
Patch::class.java.isAssignableFrom(it)
|
||||||
|
}.mapNotNull { patchClass ->
|
||||||
|
patchClass.getInstance(logger, silent = true)
|
||||||
|
}.filter {
|
||||||
|
it.name != null
|
||||||
|
}.let { patches ->
|
||||||
|
patchSet.addAll(patches)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal companion object Utils {
|
||||||
|
/**
|
||||||
|
* Instantiates a [Patch]. If the class is a singleton, the INSTANCE field will be used.
|
||||||
|
*
|
||||||
|
* @param logger The [Logger] to use for logging.
|
||||||
|
* @param silent Whether to suppress logging.
|
||||||
|
* @return The instantiated [Patch] or `null` if the [Patch] could not be instantiated.
|
||||||
|
*/
|
||||||
|
internal fun Class<*>.getInstance(logger: Logger, silent: Boolean = false): Patch<*>? {
|
||||||
|
return try {
|
||||||
|
getField("INSTANCE").get(null)
|
||||||
|
} catch (exception: NoSuchFieldException) {
|
||||||
|
if (!silent) logger.fine(
|
||||||
|
"Patch class '${name}' has no INSTANCE field, therefor not a singleton. " +
|
||||||
|
"Will try to instantiate it."
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
getDeclaredConstructor().newInstance()
|
||||||
|
} catch (exception: Exception) {
|
||||||
|
if (!silent) logger.severe(
|
||||||
|
"Patch class '${name}' is not singleton and has no suitable constructor, " +
|
||||||
|
"therefor cannot be instantiated and will be ignored."
|
||||||
|
)
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
} as Patch<*>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [PatchBundleLoader] for JAR files.
|
||||||
|
*
|
||||||
|
* @param patchBundles The path to patch bundles of JAR format.
|
||||||
|
*/
|
||||||
|
class Jar(vararg patchBundles: File) : PatchBundleLoader(
|
||||||
|
URLClassLoader(patchBundles.map { it.toURI().toURL() }.toTypedArray()),
|
||||||
|
patchBundles,
|
||||||
|
{ patchBundle ->
|
||||||
|
JarFile(patchBundle).entries().toList().filter { it.name.endsWith(".class") }
|
||||||
|
.map { it.name.replace('/', '.').replace(".class", "") }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [PatchBundleLoader] for [Dex] files.
|
||||||
|
*
|
||||||
|
* @param patchBundles The path to patch bundles of DEX format.
|
||||||
|
* @param optimizedDexDirectory The directory to store optimized DEX files in.
|
||||||
|
* This parameter is deprecated and has no effect since API level 26.
|
||||||
|
*/
|
||||||
|
class Dex(vararg patchBundles: File, optimizedDexDirectory: File? = null) : PatchBundleLoader(
|
||||||
|
DexClassLoader(
|
||||||
|
patchBundles.joinToString(File.pathSeparator) { it.absolutePath }, optimizedDexDirectory?.absolutePath,
|
||||||
|
null,
|
||||||
|
PatchBundleLoader::class.java.classLoader
|
||||||
|
),
|
||||||
|
patchBundles,
|
||||||
|
{ patchBundle ->
|
||||||
|
MultiDexIO.readDexFile(true, patchBundle, BasicDexFileNamer(), null, null).classes
|
||||||
|
.map { classDef ->
|
||||||
|
classDef.type.substring(1, classDef.length - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
@Deprecated("This constructor is deprecated. Use the constructor with the second parameter instead.")
|
||||||
|
constructor(vararg patchBundles: File) : this(*patchBundles, optimizedDexDirectory = null)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package app.revanced.patcher
|
||||||
|
|
||||||
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import java.util.function.Function
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
interface PatchExecutorFunction : Function<Boolean, Flow<PatchResult>>
|
||||||
@@ -1,417 +1,266 @@
|
|||||||
package app.revanced.patcher
|
package app.revanced.patcher
|
||||||
|
|
||||||
import app.revanced.patcher.data.Context
|
import app.revanced.patcher.PatchBundleLoader.Utils.getInstance
|
||||||
import app.revanced.patcher.extensions.PatchExtensions.dependencies
|
import app.revanced.patcher.data.ResourceContext
|
||||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
import app.revanced.patcher.fingerprint.LookupMap.Maps.clearLookupMaps
|
||||||
import app.revanced.patcher.extensions.PatchExtensions.requiresIntegrations
|
import app.revanced.patcher.fingerprint.LookupMap.Maps.initializeLookupMaps
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint.Companion.resolveUsingLookupMap
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolveUsingLookupMap
|
|
||||||
import app.revanced.patcher.patch.*
|
import app.revanced.patcher.patch.*
|
||||||
import app.revanced.patcher.util.VersionReader
|
import kotlinx.coroutines.flow.flow
|
||||||
import brut.androlib.Androlib
|
|
||||||
import brut.androlib.meta.UsesFramework
|
|
||||||
import brut.androlib.options.BuildOptions
|
|
||||||
import brut.androlib.res.AndrolibResources
|
|
||||||
import brut.androlib.res.data.ResPackage
|
|
||||||
import brut.androlib.res.decoder.AXmlResourceParser
|
|
||||||
import brut.androlib.res.decoder.ResAttrDecoder
|
|
||||||
import brut.androlib.res.decoder.XmlPullStreamDecoder
|
|
||||||
import brut.androlib.res.xml.ResXmlPatcher
|
|
||||||
import brut.directory.ExtFile
|
|
||||||
import lanchon.multidexlib2.BasicDexFileNamer
|
|
||||||
import lanchon.multidexlib2.DexIO
|
|
||||||
import lanchon.multidexlib2.MultiDexIO
|
|
||||||
import org.jf.dexlib2.Opcodes
|
|
||||||
import org.jf.dexlib2.iface.DexFile
|
|
||||||
import org.jf.dexlib2.writer.io.MemoryDataStore
|
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.OutputStream
|
import java.util.function.Supplier
|
||||||
import java.nio.file.Files
|
import java.util.logging.Logger
|
||||||
|
|
||||||
internal val NAMER = BasicDexFileNamer()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ReVanced Patcher.
|
* ReVanced Patcher.
|
||||||
|
*
|
||||||
* @param options The options for the patcher.
|
* @param options The options for the patcher.
|
||||||
*/
|
*/
|
||||||
class Patcher(private val options: PatcherOptions) {
|
class Patcher(
|
||||||
private val logger = options.logger
|
private val options: PatcherOptions
|
||||||
private val opcodes: Opcodes
|
) : PatchExecutorFunction, PatchesConsumer, IntegrationsConsumer, Supplier<PatcherResult>, Closeable {
|
||||||
private var resourceDecodingMode = ResourceDecodingMode.MANIFEST_ONLY
|
private val logger = Logger.getLogger(Patcher::class.java.name)
|
||||||
private var mergeIntegrations = false
|
|
||||||
val context: PatcherContext
|
|
||||||
|
|
||||||
companion object {
|
/**
|
||||||
@JvmStatic
|
* The context of ReVanced [Patcher].
|
||||||
val version = VersionReader.read()
|
* This holds the current state of the patcher.
|
||||||
private fun BuildOptions.setBuildOptions(options: PatcherOptions) {
|
*/
|
||||||
this.aaptPath = options.aaptPath
|
val context = PatcherContext(options)
|
||||||
this.useAapt2 = true
|
|
||||||
this.frameworkFolderLocation = options.frameworkFolderLocation
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
logger.info("Reading dex files")
|
context.resourceContext.decodeResources(ResourceContext.ResourceDecodingMode.MANIFEST_ONLY)
|
||||||
// read dex files
|
|
||||||
val dexFile = MultiDexIO.readDexFile(true, options.inputFile, NAMER, null, null)
|
|
||||||
// get the opcodes
|
|
||||||
opcodes = dexFile.opcodes
|
|
||||||
// finally create patcher context
|
|
||||||
context = PatcherContext(dexFile.classes.toMutableList(), File(options.resourceCacheDirectory))
|
|
||||||
|
|
||||||
// decode manifest file
|
|
||||||
decodeResources(ResourceDecodingMode.MANIFEST_ONLY)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Fix circular dependency detection.
|
||||||
|
// /**
|
||||||
|
// * Add [Patch]es to ReVanced [Patcher].
|
||||||
|
// * It is not guaranteed that all supplied [Patch]es will be accepted, if an exception is thrown.
|
||||||
|
// *
|
||||||
|
// * @param patches The [Patch]es to add.
|
||||||
|
// * @throws PatcherException.CircularDependencyException If a circular dependency is detected.
|
||||||
|
// */
|
||||||
/**
|
/**
|
||||||
* Add integrations to be merged by the patcher.
|
* Add [Patch]es to ReVanced [Patcher].
|
||||||
* The integrations will only be merged, if necessary.
|
|
||||||
*
|
*
|
||||||
* @param integrations The integrations, must be dex files or dex file container such as ZIP, APK or DEX files.
|
* @param patches The [Patch]es to add.
|
||||||
* @param callback The callback for [integrations] which are being added.
|
*/
|
||||||
*/
|
@Suppress("NAME_SHADOWING")
|
||||||
fun addIntegrations(
|
override fun acceptPatches(patches: List<Patch<*>>) {
|
||||||
integrations: List<File>,
|
|
||||||
callback: (File) -> Unit
|
|
||||||
) {
|
|
||||||
context.integrations.apply integrations@{
|
|
||||||
add(integrations)
|
|
||||||
this@integrations.callback = callback
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save the patched dex file.
|
|
||||||
*/
|
|
||||||
fun save(): PatcherResult {
|
|
||||||
val packageMetadata = context.packageMetadata
|
|
||||||
val metaInfo = packageMetadata.metaInfo
|
|
||||||
var resourceFile: File? = null
|
|
||||||
|
|
||||||
when (resourceDecodingMode) {
|
|
||||||
ResourceDecodingMode.FULL -> {
|
|
||||||
val cacheDirectory = ExtFile(options.resourceCacheDirectory)
|
|
||||||
try {
|
|
||||||
val androlibResources = AndrolibResources().also { resources ->
|
|
||||||
resources.buildOptions = BuildOptions().also { buildOptions ->
|
|
||||||
buildOptions.setBuildOptions(options)
|
|
||||||
buildOptions.isFramework = metaInfo.isFrameworkApk
|
|
||||||
buildOptions.resourcesAreCompressed = metaInfo.compressionType
|
|
||||||
buildOptions.doNotCompress = metaInfo.doNotCompress
|
|
||||||
}
|
|
||||||
|
|
||||||
resources.setSdkInfo(metaInfo.sdkInfo)
|
|
||||||
resources.setVersionInfo(metaInfo.versionInfo)
|
|
||||||
resources.setSharedLibrary(metaInfo.sharedLibrary)
|
|
||||||
resources.setSparseResources(metaInfo.sparseResources)
|
|
||||||
}
|
|
||||||
|
|
||||||
val manifestFile = cacheDirectory.resolve("AndroidManifest.xml")
|
|
||||||
|
|
||||||
ResXmlPatcher.fixingPublicAttrsInProviderAttributes(manifestFile)
|
|
||||||
|
|
||||||
val aaptFile = cacheDirectory.resolve("aapt_temp_file")
|
|
||||||
|
|
||||||
// delete if it exists
|
|
||||||
Files.deleteIfExists(aaptFile.toPath())
|
|
||||||
|
|
||||||
val resDirectory = cacheDirectory.resolve("res")
|
|
||||||
val includedFiles = metaInfo.usesFramework.ids.map { id ->
|
|
||||||
androlibResources.getFrameworkApk(
|
|
||||||
id, metaInfo.usesFramework.tag
|
|
||||||
)
|
|
||||||
}.toTypedArray()
|
|
||||||
|
|
||||||
logger.info("Compiling resources")
|
|
||||||
androlibResources.aaptPackage(
|
|
||||||
aaptFile, manifestFile, resDirectory, null, null, includedFiles
|
|
||||||
)
|
|
||||||
|
|
||||||
resourceFile = aaptFile
|
|
||||||
} finally {
|
|
||||||
cacheDirectory.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> logger.info("Not compiling resources because resource patching is not required")
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("Creating new dex file")
|
|
||||||
val newDexFile = object : DexFile {
|
|
||||||
override fun getClasses() = context.bytecodeContext.classes.also { it.replaceClasses() }
|
|
||||||
override fun getOpcodes() = this@Patcher.opcodes
|
|
||||||
}
|
|
||||||
|
|
||||||
// write modified dex files
|
|
||||||
logger.info("Writing modified dex files")
|
|
||||||
val dexFiles = mutableMapOf<String, MemoryDataStore>()
|
|
||||||
MultiDexIO.writeDexFile(
|
|
||||||
true, -1, // core count
|
|
||||||
dexFiles, NAMER, newDexFile, DexIO.DEFAULT_MAX_DEX_POOL_SIZE, null
|
|
||||||
)
|
|
||||||
|
|
||||||
return PatcherResult(
|
|
||||||
dexFiles.map {
|
|
||||||
app.revanced.patcher.util.dex.DexFile(it.key, it.value.readAt(0))
|
|
||||||
},
|
|
||||||
metaInfo.doNotCompress?.toList(),
|
|
||||||
resourceFile
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add [Patch]es to the patcher.
|
|
||||||
* @param patches [Patch]es The patches to add.
|
|
||||||
*/
|
|
||||||
fun addPatches(patches: Iterable<Class<out Patch<Context>>>) {
|
|
||||||
/**
|
/**
|
||||||
* Returns true if at least one patches or its dependencies matches the given predicate.
|
* Add dependencies of a [Patch] recursively to [PatcherContext.allPatches].
|
||||||
|
* If a [Patch] is already in [PatcherContext.allPatches], it will not be added again.
|
||||||
*/
|
*/
|
||||||
fun Class<out Patch<Context>>.anyRecursively(predicate: (Class<out Patch<Context>>) -> Boolean): Boolean =
|
fun PatchClass.putDependenciesRecursively() {
|
||||||
predicate(this) || dependencies?.any { it.java.anyRecursively(predicate) } == true
|
if (context.allPatches.contains(this)) return
|
||||||
|
|
||||||
|
val dependency = this.java.getInstance(logger)!!
|
||||||
|
context.allPatches[this] = dependency
|
||||||
|
|
||||||
// Determine if resource patching is required.
|
dependency.dependencies?.forEach { it.putDependenciesRecursively() }
|
||||||
for (patch in patches) {
|
|
||||||
if (patch.anyRecursively { ResourcePatch::class.java.isAssignableFrom(it) }) {
|
|
||||||
resourceDecodingMode = ResourceDecodingMode.FULL
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if merging integrations is required.
|
// Add all patches and their dependencies to the context.
|
||||||
for (patch in patches) {
|
for (patch in patches) context.executablePatches.putIfAbsent(patch::class, patch) ?: run {
|
||||||
if (patch.anyRecursively { it.requiresIntegrations }) {
|
context.allPatches[patch::class] = patch
|
||||||
mergeIntegrations = true
|
|
||||||
break
|
patch.dependencies?.forEach { it.putDependenciesRecursively() }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
context.patches.addAll(patches)
|
/* TODO: Fix circular dependency detection.
|
||||||
|
val graph = mutableMapOf<PatchClass, MutableList<PatchClass>>()
|
||||||
|
fun PatchClass.visit() {
|
||||||
|
if (this in graph) return
|
||||||
|
|
||||||
|
val group = graph.getOrPut(this) { mutableListOf(this) }
|
||||||
|
|
||||||
|
val dependencies = context.allPatches[this]!!.manifest.dependencies ?: return
|
||||||
|
dependencies.forEach { dependency ->
|
||||||
|
if (group == graph[dependency])
|
||||||
|
throw PatcherException.CircularDependencyException(context.allPatches[this]!!.manifest.name)
|
||||||
|
|
||||||
|
graph[dependency] = group.apply { add(dependency) }
|
||||||
|
dependency.visit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if at least one patch or its dependencies matches the given predicate.
|
||||||
|
*
|
||||||
|
* @param predicate The predicate to match.
|
||||||
|
*/
|
||||||
|
fun Patch<*>.anyRecursively(predicate: (Patch<*>) -> Boolean): Boolean =
|
||||||
|
predicate(this) || dependencies?.any { dependency ->
|
||||||
|
context.allPatches[dependency]!!.anyRecursively(predicate)
|
||||||
|
} ?: false
|
||||||
|
|
||||||
|
context.allPatches.values.let { patches ->
|
||||||
|
// Determine, if resource patching is required.
|
||||||
|
for (patch in patches)
|
||||||
|
if (patch.anyRecursively { patch is ResourcePatch }) {
|
||||||
|
options.resourceDecodingMode = ResourceContext.ResourceDecodingMode.FULL
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine, if merging integrations is required.
|
||||||
|
for (patch in patches)
|
||||||
|
if (patch.anyRecursively { it.requiresIntegrations }) {
|
||||||
|
context.bytecodeContext.integrations.merge = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode resources for the patcher.
|
* Add integrations to the [Patcher].
|
||||||
*
|
*
|
||||||
* @param mode The [ResourceDecodingMode] to use when decoding.
|
* @param integrations The integrations to add. Must be a DEX file or container of DEX files.
|
||||||
*/
|
*/
|
||||||
private fun decodeResources(mode: ResourceDecodingMode) {
|
override fun acceptIntegrations(integrations: List<File>) {
|
||||||
val extInputFile = ExtFile(options.inputFile)
|
context.bytecodeContext.integrations.addAll(integrations)
|
||||||
try {
|
|
||||||
val androlib = Androlib(BuildOptions().also { it.setBuildOptions(options) })
|
|
||||||
val resourceTable = androlib.getResTable(extInputFile, true)
|
|
||||||
when (mode) {
|
|
||||||
ResourceDecodingMode.FULL -> {
|
|
||||||
val outDir = File(options.resourceCacheDirectory)
|
|
||||||
if (outDir.exists()) {
|
|
||||||
logger.info("Deleting existing resource cache directory")
|
|
||||||
if (!outDir.deleteRecursively()) {
|
|
||||||
logger.error("Failed to delete existing resource cache directory")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outDir.mkdirs()
|
|
||||||
|
|
||||||
logger.info("Decoding resources")
|
|
||||||
|
|
||||||
// decode resources to cache directory
|
|
||||||
androlib.decodeManifestWithResources(extInputFile, outDir, resourceTable)
|
|
||||||
androlib.decodeResourcesFull(extInputFile, outDir, resourceTable)
|
|
||||||
|
|
||||||
// read additional metadata from the resource table
|
|
||||||
context.packageMetadata.let { metadata ->
|
|
||||||
metadata.metaInfo.usesFramework = UsesFramework().also { framework ->
|
|
||||||
framework.ids = resourceTable.listFramePackages().map { it.id }.sorted()
|
|
||||||
}
|
|
||||||
|
|
||||||
// read files to not compress
|
|
||||||
metadata.metaInfo.doNotCompress = buildList {
|
|
||||||
androlib.recordUncompressedFiles(extInputFile, this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceDecodingMode.MANIFEST_ONLY -> {
|
|
||||||
logger.info("Decoding AndroidManifest.xml only, because resources are not needed")
|
|
||||||
|
|
||||||
// create decoder for the resource table
|
|
||||||
val decoder = ResAttrDecoder()
|
|
||||||
decoder.currentPackage = ResPackage(resourceTable, 0, null)
|
|
||||||
|
|
||||||
// create xml parser with the decoder
|
|
||||||
val axmlParser = AXmlResourceParser()
|
|
||||||
axmlParser.attrDecoder = decoder
|
|
||||||
|
|
||||||
// parse package information with the decoder and parser which will set required values in the resource table
|
|
||||||
// instead of decodeManifest another more low level solution can be created to make it faster/better
|
|
||||||
XmlPullStreamDecoder(
|
|
||||||
axmlParser, AndrolibResources().resXmlSerializer
|
|
||||||
).decodeManifest(
|
|
||||||
extInputFile.directory.getFileInput("AndroidManifest.xml"),
|
|
||||||
// Older Android versions do not support OutputStream.nullOutputStream()
|
|
||||||
object : OutputStream() {
|
|
||||||
override fun write(b: Int) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// read of the resourceTable which is created by reading the manifest file
|
|
||||||
context.packageMetadata.let { metadata ->
|
|
||||||
metadata.packageName = resourceTable.currentResPackage.name
|
|
||||||
metadata.packageVersion = resourceTable.versionInfo.versionName ?: resourceTable.versionInfo.versionCode
|
|
||||||
metadata.metaInfo.versionInfo = resourceTable.versionInfo
|
|
||||||
metadata.metaInfo.sdkInfo = resourceTable.sdkInfo
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
extInputFile.close()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute patches added the patcher.
|
* Execute [Patch]es that were added to ReVanced [Patcher].
|
||||||
*
|
*
|
||||||
* @param stopOnError If true, the patches will stop on the first error.
|
* @param returnOnError If true, ReVanced [Patcher] will return immediately if a [Patch] fails.
|
||||||
* @return A pair of the name of the [Patch] and its [PatchResult].
|
* @return A pair of the name of the [Patch] and its [PatchResult].
|
||||||
*/
|
*/
|
||||||
fun executePatches(stopOnError: Boolean = false): Sequence<Pair<String, Result<PatchResultSuccess>>> {
|
override fun apply(returnOnError: Boolean) = flow {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a [Patch] and its dependencies recursively.
|
* Execute a [Patch] and its dependencies recursively.
|
||||||
*
|
*
|
||||||
* @param patchClass The [Patch] to execute.
|
* @param patch The [Patch] to execute.
|
||||||
* @param executedPatches A map of [Patch]es paired to a boolean indicating their success, to prevent infinite recursion.
|
* @param executedPatches A map to prevent [Patch]es from being executed twice due to dependencies.
|
||||||
* @return The result of executing the [Patch].
|
* @return The result of executing the [Patch].
|
||||||
*/
|
*/
|
||||||
fun executePatch(
|
fun executePatch(
|
||||||
patchClass: Class<out Patch<Context>>,
|
patch: Patch<*>,
|
||||||
executedPatches: LinkedHashMap<String, ExecutedPatch>
|
executedPatches: LinkedHashMap<Patch<*>, PatchResult>
|
||||||
): PatchResult {
|
): PatchResult {
|
||||||
val patchName = patchClass.patchName
|
val patchName = patch.name ?: patch.toString()
|
||||||
|
|
||||||
// if the patch has already applied silently skip it
|
executedPatches[patch]?.let { patchResult ->
|
||||||
if (executedPatches.contains(patchName)) {
|
patchResult.exception ?: return patchResult
|
||||||
if (!executedPatches[patchName]!!.success)
|
|
||||||
return PatchResultError("'$patchName' did not succeed previously")
|
|
||||||
|
|
||||||
logger.trace("Skipping '$patchName' because it has already been applied")
|
// Return a new result with an exception indicating that the patch was not executed previously,
|
||||||
|
// because it is a dependency of another patch that failed.
|
||||||
return PatchResultSuccess()
|
return PatchResult(patch, PatchException("'$patchName' did not succeed previously"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// recursively execute all dependency patches
|
// Recursively execute all dependency patches.
|
||||||
patchClass.dependencies?.forEach { dependencyClass ->
|
patch.dependencies?.forEach { dependencyClass ->
|
||||||
val dependency = dependencyClass.java
|
val dependency = context.allPatches[dependencyClass]!!
|
||||||
|
|
||||||
val result = executePatch(dependency, executedPatches)
|
val result = executePatch(dependency, executedPatches)
|
||||||
if (result.isSuccess()) return@forEach
|
|
||||||
|
|
||||||
return PatchResultError(
|
result.exception?.let {
|
||||||
"'$patchName' depends on '${dependency.patchName}' but the following error was raised: " +
|
return PatchResult(
|
||||||
result.error()!!.let { it.cause?.stackTraceToString() ?: it.message }
|
patch,
|
||||||
)
|
PatchException(
|
||||||
}
|
"'$patchName' depends on '${dependency.name ?: dependency}' " +
|
||||||
|
"that raised an exception:\n${it.stackTraceToString()}"
|
||||||
val isResourcePatch = ResourcePatch::class.java.isAssignableFrom(patchClass)
|
)
|
||||||
val patchInstance = patchClass.getDeclaredConstructor().newInstance()
|
)
|
||||||
|
|
||||||
// TODO: implement this in a more polymorphic way
|
|
||||||
val patchContext = if (isResourcePatch) {
|
|
||||||
context.resourceContext
|
|
||||||
} else {
|
|
||||||
context.bytecodeContext.also { context ->
|
|
||||||
(patchInstance as BytecodePatch).fingerprints?.resolveUsingLookupMap(context)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.trace("Executing '$patchName' of type: ${if (isResourcePatch) "resource" else "bytecode"}")
|
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
patchInstance.execute(patchContext).also {
|
// TODO: Implement this in a more polymorphic way.
|
||||||
executedPatches[patchName] = ExecutedPatch(patchInstance, it.isSuccess())
|
when (patch) {
|
||||||
}
|
is BytecodePatch -> {
|
||||||
} catch (e: Exception) {
|
patch.fingerprints.resolveUsingLookupMap(context.bytecodeContext)
|
||||||
PatchResultError(e).also {
|
patch.execute(context.bytecodeContext)
|
||||||
executedPatches[patchName] = ExecutedPatch(patchInstance, false)
|
}
|
||||||
}
|
is ResourcePatch -> {
|
||||||
}
|
patch.execute(context.resourceContext)
|
||||||
}
|
|
||||||
|
|
||||||
return sequence {
|
|
||||||
if (mergeIntegrations) context.integrations.merge(logger)
|
|
||||||
|
|
||||||
logger.trace("Initialize lookup maps for method MethodFingerprint resolution")
|
|
||||||
|
|
||||||
MethodFingerprint.initializeFingerprintResolutionLookupMaps(context.bytecodeContext)
|
|
||||||
|
|
||||||
// prevent from decoding the manifest twice if it is not needed
|
|
||||||
if (resourceDecodingMode == ResourceDecodingMode.FULL) decodeResources(ResourceDecodingMode.FULL)
|
|
||||||
|
|
||||||
logger.info("Executing patches")
|
|
||||||
|
|
||||||
val executedPatches = LinkedHashMap<String, ExecutedPatch>() // first is name
|
|
||||||
|
|
||||||
context.patches.forEach { patch ->
|
|
||||||
val patchResult = executePatch(patch, executedPatches)
|
|
||||||
|
|
||||||
val result = if (patchResult.isSuccess()) {
|
|
||||||
Result.success(patchResult.success()!!)
|
|
||||||
} else {
|
|
||||||
Result.failure(patchResult.error()!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: This prints before the patch really finishes in case it is a Closeable
|
|
||||||
// because the Closeable is closed after all patches are executed.
|
|
||||||
yield(patch.patchName to result)
|
|
||||||
|
|
||||||
if (stopOnError && patchResult.isError()) return@sequence
|
|
||||||
}
|
|
||||||
|
|
||||||
executedPatches.values
|
|
||||||
.filter(ExecutedPatch::success)
|
|
||||||
.map(ExecutedPatch::patchInstance)
|
|
||||||
.filterIsInstance(Closeable::class.java)
|
|
||||||
.asReversed().forEach {
|
|
||||||
try {
|
|
||||||
it.close()
|
|
||||||
} catch (exception: Exception) {
|
|
||||||
val patchName = (it as Patch<Context>).javaClass.patchName
|
|
||||||
|
|
||||||
logger.error("Failed to close '$patchName': ${exception.stackTraceToString()}")
|
|
||||||
|
|
||||||
yield(patchName to Result.failure(exception))
|
|
||||||
|
|
||||||
// This is not failsafe. If a patch throws an exception while closing,
|
|
||||||
// the other patches that depend on it may fail.
|
|
||||||
if (stopOnError) return@sequence
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PatchResult(patch)
|
||||||
|
} catch (exception: PatchException) {
|
||||||
|
PatchResult(patch, exception)
|
||||||
|
} catch (exception: Exception) {
|
||||||
|
PatchResult(patch, PatchException(exception))
|
||||||
|
}.also { executedPatches[patch] = it }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.bytecodeContext.integrations.merge) context.bytecodeContext.integrations.flush()
|
||||||
|
|
||||||
|
initializeLookupMaps(context.bytecodeContext)
|
||||||
|
|
||||||
|
// Prevent from decoding the app manifest twice if it is not needed.
|
||||||
|
if (options.resourceDecodingMode == ResourceContext.ResourceDecodingMode.FULL)
|
||||||
|
context.resourceContext.decodeResources(ResourceContext.ResourceDecodingMode.FULL)
|
||||||
|
|
||||||
|
logger.info("Executing patches")
|
||||||
|
|
||||||
|
val executedPatches = LinkedHashMap<Patch<*>, PatchResult>() // Key is name.
|
||||||
|
|
||||||
|
context.executablePatches.values.sortedBy { it.name }.forEach { patch ->
|
||||||
|
val patchResult = executePatch(patch, executedPatches)
|
||||||
|
|
||||||
|
// If the patch failed, emit the result, even if it is closeable.
|
||||||
|
// Results of executed patches that are closeable will be emitted later.
|
||||||
|
patchResult.exception?.let {
|
||||||
|
// Propagate exception to caller instead of wrapping it in a new exception.
|
||||||
|
emit(patchResult)
|
||||||
|
|
||||||
|
if (returnOnError) return@flow
|
||||||
|
} ?: run {
|
||||||
|
if (patch is Closeable) return@run
|
||||||
|
|
||||||
|
emit(patchResult)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
executedPatches.values
|
||||||
|
.filter { it.exception == null }
|
||||||
|
.filter { it.patch is Closeable }.asReversed().forEach { executedPatch ->
|
||||||
|
val patch = executedPatch.patch
|
||||||
|
|
||||||
|
val result = try {
|
||||||
|
(patch as Closeable).close()
|
||||||
|
|
||||||
|
executedPatch
|
||||||
|
} catch (exception: PatchException) {
|
||||||
|
PatchResult(patch, exception)
|
||||||
|
} catch (exception: Exception) {
|
||||||
|
PatchResult(patch, PatchException(exception))
|
||||||
|
}
|
||||||
|
|
||||||
|
result.exception?.let {
|
||||||
|
emit(
|
||||||
|
PatchResult(
|
||||||
|
patch,
|
||||||
|
PatchException(
|
||||||
|
"'${patch.name}' raised an exception while being closed: ${it.stackTraceToString()}",
|
||||||
|
result.exception
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if (returnOnError) return@flow
|
||||||
|
} ?: run {
|
||||||
|
patch.name ?: return@run
|
||||||
|
|
||||||
|
emit(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun close() = clearLookupMaps()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of decoding the resources.
|
* Compile and save the patched APK file.
|
||||||
|
*
|
||||||
|
* @return The [PatcherResult] containing the patched input files.
|
||||||
*/
|
*/
|
||||||
private enum class ResourceDecodingMode {
|
override fun get() = PatcherResult(
|
||||||
/**
|
context.bytecodeContext.get(),
|
||||||
* Decode all resources.
|
context.resourceContext.get(),
|
||||||
*/
|
context.packageMetadata.apkInfo.doNotCompress?.toList()
|
||||||
FULL,
|
)
|
||||||
|
|
||||||
/**
|
|
||||||
* Decode the manifest file only.
|
|
||||||
*/
|
|
||||||
MANIFEST_ONLY,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A result of executing a [Patch].
|
|
||||||
*
|
|
||||||
* @param patchInstance The instance of the [Patch] that was applied.
|
|
||||||
* @param success The result of the [Patch].
|
|
||||||
*/
|
|
||||||
internal data class ExecutedPatch(val patchInstance: Patch<Context>, val success: Boolean)
|
|
||||||
@@ -1,64 +1,41 @@
|
|||||||
package app.revanced.patcher
|
package app.revanced.patcher
|
||||||
|
|
||||||
import app.revanced.patcher.data.*
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.logging.Logger
|
import app.revanced.patcher.data.ResourceContext
|
||||||
import app.revanced.patcher.patch.Patch
|
import app.revanced.patcher.patch.Patch
|
||||||
import app.revanced.patcher.util.ClassMerger.merge
|
import brut.androlib.apk.ApkInfo
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import brut.directory.ExtFile
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
data class PatcherContext(
|
/**
|
||||||
val classes: MutableList<ClassDef>,
|
* A context for ReVanced [Patcher].
|
||||||
val resourceCacheDirectory: File,
|
*
|
||||||
) {
|
* @param options The [PatcherOptions] used to create this context.
|
||||||
val packageMetadata = PackageMetadata()
|
*/
|
||||||
internal val patches = mutableListOf<Class<out Patch<Context>>>()
|
class PatcherContext internal constructor(options: PatcherOptions) {
|
||||||
internal val integrations = Integrations(this)
|
/**
|
||||||
internal val bytecodeContext = BytecodeContext(classes)
|
* [PackageMetadata] of the supplied [PatcherOptions.inputFile].
|
||||||
internal val resourceContext = ResourceContext(resourceCacheDirectory)
|
*/
|
||||||
|
val packageMetadata = PackageMetadata(ApkInfo(ExtFile(options.inputFile)))
|
||||||
|
|
||||||
internal class Integrations(val context: PatcherContext) {
|
/**
|
||||||
var callback: ((File) -> Unit)? = null
|
* The map of [Patch]es associated by their [PatchClass].
|
||||||
private val integrations: MutableList<File> = mutableListOf()
|
*/
|
||||||
|
internal val executablePatches = mutableMapOf<PatchClass, Patch<*>>()
|
||||||
|
|
||||||
fun add(integrations: List<File>) = this@Integrations.integrations.addAll(integrations)
|
/**
|
||||||
|
* The map of all [Patch]es and their dependencies associated by their [PatchClass].
|
||||||
|
*/
|
||||||
|
internal val allPatches = mutableMapOf<PatchClass, Patch<*>>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge integrations.
|
* The [ResourceContext] of this [PatcherContext].
|
||||||
* @param logger A logger.
|
* This holds the current state of the resources.
|
||||||
*/
|
*/
|
||||||
fun merge(logger: Logger) {
|
internal val resourceContext = ResourceContext(this, options)
|
||||||
with(context.bytecodeContext.classes) {
|
|
||||||
for (integrations in integrations) {
|
|
||||||
callback?.let { it(integrations) }
|
|
||||||
|
|
||||||
for (classDef in lanchon.multidexlib2.MultiDexIO.readDexFile(
|
/**
|
||||||
true,
|
* The [BytecodeContext] of this [PatcherContext].
|
||||||
integrations,
|
* This holds the current state of the bytecode.
|
||||||
NAMER,
|
*/
|
||||||
null,
|
internal val bytecodeContext = BytecodeContext(options)
|
||||||
null
|
|
||||||
).classes) {
|
|
||||||
val type = classDef.type
|
|
||||||
|
|
||||||
val result = classes.findIndexed { it.type == type }
|
|
||||||
if (result == null) {
|
|
||||||
logger.trace("Merging type $type")
|
|
||||||
classes.add(classDef)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
val (existingClass, existingClassIndex) = result
|
|
||||||
|
|
||||||
logger.trace("Type $type exists. Adding missing methods and fields.")
|
|
||||||
|
|
||||||
existingClass.merge(classDef, context, logger).let { mergedClass ->
|
|
||||||
if (mergedClass !== existingClass) // referential equality check
|
|
||||||
classes[existingClassIndex] = mergedClass
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
16
src/main/kotlin/app/revanced/patcher/PatcherException.kt
Normal file
16
src/main/kotlin/app/revanced/patcher/PatcherException.kt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package app.revanced.patcher
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception thrown by ReVanced [Patcher].
|
||||||
|
*
|
||||||
|
* @param errorMessage The exception message.
|
||||||
|
* @param cause The corresponding [Throwable].
|
||||||
|
*/
|
||||||
|
sealed class PatcherException(errorMessage: String?, cause: Throwable?) : Exception(errorMessage, cause) {
|
||||||
|
constructor(errorMessage: String) : this(errorMessage, null)
|
||||||
|
|
||||||
|
|
||||||
|
class CircularDependencyException internal constructor(dependant: String) : PatcherException(
|
||||||
|
"Patch '$dependant' causes a circular dependency"
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,21 +1,51 @@
|
|||||||
package app.revanced.patcher
|
package app.revanced.patcher
|
||||||
|
|
||||||
import app.revanced.patcher.logging.Logger
|
import app.revanced.patcher.data.ResourceContext
|
||||||
import app.revanced.patcher.logging.impl.NopLogger
|
import brut.androlib.Config
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.logging.Logger
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for the [Patcher].
|
* Options for ReVanced [Patcher].
|
||||||
* @param inputFile The input file (usually an apk file).
|
* @param inputFile The input file to patch.
|
||||||
* @param resourceCacheDirectory Directory to cache resources.
|
* @param resourceCachePath The path to the directory to use for caching resources.
|
||||||
* @param aaptPath Optional path to a custom aapt binary.
|
* @param aaptBinaryPath The path to a custom aapt binary.
|
||||||
* @param frameworkFolderLocation Optional path to a custom framework folder.
|
* @param frameworkFileDirectory The path to the directory to cache the framework file in.
|
||||||
* @param logger Custom logger implementation for the [Patcher].
|
* @param multithreadingDexFileWriter Whether to use multiple threads for writing dex files.
|
||||||
|
* This can impact memory usage.
|
||||||
*/
|
*/
|
||||||
data class PatcherOptions(
|
data class PatcherOptions(
|
||||||
internal val inputFile: File,
|
internal val inputFile: File,
|
||||||
internal val resourceCacheDirectory: String,
|
internal val resourceCachePath: File = File("revanced-resource-cache"),
|
||||||
internal val aaptPath: String? = null,
|
internal val aaptBinaryPath: String? = null,
|
||||||
internal val frameworkFolderLocation: String? = null,
|
internal val frameworkFileDirectory: String? = null,
|
||||||
internal val logger: Logger = NopLogger
|
internal val multithreadingDexFileWriter: Boolean = false,
|
||||||
)
|
) {
|
||||||
|
private val logger = Logger.getLogger(PatcherOptions::class.java.name)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mode to use for resource decoding.
|
||||||
|
* @see ResourceContext.ResourceDecodingMode
|
||||||
|
*/
|
||||||
|
internal var resourceDecodingMode = ResourceContext.ResourceDecodingMode.MANIFEST_ONLY
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The configuration to use for resource decoding and compiling.
|
||||||
|
*/
|
||||||
|
internal val resourceConfig = Config.getDefaultConfig().apply {
|
||||||
|
useAapt2 = true
|
||||||
|
aaptPath = aaptBinaryPath ?: ""
|
||||||
|
frameworkDirectory = frameworkFileDirectory
|
||||||
|
}
|
||||||
|
|
||||||
|
fun recreateResourceCacheDirectory() = resourceCachePath.also {
|
||||||
|
if (it.exists()) {
|
||||||
|
logger.info("Deleting existing resource cache directory")
|
||||||
|
|
||||||
|
if (!it.deleteRecursively())
|
||||||
|
logger.severe("Failed to delete existing resource cache directory")
|
||||||
|
}
|
||||||
|
|
||||||
|
it.mkdirs()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
package app.revanced.patcher
|
package app.revanced.patcher
|
||||||
|
|
||||||
import app.revanced.patcher.util.dex.DexFile
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result of a patcher.
|
* The result of a patcher.
|
||||||
* @param dexFiles The patched dex files.
|
* @param dexFiles The patched dex files.
|
||||||
* @param doNotCompress List of relative paths to files to exclude from compressing.
|
|
||||||
* @param resourceFile File containing resources that need to be extracted into the APK.
|
* @param resourceFile File containing resources that need to be extracted into the APK.
|
||||||
|
* @param doNotCompress List of relative paths of files to exclude from compressing.
|
||||||
*/
|
*/
|
||||||
data class PatcherResult(
|
data class PatcherResult(
|
||||||
val dexFiles: List<DexFile>,
|
val dexFiles: List<PatchedDexFile>,
|
||||||
val doNotCompress: List<String>? = null,
|
val resourceFile: File?,
|
||||||
val resourceFile: File?
|
val doNotCompress: List<String>? = null
|
||||||
)
|
) {
|
||||||
|
/**
|
||||||
|
* Wrapper for dex files.
|
||||||
|
* @param name The original name of the dex file.
|
||||||
|
* @param stream The dex file as [InputStream].
|
||||||
|
*/
|
||||||
|
class PatchedDexFile(val name: String, val stream: InputStream)
|
||||||
|
}
|
||||||
8
src/main/kotlin/app/revanced/patcher/PatchesConsumer.kt
Normal file
8
src/main/kotlin/app/revanced/patcher/PatchesConsumer.kt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package app.revanced.patcher
|
||||||
|
|
||||||
|
import app.revanced.patcher.patch.Patch
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
interface PatchesConsumer {
|
||||||
|
fun acceptPatches(patches: List<Patch<*>>)
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package app.revanced.patcher.annotation
|
|
||||||
|
|
||||||
import app.revanced.patcher.patch.Patch
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation to constrain a [Patch] to compatible packages.
|
|
||||||
* @param compatiblePackages A list of packages a [Patch] is compatible with.
|
|
||||||
*/
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
|
||||||
annotation class Compatibility(
|
|
||||||
val compatiblePackages: Array<Package>,
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation to represent packages a patch can be compatible with.
|
|
||||||
* @param name The package identifier name.
|
|
||||||
* @param versions The versions of the package the [Patch] is compatible with.
|
|
||||||
*/
|
|
||||||
@Target()
|
|
||||||
annotation class Package(
|
|
||||||
val name: String,
|
|
||||||
val versions: Array<String> = [],
|
|
||||||
)
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package app.revanced.patcher.annotation
|
|
||||||
|
|
||||||
import app.revanced.patcher.patch.Patch
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation to name a [Patch].
|
|
||||||
* @param name A suggestive name for the [Patch].
|
|
||||||
*/
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
|
||||||
annotation class Name(
|
|
||||||
val name: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation to describe a [Patch].
|
|
||||||
* @param description A description for the [Patch].
|
|
||||||
*/
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
|
||||||
annotation class Description(
|
|
||||||
val description: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation to version a [Patch].
|
|
||||||
* @param version The version of a [Patch].
|
|
||||||
*/
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
|
||||||
annotation class Version(
|
|
||||||
val version: String,
|
|
||||||
)
|
|
||||||
168
src/main/kotlin/app/revanced/patcher/data/BytecodeContext.kt
Normal file
168
src/main/kotlin/app/revanced/patcher/data/BytecodeContext.kt
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
package app.revanced.patcher.data
|
||||||
|
|
||||||
|
import app.revanced.patcher.PatcherContext
|
||||||
|
import app.revanced.patcher.PatcherOptions
|
||||||
|
import app.revanced.patcher.PatcherResult
|
||||||
|
import app.revanced.patcher.patch.Patch
|
||||||
|
import app.revanced.patcher.util.ClassMerger.merge
|
||||||
|
import app.revanced.patcher.util.ProxyClassList
|
||||||
|
import app.revanced.patcher.util.method.MethodWalker
|
||||||
|
import app.revanced.patcher.util.proxy.ClassProxy
|
||||||
|
import com.android.tools.smali.dexlib2.Opcodes
|
||||||
|
import com.android.tools.smali.dexlib2.iface.ClassDef
|
||||||
|
import com.android.tools.smali.dexlib2.iface.DexFile
|
||||||
|
import com.android.tools.smali.dexlib2.iface.Method
|
||||||
|
import lanchon.multidexlib2.BasicDexFileNamer
|
||||||
|
import lanchon.multidexlib2.DexIO
|
||||||
|
import lanchon.multidexlib2.MultiDexIO
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileFilter
|
||||||
|
import java.io.Flushable
|
||||||
|
import java.util.logging.Logger
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A context for bytecode.
|
||||||
|
* This holds the current state of the bytecode.
|
||||||
|
*
|
||||||
|
* @param options The [PatcherOptions] used to create this context.
|
||||||
|
*/
|
||||||
|
class BytecodeContext internal constructor(private val options: PatcherOptions) :
|
||||||
|
Context<List<PatcherResult.PatchedDexFile>> {
|
||||||
|
private val logger = Logger.getLogger(BytecodeContext::class.java.name)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Opcodes] of the supplied [PatcherOptions.inputFile].
|
||||||
|
*/
|
||||||
|
internal lateinit var opcodes: Opcodes
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of classes.
|
||||||
|
*/
|
||||||
|
val classes by lazy {
|
||||||
|
ProxyClassList(
|
||||||
|
MultiDexIO.readDexFile(
|
||||||
|
true, options.inputFile, BasicDexFileNamer(), null, null
|
||||||
|
).also { opcodes = it.opcodes }.classes.toMutableSet()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The [Integrations] of this [PatcherContext].
|
||||||
|
*/
|
||||||
|
internal val integrations = Integrations()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a class by a given class name.
|
||||||
|
*
|
||||||
|
* @param className The name of the class.
|
||||||
|
* @return A proxy for the first class that matches the class name.
|
||||||
|
*/
|
||||||
|
fun findClass(className: String) = findClass { it.type.contains(className) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a class by a given predicate.
|
||||||
|
*
|
||||||
|
* @param predicate A predicate to match the class.
|
||||||
|
* @return A proxy for the first class that matches the predicate.
|
||||||
|
*/
|
||||||
|
fun findClass(predicate: (ClassDef) -> Boolean) =
|
||||||
|
// if we already proxied the class matching the predicate...
|
||||||
|
classes.proxies.firstOrNull { predicate(it.immutableClass) } ?:
|
||||||
|
// else resolve the class to a proxy and return it, if the predicate is matching a class
|
||||||
|
classes.find(predicate)?.let { proxy(it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proxy a class.
|
||||||
|
* This will allow the class to be modified.
|
||||||
|
*
|
||||||
|
* @param classDef The class to proxy.
|
||||||
|
* @return A proxy for the class.
|
||||||
|
*/
|
||||||
|
fun proxy(classDef: ClassDef) = this.classes.proxies.find { it.immutableClass.type == classDef.type } ?: let {
|
||||||
|
ClassProxy(classDef).also { this.classes.add(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a [MethodWalker] instance for the current [BytecodeContext].
|
||||||
|
*
|
||||||
|
* @param startMethod The method to start at.
|
||||||
|
* @return A [MethodWalker] instance.
|
||||||
|
*/
|
||||||
|
fun toMethodWalker(startMethod: Method) = MethodWalker(this, startMethod)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile bytecode from the [BytecodeContext].
|
||||||
|
*
|
||||||
|
* @return The compiled bytecode.
|
||||||
|
*/
|
||||||
|
override fun get(): List<PatcherResult.PatchedDexFile> {
|
||||||
|
logger.info("Compiling patched dex files")
|
||||||
|
|
||||||
|
val patchedDexFileResults = options.resourceCachePath.resolve("dex").also {
|
||||||
|
it.deleteRecursively() // Make sure the directory is empty.
|
||||||
|
it.mkdirs()
|
||||||
|
}.apply {
|
||||||
|
MultiDexIO.writeDexFile(
|
||||||
|
true,
|
||||||
|
if (options.multithreadingDexFileWriter) -1 else 1,
|
||||||
|
this,
|
||||||
|
BasicDexFileNamer(),
|
||||||
|
object : DexFile {
|
||||||
|
override fun getClasses() = this@BytecodeContext.classes.also(ProxyClassList::replaceClasses)
|
||||||
|
override fun getOpcodes() = this@BytecodeContext.opcodes
|
||||||
|
},
|
||||||
|
DexIO.DEFAULT_MAX_DEX_POOL_SIZE
|
||||||
|
) { _, entryName, _ -> logger.info("Compiled $entryName") }
|
||||||
|
}.listFiles(FileFilter { it.isFile })!!.map { PatcherResult.PatchedDexFile(it.name, it.inputStream()) }
|
||||||
|
|
||||||
|
System.gc()
|
||||||
|
|
||||||
|
return patchedDexFileResults
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The integrations of a [PatcherContext].
|
||||||
|
*/
|
||||||
|
internal inner class Integrations : MutableList<File> by mutableListOf(), Flushable {
|
||||||
|
/**
|
||||||
|
* Whether to merge integrations.
|
||||||
|
* Set to true, if the field requiresIntegrations of any supplied [Patch] is true.
|
||||||
|
*/
|
||||||
|
var merge = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge integrations into the [BytecodeContext] and flush all [Integrations].
|
||||||
|
*/
|
||||||
|
override fun flush() {
|
||||||
|
if (!merge) return
|
||||||
|
|
||||||
|
logger.info("Merging integrations")
|
||||||
|
|
||||||
|
val classMap = classes.associateBy { it.type }
|
||||||
|
|
||||||
|
this@Integrations.forEach { integrations ->
|
||||||
|
MultiDexIO.readDexFile(
|
||||||
|
true,
|
||||||
|
integrations, BasicDexFileNamer(),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
).classes.forEach classDef@{ classDef ->
|
||||||
|
val existingClass = classMap[classDef.type] ?: run {
|
||||||
|
logger.fine("Adding $classDef")
|
||||||
|
classes.add(classDef)
|
||||||
|
return@classDef
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.fine("$classDef exists. Adding missing methods and fields.")
|
||||||
|
|
||||||
|
existingClass.merge(classDef, this@BytecodeContext).let { mergedClass ->
|
||||||
|
// If the class was merged, replace the original class with the merged class.
|
||||||
|
if (mergedClass === existingClass) return@let
|
||||||
|
classes.apply { remove(existingClass); add(mergedClass) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clear()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,170 +1,9 @@
|
|||||||
package app.revanced.patcher.data
|
package app.revanced.patcher.data
|
||||||
|
|
||||||
import app.revanced.patcher.util.ProxyBackedClassList
|
import java.util.function.Supplier
|
||||||
import app.revanced.patcher.util.method.MethodWalker
|
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
|
||||||
import org.jf.dexlib2.iface.Method
|
|
||||||
import org.w3c.dom.Document
|
|
||||||
import java.io.Closeable
|
|
||||||
import java.io.File
|
|
||||||
import java.io.InputStream
|
|
||||||
import java.io.OutputStream
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory
|
|
||||||
import javax.xml.transform.TransformerFactory
|
|
||||||
import javax.xml.transform.dom.DOMSource
|
|
||||||
import javax.xml.transform.stream.StreamResult
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A common interface to constrain [Context] to [BytecodeContext] and [ResourceContext].
|
* A common interface for contexts such as [ResourceContext] and [BytecodeContext].
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sealed interface Context
|
sealed interface Context<T> : Supplier<T>
|
||||||
|
|
||||||
class BytecodeContext internal constructor(classes: MutableList<ClassDef>) : Context {
|
|
||||||
/**
|
|
||||||
* The list of classes.
|
|
||||||
*/
|
|
||||||
val classes = ProxyBackedClassList(classes)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find a class by a given class name.
|
|
||||||
*
|
|
||||||
* @param className The name of the class.
|
|
||||||
* @return A proxy for the first class that matches the class name.
|
|
||||||
*/
|
|
||||||
fun findClass(className: String) = findClass { it.type.contains(className) }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find a class by a given predicate.
|
|
||||||
*
|
|
||||||
* @param predicate A predicate to match the class.
|
|
||||||
* @return A proxy for the first class that matches the predicate.
|
|
||||||
*/
|
|
||||||
fun findClass(predicate: (ClassDef) -> Boolean) =
|
|
||||||
// if we already proxied the class matching the predicate...
|
|
||||||
classes.proxies.firstOrNull { predicate(it.immutableClass) } ?:
|
|
||||||
// else resolve the class to a proxy and return it, if the predicate is matching a class
|
|
||||||
classes.find(predicate)?.let { proxy(it) }
|
|
||||||
|
|
||||||
fun proxy(classDef: ClassDef): app.revanced.patcher.util.proxy.ClassProxy {
|
|
||||||
var proxy = this.classes.proxies.find { it.immutableClass.type == classDef.type }
|
|
||||||
if (proxy == null) {
|
|
||||||
proxy = app.revanced.patcher.util.proxy.ClassProxy(classDef)
|
|
||||||
this.classes.add(proxy)
|
|
||||||
}
|
|
||||||
return proxy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a [MethodWalker] instance for the current [BytecodeContext].
|
|
||||||
*
|
|
||||||
* @param startMethod The method to start at.
|
|
||||||
* @return A [MethodWalker] instance.
|
|
||||||
*/
|
|
||||||
fun BytecodeContext.toMethodWalker(startMethod: Method): MethodWalker {
|
|
||||||
return MethodWalker(this, startMethod)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal inline fun <T> Iterable<T>.findIndexed(predicate: (T) -> Boolean): Pair<T, Int>? {
|
|
||||||
for ((index, element) in this.withIndex()) {
|
|
||||||
if (predicate(element)) {
|
|
||||||
return element to index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
class ResourceContext internal constructor(private val resourceCacheDirectory: File) : Context, Iterable<File> {
|
|
||||||
val xmlEditor = XmlFileHolder()
|
|
||||||
|
|
||||||
operator fun get(path: String) = resourceCacheDirectory.resolve(path)
|
|
||||||
|
|
||||||
override fun iterator() = resourceCacheDirectory.walkTopDown().iterator()
|
|
||||||
|
|
||||||
inner class XmlFileHolder {
|
|
||||||
operator fun get(inputStream: InputStream) =
|
|
||||||
DomFileEditor(inputStream)
|
|
||||||
|
|
||||||
operator fun get(path: String): DomFileEditor {
|
|
||||||
return DomFileEditor(this@ResourceContext[path])
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper for a file that can be edited as a dom document.
|
|
||||||
*
|
|
||||||
* This constructor does not check for locks to the file when writing.
|
|
||||||
* Use the secondary constructor.
|
|
||||||
*
|
|
||||||
* @param inputStream the input stream to read the xml file from.
|
|
||||||
* @param outputStream the output stream to write the xml file to. If null, the file will be read only.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class DomFileEditor internal constructor(
|
|
||||||
private val inputStream: InputStream,
|
|
||||||
private val outputStream: Lazy<OutputStream>? = null,
|
|
||||||
) : Closeable {
|
|
||||||
// path to the xml file to unlock the resource when closing the editor
|
|
||||||
private var filePath: String? = null
|
|
||||||
private var closed: Boolean = false
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The document of the xml file
|
|
||||||
*/
|
|
||||||
val file: Document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream)
|
|
||||||
.also(Document::normalize)
|
|
||||||
|
|
||||||
|
|
||||||
// lazily open an output stream
|
|
||||||
// this is required because when constructing a DomFileEditor the output stream is created along with the input stream, which is not allowed
|
|
||||||
// the workaround is to lazily create the output stream. This way it would be used after the input stream is closed, which happens in the constructor
|
|
||||||
constructor(file: File) : this(file.inputStream(), lazy { file.outputStream() }) {
|
|
||||||
// increase the lock
|
|
||||||
locks.merge(file.path, 1, Integer::sum)
|
|
||||||
filePath = file.path
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes the editor. Write backs and decreases the lock count.
|
|
||||||
*
|
|
||||||
* Will not write back to the file if the file is still locked.
|
|
||||||
*/
|
|
||||||
override fun close() {
|
|
||||||
if (closed) return
|
|
||||||
|
|
||||||
inputStream.close()
|
|
||||||
|
|
||||||
// if the output stream is not null, do not close it
|
|
||||||
outputStream?.let {
|
|
||||||
// prevent writing to same file, if it is being locked
|
|
||||||
// isLocked will be false if the editor was created through a stream
|
|
||||||
val isLocked = filePath?.let { path ->
|
|
||||||
val isLocked = locks[path]!! > 1
|
|
||||||
// decrease the lock count if the editor was opened for a file
|
|
||||||
locks.merge(path, -1, Integer::sum)
|
|
||||||
isLocked
|
|
||||||
} ?: false
|
|
||||||
|
|
||||||
// if unlocked, write back to the file
|
|
||||||
if (!isLocked) {
|
|
||||||
it.value.use { stream ->
|
|
||||||
val result = StreamResult(stream)
|
|
||||||
TransformerFactory.newInstance().newTransformer().transform(DOMSource(file), result)
|
|
||||||
}
|
|
||||||
|
|
||||||
it.value.close()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
closed = true
|
|
||||||
}
|
|
||||||
|
|
||||||
private companion object {
|
|
||||||
// map of concurrent open files
|
|
||||||
val locks = mutableMapOf<String, Int>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package app.revanced.patcher.data
|
|
||||||
|
|
||||||
import brut.androlib.meta.MetaInfo
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata about a package.
|
|
||||||
*/
|
|
||||||
class PackageMetadata {
|
|
||||||
lateinit var packageName: String
|
|
||||||
lateinit var packageVersion: String
|
|
||||||
|
|
||||||
internal val metaInfo: MetaInfo = MetaInfo()
|
|
||||||
}
|
|
||||||
170
src/main/kotlin/app/revanced/patcher/data/ResourceContext.kt
Normal file
170
src/main/kotlin/app/revanced/patcher/data/ResourceContext.kt
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
package app.revanced.patcher.data
|
||||||
|
|
||||||
|
import app.revanced.patcher.PatcherContext
|
||||||
|
import app.revanced.patcher.PatcherOptions
|
||||||
|
import app.revanced.patcher.util.DomFileEditor
|
||||||
|
import brut.androlib.AaptInvoker
|
||||||
|
import brut.androlib.ApkDecoder
|
||||||
|
import brut.androlib.apk.UsesFramework
|
||||||
|
import brut.androlib.res.Framework
|
||||||
|
import brut.androlib.res.ResourcesDecoder
|
||||||
|
import brut.androlib.res.decoder.AndroidManifestResourceParser
|
||||||
|
import brut.androlib.res.decoder.XmlPullStreamDecoder
|
||||||
|
import brut.androlib.res.xml.ResXmlPatcher
|
||||||
|
import brut.directory.ExtFile
|
||||||
|
import java.io.File
|
||||||
|
import java.io.InputStream
|
||||||
|
import java.io.OutputStream
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.util.logging.Logger
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A context for resources.
|
||||||
|
* This holds the current state of the resources.
|
||||||
|
*
|
||||||
|
* @param context The [PatcherContext] to create the context for.
|
||||||
|
*/
|
||||||
|
class ResourceContext internal constructor(
|
||||||
|
private val context: PatcherContext,
|
||||||
|
private val options: PatcherOptions
|
||||||
|
) : Context<File?>, Iterable<File> {
|
||||||
|
private val logger = Logger.getLogger(ResourceContext::class.java.name)
|
||||||
|
|
||||||
|
val xmlEditor = XmlFileHolder()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode resources for the patcher.
|
||||||
|
*
|
||||||
|
* @param mode The [ResourceDecodingMode] to use when decoding.
|
||||||
|
*/
|
||||||
|
internal fun decodeResources(mode: ResourceDecodingMode) = with(context.packageMetadata.apkInfo) {
|
||||||
|
// Needed to decode resources.
|
||||||
|
val resourcesDecoder = ResourcesDecoder(options.resourceConfig, this)
|
||||||
|
|
||||||
|
when (mode) {
|
||||||
|
ResourceDecodingMode.FULL -> {
|
||||||
|
val outDir = options.recreateResourceCacheDirectory()
|
||||||
|
|
||||||
|
logger.info("Decoding resources")
|
||||||
|
|
||||||
|
resourcesDecoder.decodeResources(outDir)
|
||||||
|
resourcesDecoder.decodeManifest(outDir)
|
||||||
|
|
||||||
|
// Needed to record uncompressed files.
|
||||||
|
val apkDecoder = ApkDecoder(options.resourceConfig, this)
|
||||||
|
apkDecoder.recordUncompressedFiles(resourcesDecoder.resFileMapping)
|
||||||
|
|
||||||
|
usesFramework = UsesFramework().apply {
|
||||||
|
ids = resourcesDecoder.resTable.listFramePackages().map { it.id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ResourceDecodingMode.MANIFEST_ONLY -> {
|
||||||
|
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.
|
||||||
|
context.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun get(path: String) = options.resourceCachePath.resolve(path)
|
||||||
|
|
||||||
|
override fun iterator() = options.resourceCachePath.walkTopDown().iterator()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile resources from the [ResourceContext].
|
||||||
|
*
|
||||||
|
* @return The compiled resources.
|
||||||
|
*/
|
||||||
|
override fun get(): File? {
|
||||||
|
var resourceFile: File? = null
|
||||||
|
|
||||||
|
if (options.resourceDecodingMode == ResourceDecodingMode.FULL) {
|
||||||
|
logger.info("Compiling modified resources")
|
||||||
|
|
||||||
|
val cacheDirectory = ExtFile(options.resourceCachePath)
|
||||||
|
val aaptFile = cacheDirectory.resolve("aapt_temp_file").also {
|
||||||
|
Files.deleteIfExists(it.toPath())
|
||||||
|
}.also { resourceFile = it }
|
||||||
|
|
||||||
|
try {
|
||||||
|
AaptInvoker(
|
||||||
|
options.resourceConfig, context.packageMetadata.apkInfo
|
||||||
|
).invokeAapt(aaptFile,
|
||||||
|
cacheDirectory.resolve("AndroidManifest.xml").also {
|
||||||
|
ResXmlPatcher.fixingPublicAttrsInProviderAttributes(it)
|
||||||
|
},
|
||||||
|
cacheDirectory.resolve("res"),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
context.packageMetadata.apkInfo.usesFramework.let { usesFramework ->
|
||||||
|
usesFramework.ids.map { id ->
|
||||||
|
Framework(options.resourceConfig).getFrameworkApk(id, usesFramework.tag)
|
||||||
|
}.toTypedArray()
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
cacheDirectory.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resourceFile
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of decoding the resources.
|
||||||
|
*/
|
||||||
|
internal enum class ResourceDecodingMode {
|
||||||
|
/**
|
||||||
|
* Decode all resources.
|
||||||
|
*/
|
||||||
|
FULL,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode the manifest file only.
|
||||||
|
*/
|
||||||
|
MANIFEST_ONLY,
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class XmlFileHolder {
|
||||||
|
operator fun get(inputStream: InputStream) =
|
||||||
|
DomFileEditor(inputStream)
|
||||||
|
|
||||||
|
operator fun get(path: String): DomFileEditor {
|
||||||
|
return DomFileEditor(this@ResourceContext[path])
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.extensions
|
package app.revanced.patcher.extensions
|
||||||
|
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import org.jf.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a label for the instruction at given index.
|
* Create a label for the instruction at given index.
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
|||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
import app.revanced.patcher.util.smali.toInstruction
|
import app.revanced.patcher.util.smali.toInstruction
|
||||||
import app.revanced.patcher.util.smali.toInstructions
|
import app.revanced.patcher.util.smali.toInstructions
|
||||||
import org.jf.dexlib2.builder.BuilderInstruction
|
import com.android.tools.smali.dexlib2.builder.BuilderInstruction
|
||||||
import org.jf.dexlib2.builder.BuilderOffsetInstruction
|
import com.android.tools.smali.dexlib2.builder.BuilderOffsetInstruction
|
||||||
import org.jf.dexlib2.builder.Label
|
import com.android.tools.smali.dexlib2.builder.Label
|
||||||
import org.jf.dexlib2.builder.MutableMethodImplementation
|
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
|
||||||
import org.jf.dexlib2.builder.instruction.*
|
import com.android.tools.smali.dexlib2.builder.instruction.*
|
||||||
import org.jf.dexlib2.iface.instruction.Instruction
|
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
||||||
|
|
||||||
object InstructionExtensions {
|
object InstructionExtensions {
|
||||||
|
|
||||||
@@ -22,8 +22,7 @@ object InstructionExtensions {
|
|||||||
fun MutableMethodImplementation.addInstructions(
|
fun MutableMethodImplementation.addInstructions(
|
||||||
index: Int,
|
index: Int,
|
||||||
instructions: List<BuilderInstruction>
|
instructions: List<BuilderInstruction>
|
||||||
) =
|
) = instructions.asReversed().forEach { addInstruction(index, it) }
|
||||||
instructions.asReversed().forEach { addInstruction(index, it) }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add instructions to a method.
|
* Add instructions to a method.
|
||||||
@@ -321,6 +320,11 @@ object InstructionExtensions {
|
|||||||
* @param T The type of instruction to return.
|
* @param T The type of instruction to return.
|
||||||
* @return The instruction.
|
* @return The instruction.
|
||||||
*/
|
*/
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
fun <T> MutableMethod.getInstruction(index: Int): T = implementation!!.getInstruction<T>(index)
|
fun <T> MutableMethod.getInstruction(index: Int): T = implementation!!.getInstruction<T>(index)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the instructions of a method.
|
||||||
|
* @return The instructions.
|
||||||
|
*/
|
||||||
|
fun MutableMethod.getInstructions(): MutableList<BuilderInstruction> = implementation!!.instructions
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,11 @@
|
|||||||
package app.revanced.patcher.extensions
|
package app.revanced.patcher.extensions
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.AnnotationExtensions.findAnnotationRecursively
|
import app.revanced.patcher.extensions.AnnotationExtensions.findAnnotationRecursively
|
||||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
import app.revanced.patcher.fingerprint.annotation.FuzzyPatternScanMethod
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
|
||||||
object MethodFingerprintExtensions {
|
object MethodFingerprintExtensions {
|
||||||
|
// TODO: Make this a property.
|
||||||
/**
|
|
||||||
* The name of a [MethodFingerprint].
|
|
||||||
*/
|
|
||||||
val MethodFingerprint.name: String
|
|
||||||
get() = this.javaClass.simpleName
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The [FuzzyPatternScanMethod] annotation of a [MethodFingerprint].
|
* The [FuzzyPatternScanMethod] annotation of a [MethodFingerprint].
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
package app.revanced.patcher.extensions
|
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Compatibility
|
|
||||||
import app.revanced.patcher.annotation.Description
|
|
||||||
import app.revanced.patcher.annotation.Name
|
|
||||||
import app.revanced.patcher.annotation.Version
|
|
||||||
import app.revanced.patcher.data.Context
|
|
||||||
import app.revanced.patcher.extensions.AnnotationExtensions.findAnnotationRecursively
|
|
||||||
import app.revanced.patcher.patch.OptionsContainer
|
|
||||||
import app.revanced.patcher.patch.Patch
|
|
||||||
import app.revanced.patcher.patch.PatchOptions
|
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
|
||||||
import app.revanced.patcher.patch.annotations.RequiresIntegrations
|
|
||||||
import kotlin.reflect.KVisibility
|
|
||||||
import kotlin.reflect.full.companionObject
|
|
||||||
import kotlin.reflect.full.companionObjectInstance
|
|
||||||
|
|
||||||
object PatchExtensions {
|
|
||||||
/**
|
|
||||||
* The name of a [Patch].
|
|
||||||
*/
|
|
||||||
val Class<out Patch<Context>>.patchName: String
|
|
||||||
get() = findAnnotationRecursively(Name::class)?.name ?: this.simpleName
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The version of a [Patch].
|
|
||||||
*/
|
|
||||||
val Class<out Patch<Context>>.version
|
|
||||||
get() = findAnnotationRecursively(Version::class)?.version
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Weather or not a [Patch] should be included.
|
|
||||||
*/
|
|
||||||
val Class<out Patch<Context>>.include
|
|
||||||
get() = findAnnotationRecursively(app.revanced.patcher.patch.annotations.Patch::class)!!.include
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The description of a [Patch].
|
|
||||||
*/
|
|
||||||
val Class<out Patch<Context>>.description
|
|
||||||
get() = findAnnotationRecursively(Description::class)?.description
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The dependencies of a [Patch].
|
|
||||||
*/
|
|
||||||
val Class<out Patch<Context>>.dependencies
|
|
||||||
get() = findAnnotationRecursively(DependsOn::class)?.dependencies
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The packages a [Patch] is compatible with.
|
|
||||||
*/
|
|
||||||
val Class<out Patch<Context>>.compatiblePackages
|
|
||||||
get() = findAnnotationRecursively(Compatibility::class)?.compatiblePackages
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Weather or not a [Patch] requires integrations.
|
|
||||||
*/
|
|
||||||
internal val Class<out Patch<Context>>.requiresIntegrations
|
|
||||||
get() = findAnnotationRecursively(RequiresIntegrations::class) != null
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The options of a [Patch].
|
|
||||||
*/
|
|
||||||
val Class<out Patch<Context>>.options: PatchOptions?
|
|
||||||
get() = kotlin.companionObject?.let { cl ->
|
|
||||||
if (cl.visibility != KVisibility.PUBLIC) return null
|
|
||||||
kotlin.companionObjectInstance?.let {
|
|
||||||
(it as? OptionsContainer)?.options
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package app.revanced.patcher.fingerprint
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A ReVanced fingerprint.
|
|
||||||
* Can be a [MethodFingerprint].
|
|
||||||
*/
|
|
||||||
interface Fingerprint
|
|
||||||
125
src/main/kotlin/app/revanced/patcher/fingerprint/LookupMap.kt
Normal file
125
src/main/kotlin/app/revanced/patcher/fingerprint/LookupMap.kt
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
package app.revanced.patcher.fingerprint
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.ClassDef
|
||||||
|
import com.android.tools.smali.dexlib2.iface.Method
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
internal typealias MethodClassPair = Pair<Method, ClassDef>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup map for methods.
|
||||||
|
*/
|
||||||
|
internal class LookupMap : MutableMap<String, LookupMap.MethodClassList> by mutableMapOf() {
|
||||||
|
/**
|
||||||
|
* Adds a [MethodClassPair] to the list associated with the given key.
|
||||||
|
* If the key does not exist, a new list is created and the [MethodClassPair] is added to it.
|
||||||
|
*/
|
||||||
|
fun add(
|
||||||
|
key: String,
|
||||||
|
methodClassPair: MethodClassPair
|
||||||
|
) {
|
||||||
|
getOrPut(key) { MethodClassList() }.add(methodClassPair)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of methods and the class they are a member of.
|
||||||
|
*/
|
||||||
|
internal class MethodClassList : LinkedList<MethodClassPair>()
|
||||||
|
|
||||||
|
companion object Maps {
|
||||||
|
/**
|
||||||
|
* A list of methods and the class they are a member of.
|
||||||
|
*/
|
||||||
|
internal val methods = MethodClassList()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup map for methods keyed to the methods access flags, return type and parameter.
|
||||||
|
*/
|
||||||
|
internal val methodSignatureLookupMap = LookupMap()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup map for methods associated by strings referenced in the method.
|
||||||
|
*/
|
||||||
|
internal val methodStringsLookupMap = LookupMap()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes lookup maps for [MethodFingerprint] resolution
|
||||||
|
* using attributes of methods such as the method signature or strings.
|
||||||
|
*
|
||||||
|
* @param context The [BytecodeContext] containing the classes to initialize the lookup maps with.
|
||||||
|
*/
|
||||||
|
internal fun initializeLookupMaps(context: BytecodeContext) {
|
||||||
|
if (methods.isNotEmpty()) clearLookupMaps()
|
||||||
|
|
||||||
|
context.classes.forEach { classDef ->
|
||||||
|
classDef.methods.forEach { method ->
|
||||||
|
val methodClassPair = method to classDef
|
||||||
|
|
||||||
|
// For fingerprints with no access or return type specified.
|
||||||
|
methods += methodClassPair
|
||||||
|
|
||||||
|
val accessFlagsReturnKey = method.accessFlags.toString() + method.returnType.first()
|
||||||
|
|
||||||
|
// Add <access><returnType> as the key.
|
||||||
|
methodSignatureLookupMap.add(accessFlagsReturnKey, methodClassPair)
|
||||||
|
|
||||||
|
// Add <access><returnType>[parameters] as the key.
|
||||||
|
methodSignatureLookupMap.add(
|
||||||
|
buildString {
|
||||||
|
append(accessFlagsReturnKey)
|
||||||
|
appendParameters(method.parameterTypes)
|
||||||
|
},
|
||||||
|
methodClassPair
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add strings contained in the method as the key.
|
||||||
|
method.implementation?.instructions?.forEach instructions@{ instruction ->
|
||||||
|
if (instruction.opcode != Opcode.CONST_STRING && instruction.opcode != Opcode.CONST_STRING_JUMBO)
|
||||||
|
return@instructions
|
||||||
|
|
||||||
|
val string = ((instruction as ReferenceInstruction).reference as StringReference).string
|
||||||
|
|
||||||
|
methodStringsLookupMap.add(string, methodClassPair)
|
||||||
|
}
|
||||||
|
|
||||||
|
// In the future, the class type could be added to the lookup map.
|
||||||
|
// This would require MethodFingerprint to be changed to include the class type.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the internal lookup maps created in [initializeLookupMaps]
|
||||||
|
*/
|
||||||
|
internal fun clearLookupMaps() {
|
||||||
|
methods.clear()
|
||||||
|
methodSignatureLookupMap.clear()
|
||||||
|
methodStringsLookupMap.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,320 @@
|
|||||||
|
package app.revanced.patcher.fingerprint
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.MethodFingerprintExtensions.fuzzyPatternScanMethod
|
||||||
|
import app.revanced.patcher.fingerprint.LookupMap.Maps.appendParameters
|
||||||
|
import app.revanced.patcher.fingerprint.LookupMap.Maps.initializeLookupMaps
|
||||||
|
import app.revanced.patcher.fingerprint.LookupMap.Maps.methodSignatureLookupMap
|
||||||
|
import app.revanced.patcher.fingerprint.LookupMap.Maps.methodStringsLookupMap
|
||||||
|
import app.revanced.patcher.fingerprint.LookupMap.Maps.methods
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult
|
||||||
|
import app.revanced.patcher.fingerprint.annotation.FuzzyPatternScanMethod
|
||||||
|
import app.revanced.patcher.patch.PatchException
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.ClassDef
|
||||||
|
import com.android.tools.smali.dexlib2.iface.Method
|
||||||
|
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.reference.StringReference
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A fingerprint to resolve methods.
|
||||||
|
*
|
||||||
|
* @param returnType The method's return type compared using [String.startsWith].
|
||||||
|
* @param accessFlags The method's exact access flags using values of [AccessFlags].
|
||||||
|
* @param parameters The parameters of the method. Partial matches allowed and follow the same rules as [returnType].
|
||||||
|
* @param opcodes An opcode pattern of the method's instructions. Wildcard or unknown opcodes can be specified by `null`.
|
||||||
|
* @param strings A list of the method's strings compared each using [String.contains].
|
||||||
|
* @param customFingerprint A custom condition for this fingerprint.
|
||||||
|
*/
|
||||||
|
abstract class MethodFingerprint(
|
||||||
|
internal val returnType: String? = null,
|
||||||
|
internal val accessFlags: Int? = null,
|
||||||
|
internal val parameters: Iterable<String>? = null,
|
||||||
|
internal val opcodes: Iterable<Opcode?>? = null,
|
||||||
|
internal val strings: Iterable<String>? = null,
|
||||||
|
internal val customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null
|
||||||
|
) {
|
||||||
|
/**
|
||||||
|
* The result of the [MethodFingerprint].
|
||||||
|
*/
|
||||||
|
var result: MethodFingerprintResult? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a [MethodFingerprint] using the lookup map built by [initializeLookupMaps].
|
||||||
|
*
|
||||||
|
* [MethodFingerprint] resolution is fast, but if many are present they can consume a noticeable
|
||||||
|
* amount of time because they are resolved in sequence.
|
||||||
|
*
|
||||||
|
* For apps with many fingerprints, resolving performance can be improved by:
|
||||||
|
* - Slowest: Specify [opcodes] and nothing else.
|
||||||
|
* - Fast: Specify [accessFlags], [returnType].
|
||||||
|
* - Faster: Specify [accessFlags], [returnType] and [parameters].
|
||||||
|
* - Fastest: Specify [strings], with at least one string being an exact (non-partial) match.
|
||||||
|
*/
|
||||||
|
internal fun resolveUsingLookupMap(context: BytecodeContext): Boolean {
|
||||||
|
/**
|
||||||
|
* Lookup [MethodClassPair]s that match the methods strings present in a [MethodFingerprint].
|
||||||
|
*
|
||||||
|
* @return A list of [MethodClassPair]s that match the methods strings present in a [MethodFingerprint].
|
||||||
|
*/
|
||||||
|
fun MethodFingerprint.methodStringsLookup(): LookupMap.MethodClassList? {
|
||||||
|
strings?.forEach {
|
||||||
|
val methods = methodStringsLookupMap[it]
|
||||||
|
if (methods != null) return methods
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup [MethodClassPair]s that match the method signature present in a [MethodFingerprint].
|
||||||
|
*
|
||||||
|
* @return A list of [MethodClassPair]s that match the method signature present in a [MethodFingerprint].
|
||||||
|
*/
|
||||||
|
fun MethodFingerprint.methodSignatureLookup(): LookupMap.MethodClassList {
|
||||||
|
if (accessFlags == null) return methods
|
||||||
|
|
||||||
|
var returnTypeValue = returnType
|
||||||
|
if (returnTypeValue == null) {
|
||||||
|
if (AccessFlags.CONSTRUCTOR.isSet(accessFlags)) {
|
||||||
|
// Constructors always have void return type
|
||||||
|
returnTypeValue = "V"
|
||||||
|
} else {
|
||||||
|
return methods
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val key = buildString {
|
||||||
|
append(accessFlags)
|
||||||
|
append(returnTypeValue.first())
|
||||||
|
if (parameters != null) appendParameters(parameters)
|
||||||
|
}
|
||||||
|
return methodSignatureLookupMap[key] ?: return LookupMap.MethodClassList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a [MethodFingerprint] using a list of [MethodClassPair].
|
||||||
|
*
|
||||||
|
* @return True if the resolution was successful, false otherwise.
|
||||||
|
*/
|
||||||
|
fun MethodFingerprint.resolveUsingMethodClassPair(methodClasses: LookupMap.MethodClassList): Boolean {
|
||||||
|
methodClasses.forEach { classAndMethod ->
|
||||||
|
if (resolve(context, classAndMethod.first, classAndMethod.second)) return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
val methodsWithSameStrings = methodStringsLookup()
|
||||||
|
if (methodsWithSameStrings != null) if (resolveUsingMethodClassPair(methodsWithSameStrings)) return true
|
||||||
|
|
||||||
|
// No strings declared or none matched (partial matches are allowed).
|
||||||
|
// Use signature matching.
|
||||||
|
return resolveUsingMethodClassPair(methodSignatureLookup())
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a [MethodFingerprint] against a [ClassDef].
|
||||||
|
*
|
||||||
|
* @param forClass The class on which to resolve the [MethodFingerprint] in.
|
||||||
|
* @param context The [BytecodeContext] to host proxies.
|
||||||
|
* @return True if the resolution was successful, false otherwise.
|
||||||
|
*/
|
||||||
|
fun resolve(context: BytecodeContext, forClass: ClassDef): Boolean {
|
||||||
|
for (method in forClass.methods)
|
||||||
|
if (resolve(context, method, forClass))
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a [MethodFingerprint] against a [Method].
|
||||||
|
*
|
||||||
|
* @param method The class on which to resolve the [MethodFingerprint] in.
|
||||||
|
* @param forClass The class on which to resolve the [MethodFingerprint].
|
||||||
|
* @param context The [BytecodeContext] to host proxies.
|
||||||
|
* @return True if the resolution was successful or if the fingerprint is already resolved, false otherwise.
|
||||||
|
*/
|
||||||
|
fun resolve(context: BytecodeContext, method: Method, forClass: ClassDef): Boolean {
|
||||||
|
val methodFingerprint = this
|
||||||
|
|
||||||
|
if (methodFingerprint.result != null) return true
|
||||||
|
|
||||||
|
if (methodFingerprint.returnType != null && !method.returnType.startsWith(methodFingerprint.returnType))
|
||||||
|
return false
|
||||||
|
|
||||||
|
if (methodFingerprint.accessFlags != null && methodFingerprint.accessFlags != method.accessFlags)
|
||||||
|
return false
|
||||||
|
|
||||||
|
|
||||||
|
fun parametersEqual(
|
||||||
|
parameters1: Iterable<CharSequence>, parameters2: Iterable<CharSequence>
|
||||||
|
): Boolean {
|
||||||
|
if (parameters1.count() != parameters2.count()) return false
|
||||||
|
val iterator1 = parameters1.iterator()
|
||||||
|
parameters2.forEach {
|
||||||
|
if (!it.startsWith(iterator1.next())) return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (methodFingerprint.parameters != null && !parametersEqual(
|
||||||
|
methodFingerprint.parameters, // TODO: parseParameters()
|
||||||
|
method.parameterTypes
|
||||||
|
)
|
||||||
|
) return false
|
||||||
|
|
||||||
|
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
|
||||||
|
if (methodFingerprint.customFingerprint != null && !methodFingerprint.customFingerprint!!(method, forClass))
|
||||||
|
return false
|
||||||
|
|
||||||
|
val stringsScanResult: StringsScanResult? =
|
||||||
|
if (methodFingerprint.strings != null) {
|
||||||
|
StringsScanResult(
|
||||||
|
buildList {
|
||||||
|
val implementation = method.implementation ?: return false
|
||||||
|
|
||||||
|
val stringsList = methodFingerprint.strings.toMutableList()
|
||||||
|
|
||||||
|
implementation.instructions.forEachIndexed { instructionIndex, instruction ->
|
||||||
|
if (
|
||||||
|
instruction.opcode != Opcode.CONST_STRING &&
|
||||||
|
instruction.opcode != Opcode.CONST_STRING_JUMBO
|
||||||
|
) return@forEachIndexed
|
||||||
|
|
||||||
|
val string = ((instruction as ReferenceInstruction).reference as StringReference).string
|
||||||
|
val index = stringsList.indexOfFirst(string::contains)
|
||||||
|
if (index == -1) return@forEachIndexed
|
||||||
|
|
||||||
|
add(StringsScanResult.StringMatch(string, instructionIndex))
|
||||||
|
stringsList.removeAt(index)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stringsList.isNotEmpty()) return false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else null
|
||||||
|
|
||||||
|
val patternScanResult = if (methodFingerprint.opcodes != null) {
|
||||||
|
method.implementation?.instructions ?: return false
|
||||||
|
|
||||||
|
fun MethodFingerprintResult.MethodFingerprintScanResult.PatternScanResult.newWarnings(
|
||||||
|
pattern: Iterable<Opcode?>, instructions: Iterable<Instruction>
|
||||||
|
) = buildList {
|
||||||
|
for ((patternIndex, instructionIndex) in (this@newWarnings.startIndex until this@newWarnings.endIndex).withIndex()) {
|
||||||
|
val originalOpcode = instructions.elementAt(instructionIndex).opcode
|
||||||
|
val patternOpcode = pattern.elementAt(patternIndex)
|
||||||
|
|
||||||
|
if (patternOpcode == null || patternOpcode.ordinal == originalOpcode.ordinal) continue
|
||||||
|
|
||||||
|
this.add(
|
||||||
|
MethodFingerprintResult.MethodFingerprintScanResult.PatternScanResult.Warning(
|
||||||
|
originalOpcode,
|
||||||
|
patternOpcode,
|
||||||
|
instructionIndex,
|
||||||
|
patternIndex
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Method.patternScan(
|
||||||
|
fingerprint: MethodFingerprint
|
||||||
|
): MethodFingerprintResult.MethodFingerprintScanResult.PatternScanResult? {
|
||||||
|
val instructions = this.implementation!!.instructions
|
||||||
|
val fingerprintFuzzyPatternScanThreshold = fingerprint.fuzzyPatternScanMethod?.threshold ?: 0
|
||||||
|
|
||||||
|
val pattern = fingerprint.opcodes!!
|
||||||
|
val instructionLength = instructions.count()
|
||||||
|
val patternLength = pattern.count()
|
||||||
|
|
||||||
|
for (index in 0 until instructionLength) {
|
||||||
|
var patternIndex = 0
|
||||||
|
var threshold = fingerprintFuzzyPatternScanThreshold
|
||||||
|
|
||||||
|
while (index + patternIndex < instructionLength) {
|
||||||
|
val originalOpcode = instructions.elementAt(index + patternIndex).opcode
|
||||||
|
val patternOpcode = pattern.elementAt(patternIndex)
|
||||||
|
|
||||||
|
if (patternOpcode != null && patternOpcode.ordinal != originalOpcode.ordinal) {
|
||||||
|
// reaching maximum threshold (0) means,
|
||||||
|
// the pattern does not match to the current instructions
|
||||||
|
if (threshold-- == 0) break
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patternIndex < patternLength - 1) {
|
||||||
|
// if the entire pattern has not been scanned yet
|
||||||
|
// continue the scan
|
||||||
|
patternIndex++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// the pattern is valid, generate warnings if fuzzyPatternScanMethod is FuzzyPatternScanMethod
|
||||||
|
val result =
|
||||||
|
MethodFingerprintResult.MethodFingerprintScanResult.PatternScanResult(
|
||||||
|
index,
|
||||||
|
index + patternIndex
|
||||||
|
)
|
||||||
|
if (fingerprint.fuzzyPatternScanMethod !is FuzzyPatternScanMethod) return result
|
||||||
|
result.warnings = result.newWarnings(pattern, instructions)
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
method.patternScan(methodFingerprint) ?: return false
|
||||||
|
} else null
|
||||||
|
|
||||||
|
methodFingerprint.result = MethodFingerprintResult(
|
||||||
|
method,
|
||||||
|
forClass,
|
||||||
|
MethodFingerprintResult.MethodFingerprintScanResult(
|
||||||
|
patternScanResult,
|
||||||
|
stringsScanResult
|
||||||
|
),
|
||||||
|
context
|
||||||
|
)
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
/**
|
||||||
|
* Resolve a list of [MethodFingerprint] using the lookup map built by [initializeLookupMaps].
|
||||||
|
*
|
||||||
|
* [MethodFingerprint] resolution is fast, but if many are present they can consume a noticeable
|
||||||
|
* amount of time because they are resolved in sequence.
|
||||||
|
*
|
||||||
|
* For apps with many fingerprints, resolving performance can be improved by:
|
||||||
|
* - Slowest: Specify [opcodes] and nothing else.
|
||||||
|
* - Fast: Specify [accessFlags], [returnType].
|
||||||
|
* - Faster: Specify [accessFlags], [returnType] and [parameters].
|
||||||
|
* - Fastest: Specify [strings], with at least one string being an exact (non-partial) match.
|
||||||
|
*/
|
||||||
|
internal fun Set<MethodFingerprint>.resolveUsingLookupMap(context: BytecodeContext) {
|
||||||
|
if (methods.isEmpty()) throw PatchException("lookup map not initialized")
|
||||||
|
|
||||||
|
forEach { fingerprint ->
|
||||||
|
fingerprint.resolveUsingLookupMap(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a list of [MethodFingerprint] against a list of [ClassDef].
|
||||||
|
*
|
||||||
|
* @param classes The classes on which to resolve the [MethodFingerprint] in.
|
||||||
|
* @param context The [BytecodeContext] to host proxies.
|
||||||
|
* @return True if the resolution was successful, false otherwise.
|
||||||
|
*/
|
||||||
|
fun Iterable<MethodFingerprint>.resolve(context: BytecodeContext, classes: Iterable<ClassDef>) =
|
||||||
|
forEach { fingerprint ->
|
||||||
|
for (classDef in classes) {
|
||||||
|
if (fingerprint.resolve(context, classDef)) break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package app.revanced.patcher.fingerprint
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.util.proxy.ClassProxy
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.ClassDef
|
||||||
|
import com.android.tools.smali.dexlib2.iface.Method
|
||||||
|
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the result of a [MethodFingerprintResult].
|
||||||
|
*
|
||||||
|
* @param method The matching method.
|
||||||
|
* @param classDef The [ClassDef] that contains the matching [method].
|
||||||
|
* @param scanResult The result of scanning for the [MethodFingerprint].
|
||||||
|
* @param context The [BytecodeContext] this [MethodFingerprintResult] is attached to, to create proxies.
|
||||||
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
class MethodFingerprintResult(
|
||||||
|
val method: Method,
|
||||||
|
val classDef: ClassDef,
|
||||||
|
val scanResult: MethodFingerprintScanResult,
|
||||||
|
internal val context: BytecodeContext
|
||||||
|
) {
|
||||||
|
/**
|
||||||
|
* Returns a mutable clone of [classDef]
|
||||||
|
*
|
||||||
|
* Please note, this method allocates a [ClassProxy].
|
||||||
|
* Use [classDef] where possible.
|
||||||
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
val mutableClass by lazy { context.proxy(classDef).mutableClass }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a mutable clone of [method]
|
||||||
|
*
|
||||||
|
* Please note, this method allocates a [ClassProxy].
|
||||||
|
* Use [method] where possible.
|
||||||
|
*/
|
||||||
|
val mutableMethod by lazy {
|
||||||
|
mutableClass.methods.first {
|
||||||
|
MethodUtil.methodSignaturesMatch(it, this.method)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The result of scanning on the [MethodFingerprint].
|
||||||
|
* @param patternScanResult The result of the pattern scan.
|
||||||
|
* @param stringsScanResult The result of the string scan.
|
||||||
|
*/
|
||||||
|
class MethodFingerprintScanResult(
|
||||||
|
val patternScanResult: PatternScanResult?,
|
||||||
|
val stringsScanResult: StringsScanResult?
|
||||||
|
) {
|
||||||
|
/**
|
||||||
|
* The result of scanning strings on the [MethodFingerprint].
|
||||||
|
* @param matches The list of strings that were matched.
|
||||||
|
*/
|
||||||
|
class StringsScanResult(val matches: List<StringMatch>) {
|
||||||
|
/**
|
||||||
|
* Represents a match for a string at an index.
|
||||||
|
* @param string The string that was matched.
|
||||||
|
* @param index The index of the string.
|
||||||
|
*/
|
||||||
|
class StringMatch(val string: String, val index: Int)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The result of a pattern scan.
|
||||||
|
* @param startIndex The start index of the instructions where to which this pattern matches.
|
||||||
|
* @param endIndex The end index of the instructions where to which this pattern matches.
|
||||||
|
* @param warnings A list of warnings considering this [PatternScanResult].
|
||||||
|
*/
|
||||||
|
class PatternScanResult(
|
||||||
|
val startIndex: Int,
|
||||||
|
val endIndex: Int,
|
||||||
|
var warnings: List<Warning>? = null
|
||||||
|
) {
|
||||||
|
/**
|
||||||
|
* Represents warnings of the pattern scan.
|
||||||
|
* @param correctOpcode The opcode the instruction list has.
|
||||||
|
* @param wrongOpcode The opcode the pattern list of the signature currently has.
|
||||||
|
* @param instructionIndex The index of the opcode relative to the instruction list.
|
||||||
|
* @param patternIndex The index of the opcode relative to the pattern list from the signature.
|
||||||
|
*/
|
||||||
|
class Warning(
|
||||||
|
val correctOpcode: Opcode,
|
||||||
|
val wrongOpcode: Opcode,
|
||||||
|
val instructionIndex: Int,
|
||||||
|
val patternIndex: Int,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package app.revanced.patcher.fingerprint.method.annotation
|
package app.revanced.patcher.fingerprint.annotation
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotations to scan a pattern [MethodFingerprint] with fuzzy algorithm.
|
* Annotations to scan a pattern [MethodFingerprint] with fuzzy algorithm.
|
||||||
@@ -1,504 +0,0 @@
|
|||||||
package app.revanced.patcher.fingerprint.method.impl
|
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
|
||||||
import app.revanced.patcher.extensions.MethodFingerprintExtensions.fuzzyPatternScanMethod
|
|
||||||
import app.revanced.patcher.fingerprint.Fingerprint
|
|
||||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
|
||||||
import app.revanced.patcher.patch.PatchResultError
|
|
||||||
import app.revanced.patcher.util.proxy.ClassProxy
|
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
|
||||||
import org.jf.dexlib2.iface.Method
|
|
||||||
import org.jf.dexlib2.iface.instruction.Instruction
|
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
|
||||||
import org.jf.dexlib2.iface.reference.StringReference
|
|
||||||
import org.jf.dexlib2.util.MethodUtil
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
private typealias StringMatch = MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult.StringMatch
|
|
||||||
private typealias StringsScanResult = MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult
|
|
||||||
private typealias MethodClassPair = Pair<Method, ClassDef>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A fingerprint to resolve methods.
|
|
||||||
*
|
|
||||||
* @param returnType The method's return type compared using [String.startsWith].
|
|
||||||
* @param accessFlags The method's exact access flags using values of [AccessFlags].
|
|
||||||
* @param parameters The parameters of the method. Partial matches allowed and follow the same rules as [returnType].
|
|
||||||
* @param opcodes An opcode pattern of the method's instructions. Wildcard or unknown opcodes can be specified by `null`.
|
|
||||||
* @param strings A list of the method's strings compared each using [String.contains].
|
|
||||||
* @param customFingerprint A custom condition for this fingerprint.
|
|
||||||
*/
|
|
||||||
abstract class MethodFingerprint(
|
|
||||||
internal val returnType: String? = null,
|
|
||||||
internal val accessFlags: Int? = null,
|
|
||||||
internal val parameters: Iterable<String>? = null,
|
|
||||||
internal val opcodes: Iterable<Opcode?>? = null,
|
|
||||||
internal val strings: Iterable<String>? = null,
|
|
||||||
internal val customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null
|
|
||||||
) : Fingerprint {
|
|
||||||
/**
|
|
||||||
* The result of the [MethodFingerprint].
|
|
||||||
*/
|
|
||||||
var result: MethodFingerprintResult? = null
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
/**
|
|
||||||
* A list of methods and the class they were found in.
|
|
||||||
*/
|
|
||||||
private val methods = mutableListOf<MethodClassPair>()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lookup map for methods keyed to the methods access flags, return type and parameter.
|
|
||||||
*/
|
|
||||||
private val methodSignatureLookupMap = mutableMapOf<String, MutableList<MethodClassPair>>()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lookup map for methods keyed to the strings contained in the method.
|
|
||||||
*/
|
|
||||||
private val methodStringsLookupMap = mutableMapOf<String, MutableList<MethodClassPair>>()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends a string based on the parameter reference types of this method.
|
|
||||||
*/
|
|
||||||
private 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())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes lookup maps for [MethodFingerprint] resolution
|
|
||||||
* using attributes of methods such as the method signature or strings.
|
|
||||||
*
|
|
||||||
* @param context The [BytecodeContext] containing the classes to initialize the lookup maps with.
|
|
||||||
*/
|
|
||||||
internal fun initializeFingerprintResolutionLookupMaps(context: BytecodeContext) {
|
|
||||||
fun MutableMap<String, MutableList<MethodClassPair>>.add(
|
|
||||||
key: String,
|
|
||||||
methodClassPair: MethodClassPair
|
|
||||||
) {
|
|
||||||
var methodClassPairs = this[key]
|
|
||||||
|
|
||||||
methodClassPairs ?: run {
|
|
||||||
methodClassPairs = LinkedList<MethodClassPair>().also { this[key] = it }
|
|
||||||
}
|
|
||||||
|
|
||||||
methodClassPairs!!.add(methodClassPair)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (methods.isNotEmpty()) throw PatchResultError("Map already initialized")
|
|
||||||
|
|
||||||
context.classes.classes.forEach { classDef ->
|
|
||||||
classDef.methods.forEach { method ->
|
|
||||||
val methodClassPair = method to classDef
|
|
||||||
|
|
||||||
// For fingerprints with no access or return type specified.
|
|
||||||
methods += methodClassPair
|
|
||||||
|
|
||||||
val accessFlagsReturnKey = method.accessFlags.toString() + method.returnType.first()
|
|
||||||
|
|
||||||
// Add <access><returnType> as the key.
|
|
||||||
methodSignatureLookupMap.add(accessFlagsReturnKey, methodClassPair)
|
|
||||||
|
|
||||||
// Add <access><returnType>[parameters] as the key.
|
|
||||||
methodSignatureLookupMap.add(
|
|
||||||
buildString {
|
|
||||||
append(accessFlagsReturnKey)
|
|
||||||
appendParameters(method.parameterTypes)
|
|
||||||
},
|
|
||||||
methodClassPair
|
|
||||||
)
|
|
||||||
|
|
||||||
// Add strings contained in the method as the key.
|
|
||||||
method.implementation?.instructions?.forEach instructions@{ instruction ->
|
|
||||||
if (instruction.opcode != Opcode.CONST_STRING && instruction.opcode != Opcode.CONST_STRING_JUMBO)
|
|
||||||
return@instructions
|
|
||||||
|
|
||||||
val string = ((instruction as ReferenceInstruction).reference as StringReference).string
|
|
||||||
|
|
||||||
methodStringsLookupMap.add(string, methodClassPair)
|
|
||||||
}
|
|
||||||
|
|
||||||
// In the future, the class type could be added to the lookup map.
|
|
||||||
// This would require MethodFingerprint to be changed to include the class type.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve a list of [MethodFingerprint] using the lookup map built by [initializeFingerprintResolutionLookupMaps].
|
|
||||||
*
|
|
||||||
* [MethodFingerprint] resolution is fast, but if many are present they can consume a noticeable
|
|
||||||
* amount of time because they are resolved in sequence.
|
|
||||||
*
|
|
||||||
* For apps with many fingerprints, resolving performance can be improved by:
|
|
||||||
* - Slowest: Specify [opcodes] and nothing else.
|
|
||||||
* - Fast: Specify [accessFlags], [returnType].
|
|
||||||
* - Faster: Specify [accessFlags], [returnType] and [parameters].
|
|
||||||
* - Fastest: Specify [strings], with at least one string being an exact (non-partial) match.
|
|
||||||
*/
|
|
||||||
internal fun Iterable<MethodFingerprint>.resolveUsingLookupMap(context: BytecodeContext) {
|
|
||||||
if (methods.isEmpty()) throw PatchResultError("lookup map not initialized")
|
|
||||||
|
|
||||||
for (fingerprint in this) {
|
|
||||||
fingerprint.resolveUsingLookupMap(context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve a [MethodFingerprint] using the lookup map built by [initializeFingerprintResolutionLookupMaps].
|
|
||||||
*
|
|
||||||
* [MethodFingerprint] resolution is fast, but if many are present they can consume a noticeable
|
|
||||||
* amount of time because they are resolved in sequence.
|
|
||||||
*
|
|
||||||
* For apps with many fingerprints, resolving performance can be improved by:
|
|
||||||
* - Slowest: Specify [opcodes] and nothing else.
|
|
||||||
* - Fast: Specify [accessFlags], [returnType].
|
|
||||||
* - Faster: Specify [accessFlags], [returnType] and [parameters].
|
|
||||||
* - Fastest: Specify [strings], with at least one string being an exact (non-partial) match.
|
|
||||||
*/
|
|
||||||
internal fun MethodFingerprint.resolveUsingLookupMap(context: BytecodeContext): Boolean {
|
|
||||||
/**
|
|
||||||
* Lookup [MethodClassPair]s that match the methods strings present in a [MethodFingerprint].
|
|
||||||
*
|
|
||||||
* @return A list of [MethodClassPair]s that match the methods strings present in a [MethodFingerprint].
|
|
||||||
*/
|
|
||||||
fun MethodFingerprint.methodStringsLookup(): List<MethodClassPair>? {
|
|
||||||
strings?.forEach {
|
|
||||||
val methods = methodStringsLookupMap[it]
|
|
||||||
if (methods != null) return methods
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lookup [MethodClassPair]s that match the method signature present in a [MethodFingerprint].
|
|
||||||
*
|
|
||||||
* @return A list of [MethodClassPair]s that match the method signature present in a [MethodFingerprint].
|
|
||||||
*/
|
|
||||||
fun MethodFingerprint.methodSignatureLookup(): List<MethodClassPair> {
|
|
||||||
if (accessFlags == null) return methods
|
|
||||||
|
|
||||||
var returnTypeValue = returnType
|
|
||||||
if (returnTypeValue == null) {
|
|
||||||
if (AccessFlags.CONSTRUCTOR.isSet(accessFlags)) {
|
|
||||||
// Constructors always have void return type
|
|
||||||
returnTypeValue = "V"
|
|
||||||
} else {
|
|
||||||
return methods
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val key = buildString {
|
|
||||||
append(accessFlags)
|
|
||||||
append(returnTypeValue.first())
|
|
||||||
if (parameters != null) appendParameters(parameters)
|
|
||||||
}
|
|
||||||
return methodSignatureLookupMap[key]!!
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve a [MethodFingerprint] using a list of [MethodClassPair].
|
|
||||||
*
|
|
||||||
* @return True if the resolution was successful, false otherwise.
|
|
||||||
*/
|
|
||||||
fun MethodFingerprint.resolveUsingMethodClassPair(classMethods: Iterable<MethodClassPair>): Boolean {
|
|
||||||
classMethods.forEach { classAndMethod ->
|
|
||||||
if (resolve(context, classAndMethod.first, classAndMethod.second)) return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
val methodsWithSameStrings = methodStringsLookup()
|
|
||||||
if (methodsWithSameStrings != null) if (resolveUsingMethodClassPair(methodsWithSameStrings)) return true
|
|
||||||
|
|
||||||
// No strings declared or none matched (partial matches are allowed).
|
|
||||||
// Use signature matching.
|
|
||||||
return resolveUsingMethodClassPair(methodSignatureLookup())
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve a list of [MethodFingerprint] against a list of [ClassDef].
|
|
||||||
*
|
|
||||||
* @param classes The classes on which to resolve the [MethodFingerprint] in.
|
|
||||||
* @param context The [BytecodeContext] to host proxies.
|
|
||||||
* @return True if the resolution was successful, false otherwise.
|
|
||||||
*/
|
|
||||||
fun Iterable<MethodFingerprint>.resolve(context: BytecodeContext, classes: Iterable<ClassDef>) {
|
|
||||||
for (fingerprint in this) // For each fingerprint...
|
|
||||||
classes@ for (classDef in classes) // ...search through all classes for the MethodFingerprint
|
|
||||||
if (fingerprint.resolve(context, classDef))
|
|
||||||
break@classes // ...if the resolution succeeded, continue with the next MethodFingerprint.
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve a [MethodFingerprint] against a [ClassDef].
|
|
||||||
*
|
|
||||||
* @param forClass The class on which to resolve the [MethodFingerprint] in.
|
|
||||||
* @param context The [BytecodeContext] to host proxies.
|
|
||||||
* @return True if the resolution was successful, false otherwise.
|
|
||||||
*/
|
|
||||||
fun MethodFingerprint.resolve(context: BytecodeContext, forClass: ClassDef): Boolean {
|
|
||||||
for (method in forClass.methods)
|
|
||||||
if (this.resolve(context, method, forClass))
|
|
||||||
return true
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve a [MethodFingerprint] against a [Method].
|
|
||||||
*
|
|
||||||
* @param method The class on which to resolve the [MethodFingerprint] in.
|
|
||||||
* @param forClass The class on which to resolve the [MethodFingerprint].
|
|
||||||
* @param context The [BytecodeContext] to host proxies.
|
|
||||||
* @return True if the resolution was successful or if the fingerprint is already resolved, false otherwise.
|
|
||||||
*/
|
|
||||||
fun MethodFingerprint.resolve(context: BytecodeContext, method: Method, forClass: ClassDef): Boolean {
|
|
||||||
val methodFingerprint = this
|
|
||||||
|
|
||||||
if (methodFingerprint.result != null) return true
|
|
||||||
|
|
||||||
if (methodFingerprint.returnType != null && !method.returnType.startsWith(methodFingerprint.returnType))
|
|
||||||
return false
|
|
||||||
|
|
||||||
if (methodFingerprint.accessFlags != null && methodFingerprint.accessFlags != method.accessFlags)
|
|
||||||
return false
|
|
||||||
|
|
||||||
|
|
||||||
fun parametersEqual(
|
|
||||||
parameters1: Iterable<CharSequence>, parameters2: Iterable<CharSequence>
|
|
||||||
): Boolean {
|
|
||||||
if (parameters1.count() != parameters2.count()) return false
|
|
||||||
val iterator1 = parameters1.iterator()
|
|
||||||
parameters2.forEach {
|
|
||||||
if (!it.startsWith(iterator1.next())) return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (methodFingerprint.parameters != null && !parametersEqual(
|
|
||||||
methodFingerprint.parameters, // TODO: parseParameters()
|
|
||||||
method.parameterTypes
|
|
||||||
)
|
|
||||||
) return false
|
|
||||||
|
|
||||||
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
|
|
||||||
if (methodFingerprint.customFingerprint != null && !methodFingerprint.customFingerprint!!(method, forClass))
|
|
||||||
return false
|
|
||||||
|
|
||||||
val stringsScanResult: StringsScanResult? =
|
|
||||||
if (methodFingerprint.strings != null) {
|
|
||||||
StringsScanResult(
|
|
||||||
buildList {
|
|
||||||
val implementation = method.implementation ?: return false
|
|
||||||
|
|
||||||
val stringsList = methodFingerprint.strings.toMutableList()
|
|
||||||
|
|
||||||
implementation.instructions.forEachIndexed { instructionIndex, instruction ->
|
|
||||||
if (
|
|
||||||
instruction.opcode != Opcode.CONST_STRING &&
|
|
||||||
instruction.opcode != Opcode.CONST_STRING_JUMBO
|
|
||||||
) return@forEachIndexed
|
|
||||||
|
|
||||||
val string = ((instruction as ReferenceInstruction).reference as StringReference).string
|
|
||||||
val index = stringsList.indexOfFirst(string::contains)
|
|
||||||
if (index == -1) return@forEachIndexed
|
|
||||||
|
|
||||||
add(
|
|
||||||
StringMatch(
|
|
||||||
string,
|
|
||||||
instructionIndex
|
|
||||||
)
|
|
||||||
)
|
|
||||||
stringsList.removeAt(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stringsList.isNotEmpty()) return false
|
|
||||||
}
|
|
||||||
)
|
|
||||||
} else null
|
|
||||||
|
|
||||||
val patternScanResult = if (methodFingerprint.opcodes != null) {
|
|
||||||
method.implementation?.instructions ?: return false
|
|
||||||
|
|
||||||
fun Method.patternScan(
|
|
||||||
fingerprint: MethodFingerprint
|
|
||||||
): MethodFingerprintResult.MethodFingerprintScanResult.PatternScanResult? {
|
|
||||||
val instructions = this.implementation!!.instructions
|
|
||||||
val fingerprintFuzzyPatternScanThreshold = fingerprint.fuzzyPatternScanMethod?.threshold ?: 0
|
|
||||||
|
|
||||||
val pattern = fingerprint.opcodes!!
|
|
||||||
val instructionLength = instructions.count()
|
|
||||||
val patternLength = pattern.count()
|
|
||||||
|
|
||||||
for (index in 0 until instructionLength) {
|
|
||||||
var patternIndex = 0
|
|
||||||
var threshold = fingerprintFuzzyPatternScanThreshold
|
|
||||||
|
|
||||||
while (index + patternIndex < instructionLength) {
|
|
||||||
val originalOpcode = instructions.elementAt(index + patternIndex).opcode
|
|
||||||
val patternOpcode = pattern.elementAt(patternIndex)
|
|
||||||
|
|
||||||
if (patternOpcode != null && patternOpcode.ordinal != originalOpcode.ordinal) {
|
|
||||||
// reaching maximum threshold (0) means,
|
|
||||||
// the pattern does not match to the current instructions
|
|
||||||
if (threshold-- == 0) break
|
|
||||||
}
|
|
||||||
|
|
||||||
if (patternIndex < patternLength - 1) {
|
|
||||||
// if the entire pattern has not been scanned yet
|
|
||||||
// continue the scan
|
|
||||||
patternIndex++
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// the pattern is valid, generate warnings if fuzzyPatternScanMethod is FuzzyPatternScanMethod
|
|
||||||
val result =
|
|
||||||
MethodFingerprintResult.MethodFingerprintScanResult.PatternScanResult(
|
|
||||||
index,
|
|
||||||
index + patternIndex
|
|
||||||
)
|
|
||||||
if (fingerprint.fuzzyPatternScanMethod !is FuzzyPatternScanMethod) return result
|
|
||||||
result.warnings = result.createWarnings(pattern, instructions)
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
method.patternScan(methodFingerprint) ?: return false
|
|
||||||
} else null
|
|
||||||
|
|
||||||
methodFingerprint.result = MethodFingerprintResult(
|
|
||||||
method,
|
|
||||||
forClass,
|
|
||||||
MethodFingerprintResult.MethodFingerprintScanResult(
|
|
||||||
patternScanResult,
|
|
||||||
stringsScanResult
|
|
||||||
),
|
|
||||||
context
|
|
||||||
)
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun MethodFingerprintResult.MethodFingerprintScanResult.PatternScanResult.createWarnings(
|
|
||||||
pattern: Iterable<Opcode?>, instructions: Iterable<Instruction>
|
|
||||||
) = buildList {
|
|
||||||
for ((patternIndex, instructionIndex) in (this@createWarnings.startIndex until this@createWarnings.endIndex).withIndex()) {
|
|
||||||
val originalOpcode = instructions.elementAt(instructionIndex).opcode
|
|
||||||
val patternOpcode = pattern.elementAt(patternIndex)
|
|
||||||
|
|
||||||
if (patternOpcode == null || patternOpcode.ordinal == originalOpcode.ordinal) continue
|
|
||||||
|
|
||||||
this.add(
|
|
||||||
MethodFingerprintResult.MethodFingerprintScanResult.PatternScanResult.Warning(
|
|
||||||
originalOpcode,
|
|
||||||
patternOpcode,
|
|
||||||
instructionIndex,
|
|
||||||
patternIndex
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the result of a [MethodFingerprintResult].
|
|
||||||
*
|
|
||||||
* @param method The matching method.
|
|
||||||
* @param classDef The [ClassDef] that contains the matching [method].
|
|
||||||
* @param scanResult The result of scanning for the [MethodFingerprint].
|
|
||||||
* @param context The [BytecodeContext] this [MethodFingerprintResult] is attached to, to create proxies.
|
|
||||||
*/
|
|
||||||
data class MethodFingerprintResult(
|
|
||||||
val method: Method,
|
|
||||||
val classDef: ClassDef,
|
|
||||||
val scanResult: MethodFingerprintScanResult,
|
|
||||||
internal val context: BytecodeContext
|
|
||||||
) {
|
|
||||||
/**
|
|
||||||
* Returns a mutable clone of [classDef]
|
|
||||||
*
|
|
||||||
* Please note, this method allocates a [ClassProxy].
|
|
||||||
* Use [classDef] where possible.
|
|
||||||
*/
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
val mutableClass by lazy { context.proxy(classDef).mutableClass }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a mutable clone of [method]
|
|
||||||
*
|
|
||||||
* Please note, this method allocates a [ClassProxy].
|
|
||||||
* Use [method] where possible.
|
|
||||||
*/
|
|
||||||
val mutableMethod by lazy {
|
|
||||||
mutableClass.methods.first {
|
|
||||||
MethodUtil.methodSignaturesMatch(it, this.method)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The result of scanning on the [MethodFingerprint].
|
|
||||||
* @param patternScanResult The result of the pattern scan.
|
|
||||||
* @param stringsScanResult The result of the string scan.
|
|
||||||
*/
|
|
||||||
data class MethodFingerprintScanResult(
|
|
||||||
val patternScanResult: PatternScanResult?,
|
|
||||||
val stringsScanResult: StringsScanResult?
|
|
||||||
) {
|
|
||||||
/**
|
|
||||||
* The result of scanning strings on the [MethodFingerprint].
|
|
||||||
* @param matches The list of strings that were matched.
|
|
||||||
*/
|
|
||||||
data class StringsScanResult(val matches: List<StringMatch>) {
|
|
||||||
/**
|
|
||||||
* Represents a match for a string at an index.
|
|
||||||
* @param string The string that was matched.
|
|
||||||
* @param index The index of the string.
|
|
||||||
*/
|
|
||||||
data class StringMatch(val string: String, val index: Int)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The result of a pattern scan.
|
|
||||||
* @param startIndex The start index of the instructions where to which this pattern matches.
|
|
||||||
* @param endIndex The end index of the instructions where to which this pattern matches.
|
|
||||||
* @param warnings A list of warnings considering this [PatternScanResult].
|
|
||||||
*/
|
|
||||||
data class PatternScanResult(
|
|
||||||
val startIndex: Int,
|
|
||||||
val endIndex: Int,
|
|
||||||
var warnings: List<Warning>? = null
|
|
||||||
) {
|
|
||||||
/**
|
|
||||||
* Represents warnings of the pattern scan.
|
|
||||||
* @param correctOpcode The opcode the instruction list has.
|
|
||||||
* @param wrongOpcode The opcode the pattern list of the signature currently has.
|
|
||||||
* @param instructionIndex The index of the opcode relative to the instruction list.
|
|
||||||
* @param patternIndex The index of the opcode relative to the pattern list from the signature.
|
|
||||||
*/
|
|
||||||
data class Warning(
|
|
||||||
val correctOpcode: Opcode,
|
|
||||||
val wrongOpcode: Opcode,
|
|
||||||
val instructionIndex: Int,
|
|
||||||
val patternIndex: Int,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package app.revanced.patcher.logging
|
|
||||||
|
|
||||||
interface Logger {
|
|
||||||
fun error(msg: String) {}
|
|
||||||
fun warn(msg: String) {}
|
|
||||||
fun info(msg: String) {}
|
|
||||||
fun trace(msg: String) {}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package app.revanced.patcher.logging.impl
|
|
||||||
|
|
||||||
import app.revanced.patcher.logging.Logger
|
|
||||||
|
|
||||||
object NopLogger : Logger
|
|
||||||
13
src/main/kotlin/app/revanced/patcher/patch/BytecodePatch.kt
Normal file
13
src/main/kotlin/app/revanced/patcher/patch/BytecodePatch.kt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package app.revanced.patcher.patch
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A ReVanced [Patch] that works on [BytecodeContext].
|
||||||
|
*
|
||||||
|
* @param fingerprints A list of [MethodFingerprint]s which will be resolved before the patch is executed.
|
||||||
|
*/
|
||||||
|
abstract class BytecodePatch(
|
||||||
|
internal val fingerprints : Set<MethodFingerprint> = emptySet(),
|
||||||
|
) : Patch<BytecodeContext>()
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package app.revanced.patcher.patch
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A container for patch options.
|
|
||||||
*/
|
|
||||||
abstract class OptionsContainer {
|
|
||||||
/**
|
|
||||||
* A list of [PatchOption]s.
|
|
||||||
* @see PatchOptions
|
|
||||||
*/
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
val options = PatchOptions()
|
|
||||||
|
|
||||||
protected fun <T> option(opt: PatchOption<T>): PatchOption<T> {
|
|
||||||
options.register(opt)
|
|
||||||
return opt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +1,107 @@
|
|||||||
|
@file:Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
|
||||||
package app.revanced.patcher.patch
|
package app.revanced.patcher.patch
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.PatchClass
|
||||||
|
import app.revanced.patcher.Patcher
|
||||||
import app.revanced.patcher.data.Context
|
import app.revanced.patcher.data.Context
|
||||||
import app.revanced.patcher.data.ResourceContext
|
import app.revanced.patcher.patch.options.PatchOptions
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
|
import kotlin.reflect.full.findAnnotation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ReVanced patch.
|
* A ReVanced patch.
|
||||||
|
* If an implementation of [Patch] also implements [Closeable]
|
||||||
|
* it will be closed in reverse execution order of patches executed by ReVanced [Patcher].
|
||||||
*
|
*
|
||||||
* If it implements [Closeable], it will be closed after all patches have been executed.
|
* @param T The [Context] type this patch will work on.
|
||||||
* Closing will be done in reverse execution order.
|
|
||||||
*/
|
*/
|
||||||
sealed interface Patch<out T : Context> {
|
sealed class Patch<out T : Context<*>> {
|
||||||
/**
|
/**
|
||||||
* The main function of the [Patch] which the patcher will call.
|
* The name of the patch.
|
||||||
|
*/
|
||||||
|
var name: String? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The description of the patch.
|
||||||
|
*/
|
||||||
|
var description: String? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The packages the patch is compatible with.
|
||||||
|
*/
|
||||||
|
var compatiblePackages: Set<CompatiblePackage>? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Other patches this patch depends on.
|
||||||
|
*/
|
||||||
|
var dependencies: Set<PatchClass>? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Weather or not the patch should be used.
|
||||||
|
*/
|
||||||
|
var use = true
|
||||||
|
private set
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Remove this property, once integrations are coupled with patches.
|
||||||
|
/**
|
||||||
|
* Weather or not the patch requires integrations.
|
||||||
|
*/
|
||||||
|
var requiresIntegrations = false
|
||||||
|
private set
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The options of the patch associated by the options key.
|
||||||
|
*/
|
||||||
|
val options = PatchOptions()
|
||||||
|
|
||||||
|
init {
|
||||||
|
this::class.findAnnotation<app.revanced.patcher.patch.annotation.Patch>()?.let { annotation ->
|
||||||
|
name = annotation.name.ifEmpty { null }
|
||||||
|
description = annotation.description.ifEmpty { null }
|
||||||
|
compatiblePackages = annotation.compatiblePackages
|
||||||
|
.map { CompatiblePackage(it.name, it.versions.toSet().ifEmpty { null }) }
|
||||||
|
.toSet().ifEmpty { null }
|
||||||
|
dependencies = annotation.dependencies.toSet().ifEmpty { null }
|
||||||
|
use = annotation.use
|
||||||
|
requiresIntegrations = annotation.requiresIntegrations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The execution function of the patch.
|
||||||
*
|
*
|
||||||
* @param context The [Context] the patch will work on.
|
* @param context The [Context] the patch will work on.
|
||||||
* @return The result of executing the patch.
|
* @return The result of executing the patch.
|
||||||
*/
|
*/
|
||||||
fun execute(context: @UnsafeVariance T): PatchResult
|
abstract fun execute(context: @UnsafeVariance T)
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
override fun hashCode() = name.hashCode()
|
||||||
* Resource patch for the Patcher.
|
|
||||||
*/
|
|
||||||
interface ResourcePatch : Patch<ResourceContext>
|
|
||||||
|
|
||||||
/**
|
override fun toString() = name ?: this::class.simpleName ?: "Unnamed patch"
|
||||||
* Bytecode patch for the Patcher.
|
|
||||||
*
|
override fun equals(other: Any?): Boolean {
|
||||||
* @param fingerprints A list of [MethodFingerprint] this patch relies on.
|
if (this === other) return true
|
||||||
*/
|
if (javaClass != other?.javaClass) return false
|
||||||
abstract class BytecodePatch(
|
|
||||||
internal val fingerprints: Iterable<MethodFingerprint>? = null
|
other as Patch<*>
|
||||||
) : Patch<BytecodeContext>
|
|
||||||
|
return name == other.name
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A package a [Patch] is compatible with.
|
||||||
|
*
|
||||||
|
* @param name The name of the package.
|
||||||
|
* @param versions The versions of the package.
|
||||||
|
*/
|
||||||
|
class CompatiblePackage(
|
||||||
|
val name: String,
|
||||||
|
val versions: Set<String>? = null,
|
||||||
|
)
|
||||||
|
}
|
||||||
12
src/main/kotlin/app/revanced/patcher/patch/PatchException.kt
Normal file
12
src/main/kotlin/app/revanced/patcher/patch/PatchException.kt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.patcher.patch
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception thrown when patching.
|
||||||
|
*
|
||||||
|
* @param errorMessage The exception message.
|
||||||
|
* @param cause The corresponding [Throwable].
|
||||||
|
*/
|
||||||
|
class PatchException(errorMessage: String?, cause: Throwable?) : Exception(errorMessage, cause) {
|
||||||
|
constructor(errorMessage: String) : this(errorMessage, null)
|
||||||
|
constructor(cause: Throwable) : this(cause.message, cause)
|
||||||
|
}
|
||||||
@@ -1,248 +0,0 @@
|
|||||||
@file:Suppress("CanBeParameter", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST")
|
|
||||||
|
|
||||||
package app.revanced.patcher.patch
|
|
||||||
|
|
||||||
import java.nio.file.Path
|
|
||||||
import kotlin.io.path.pathString
|
|
||||||
import kotlin.reflect.KProperty
|
|
||||||
|
|
||||||
class NoSuchOptionException(val option: String) : Exception("No such option: $option")
|
|
||||||
class IllegalValueException(val value: Any?) : Exception("Illegal value: $value")
|
|
||||||
class InvalidTypeException(val got: String, val expected: String) :
|
|
||||||
Exception("Invalid option value type: $got, expected $expected")
|
|
||||||
|
|
||||||
object RequirementNotMetException : Exception("null was passed into an option that requires a value")
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A registry for an array of [PatchOption]s.
|
|
||||||
* @param options An array of [PatchOption]s.
|
|
||||||
*/
|
|
||||||
class PatchOptions(vararg options: PatchOption<*>) : Iterable<PatchOption<*>> {
|
|
||||||
private val register = mutableMapOf<String, PatchOption<*>>()
|
|
||||||
|
|
||||||
init {
|
|
||||||
options.forEach { register(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun register(option: PatchOption<*>) {
|
|
||||||
if (register.containsKey(option.key)) {
|
|
||||||
throw IllegalStateException("Multiple options found with the same key")
|
|
||||||
}
|
|
||||||
register[option.key] = option
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a [PatchOption] by its key.
|
|
||||||
* @param key The key of the [PatchOption].
|
|
||||||
*/
|
|
||||||
@JvmName("getUntyped")
|
|
||||||
operator fun get(key: String) = register[key] ?: throw NoSuchOptionException(key)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a [PatchOption] by its key.
|
|
||||||
* @param key The key of the [PatchOption].
|
|
||||||
*/
|
|
||||||
inline operator fun <reified T> get(key: String): PatchOption<T> {
|
|
||||||
val opt = get(key)
|
|
||||||
if (opt.value !is T) throw InvalidTypeException(
|
|
||||||
opt.value?.let { it::class.java.canonicalName } ?: "null",
|
|
||||||
T::class.java.canonicalName
|
|
||||||
)
|
|
||||||
return opt as PatchOption<T>
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value of a [PatchOption].
|
|
||||||
* @param key The key of the [PatchOption].
|
|
||||||
* @param value The value you want it to be.
|
|
||||||
* Please note that using the wrong value type results in a runtime error.
|
|
||||||
*/
|
|
||||||
inline operator fun <reified T> set(key: String, value: T) {
|
|
||||||
val opt = get<T>(key)
|
|
||||||
if (opt.value !is T) throw InvalidTypeException(
|
|
||||||
T::class.java.canonicalName,
|
|
||||||
opt.value?.let { it::class.java.canonicalName } ?: "null"
|
|
||||||
)
|
|
||||||
opt.value = value
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of a [PatchOption] to `null`.
|
|
||||||
* @param key The key of the [PatchOption].
|
|
||||||
*/
|
|
||||||
fun nullify(key: String) {
|
|
||||||
get(key).value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun iterator() = register.values.iterator()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A [Patch] option.
|
|
||||||
* @param key Unique identifier of the option. Example: _`settings.microg.enabled`_
|
|
||||||
* @param default The default value of the option.
|
|
||||||
* @param title A human-readable title of the option. Example: _MicroG Settings_
|
|
||||||
* @param description A human-readable description of the option. Example: _Settings integration for MicroG._
|
|
||||||
* @param required Whether the option is required.
|
|
||||||
*/
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
sealed class PatchOption<T>(
|
|
||||||
val key: String,
|
|
||||||
default: T?,
|
|
||||||
val title: String,
|
|
||||||
val description: String,
|
|
||||||
val required: Boolean,
|
|
||||||
val validator: (T?) -> Boolean
|
|
||||||
) {
|
|
||||||
var value: T? = default
|
|
||||||
get() {
|
|
||||||
if (field == null && required) {
|
|
||||||
throw RequirementNotMetException
|
|
||||||
}
|
|
||||||
return field
|
|
||||||
}
|
|
||||||
set(value) {
|
|
||||||
if (value == null && required) {
|
|
||||||
throw RequirementNotMetException
|
|
||||||
}
|
|
||||||
if (!validator(value)) {
|
|
||||||
throw IllegalValueException(value)
|
|
||||||
}
|
|
||||||
field = value
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value of the option.
|
|
||||||
* Please note that using the wrong value type results in a runtime error.
|
|
||||||
*/
|
|
||||||
@JvmName("getValueTyped")
|
|
||||||
inline operator fun <reified V> getValue(thisRef: Nothing?, property: KProperty<*>): V? {
|
|
||||||
if (value !is V?) throw InvalidTypeException(
|
|
||||||
V::class.java.canonicalName,
|
|
||||||
value?.let { it::class.java.canonicalName } ?: "null"
|
|
||||||
)
|
|
||||||
return value as? V?
|
|
||||||
}
|
|
||||||
|
|
||||||
operator fun getValue(thisRef: Any?, property: KProperty<*>) = value
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value of the option.
|
|
||||||
* Please note that using the wrong value type results in a runtime error.
|
|
||||||
*/
|
|
||||||
@JvmName("setValueTyped")
|
|
||||||
inline operator fun <reified V> setValue(thisRef: Nothing?, property: KProperty<*>, new: V) {
|
|
||||||
if (value !is V) throw InvalidTypeException(
|
|
||||||
V::class.java.canonicalName,
|
|
||||||
value?.let { it::class.java.canonicalName } ?: "null"
|
|
||||||
)
|
|
||||||
value = new as T
|
|
||||||
}
|
|
||||||
|
|
||||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, new: T?) {
|
|
||||||
value = new
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A [PatchOption] representing a [String].
|
|
||||||
* @see PatchOption
|
|
||||||
*/
|
|
||||||
class StringOption(
|
|
||||||
key: String,
|
|
||||||
default: String?,
|
|
||||||
title: String,
|
|
||||||
description: String,
|
|
||||||
required: Boolean = false,
|
|
||||||
validator: (String?) -> Boolean = { true }
|
|
||||||
) : PatchOption<String>(
|
|
||||||
key, default, title, description, required, validator
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A [PatchOption] representing a [Boolean].
|
|
||||||
* @see PatchOption
|
|
||||||
*/
|
|
||||||
class BooleanOption(
|
|
||||||
key: String,
|
|
||||||
default: Boolean?,
|
|
||||||
title: String,
|
|
||||||
description: String,
|
|
||||||
required: Boolean = false,
|
|
||||||
validator: (Boolean?) -> Boolean = { true }
|
|
||||||
) : PatchOption<Boolean>(
|
|
||||||
key, default, title, description, required, validator
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A [PatchOption] with a list of allowed options.
|
|
||||||
* @param options A list of allowed options for the [ListOption].
|
|
||||||
* @see PatchOption
|
|
||||||
*/
|
|
||||||
sealed class ListOption<E>(
|
|
||||||
key: String,
|
|
||||||
default: E?,
|
|
||||||
val options: Iterable<E>,
|
|
||||||
title: String,
|
|
||||||
description: String,
|
|
||||||
required: Boolean = false,
|
|
||||||
validator: (E?) -> Boolean = { true }
|
|
||||||
) : PatchOption<E>(
|
|
||||||
key, default, title, description, required, {
|
|
||||||
(it?.let { it in options } ?: true) && validator(it)
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
init {
|
|
||||||
if (default != null && default !in options) {
|
|
||||||
throw IllegalStateException("Default option must be an allowed option")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A [ListOption] of type [String].
|
|
||||||
* @see ListOption
|
|
||||||
*/
|
|
||||||
class StringListOption(
|
|
||||||
key: String,
|
|
||||||
default: String?,
|
|
||||||
options: Iterable<String>,
|
|
||||||
title: String,
|
|
||||||
description: String,
|
|
||||||
required: Boolean = false,
|
|
||||||
validator: (String?) -> Boolean = { true }
|
|
||||||
) : ListOption<String>(
|
|
||||||
key, default, options, title, description, required, validator
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A [ListOption] of type [Int].
|
|
||||||
* @see ListOption
|
|
||||||
*/
|
|
||||||
class IntListOption(
|
|
||||||
key: String,
|
|
||||||
default: Int?,
|
|
||||||
options: Iterable<Int>,
|
|
||||||
title: String,
|
|
||||||
description: String,
|
|
||||||
required: Boolean = false,
|
|
||||||
validator: (Int?) -> Boolean = { true }
|
|
||||||
) : ListOption<Int>(
|
|
||||||
key, default, options, title, description, required, validator
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A [PatchOption] representing a [Path], backed by a [String].
|
|
||||||
* The validator passes a [String], if you need a [Path] you will have to convert it yourself.
|
|
||||||
* @see PatchOption
|
|
||||||
*/
|
|
||||||
class PathOption(
|
|
||||||
key: String,
|
|
||||||
default: Path?,
|
|
||||||
title: String,
|
|
||||||
description: String,
|
|
||||||
required: Boolean = false,
|
|
||||||
validator: (String?) -> Boolean = { true }
|
|
||||||
) : PatchOption<String>(
|
|
||||||
key, default?.pathString, title, description, required, validator
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,35 +1,9 @@
|
|||||||
package app.revanced.patcher.patch
|
package app.revanced.patcher.patch
|
||||||
|
|
||||||
interface PatchResult {
|
/**
|
||||||
fun error(): PatchResultError? {
|
* A result of executing a [Patch].
|
||||||
if (this is PatchResultError) {
|
*
|
||||||
return this
|
* @param patch The [Patch] that was executed.
|
||||||
}
|
* @param exception The [PatchException] thrown, if any.
|
||||||
return null
|
*/
|
||||||
}
|
class PatchResult internal constructor(val patch: Patch<*>, val exception: PatchException? = null)
|
||||||
|
|
||||||
fun success(): PatchResultSuccess? {
|
|
||||||
if (this is PatchResultSuccess) {
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isError(): Boolean {
|
|
||||||
return this is PatchResultError
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isSuccess(): Boolean {
|
|
||||||
return this is PatchResultSuccess
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class PatchResultError(
|
|
||||||
errorMessage: String?, cause: Exception?
|
|
||||||
) : Exception(errorMessage, cause), PatchResult {
|
|
||||||
constructor(errorMessage: String) : this(errorMessage, null)
|
|
||||||
constructor(cause: Exception) : this(cause.message, cause)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class PatchResultSuccess : PatchResult
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package app.revanced.patcher.patch
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.ResourceContext
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A ReVanced [Patch] that works on [ResourceContext].
|
||||||
|
*/
|
||||||
|
abstract class ResourcePatch : Patch<ResourceContext>()
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package app.revanced.patcher.patch.annotation
|
||||||
|
|
||||||
|
import java.lang.annotation.Inherited
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation for [app.revanced.patcher.patch.Patch] classes.
|
||||||
|
*
|
||||||
|
* @param name The name of the patch. If empty, the patch will be unnamed.
|
||||||
|
* @param description The description of the patch. If empty, no description will be used.
|
||||||
|
* @param dependencies The patches this patch depends on.
|
||||||
|
* @param compatiblePackages The packages this patch is compatible with.
|
||||||
|
* @param use Whether this patch should be used.
|
||||||
|
* @param requiresIntegrations Whether this patch requires integrations.
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Inherited
|
||||||
|
annotation class Patch(
|
||||||
|
val name: String = "",
|
||||||
|
val description: String = "",
|
||||||
|
val dependencies: Array<KClass<out app.revanced.patcher.patch.Patch<*>>> = [],
|
||||||
|
val compatiblePackages: Array<CompatiblePackage> = [],
|
||||||
|
val use: Boolean = true,
|
||||||
|
// TODO: Remove this property, once integrations are coupled with patches.
|
||||||
|
val requiresIntegrations: Boolean = false,
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A package that a [app.revanced.patcher.patch.Patch] is compatible with.
|
||||||
|
*
|
||||||
|
* @param name The name of the package.
|
||||||
|
* @param versions The versions of the package.
|
||||||
|
*/
|
||||||
|
annotation class CompatiblePackage(
|
||||||
|
val name: String,
|
||||||
|
val versions: Array<String> = [],
|
||||||
|
)
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package app.revanced.patcher.patch.annotations
|
|
||||||
|
|
||||||
import app.revanced.patcher.data.Context
|
|
||||||
import app.revanced.patcher.patch.Patch
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation to mark a class as a patch.
|
|
||||||
* @param include If false, the patch should be treated as optional by default.
|
|
||||||
*/
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
|
||||||
annotation class Patch(val include: Boolean = true)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation for dependencies of [Patch]es.
|
|
||||||
*/
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
|
||||||
annotation class DependsOn(
|
|
||||||
val dependencies: Array<KClass<out Patch<Context>>> = []
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation to mark [Patch]es which depend on integrations.
|
|
||||||
*/
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
|
||||||
annotation class RequiresIntegrations // required because integrations are decoupled from patches
|
|
||||||
@@ -0,0 +1,342 @@
|
|||||||
|
package app.revanced.patcher.patch.options
|
||||||
|
|
||||||
|
import app.revanced.patcher.patch.Patch
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [Patch] option.
|
||||||
|
*
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param default The default value.
|
||||||
|
* @param values The set of guaranteed valid values identified by their string representation.
|
||||||
|
* @param title The title.
|
||||||
|
* @param description A description.
|
||||||
|
* @param required Whether the option is required.
|
||||||
|
* @param validator The function to validate the option value.
|
||||||
|
* @param T The value type of the option.
|
||||||
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate", "unused")
|
||||||
|
open class PatchOption<T>(
|
||||||
|
val key: String,
|
||||||
|
val default: T?,
|
||||||
|
val values: Map<String, T?>?,
|
||||||
|
val title: String?,
|
||||||
|
val description: String?,
|
||||||
|
val required: Boolean,
|
||||||
|
val validator: PatchOption<T>.(T?) -> Boolean
|
||||||
|
) {
|
||||||
|
/**
|
||||||
|
* The value of the [PatchOption].
|
||||||
|
*/
|
||||||
|
var value: T?
|
||||||
|
/**
|
||||||
|
* Set the value of the [PatchOption].
|
||||||
|
*
|
||||||
|
* @param value The value to set.
|
||||||
|
*
|
||||||
|
* @throws PatchOptionException.ValueRequiredException If the value is required but null.
|
||||||
|
* @throws PatchOptionException.ValueValidationException If the value is invalid.
|
||||||
|
*/
|
||||||
|
set(value) {
|
||||||
|
assertRequiredButNotNull(value)
|
||||||
|
assertValid(value)
|
||||||
|
|
||||||
|
uncheckedValue = value
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the value of the [PatchOption].
|
||||||
|
*
|
||||||
|
* @return The value.
|
||||||
|
*
|
||||||
|
* @throws PatchOptionException.ValueRequiredException If the value is required but null.
|
||||||
|
* @throws PatchOptionException.ValueValidationException If the value is invalid.
|
||||||
|
*/
|
||||||
|
get() {
|
||||||
|
assertRequiredButNotNull(uncheckedValue)
|
||||||
|
assertValid(uncheckedValue)
|
||||||
|
|
||||||
|
return uncheckedValue
|
||||||
|
}
|
||||||
|
|
||||||
|
// The unchecked value is used to allow setting the value without validation.
|
||||||
|
private var uncheckedValue = default
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the [PatchOption] to its default value.
|
||||||
|
* Override this method if you need to mutate the value instead of replacing it.
|
||||||
|
*/
|
||||||
|
open fun reset() {
|
||||||
|
uncheckedValue = default
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun assertRequiredButNotNull(value: T?) {
|
||||||
|
if (required && value == null) throw PatchOptionException.ValueRequiredException(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun assertValid(value: T?) {
|
||||||
|
if (!validator(value)) throw PatchOptionException.ValueValidationException(value, this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toString() = value.toString()
|
||||||
|
|
||||||
|
operator fun getValue(thisRef: Any?, property: KProperty<*>) = value
|
||||||
|
|
||||||
|
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T?) {
|
||||||
|
this.value = value
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
companion object PatchExtensions {
|
||||||
|
/**
|
||||||
|
* Create a new [PatchOption] with a string value and add it to the current [Patch].
|
||||||
|
*
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param default The default value.
|
||||||
|
* @param values The set of guaranteed valid values.
|
||||||
|
* @param title The title.
|
||||||
|
* @param description A description.
|
||||||
|
* @param required Whether the option is required.
|
||||||
|
* @param validator The function to validate the option value.
|
||||||
|
*
|
||||||
|
* @return The created [PatchOption].
|
||||||
|
*
|
||||||
|
* @see PatchOption
|
||||||
|
*/
|
||||||
|
fun <P : Patch<*>> P.stringPatchOption(
|
||||||
|
key: String,
|
||||||
|
default: String? = null,
|
||||||
|
values: Map<String, String?>? = null,
|
||||||
|
title: String? = null,
|
||||||
|
description: String? = null,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: PatchOption<String>.(String?) -> Boolean = { true }
|
||||||
|
) = PatchOption(key, default, values, title, description, required, validator).also { registerOption(it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new [PatchOption] with an integer value and add it to the current [Patch].
|
||||||
|
*
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param default The default value.
|
||||||
|
* @param values The set of guaranteed valid values.
|
||||||
|
* @param title The title.
|
||||||
|
* @param description A description.
|
||||||
|
* @param required Whether the option is required.
|
||||||
|
* @param validator The function to validate the option value.
|
||||||
|
*
|
||||||
|
* @return The created [PatchOption].
|
||||||
|
*
|
||||||
|
* @see PatchOption
|
||||||
|
*/
|
||||||
|
fun <P : Patch<*>> P.intPatchOption(
|
||||||
|
key: String,
|
||||||
|
default: Int? = null,
|
||||||
|
values: Map<String, Int?>? = null,
|
||||||
|
title: String? = null,
|
||||||
|
description: String? = null,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: PatchOption<Int?>.(Int?) -> Boolean = { true }
|
||||||
|
) = PatchOption(key, default, values, title, description, required, validator).also { registerOption(it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new [PatchOption] with a boolean value and add it to the current [Patch].
|
||||||
|
*
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param default The default value.
|
||||||
|
* @param values The set of guaranteed valid values.
|
||||||
|
* @param title The title.
|
||||||
|
* @param description A description.
|
||||||
|
* @param required Whether the option is required.
|
||||||
|
* @param validator The function to validate the option value.
|
||||||
|
*
|
||||||
|
* @return The created [PatchOption].
|
||||||
|
*
|
||||||
|
* @see PatchOption
|
||||||
|
*/
|
||||||
|
fun <P : Patch<*>> P.booleanPatchOption(
|
||||||
|
key: String,
|
||||||
|
default: Boolean? = null,
|
||||||
|
values: Map<String, Boolean?>? = null,
|
||||||
|
title: String? = null,
|
||||||
|
description: String? = null,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: PatchOption<Boolean?>.(Boolean?) -> Boolean = { true }
|
||||||
|
) = PatchOption(key, default, values, title, description, required, validator).also { registerOption(it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new [PatchOption] with a float value and add it to the current [Patch].
|
||||||
|
*
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param default The default value.
|
||||||
|
* @param values The set of guaranteed valid values.
|
||||||
|
* @param title The title.
|
||||||
|
* @param description A description.
|
||||||
|
* @param required Whether the option is required.
|
||||||
|
* @param validator The function to validate the option value.
|
||||||
|
*
|
||||||
|
* @return The created [PatchOption].
|
||||||
|
*
|
||||||
|
* @see PatchOption
|
||||||
|
*/
|
||||||
|
fun <P : Patch<*>> P.floatPatchOption(
|
||||||
|
key: String,
|
||||||
|
default: Float? = null,
|
||||||
|
values: Map<String, Float?>? = null,
|
||||||
|
title: String? = null,
|
||||||
|
description: String? = null,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: PatchOption<Float?>.(Float?) -> Boolean = { true }
|
||||||
|
) = PatchOption(key, default, values, title, description, required, validator).also { registerOption(it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new [PatchOption] with a long value and add it to the current [Patch].
|
||||||
|
*
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param default The default value.
|
||||||
|
* @param values The set of guaranteed valid values.
|
||||||
|
* @param title The title.
|
||||||
|
* @param description A description.
|
||||||
|
* @param required Whether the option is required.
|
||||||
|
* @param validator The function to validate the option value.
|
||||||
|
*
|
||||||
|
* @return The created [PatchOption].
|
||||||
|
*
|
||||||
|
* @see PatchOption
|
||||||
|
*/
|
||||||
|
fun <P : Patch<*>> P.longPatchOption(
|
||||||
|
key: String,
|
||||||
|
default: Long? = null,
|
||||||
|
values: Map<String, Long?>? = null,
|
||||||
|
title: String? = null,
|
||||||
|
description: String? = null,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: PatchOption<Long?>.(Long?) -> Boolean = { true }
|
||||||
|
) = PatchOption(key, default, values, title, description, required, validator).also { registerOption(it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new [PatchOption] with a string array value and add it to the current [Patch].
|
||||||
|
*
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param default The default value.
|
||||||
|
* @param values The set of guaranteed valid values.
|
||||||
|
* @param title The title.
|
||||||
|
* @param description A description.
|
||||||
|
* @param required Whether the option is required.
|
||||||
|
* @param validator The function to validate the option value.
|
||||||
|
*
|
||||||
|
* @return The created [PatchOption].
|
||||||
|
*
|
||||||
|
* @see PatchOption
|
||||||
|
*/
|
||||||
|
fun <P : Patch<*>> P.stringArrayPatchOption(
|
||||||
|
key: String,
|
||||||
|
default: Array<String>? = null,
|
||||||
|
values: Map<String, Array<String>?>? = null,
|
||||||
|
title: String? = null,
|
||||||
|
description: String? = null,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: PatchOption<Array<String>?>.(Array<String>?) -> Boolean = { true }
|
||||||
|
) = PatchOption(key, default, values, title, description, required, validator).also { registerOption(it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new [PatchOption] with an integer array value and add it to the current [Patch].
|
||||||
|
*
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param default The default value.
|
||||||
|
* @param values The set of guaranteed valid values.
|
||||||
|
* @param title The title.
|
||||||
|
* @param description A description.
|
||||||
|
* @param required Whether the option is required.
|
||||||
|
* @param validator The function to validate the option value.
|
||||||
|
*
|
||||||
|
* @return The created [PatchOption].
|
||||||
|
*
|
||||||
|
* @see PatchOption
|
||||||
|
*/
|
||||||
|
fun <P : Patch<*>> P.intArrayPatchOption(
|
||||||
|
key: String,
|
||||||
|
default: Array<Int>? = null,
|
||||||
|
values: Map<String, Array<Int>?>? = null,
|
||||||
|
title: String? = null,
|
||||||
|
description: String? = null,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: PatchOption<Array<Int>?>.(Array<Int>?) -> Boolean = { true }
|
||||||
|
) = PatchOption(key, default, values, title, description, required, validator).also { registerOption(it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new [PatchOption] with a boolean array value and add it to the current [Patch].
|
||||||
|
*
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param default The default value.
|
||||||
|
* @param values The set of guaranteed valid values.
|
||||||
|
* @param title The title.
|
||||||
|
* @param description A description.
|
||||||
|
* @param required Whether the option is required.
|
||||||
|
* @param validator The function to validate the option value.
|
||||||
|
*
|
||||||
|
* @return The created [PatchOption].
|
||||||
|
*
|
||||||
|
* @see PatchOption
|
||||||
|
*/
|
||||||
|
fun <P : Patch<*>> P.booleanArrayPatchOption(
|
||||||
|
key: String,
|
||||||
|
default: Array<Boolean>? = null,
|
||||||
|
values: Map<String, Array<Boolean>?>? = null,
|
||||||
|
title: String? = null,
|
||||||
|
description: String? = null,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: PatchOption<Array<Boolean>?>.(Array<Boolean>?) -> Boolean = { true }
|
||||||
|
) = PatchOption(key, default, values, title, description, required, validator).also { registerOption(it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new [PatchOption] with a float array value and add it to the current [Patch].
|
||||||
|
*
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param default The default value.
|
||||||
|
* @param values The set of guaranteed valid values.
|
||||||
|
* @param title The title.
|
||||||
|
* @param description A description.
|
||||||
|
* @param required Whether the option is required.
|
||||||
|
* @param validator The function to validate the option value.
|
||||||
|
*
|
||||||
|
* @return The created [PatchOption].
|
||||||
|
*
|
||||||
|
* @see PatchOption
|
||||||
|
*/
|
||||||
|
fun <P : Patch<*>> P.floatArrayPatchOption(
|
||||||
|
key: String,
|
||||||
|
default: Array<Float>? = null,
|
||||||
|
values: Map<String, Array<Float>?>? = null,
|
||||||
|
title: String? = null,
|
||||||
|
description: String? = null,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: PatchOption<Array<Float>?>.(Array<Float>?) -> Boolean = { true }
|
||||||
|
) = PatchOption(key, default, values, title, description, required, validator).also { registerOption(it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new [PatchOption] with a long array value and add it to the current [Patch].
|
||||||
|
*
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param default The default value.
|
||||||
|
* @param values The set of guaranteed valid values.
|
||||||
|
* @param title The title.
|
||||||
|
* @param description A description.
|
||||||
|
* @param required Whether the option is required.
|
||||||
|
* @param validator The function to validate the option value.
|
||||||
|
*
|
||||||
|
* @return The created [PatchOption].
|
||||||
|
*
|
||||||
|
* @see PatchOption
|
||||||
|
*/
|
||||||
|
fun <P : Patch<*>> P.longArrayPatchOption(
|
||||||
|
key: String,
|
||||||
|
default: Array<Long>? = null,
|
||||||
|
values: Map<String, Array<Long>?>? = null,
|
||||||
|
title: String? = null,
|
||||||
|
description: String? = null,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: PatchOption<Array<Long>?>.(Array<Long>?) -> Boolean = { true }
|
||||||
|
) = PatchOption(key, default, values, title, description, required, validator).also { registerOption(it) }
|
||||||
|
|
||||||
|
private fun <P : Patch<*>> P.registerOption(option: PatchOption<*>) = option.also { options.register(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package app.revanced.patcher.patch.options
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception thrown when using [PatchOption]s.
|
||||||
|
*
|
||||||
|
* @param errorMessage The exception message.
|
||||||
|
*/
|
||||||
|
sealed class PatchOptionException(errorMessage: String) : Exception(errorMessage, null) {
|
||||||
|
/**
|
||||||
|
* An exception thrown when a [PatchOption] is set to an invalid value.
|
||||||
|
*
|
||||||
|
* @param invalidType The type of the value that was passed.
|
||||||
|
* @param expectedType The type of the value that was expected.
|
||||||
|
*/
|
||||||
|
class InvalidValueTypeException(invalidType: String, expectedType: String) :
|
||||||
|
PatchOptionException("Type $expectedType was expected but received type $invalidType")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception thrown when a value did not satisfy the value conditions specified by the [PatchOption].
|
||||||
|
*
|
||||||
|
* @param value The value that failed validation.
|
||||||
|
*/
|
||||||
|
class ValueValidationException(value: Any?, option: PatchOption<*>) :
|
||||||
|
PatchOptionException("The option value \"$value\" failed validation for ${option.key}")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception thrown when a value is required but null was passed.
|
||||||
|
*
|
||||||
|
* @param option The [PatchOption] that requires a value.
|
||||||
|
*/
|
||||||
|
class ValueRequiredException(option: PatchOption<*>) :
|
||||||
|
PatchOptionException("The option ${option.key} requires a value, but null was passed")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception thrown when a [PatchOption] is not found.
|
||||||
|
*
|
||||||
|
* @param key The key of the [PatchOption].
|
||||||
|
*/
|
||||||
|
class PatchOptionNotFoundException(key: String)
|
||||||
|
: PatchOptionException("No option with key $key")
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package app.revanced.patcher.patch.options
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A map of [PatchOption]s associated by their keys.
|
||||||
|
*
|
||||||
|
* @param options The [PatchOption]s to initialize with.
|
||||||
|
*/
|
||||||
|
class PatchOptions internal constructor(
|
||||||
|
private val options: MutableMap<String, PatchOption<*>> = mutableMapOf()
|
||||||
|
) : MutableMap<String, PatchOption<*>> by options {
|
||||||
|
/**
|
||||||
|
* Register a [PatchOption]. Acts like [MutableMap.put].
|
||||||
|
* @param value The [PatchOption] to register.
|
||||||
|
*/
|
||||||
|
fun register(value: PatchOption<*>) {
|
||||||
|
options[value.key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an option's value.
|
||||||
|
* @param key The identifier.
|
||||||
|
* @param value The value.
|
||||||
|
* @throws PatchOptionException.PatchOptionNotFoundException If the option does not exist.
|
||||||
|
*/
|
||||||
|
operator fun <T : Any> set(key: String, value: T?) {
|
||||||
|
val option = this[key]
|
||||||
|
|
||||||
|
try {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
(option as PatchOption<T>).value = value
|
||||||
|
} catch (e: ClassCastException) {
|
||||||
|
throw PatchOptionException.InvalidValueTypeException(
|
||||||
|
value?.let { it::class.java.name } ?: "null",
|
||||||
|
option.value?.let { it::class.java.name } ?: "null",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an option.
|
||||||
|
*/
|
||||||
|
override operator fun get(key: String) =
|
||||||
|
options[key] ?: throw PatchOptionException.PatchOptionNotFoundException(key)
|
||||||
|
}
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
package app.revanced.patcher.util
|
package app.revanced.patcher.util
|
||||||
|
|
||||||
import app.revanced.patcher.PatcherContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.logging.Logger
|
|
||||||
import app.revanced.patcher.util.ClassMerger.Utils.asMutableClass
|
import app.revanced.patcher.util.ClassMerger.Utils.asMutableClass
|
||||||
import app.revanced.patcher.util.ClassMerger.Utils.filterAny
|
import app.revanced.patcher.util.ClassMerger.Utils.filterAny
|
||||||
import app.revanced.patcher.util.ClassMerger.Utils.filterNotAny
|
import app.revanced.patcher.util.ClassMerger.Utils.filterNotAny
|
||||||
import app.revanced.patcher.util.ClassMerger.Utils.isPublic
|
import app.revanced.patcher.util.ClassMerger.Utils.isPublic
|
||||||
import app.revanced.patcher.util.ClassMerger.Utils.toPublic
|
import app.revanced.patcher.util.ClassMerger.Utils.toPublic
|
||||||
import app.revanced.patcher.util.TypeUtil.traverseClassHierarchy
|
import app.revanced.patcher.util.ClassMerger.Utils.traverseClassHierarchy
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass.Companion.toMutable
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableField
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableField
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
import org.jf.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import com.android.tools.smali.dexlib2.iface.ClassDef
|
||||||
import org.jf.dexlib2.util.MethodUtil
|
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||||
|
import java.util.logging.Logger
|
||||||
import kotlin.reflect.KFunction2
|
import kotlin.reflect.KFunction2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,27 +25,28 @@ import kotlin.reflect.KFunction2
|
|||||||
* Note: This will not consider method implementations or if the class is missing a superclass or interfaces.
|
* Note: This will not consider method implementations or if the class is missing a superclass or interfaces.
|
||||||
*/
|
*/
|
||||||
internal object ClassMerger {
|
internal object ClassMerger {
|
||||||
|
private val logger = Logger.getLogger(ClassMerger::class.java.name)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge a class with [otherClass].
|
* Merge a class with [otherClass].
|
||||||
*
|
*
|
||||||
* @param otherClass The class to merge with
|
* @param otherClass The class to merge with
|
||||||
* @param context The context to traverse the class hierarchy in.
|
* @param context The context to traverse the class hierarchy in.
|
||||||
* @param logger A logger.
|
* @return The merged class or the original class if no merge was needed.
|
||||||
*/
|
*/
|
||||||
fun ClassDef.merge(otherClass: ClassDef, context: PatcherContext, logger: Logger? = null) = this
|
fun ClassDef.merge(otherClass: ClassDef, context: BytecodeContext) = this
|
||||||
//.fixFieldAccess(otherClass, logger)
|
//.fixFieldAccess(otherClass)
|
||||||
//.fixMethodAccess(otherClass, logger)
|
//.fixMethodAccess(otherClass)
|
||||||
.addMissingFields(otherClass, logger)
|
.addMissingFields(otherClass)
|
||||||
.addMissingMethods(otherClass, logger)
|
.addMissingMethods(otherClass)
|
||||||
.publicize(otherClass, context, logger)
|
.publicize(otherClass, context)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add methods which are missing but existing in [fromClass].
|
* Add methods which are missing but existing in [fromClass].
|
||||||
*
|
*
|
||||||
* @param fromClass The class to add missing methods from.
|
* @param fromClass The class to add missing methods from.
|
||||||
* @param logger A logger.
|
|
||||||
*/
|
*/
|
||||||
private fun ClassDef.addMissingMethods(fromClass: ClassDef, logger: Logger? = null): ClassDef {
|
private fun ClassDef.addMissingMethods(fromClass: ClassDef): ClassDef {
|
||||||
val missingMethods = fromClass.methods.let { fromMethods ->
|
val missingMethods = fromClass.methods.let { fromMethods ->
|
||||||
methods.filterNot { method ->
|
methods.filterNot { method ->
|
||||||
fromMethods.any { fromMethod ->
|
fromMethods.any { fromMethod ->
|
||||||
@@ -56,7 +57,7 @@ internal object ClassMerger {
|
|||||||
|
|
||||||
if (missingMethods.isEmpty()) return this
|
if (missingMethods.isEmpty()) return this
|
||||||
|
|
||||||
logger?.trace("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() })
|
||||||
@@ -67,16 +68,15 @@ internal object ClassMerger {
|
|||||||
* Add fields which are missing but existing in [fromClass].
|
* Add fields which are missing but existing in [fromClass].
|
||||||
*
|
*
|
||||||
* @param fromClass The class to add missing fields from.
|
* @param fromClass The class to add missing fields from.
|
||||||
* @param logger A logger.
|
|
||||||
*/
|
*/
|
||||||
private fun ClassDef.addMissingFields(fromClass: ClassDef, logger: Logger? = null): ClassDef {
|
private fun ClassDef.addMissingFields(fromClass: ClassDef): ClassDef {
|
||||||
val missingFields = fields.filterNotAny(fromClass.fields) { field, fromField ->
|
val missingFields = fields.filterNotAny(fromClass.fields) { field, fromField ->
|
||||||
fromField.name == field.name
|
fromField.name == field.name
|
||||||
}
|
}
|
||||||
|
|
||||||
if (missingFields.isEmpty()) return this
|
if (missingFields.isEmpty()) return this
|
||||||
|
|
||||||
logger?.trace("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() })
|
||||||
@@ -87,15 +87,14 @@ internal object ClassMerger {
|
|||||||
* Make a class and its super class public recursively.
|
* Make a class and its super class public recursively.
|
||||||
* @param reference The class to check the [AccessFlags] of.
|
* @param reference The class to check the [AccessFlags] of.
|
||||||
* @param context The context to traverse the class hierarchy in.
|
* @param context The context to traverse the class hierarchy in.
|
||||||
* @param logger A logger.
|
|
||||||
*/
|
*/
|
||||||
private fun ClassDef.publicize(reference: ClassDef, context: PatcherContext, logger: Logger? = null) =
|
private fun ClassDef.publicize(reference: ClassDef, context: BytecodeContext) =
|
||||||
if (reference.accessFlags.isPublic() && !accessFlags.isPublic())
|
if (reference.accessFlags.isPublic() && !accessFlags.isPublic())
|
||||||
this.asMutableClass().apply {
|
this.asMutableClass().apply {
|
||||||
context.bytecodeContext.traverseClassHierarchy(this) {
|
context.traverseClassHierarchy(this) {
|
||||||
if (accessFlags.isPublic()) return@traverseClassHierarchy
|
if (accessFlags.isPublic()) return@traverseClassHierarchy
|
||||||
|
|
||||||
logger?.trace("Publicizing ${this.type}")
|
logger.fine("Publicizing ${this.type}")
|
||||||
|
|
||||||
accessFlags = accessFlags.toPublic()
|
accessFlags = accessFlags.toPublic()
|
||||||
}
|
}
|
||||||
@@ -106,9 +105,8 @@ internal object ClassMerger {
|
|||||||
* Publicize fields if they are public in [reference].
|
* Publicize fields if they are public in [reference].
|
||||||
*
|
*
|
||||||
* @param reference The class to check the [AccessFlags] of the fields in.
|
* @param reference The class to check the [AccessFlags] of the fields in.
|
||||||
* @param logger A logger.
|
|
||||||
*/
|
*/
|
||||||
private fun ClassDef.fixFieldAccess(reference: ClassDef, logger: Logger? = null): ClassDef {
|
private fun ClassDef.fixFieldAccess(reference: ClassDef): ClassDef {
|
||||||
val brokenFields = fields.filterAny(reference.fields) { field, referenceField ->
|
val brokenFields = fields.filterAny(reference.fields) { field, referenceField ->
|
||||||
if (field.name != referenceField.name) return@filterAny false
|
if (field.name != referenceField.name) return@filterAny false
|
||||||
|
|
||||||
@@ -117,7 +115,7 @@ internal object ClassMerger {
|
|||||||
|
|
||||||
if (brokenFields.isEmpty()) return this
|
if (brokenFields.isEmpty()) return this
|
||||||
|
|
||||||
logger?.trace("Found ${brokenFields.size} broken fields")
|
logger.fine("Found ${brokenFields.size} broken fields")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a field public.
|
* Make a field public.
|
||||||
@@ -135,9 +133,8 @@ internal object ClassMerger {
|
|||||||
* Publicize methods if they are public in [reference].
|
* Publicize methods if they are public in [reference].
|
||||||
*
|
*
|
||||||
* @param reference The class to check the [AccessFlags] of the methods in.
|
* @param reference The class to check the [AccessFlags] of the methods in.
|
||||||
* @param logger A logger.
|
|
||||||
*/
|
*/
|
||||||
private fun ClassDef.fixMethodAccess(reference: ClassDef, logger: Logger? = null): ClassDef {
|
private fun ClassDef.fixMethodAccess(reference: ClassDef): ClassDef {
|
||||||
val brokenMethods = methods.filterAny(reference.methods) { method, referenceMethod ->
|
val brokenMethods = methods.filterAny(reference.methods) { method, referenceMethod ->
|
||||||
if (!MethodUtil.methodSignaturesMatch(method, referenceMethod)) return@filterAny false
|
if (!MethodUtil.methodSignaturesMatch(method, referenceMethod)) return@filterAny false
|
||||||
|
|
||||||
@@ -146,7 +143,7 @@ internal object ClassMerger {
|
|||||||
|
|
||||||
if (brokenMethods.isEmpty()) return this
|
if (brokenMethods.isEmpty()) return this
|
||||||
|
|
||||||
logger?.trace("Found ${brokenMethods.size} methods")
|
logger.fine("Found ${brokenMethods.size} methods")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a method public.
|
* Make a method public.
|
||||||
@@ -161,6 +158,19 @@ internal object ClassMerger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private object Utils {
|
private object Utils {
|
||||||
|
/**
|
||||||
|
* traverse the class hierarchy starting from the given root class
|
||||||
|
*
|
||||||
|
* @param targetClass the class to start traversing the class hierarchy from
|
||||||
|
* @param callback function that is called for every class in the hierarchy
|
||||||
|
*/
|
||||||
|
fun BytecodeContext.traverseClassHierarchy(targetClass: MutableClass, callback: MutableClass.() -> Unit) {
|
||||||
|
callback(targetClass)
|
||||||
|
this.findClass(targetClass.superclass ?: return)?.mutableClass?.let {
|
||||||
|
traverseClassHierarchy(it, callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun ClassDef.asMutableClass() = if (this is MutableClass) this else this.toMutable()
|
fun ClassDef.asMutableClass() = if (this is MutableClass) this else this.toMutable()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -180,7 +190,6 @@ internal object ClassMerger {
|
|||||||
/**
|
/**
|
||||||
* Filter [this] on [needles] matching the given [predicate].
|
* Filter [this] on [needles] matching the given [predicate].
|
||||||
*
|
*
|
||||||
* @param this The hay to filter for [needles].
|
|
||||||
* @param needles The needles to filter [this] with.
|
* @param needles The needles to filter [this] with.
|
||||||
* @param predicate The filter.
|
* @param predicate The filter.
|
||||||
* @return The [this] filtered on [needles] matching the given [predicate].
|
* @return The [this] filtered on [needles] matching the given [predicate].
|
||||||
@@ -192,7 +201,6 @@ internal object ClassMerger {
|
|||||||
/**
|
/**
|
||||||
* Filter [this] on [needles] not matching the given [predicate].
|
* Filter [this] on [needles] not matching the given [predicate].
|
||||||
*
|
*
|
||||||
* @param this The hay to filter for [needles].
|
|
||||||
* @param needles The needles to filter [this] with.
|
* @param needles The needles to filter [this] with.
|
||||||
* @param predicate The filter.
|
* @param predicate The filter.
|
||||||
* @return The [this] filtered on [needles] not matching the given [predicate].
|
* @return The [this] filtered on [needles] not matching the given [predicate].
|
||||||
|
|||||||
87
src/main/kotlin/app/revanced/patcher/util/DomFileEditor.kt
Normal file
87
src/main/kotlin/app/revanced/patcher/util/DomFileEditor.kt
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
package app.revanced.patcher.util
|
||||||
|
|
||||||
|
import org.w3c.dom.Document
|
||||||
|
import java.io.Closeable
|
||||||
|
import java.io.File
|
||||||
|
import java.io.InputStream
|
||||||
|
import java.io.OutputStream
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory
|
||||||
|
import javax.xml.transform.TransformerFactory
|
||||||
|
import javax.xml.transform.dom.DOMSource
|
||||||
|
import javax.xml.transform.stream.StreamResult
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for a file that can be edited as a dom document.
|
||||||
|
*
|
||||||
|
* This constructor does not check for locks to the file when writing.
|
||||||
|
* Use the secondary constructor.
|
||||||
|
*
|
||||||
|
* @param inputStream the input stream to read the xml file from.
|
||||||
|
* @param outputStream the output stream to write the xml file to. If null, the file will be read only.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class DomFileEditor internal constructor(
|
||||||
|
private val inputStream: InputStream,
|
||||||
|
private val outputStream: Lazy<OutputStream>? = null,
|
||||||
|
) : Closeable {
|
||||||
|
// path to the xml file to unlock the resource when closing the editor
|
||||||
|
private var filePath: String? = null
|
||||||
|
private var closed: Boolean = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The document of the xml file
|
||||||
|
*/
|
||||||
|
val file: Document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream)
|
||||||
|
.also(Document::normalize)
|
||||||
|
|
||||||
|
|
||||||
|
// lazily open an output stream
|
||||||
|
// this is required because when constructing a DomFileEditor the output stream is created along with the input stream, which is not allowed
|
||||||
|
// the workaround is to lazily create the output stream. This way it would be used after the input stream is closed, which happens in the constructor
|
||||||
|
constructor(file: File) : this(file.inputStream(), lazy { file.outputStream() }) {
|
||||||
|
// increase the lock
|
||||||
|
locks.merge(file.path, 1, Integer::sum)
|
||||||
|
filePath = file.path
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the editor. Write backs and decreases the lock count.
|
||||||
|
*
|
||||||
|
* Will not write back to the file if the file is still locked.
|
||||||
|
*/
|
||||||
|
override fun close() {
|
||||||
|
if (closed) return
|
||||||
|
|
||||||
|
inputStream.close()
|
||||||
|
|
||||||
|
// if the output stream is not null, do not close it
|
||||||
|
outputStream?.let {
|
||||||
|
// prevent writing to same file, if it is being locked
|
||||||
|
// isLocked will be false if the editor was created through a stream
|
||||||
|
val isLocked = filePath?.let { path ->
|
||||||
|
val isLocked = locks[path]!! > 1
|
||||||
|
// decrease the lock count if the editor was opened for a file
|
||||||
|
locks.merge(path, -1, Integer::sum)
|
||||||
|
isLocked
|
||||||
|
} ?: false
|
||||||
|
|
||||||
|
// if unlocked, write back to the file
|
||||||
|
if (!isLocked) {
|
||||||
|
it.value.use { stream ->
|
||||||
|
val result = StreamResult(stream)
|
||||||
|
TransformerFactory.newInstance().newTransformer().transform(DOMSource(file), result)
|
||||||
|
}
|
||||||
|
|
||||||
|
it.value.close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closed = true
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
// map of concurrent open files
|
||||||
|
val locks = mutableMapOf<String, Int>()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package app.revanced.patcher.util
|
|
||||||
|
|
||||||
internal class ListBackedSet<E>(private val list: MutableList<E>) : MutableSet<E> {
|
|
||||||
override val size get() = list.size
|
|
||||||
override fun add(element: E) = list.add(element)
|
|
||||||
override fun addAll(elements: Collection<E>) = list.addAll(elements)
|
|
||||||
override fun clear() = list.clear()
|
|
||||||
override fun iterator() = list.listIterator()
|
|
||||||
override fun remove(element: E) = list.remove(element)
|
|
||||||
override fun removeAll(elements: Collection<E>) = list.removeAll(elements)
|
|
||||||
override fun retainAll(elements: Collection<E>) = list.retainAll(elements)
|
|
||||||
override fun contains(element: E) = list.contains(element)
|
|
||||||
override fun containsAll(elements: Collection<E>) = list.containsAll(elements)
|
|
||||||
override fun isEmpty() = list.isEmpty()
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package app.revanced.patcher.util
|
|
||||||
|
|
||||||
import app.revanced.patcher.util.proxy.ClassProxy
|
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A class that represents a set of classes and proxies.
|
|
||||||
*
|
|
||||||
* @param classes The classes to be backed by proxies.
|
|
||||||
*/
|
|
||||||
class ProxyBackedClassList(internal val classes: MutableList<ClassDef>) : Set<ClassDef> {
|
|
||||||
internal val proxies = mutableListOf<ClassProxy>()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a [ClassDef].
|
|
||||||
*/
|
|
||||||
fun add(classDef: ClassDef) = classes.add(classDef)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a [ClassProxy].
|
|
||||||
*/
|
|
||||||
fun add(classProxy: ClassProxy) = proxies.add(classProxy)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace all classes with their mutated versions.
|
|
||||||
*/
|
|
||||||
internal fun replaceClasses() =
|
|
||||||
proxies.removeIf { proxy ->
|
|
||||||
// if the proxy is unused, keep it in the list
|
|
||||||
if (!proxy.resolved) return@removeIf false
|
|
||||||
|
|
||||||
// if it has been used, replace the original class with the new class
|
|
||||||
val index = classes.indexOfFirst { it.type == proxy.immutableClass.type }
|
|
||||||
classes[index] = proxy.mutableClass
|
|
||||||
|
|
||||||
// return true to remove it from the proxies list
|
|
||||||
return@removeIf true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override val size get() = classes.size
|
|
||||||
override fun contains(element: ClassDef) = classes.contains(element)
|
|
||||||
override fun containsAll(elements: Collection<ClassDef>) = classes.containsAll(elements)
|
|
||||||
override fun isEmpty() = classes.isEmpty()
|
|
||||||
override fun iterator() = classes.iterator()
|
|
||||||
}
|
|
||||||
33
src/main/kotlin/app/revanced/patcher/util/ProxyClassList.kt
Normal file
33
src/main/kotlin/app/revanced/patcher/util/ProxyClassList.kt
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package app.revanced.patcher.util
|
||||||
|
|
||||||
|
import app.revanced.patcher.util.proxy.ClassProxy
|
||||||
|
import com.android.tools.smali.dexlib2.iface.ClassDef
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class that represents a set of classes and proxies.
|
||||||
|
*
|
||||||
|
* @param classes The classes to be backed by proxies.
|
||||||
|
*/
|
||||||
|
class ProxyClassList internal constructor(classes: MutableSet<ClassDef>) : MutableSet<ClassDef> by classes {
|
||||||
|
internal val proxies = mutableListOf<ClassProxy>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a [ClassProxy].
|
||||||
|
*/
|
||||||
|
fun add(classProxy: ClassProxy) = proxies.add(classProxy)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace all classes with their mutated versions.
|
||||||
|
*/
|
||||||
|
internal fun replaceClasses() = proxies.removeIf { proxy ->
|
||||||
|
// If the proxy is unused, return false to keep it in the proxies list.
|
||||||
|
if (!proxy.resolved) return@removeIf false
|
||||||
|
|
||||||
|
// If it has been used, replace the original class with the mutable class.
|
||||||
|
remove(proxy.immutableClass)
|
||||||
|
add(proxy.mutableClass)
|
||||||
|
|
||||||
|
// Return true to remove the proxy from the proxies list.
|
||||||
|
return@removeIf true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package app.revanced.patcher.util
|
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
|
||||||
|
|
||||||
object TypeUtil {
|
|
||||||
/**
|
|
||||||
* traverse the class hierarchy starting from the given root class
|
|
||||||
*
|
|
||||||
* @param targetClass the class to start traversing the class hierarchy from
|
|
||||||
* @param callback function that is called for every class in the hierarchy
|
|
||||||
*/
|
|
||||||
fun BytecodeContext.traverseClassHierarchy(targetClass: MutableClass, callback: MutableClass.() -> Unit) {
|
|
||||||
callback(targetClass)
|
|
||||||
this.findClass(targetClass.superclass ?: return)?.mutableClass?.let {
|
|
||||||
traverseClassHierarchy(it, callback)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package app.revanced.patcher.util
|
|
||||||
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
internal object VersionReader {
|
|
||||||
@JvmStatic
|
|
||||||
private val props = Properties().apply {
|
|
||||||
load(
|
|
||||||
VersionReader::class.java.getResourceAsStream("/revanced-patcher/version.properties")
|
|
||||||
?: throw IllegalStateException("Could not load version.properties")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun read(): String {
|
|
||||||
return props.getProperty("version") ?: throw IllegalStateException("Version not found")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package app.revanced.patcher.util.dex
|
|
||||||
|
|
||||||
import java.io.InputStream
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper for dex files.
|
|
||||||
* @param name The original name of the dex file.
|
|
||||||
* @param stream The dex file as [InputStream].
|
|
||||||
*/
|
|
||||||
data class DexFile(val name: String, val stream: InputStream)
|
|
||||||
@@ -2,10 +2,10 @@ package app.revanced.patcher.util.method
|
|||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import org.jf.dexlib2.iface.Method
|
import com.android.tools.smali.dexlib2.iface.Method
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import org.jf.dexlib2.iface.reference.MethodReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
import org.jf.dexlib2.util.MethodUtil
|
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a method from another method via instruction offsets.
|
* Find a method from another method via instruction offsets.
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
@file:Suppress("unused")
|
|
||||||
|
|
||||||
package app.revanced.patcher.util.patch
|
|
||||||
|
|
||||||
import app.revanced.patcher.data.Context
|
|
||||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
|
||||||
import app.revanced.patcher.patch.Patch
|
|
||||||
import org.jf.dexlib2.DexFileFactory
|
|
||||||
import java.io.File
|
|
||||||
import java.net.URLClassLoader
|
|
||||||
import java.util.jar.JarFile
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A patch bundle.
|
|
||||||
|
|
||||||
* @param path The path to the patch bundle.
|
|
||||||
*/
|
|
||||||
sealed class PatchBundle(path: String) : File(path) {
|
|
||||||
internal fun loadPatches(classLoader: ClassLoader, classNames: Iterator<String>) = buildList {
|
|
||||||
classNames.forEach { className ->
|
|
||||||
val clazz = classLoader.loadClass(className)
|
|
||||||
if (!clazz.isAnnotationPresent(app.revanced.patcher.patch.annotations.Patch::class.java)) return@forEach
|
|
||||||
@Suppress("UNCHECKED_CAST") this.add(clazz as Class<out Patch<Context>>)
|
|
||||||
}
|
|
||||||
}.sortedBy { it.patchName }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A patch bundle of type [Jar].
|
|
||||||
*
|
|
||||||
* @param patchBundlePath The path to the patch bundle.
|
|
||||||
*/
|
|
||||||
class Jar(patchBundlePath: String) : PatchBundle(patchBundlePath) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load patches from the patch bundle.
|
|
||||||
*
|
|
||||||
* Patches will be loaded with a new [URLClassLoader].
|
|
||||||
*/
|
|
||||||
fun loadPatches() = loadPatches(
|
|
||||||
URLClassLoader(
|
|
||||||
arrayOf(this.toURI().toURL()),
|
|
||||||
Thread.currentThread().contextClassLoader // TODO: find out why this is required
|
|
||||||
),
|
|
||||||
JarFile(this)
|
|
||||||
.stream()
|
|
||||||
.filter {it.name.endsWith(".class") && !it.name.contains("$")}
|
|
||||||
.map({it -> it.realName.replace('/', '.').replace(".class", "")}).iterator()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A patch bundle of type [Dex] format.
|
|
||||||
*
|
|
||||||
* @param patchBundlePath The path to a patch bundle of dex format.
|
|
||||||
* @param dexClassLoader The dex class loader.
|
|
||||||
*/
|
|
||||||
class Dex(patchBundlePath: String, private val dexClassLoader: ClassLoader) : PatchBundle(patchBundlePath) {
|
|
||||||
/**
|
|
||||||
* Load patches from the patch bundle.
|
|
||||||
*
|
|
||||||
* Patches will be loaded to the provided [dexClassLoader].
|
|
||||||
*/
|
|
||||||
fun loadPatches() = loadPatches(dexClassLoader,
|
|
||||||
DexFileFactory.loadDexFile(path, null).classes.asSequence().map({ classDef ->
|
|
||||||
classDef.type.substring(1, classDef.length - 1).replace('/', '.')
|
|
||||||
}).iterator())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy
|
package app.revanced.patcher.util.proxy
|
||||||
|
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import com.android.tools.smali.dexlib2.iface.ClassDef
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A proxy class for a [ClassDef].
|
* A proxy class for a [ClassDef].
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes
|
package app.revanced.patcher.util.proxy.mutableTypes
|
||||||
|
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotationElement.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotationElement.Companion.toMutable
|
||||||
import org.jf.dexlib2.base.BaseAnnotation
|
import com.android.tools.smali.dexlib2.base.BaseAnnotation
|
||||||
import org.jf.dexlib2.iface.Annotation
|
import com.android.tools.smali.dexlib2.iface.Annotation
|
||||||
|
|
||||||
class MutableAnnotation(annotation: Annotation) : BaseAnnotation() {
|
class MutableAnnotation(annotation: Annotation) : BaseAnnotation() {
|
||||||
private val visibility = annotation.visibility
|
private val visibility = annotation.visibility
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package app.revanced.patcher.util.proxy.mutableTypes
|
|||||||
|
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue
|
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
||||||
import org.jf.dexlib2.base.BaseAnnotationElement
|
import com.android.tools.smali.dexlib2.base.BaseAnnotationElement
|
||||||
import org.jf.dexlib2.iface.AnnotationElement
|
import com.android.tools.smali.dexlib2.iface.AnnotationElement
|
||||||
import org.jf.dexlib2.iface.value.EncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.EncodedValue
|
||||||
|
|
||||||
class MutableAnnotationElement(annotationElement: AnnotationElement) : BaseAnnotationElement() {
|
class MutableAnnotationElement(annotationElement: AnnotationElement) : BaseAnnotationElement() {
|
||||||
private var name = annotationElement.name
|
private var name = annotationElement.name
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotation.Companion.
|
|||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
import com.google.common.collect.Iterables
|
import com.google.common.collect.Iterables
|
||||||
import org.jf.dexlib2.base.reference.BaseTypeReference
|
import com.android.tools.smali.dexlib2.base.reference.BaseTypeReference
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import com.android.tools.smali.dexlib2.iface.ClassDef
|
||||||
import org.jf.dexlib2.util.FieldUtil
|
import com.android.tools.smali.dexlib2.util.FieldUtil
|
||||||
import org.jf.dexlib2.util.MethodUtil
|
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||||
|
|
||||||
class MutableClass(classDef: ClassDef) : ClassDef, BaseTypeReference() {
|
class MutableClass(classDef: ClassDef) : ClassDef, BaseTypeReference() {
|
||||||
// Class
|
// Class
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package app.revanced.patcher.util.proxy.mutableTypes
|
|||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue
|
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
||||||
import org.jf.dexlib2.HiddenApiRestriction
|
import com.android.tools.smali.dexlib2.HiddenApiRestriction
|
||||||
import org.jf.dexlib2.base.reference.BaseFieldReference
|
import com.android.tools.smali.dexlib2.base.reference.BaseFieldReference
|
||||||
import org.jf.dexlib2.iface.Field
|
import com.android.tools.smali.dexlib2.iface.Field
|
||||||
|
|
||||||
class MutableField(field: Field) : Field, BaseFieldReference() {
|
class MutableField(field: Field) : Field, BaseFieldReference() {
|
||||||
private var definingClass = field.definingClass
|
private var definingClass = field.definingClass
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package app.revanced.patcher.util.proxy.mutableTypes
|
|||||||
|
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethodParameter.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethodParameter.Companion.toMutable
|
||||||
import org.jf.dexlib2.HiddenApiRestriction
|
import com.android.tools.smali.dexlib2.HiddenApiRestriction
|
||||||
import org.jf.dexlib2.base.reference.BaseMethodReference
|
import com.android.tools.smali.dexlib2.base.reference.BaseMethodReference
|
||||||
import org.jf.dexlib2.builder.MutableMethodImplementation
|
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
|
||||||
import org.jf.dexlib2.iface.Method
|
import com.android.tools.smali.dexlib2.iface.Method
|
||||||
|
|
||||||
class MutableMethod(method: Method) : Method, BaseMethodReference() {
|
class MutableMethod(method: Method) : Method, BaseMethodReference() {
|
||||||
private var definingClass = method.definingClass
|
private var definingClass = method.definingClass
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes
|
package app.revanced.patcher.util.proxy.mutableTypes
|
||||||
|
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
||||||
import org.jf.dexlib2.base.BaseMethodParameter
|
import com.android.tools.smali.dexlib2.base.BaseMethodParameter
|
||||||
import org.jf.dexlib2.iface.MethodParameter
|
import com.android.tools.smali.dexlib2.iface.MethodParameter
|
||||||
|
|
||||||
// TODO: finish overriding all members if necessary
|
// TODO: finish overriding all members if necessary
|
||||||
class MutableMethodParameter(parameter: MethodParameter) : MethodParameter, BaseMethodParameter() {
|
class MutableMethodParameter(parameter: MethodParameter) : MethodParameter, BaseMethodParameter() {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotationElement.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotationElement.Companion.toMutable
|
||||||
import org.jf.dexlib2.base.value.BaseAnnotationEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseAnnotationEncodedValue
|
||||||
import org.jf.dexlib2.iface.AnnotationElement
|
import com.android.tools.smali.dexlib2.iface.AnnotationElement
|
||||||
import org.jf.dexlib2.iface.value.AnnotationEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.AnnotationEncodedValue
|
||||||
|
|
||||||
class MutableAnnotationEncodedValue(annotationEncodedValue: AnnotationEncodedValue) : BaseAnnotationEncodedValue(),
|
class MutableAnnotationEncodedValue(annotationEncodedValue: AnnotationEncodedValue) : BaseAnnotationEncodedValue(),
|
||||||
MutableEncodedValue {
|
MutableEncodedValue {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
||||||
import org.jf.dexlib2.base.value.BaseArrayEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseArrayEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.ArrayEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.ArrayEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.EncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.EncodedValue
|
||||||
|
|
||||||
class MutableArrayEncodedValue(arrayEncodedValue: ArrayEncodedValue) : BaseArrayEncodedValue(), MutableEncodedValue {
|
class MutableArrayEncodedValue(arrayEncodedValue: ArrayEncodedValue) : BaseArrayEncodedValue(), MutableEncodedValue {
|
||||||
private val _value by lazy {
|
private val _value by lazy {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseBooleanEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseBooleanEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.BooleanEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.BooleanEncodedValue
|
||||||
|
|
||||||
class MutableBooleanEncodedValue(booleanEncodedValue: BooleanEncodedValue) : BaseBooleanEncodedValue(),
|
class MutableBooleanEncodedValue(booleanEncodedValue: BooleanEncodedValue) : BaseBooleanEncodedValue(),
|
||||||
MutableEncodedValue {
|
MutableEncodedValue {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseByteEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseByteEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.ByteEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.ByteEncodedValue
|
||||||
|
|
||||||
class MutableByteEncodedValue(byteEncodedValue: ByteEncodedValue) : BaseByteEncodedValue(), MutableEncodedValue {
|
class MutableByteEncodedValue(byteEncodedValue: ByteEncodedValue) : BaseByteEncodedValue(), MutableEncodedValue {
|
||||||
private var value = byteEncodedValue.value
|
private var value = byteEncodedValue.value
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseCharEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseCharEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.CharEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.CharEncodedValue
|
||||||
|
|
||||||
class MutableCharEncodedValue(charEncodedValue: CharEncodedValue) : BaseCharEncodedValue(), MutableEncodedValue {
|
class MutableCharEncodedValue(charEncodedValue: CharEncodedValue) : BaseCharEncodedValue(), MutableEncodedValue {
|
||||||
private var value = charEncodedValue.value
|
private var value = charEncodedValue.value
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseDoubleEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseDoubleEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.DoubleEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.DoubleEncodedValue
|
||||||
|
|
||||||
class MutableDoubleEncodedValue(doubleEncodedValue: DoubleEncodedValue) : BaseDoubleEncodedValue(),
|
class MutableDoubleEncodedValue(doubleEncodedValue: DoubleEncodedValue) : BaseDoubleEncodedValue(),
|
||||||
MutableEncodedValue {
|
MutableEncodedValue {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.ValueType
|
import com.android.tools.smali.dexlib2.ValueType
|
||||||
import org.jf.dexlib2.iface.value.*
|
import com.android.tools.smali.dexlib2.iface.value.*
|
||||||
|
|
||||||
interface MutableEncodedValue : EncodedValue {
|
interface MutableEncodedValue : EncodedValue {
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseEnumEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseEnumEncodedValue
|
||||||
import org.jf.dexlib2.iface.reference.FieldReference
|
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||||
import org.jf.dexlib2.iface.value.EnumEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.EnumEncodedValue
|
||||||
|
|
||||||
class MutableEnumEncodedValue(enumEncodedValue: EnumEncodedValue) : BaseEnumEncodedValue(), MutableEncodedValue {
|
class MutableEnumEncodedValue(enumEncodedValue: EnumEncodedValue) : BaseEnumEncodedValue(), MutableEncodedValue {
|
||||||
private var value = enumEncodedValue.value
|
private var value = enumEncodedValue.value
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.ValueType
|
import com.android.tools.smali.dexlib2.ValueType
|
||||||
import org.jf.dexlib2.base.value.BaseFieldEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseFieldEncodedValue
|
||||||
import org.jf.dexlib2.iface.reference.FieldReference
|
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||||
import org.jf.dexlib2.iface.value.FieldEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.FieldEncodedValue
|
||||||
|
|
||||||
class MutableFieldEncodedValue(fieldEncodedValue: FieldEncodedValue) : BaseFieldEncodedValue(), MutableEncodedValue {
|
class MutableFieldEncodedValue(fieldEncodedValue: FieldEncodedValue) : BaseFieldEncodedValue(), MutableEncodedValue {
|
||||||
private var value = fieldEncodedValue.value
|
private var value = fieldEncodedValue.value
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseFloatEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseFloatEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.FloatEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.FloatEncodedValue
|
||||||
|
|
||||||
class MutableFloatEncodedValue(floatEncodedValue: FloatEncodedValue) : BaseFloatEncodedValue(), MutableEncodedValue {
|
class MutableFloatEncodedValue(floatEncodedValue: FloatEncodedValue) : BaseFloatEncodedValue(), MutableEncodedValue {
|
||||||
private var value = floatEncodedValue.value
|
private var value = floatEncodedValue.value
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseIntEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseIntEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.IntEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.IntEncodedValue
|
||||||
|
|
||||||
class MutableIntEncodedValue(intEncodedValue: IntEncodedValue) : BaseIntEncodedValue(), MutableEncodedValue {
|
class MutableIntEncodedValue(intEncodedValue: IntEncodedValue) : BaseIntEncodedValue(), MutableEncodedValue {
|
||||||
private var value = intEncodedValue.value
|
private var value = intEncodedValue.value
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseLongEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseLongEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.LongEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.LongEncodedValue
|
||||||
|
|
||||||
class MutableLongEncodedValue(longEncodedValue: LongEncodedValue) : BaseLongEncodedValue(), MutableEncodedValue {
|
class MutableLongEncodedValue(longEncodedValue: LongEncodedValue) : BaseLongEncodedValue(), MutableEncodedValue {
|
||||||
private var value = longEncodedValue.value
|
private var value = longEncodedValue.value
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseMethodEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseMethodEncodedValue
|
||||||
import org.jf.dexlib2.iface.reference.MethodReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
import org.jf.dexlib2.iface.value.MethodEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.MethodEncodedValue
|
||||||
|
|
||||||
class MutableMethodEncodedValue(methodEncodedValue: MethodEncodedValue) : BaseMethodEncodedValue(),
|
class MutableMethodEncodedValue(methodEncodedValue: MethodEncodedValue) : BaseMethodEncodedValue(),
|
||||||
MutableEncodedValue {
|
MutableEncodedValue {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseMethodHandleEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseMethodHandleEncodedValue
|
||||||
import org.jf.dexlib2.iface.reference.MethodHandleReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodHandleReference
|
||||||
import org.jf.dexlib2.iface.value.MethodHandleEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.MethodHandleEncodedValue
|
||||||
|
|
||||||
class MutableMethodHandleEncodedValue(methodHandleEncodedValue: MethodHandleEncodedValue) :
|
class MutableMethodHandleEncodedValue(methodHandleEncodedValue: MethodHandleEncodedValue) :
|
||||||
BaseMethodHandleEncodedValue(),
|
BaseMethodHandleEncodedValue(),
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseMethodTypeEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseMethodTypeEncodedValue
|
||||||
import org.jf.dexlib2.iface.reference.MethodProtoReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodProtoReference
|
||||||
import org.jf.dexlib2.iface.value.MethodTypeEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.MethodTypeEncodedValue
|
||||||
|
|
||||||
class MutableMethodTypeEncodedValue(methodTypeEncodedValue: MethodTypeEncodedValue) : BaseMethodTypeEncodedValue(),
|
class MutableMethodTypeEncodedValue(methodTypeEncodedValue: MethodTypeEncodedValue) : BaseMethodTypeEncodedValue(),
|
||||||
MutableEncodedValue {
|
MutableEncodedValue {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseNullEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseNullEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.ByteEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.ByteEncodedValue
|
||||||
|
|
||||||
class MutableNullEncodedValue : BaseNullEncodedValue(), MutableEncodedValue {
|
class MutableNullEncodedValue : BaseNullEncodedValue(), MutableEncodedValue {
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseShortEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseShortEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.ShortEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.ShortEncodedValue
|
||||||
|
|
||||||
class MutableShortEncodedValue(shortEncodedValue: ShortEncodedValue) : BaseShortEncodedValue(), MutableEncodedValue {
|
class MutableShortEncodedValue(shortEncodedValue: ShortEncodedValue) : BaseShortEncodedValue(), MutableEncodedValue {
|
||||||
private var value = shortEncodedValue.value
|
private var value = shortEncodedValue.value
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseStringEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseStringEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.ByteEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.ByteEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.StringEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.StringEncodedValue
|
||||||
|
|
||||||
class MutableStringEncodedValue(stringEncodedValue: StringEncodedValue) : BaseStringEncodedValue(),
|
class MutableStringEncodedValue(stringEncodedValue: StringEncodedValue) : BaseStringEncodedValue(),
|
||||||
MutableEncodedValue {
|
MutableEncodedValue {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseTypeEncodedValue
|
import com.android.tools.smali.dexlib2.base.value.BaseTypeEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.TypeEncodedValue
|
import com.android.tools.smali.dexlib2.iface.value.TypeEncodedValue
|
||||||
|
|
||||||
class MutableTypeEncodedValue(typeEncodedValue: TypeEncodedValue) : BaseTypeEncodedValue(), MutableEncodedValue {
|
class MutableTypeEncodedValue(typeEncodedValue: TypeEncodedValue) : BaseTypeEncodedValue(), MutableEncodedValue {
|
||||||
private var value = typeEncodedValue.value
|
private var value = typeEncodedValue.value
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package app.revanced.patcher.util.smali
|
package app.revanced.patcher.util.smali
|
||||||
|
|
||||||
import org.jf.dexlib2.iface.instruction.Instruction
|
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that represents a label for an instruction.
|
* A class that represents a label for an instruction.
|
||||||
|
|||||||
@@ -4,15 +4,16 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
|||||||
import org.antlr.runtime.CommonTokenStream
|
import org.antlr.runtime.CommonTokenStream
|
||||||
import org.antlr.runtime.TokenSource
|
import org.antlr.runtime.TokenSource
|
||||||
import org.antlr.runtime.tree.CommonTreeNodeStream
|
import org.antlr.runtime.tree.CommonTreeNodeStream
|
||||||
import org.jf.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Opcodes
|
import com.android.tools.smali.dexlib2.Opcodes
|
||||||
import org.jf.dexlib2.builder.BuilderInstruction
|
import com.android.tools.smali.dexlib2.builder.BuilderInstruction
|
||||||
import org.jf.dexlib2.writer.builder.DexBuilder
|
import com.android.tools.smali.dexlib2.writer.builder.DexBuilder
|
||||||
import org.jf.smali.LexerErrorInterface
|
import com.android.tools.smali.smali.LexerErrorInterface
|
||||||
import org.jf.smali.smaliFlexLexer
|
import com.android.tools.smali.smali.smaliFlexLexer
|
||||||
import org.jf.smali.smaliParser
|
import com.android.tools.smali.smali.smaliParser
|
||||||
import org.jf.smali.smaliTreeWalker
|
import com.android.tools.smali.smali.smaliTreeWalker
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
private const val METHOD_TEMPLATE = """
|
private const val METHOD_TEMPLATE = """
|
||||||
.class LInlineCompiler;
|
.class LInlineCompiler;
|
||||||
@@ -33,7 +34,7 @@ class InlineSmaliCompiler {
|
|||||||
fun compile(
|
fun compile(
|
||||||
instructions: String, parameters: String, registers: Int, forStaticMethod: Boolean
|
instructions: String, parameters: String, registers: Int, forStaticMethod: Boolean
|
||||||
): List<BuilderInstruction> {
|
): List<BuilderInstruction> {
|
||||||
val input = METHOD_TEMPLATE.format(
|
val input = METHOD_TEMPLATE.format(Locale.ENGLISH,
|
||||||
if (forStaticMethod) {
|
if (forStaticMethod) {
|
||||||
"static"
|
"static"
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions
|
|||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
import org.jf.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.builder.BuilderOffsetInstruction
|
import com.android.tools.smali.dexlib2.builder.BuilderOffsetInstruction
|
||||||
import org.jf.dexlib2.builder.MutableMethodImplementation
|
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
|
||||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction21s
|
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21s
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import org.jf.dexlib2.immutable.ImmutableMethod
|
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
private object InstructionExtensionsTest {
|
private object InstructionExtensionsTest {
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package app.revanced.patcher.issues
|
|
||||||
|
|
||||||
import app.revanced.patcher.patch.PatchOption
|
|
||||||
import org.junit.jupiter.api.Test
|
|
||||||
import kotlin.test.assertNull
|
|
||||||
|
|
||||||
internal class Issue98 {
|
|
||||||
companion object {
|
|
||||||
var key1: String? by PatchOption.StringOption(
|
|
||||||
"key1", null, "title", "description"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `should infer nullable type correctly`() {
|
|
||||||
assertNull(key1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
package app.revanced.patcher.patch
|
|
||||||
|
|
||||||
import app.revanced.patcher.usage.bytecode.ExampleBytecodePatch
|
|
||||||
import org.junit.jupiter.api.Test
|
|
||||||
import org.junit.jupiter.api.assertThrows
|
|
||||||
import kotlin.io.path.Path
|
|
||||||
import kotlin.io.path.pathString
|
|
||||||
import kotlin.test.assertNotEquals
|
|
||||||
|
|
||||||
internal class PatchOptionsTest {
|
|
||||||
private val options = ExampleBytecodePatch.options
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `should not throw an exception`() {
|
|
||||||
for (option in options) {
|
|
||||||
when (option) {
|
|
||||||
is PatchOption.StringOption -> {
|
|
||||||
option.value = "Hello World"
|
|
||||||
}
|
|
||||||
|
|
||||||
is PatchOption.BooleanOption -> {
|
|
||||||
option.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
is PatchOption.StringListOption -> {
|
|
||||||
option.value = option.options.first()
|
|
||||||
for (choice in option.options) {
|
|
||||||
println(choice)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
is PatchOption.IntListOption -> {
|
|
||||||
option.value = option.options.first()
|
|
||||||
for (choice in option.options) {
|
|
||||||
println(choice)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
is PatchOption.PathOption -> {
|
|
||||||
option.value = Path("test.txt").pathString
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val option = options.get<String>("key1")
|
|
||||||
// or: val option: String? by options["key1"]
|
|
||||||
// then you won't need `.value` every time
|
|
||||||
println(option.value)
|
|
||||||
options["key1"] = "Hello, world!"
|
|
||||||
println(option.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `should return a different value when changed`() {
|
|
||||||
var value: String? by options["key1"]
|
|
||||||
val current = value + "" // force a copy
|
|
||||||
value = "Hello, world!"
|
|
||||||
assertNotEquals(current, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `should be able to set value to null`() {
|
|
||||||
// Sadly, doing:
|
|
||||||
// > options["key2"] = null
|
|
||||||
// is not possible because Kotlin
|
|
||||||
// cannot reify the type "Nothing?".
|
|
||||||
// So we have to do this instead:
|
|
||||||
options["key2"] = null as Any?
|
|
||||||
// This is a cleaner replacement for the above:
|
|
||||||
options.nullify("key2")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `should fail because the option does not exist`() {
|
|
||||||
assertThrows<NoSuchOptionException> {
|
|
||||||
options["this option does not exist"] = 123
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `should fail because of invalid value type when setting an option`() {
|
|
||||||
assertThrows<InvalidTypeException> {
|
|
||||||
options["key1"] = 123
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `should fail because of invalid value type when getting an option`() {
|
|
||||||
assertThrows<InvalidTypeException> {
|
|
||||||
options.get<Int>("key1")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `should fail because of an illegal value`() {
|
|
||||||
assertThrows<IllegalValueException> {
|
|
||||||
options["key3"] = "this value is not an allowed option"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `should fail because the requirement is not met`() {
|
|
||||||
assertThrows<RequirementNotMetException> {
|
|
||||||
options.nullify("key1")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `should fail because getting a non-initialized option is illegal`() {
|
|
||||||
assertThrows<RequirementNotMetException> {
|
|
||||||
println(options["key5"].value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
package app.revanced.patcher.patch.options
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.booleanPatchOption
|
||||||
|
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringArrayPatchOption
|
||||||
|
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption
|
||||||
|
import org.junit.jupiter.api.assertDoesNotThrow
|
||||||
|
import org.junit.jupiter.api.assertThrows
|
||||||
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertNull
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
internal class PatchOptionsTest {
|
||||||
|
@Test
|
||||||
|
fun `should not fail because default value is unvalidated`() {
|
||||||
|
assertDoesNotThrow { OptionsTestPatch.requiredStringOption }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `should not allow setting custom value with validation`() {
|
||||||
|
// Getter validation on incorrect value.
|
||||||
|
assertThrows<PatchOptionException.ValueValidationException> { OptionsTestPatch.validatedOption }
|
||||||
|
|
||||||
|
// Setter validation on incorrect value.
|
||||||
|
assertThrows<PatchOptionException.ValueValidationException> { OptionsTestPatch.validatedOption = "invalid" }
|
||||||
|
|
||||||
|
// Setter validation on correct value.
|
||||||
|
assertDoesNotThrow { OptionsTestPatch.validatedOption = "valid" }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `should throw due to incorrect type`() {
|
||||||
|
assertThrows<PatchOptionException.InvalidValueTypeException> {
|
||||||
|
OptionsTestPatch.options["bool"] = "not a boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `should be nullable`() {
|
||||||
|
OptionsTestPatch.booleanOption = null
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `option should not be found`() {
|
||||||
|
assertThrows<PatchOptionException.PatchOptionNotFoundException> {
|
||||||
|
OptionsTestPatch.options["this option does not exist"] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `should be able to add options manually`() {
|
||||||
|
assertThrows<PatchOptionException.InvalidValueTypeException> {
|
||||||
|
OptionsTestPatch.options["array"] = OptionsTestPatch.stringArrayOption
|
||||||
|
}
|
||||||
|
assertDoesNotThrow {
|
||||||
|
OptionsTestPatch.options.register(OptionsTestPatch.stringArrayOption)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@Test
|
||||||
|
fun `should allow setting value from values`() =
|
||||||
|
with(OptionsTestPatch.options["choices"] as PatchOption<String>) {
|
||||||
|
value = values!!.values.last()
|
||||||
|
assertTrue(value == "valid")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `should allow setting custom value`() =
|
||||||
|
assertDoesNotThrow { OptionsTestPatch.stringOptionWithChoices = "unknown" }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `should allow resetting value`() = assertDoesNotThrow { OptionsTestPatch.stringOptionWithChoices = null }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `reset should not fail`() {
|
||||||
|
assertDoesNotThrow {
|
||||||
|
OptionsTestPatch.resettableOption.value = "test"
|
||||||
|
OptionsTestPatch.resettableOption.reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
assertThrows<PatchOptionException.ValueRequiredException> {
|
||||||
|
OptionsTestPatch.resettableOption.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `getting default value should work`() =
|
||||||
|
assertDoesNotThrow { assertNull(OptionsTestPatch.resettableOption.default) }
|
||||||
|
|
||||||
|
private object OptionsTestPatch : BytecodePatch() {
|
||||||
|
var booleanOption by booleanPatchOption(
|
||||||
|
"bool",
|
||||||
|
true
|
||||||
|
)
|
||||||
|
var requiredStringOption by stringPatchOption(
|
||||||
|
"required",
|
||||||
|
"default",
|
||||||
|
required = true
|
||||||
|
)
|
||||||
|
var stringArrayOption = stringArrayPatchOption(
|
||||||
|
"array",
|
||||||
|
arrayOf("1", "2")
|
||||||
|
)
|
||||||
|
var stringOptionWithChoices by stringPatchOption(
|
||||||
|
"choices",
|
||||||
|
"value",
|
||||||
|
values = mapOf("Valid option value" to "valid")
|
||||||
|
)
|
||||||
|
var validatedOption by stringPatchOption(
|
||||||
|
|
||||||
|
"validated",
|
||||||
|
"default"
|
||||||
|
) { it == "valid" }
|
||||||
|
var resettableOption = stringPatchOption(
|
||||||
|
"resettable", null,
|
||||||
|
required = true
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun execute(context: BytecodeContext) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
package app.revanced.patcher.patch.usage
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.PatchException
|
||||||
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
import com.android.tools.smali.dexlib2.Format
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction11x
|
||||||
|
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction21c
|
||||||
|
import com.android.tools.smali.dexlib2.immutable.ImmutableField
|
||||||
|
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
|
||||||
|
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodImplementation
|
||||||
|
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableFieldReference
|
||||||
|
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableStringReference
|
||||||
|
import com.android.tools.smali.dexlib2.immutable.value.ImmutableFieldEncodedValue
|
||||||
|
import com.android.tools.smali.dexlib2.util.Preconditions
|
||||||
|
import com.google.common.collect.ImmutableList
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
@Patch(
|
||||||
|
name = "Example bytecode patch",
|
||||||
|
description = "Example demonstration of a bytecode patch.",
|
||||||
|
dependencies = [ExampleResourcePatch::class],
|
||||||
|
compatiblePackages = [CompatiblePackage("com.example.examplePackage", arrayOf("0.0.1", "0.0.2"))]
|
||||||
|
)
|
||||||
|
object ExampleBytecodePatch : BytecodePatch(setOf(ExampleFingerprint)) {
|
||||||
|
// Entry point of a patch. Supplied fingerprints are resolved at this point.
|
||||||
|
override fun execute(context: BytecodeContext) {
|
||||||
|
ExampleFingerprint.result?.let { result ->
|
||||||
|
// Let's modify it, so it prints "Hello, ReVanced! Editing bytecode."
|
||||||
|
// Get the start index of our opcode pattern.
|
||||||
|
// This will be the index of the instruction with the opcode CONST_STRING.
|
||||||
|
val startIndex = result.scanResult.patternScanResult!!.startIndex
|
||||||
|
|
||||||
|
result.mutableMethod.apply {
|
||||||
|
replaceStringAt(startIndex, "Hello, ReVanced! Editing bytecode.")
|
||||||
|
|
||||||
|
// Store the fields initial value into the first virtual register.
|
||||||
|
replaceInstruction(0, "sget-object v0, LTestClass;->dummyField:Ljava/io/PrintStream;")
|
||||||
|
|
||||||
|
// Now let's create a new call to our method and print the return value!
|
||||||
|
// You can also use the smali compiler to create instructions.
|
||||||
|
// For this sake of example I reuse the TestClass field dummyField inside the virtual register 0.
|
||||||
|
//
|
||||||
|
// Control flow instructions are not supported as of now.
|
||||||
|
addInstructionsWithLabels(
|
||||||
|
startIndex + 2,
|
||||||
|
"""
|
||||||
|
invoke-static { }, LTestClass;->returnHello()Ljava/lang/String;
|
||||||
|
move-result-object v1
|
||||||
|
invoke-virtual { v0, v1 }, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the class in which the method matching our fingerprint is defined in.
|
||||||
|
context.findClass(result.classDef.type)!!.mutableClass.apply {
|
||||||
|
// Add a new method that returns a string.
|
||||||
|
methods.add(
|
||||||
|
ImmutableMethod(
|
||||||
|
result.classDef.type,
|
||||||
|
"returnHello",
|
||||||
|
null,
|
||||||
|
"Ljava/lang/String;",
|
||||||
|
AccessFlags.PRIVATE or AccessFlags.STATIC,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
ImmutableMethodImplementation(
|
||||||
|
1,
|
||||||
|
ImmutableList.of(
|
||||||
|
BuilderInstruction21c(
|
||||||
|
Opcode.CONST_STRING,
|
||||||
|
0,
|
||||||
|
ImmutableStringReference("Hello, ReVanced! Adding bytecode.")
|
||||||
|
),
|
||||||
|
BuilderInstruction11x(Opcode.RETURN_OBJECT, 0)
|
||||||
|
),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
).toMutable()
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add a field in the main class.
|
||||||
|
// We will use this field in our method below to call println on.
|
||||||
|
// The field holds the Ljava/io/PrintStream->out; field.
|
||||||
|
fields.add(
|
||||||
|
ImmutableField(
|
||||||
|
type,
|
||||||
|
"dummyField",
|
||||||
|
"Ljava/io/PrintStream;",
|
||||||
|
AccessFlags.PRIVATE or AccessFlags.STATIC,
|
||||||
|
ImmutableFieldEncodedValue(
|
||||||
|
ImmutableFieldReference(
|
||||||
|
"Ljava/lang/System;",
|
||||||
|
"out",
|
||||||
|
"Ljava/io/PrintStream;"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
).toMutable()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: throw PatchException("Fingerprint failed to resolve.")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace an existing instruction with a new one containing a reference to a new string.
|
||||||
|
* @param index The index of the instruction to replace.
|
||||||
|
* @param string The replacement string.
|
||||||
|
*/
|
||||||
|
private fun MutableMethod.replaceStringAt(index: Int, string: String) {
|
||||||
|
val instruction = getInstruction(index)
|
||||||
|
|
||||||
|
// Utility method of dexlib2.
|
||||||
|
Preconditions.checkFormat(instruction.opcode, Format.Format21c)
|
||||||
|
|
||||||
|
// Cast this to an instruction of the format 21c.
|
||||||
|
// The instruction format can be found in the docs at
|
||||||
|
// https://source.android.com/devices/tech/dalvik/dalvik-bytecode
|
||||||
|
val strInstruction = instruction as Instruction21c
|
||||||
|
|
||||||
|
// In our case we want an instruction with the opcode CONST_STRING
|
||||||
|
// The format is 21c, so we create a new BuilderInstruction21c
|
||||||
|
// This instruction will hold the string reference constant in the virtual register of the original instruction
|
||||||
|
// For that a reference to the string is needed. It can be created with an ImmutableStringReference.
|
||||||
|
// At last, use the method replaceInstruction to replace it at the given index startIndex.
|
||||||
|
replaceInstruction(
|
||||||
|
index,
|
||||||
|
"const-string ${strInstruction.registerA}, ${ImmutableStringReference(string)}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package app.revanced.patcher.patch.usage
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.annotation.FuzzyPatternScanMethod
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
|
@FuzzyPatternScanMethod(2)
|
||||||
|
object ExampleFingerprint : MethodFingerprint(
|
||||||
|
"V",
|
||||||
|
AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||||
|
listOf("[L"),
|
||||||
|
listOf(
|
||||||
|
Opcode.SGET_OBJECT,
|
||||||
|
null, // Matching unknown opcodes.
|
||||||
|
Opcode.INVOKE_STATIC, // This is intentionally wrong to test fuzzy matching.
|
||||||
|
Opcode.RETURN_VOID
|
||||||
|
),
|
||||||
|
null
|
||||||
|
)
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package app.revanced.patcher.patch.usage
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.ResourceContext
|
||||||
|
import app.revanced.patcher.patch.ResourcePatch
|
||||||
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
|
|
||||||
|
class ExampleResourcePatch : ResourcePatch() {
|
||||||
|
override fun execute(context: ResourceContext) {
|
||||||
|
context.xmlEditor["AndroidManifest.xml"].use { editor ->
|
||||||
|
val element = editor // regular DomFileEditor
|
||||||
|
.file
|
||||||
|
.getElementsByTagName("application")
|
||||||
|
.item(0) as Element
|
||||||
|
element
|
||||||
|
.setAttribute(
|
||||||
|
"exampleAttribute",
|
||||||
|
"exampleValue"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user