You've already forked revanced-patcher
mirror of
https://github.com/revanced/revanced-patcher
synced 2025-09-06 16:38:50 +02:00
Compare commits
164 Commits
v6.3.1-dev
...
v1.0.0-dev
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5c3fbaee7a | ||
![]() |
08525e9c26 | ||
![]() |
5630e49663 | ||
![]() |
0543122427 | ||
![]() |
0873703056 | ||
![]() |
1a99ecaffe | ||
![]() |
6726884be5 | ||
![]() |
8b4f3947f8 | ||
![]() |
4d74de4061 | ||
![]() |
4fbee7d255 | ||
![]() |
fd9f639605 | ||
![]() |
9084ccc2a2 | ||
![]() |
83a8a48176 | ||
![]() |
66b08f8b3a | ||
![]() |
e286ba5090 | ||
![]() |
e5c054ac2f | ||
![]() |
cb0741d05f | ||
![]() |
38556d61ab | ||
![]() |
ce8021b482 | ||
![]() |
243dba7751 | ||
![]() |
698f759979 | ||
![]() |
1701da3dde | ||
![]() |
37fa9949ec | ||
![]() |
ac36d19693 | ||
![]() |
c245edb0c5 | ||
![]() |
1f7bf3ac6c | ||
![]() |
bfeeaf4435 | ||
![]() |
748d0abad0 | ||
![]() |
569238ab76 | ||
![]() |
23197879b2 | ||
![]() |
305a81793a | ||
![]() |
33f9211f98 | ||
![]() |
864e38c069 | ||
![]() |
659e1087c9 | ||
![]() |
03700ffa51 | ||
![]() |
ae06d826e8 | ||
![]() |
5ca5188fc2 | ||
![]() |
f88c11820d | ||
![]() |
93e81ff047 | ||
![]() |
d49df10a3c | ||
![]() |
04b49b8b66 | ||
![]() |
5ddc63f979 | ||
![]() |
82b1e66d54 | ||
![]() |
fd630cd429 | ||
![]() |
f4a47d4dc8 | ||
![]() |
3bfc24fc16 | ||
![]() |
25bba2c1d8 | ||
![]() |
4dea27e831 | ||
![]() |
a0d6d46217 | ||
![]() |
643a14e664 | ||
![]() |
355e6d82cc | ||
![]() |
df7503b47b | ||
![]() |
a01dded092 | ||
![]() |
9ae95174e6 | ||
![]() |
e161f7fea4 | ||
![]() |
200e3c9fdb | ||
![]() |
f0f34031dd | ||
![]() |
560c485ab0 | ||
![]() |
cc5a414692 | ||
![]() |
c2a334eb3f | ||
![]() |
1b2fbbca26 | ||
![]() |
4458141d6d | ||
![]() |
8544fc4cbc | ||
![]() |
a492808021 | ||
![]() |
0204eee79e | ||
![]() |
4022b8b847 | ||
![]() |
8daf877fac | ||
![]() |
7d38bb0baa | ||
![]() |
5f71a342ac | ||
![]() |
866b03af21 | ||
![]() |
4c1a42b216 | ||
![]() |
264989f488 | ||
![]() |
4281546f69 | ||
![]() |
af4f2396c7 | ||
![]() |
147195647c | ||
![]() |
433914feda | ||
![]() |
622138736d | ||
![]() |
aed4fd9a3c | ||
![]() |
32e645850d | ||
![]() |
e45fc02aae | ||
![]() |
e0d29cf450 | ||
![]() |
2b888e381c | ||
![]() |
f72dd68ec5 | ||
![]() |
3b68d5c65e | ||
![]() |
eed1cfda7b | ||
![]() |
8b70bb4290 | ||
![]() |
dbda641d0c | ||
![]() |
5ae5e98f1f | ||
![]() |
1ba40ab1cb | ||
![]() |
e9c119ebb1 | ||
![]() |
1bd6d1d5b8 | ||
![]() |
4e7378bd79 | ||
![]() |
28ed4793e3 | ||
![]() |
312235b194 | ||
![]() |
6ab21e5891 | ||
![]() |
db8d1150c3 | ||
![]() |
8f778f38fe | ||
![]() |
88a6a27302 | ||
![]() |
a9e4e8ac32 | ||
![]() |
d5e694c306 | ||
![]() |
dde0a22642 | ||
![]() |
9a67aa3ff4 | ||
![]() |
e69708f21e | ||
![]() |
c49071aff7 | ||
![]() |
d15240d033 | ||
![]() |
6767c8fbc1 | ||
![]() |
4543b36616 | ||
![]() |
ec6d462ade | ||
![]() |
84bc7e0dc7 | ||
![]() |
6ad51aad9a | ||
![]() |
b711b8001e | ||
![]() |
12c10d8c64 | ||
![]() |
05e44007d8 | ||
![]() |
dbafe2ab37 | ||
![]() |
45a885dbde | ||
![]() |
78235d1abe | ||
![]() |
aec5eeb597 | ||
![]() |
d98c9eeb30 | ||
![]() |
f8e978af88 | ||
![]() |
86cb053566 | ||
![]() |
c1ccb70de4 | ||
![]() |
bb42fa3c6f | ||
![]() |
2d3c61113d | ||
![]() |
6bc4e7eab7 | ||
![]() |
be51f42710 | ||
![]() |
fa0412985c | ||
![]() |
0048788dd0 | ||
![]() |
47eb493f54 | ||
![]() |
6b1337e4fc | ||
![]() |
f4589db3a9 | ||
![]() |
1af31b2aa3 | ||
![]() |
14f7667156 | ||
![]() |
cd57a8c9a0 | ||
![]() |
0d3beb353d | ||
![]() |
ddef338631 | ||
![]() |
fc4b673087 | ||
![]() |
8d1bb5f3d9 | ||
![]() |
c8a017a4c0 | ||
![]() |
51fb59a43c | ||
![]() |
a78715133c | ||
![]() |
e8f6973938 | ||
![]() |
3cb1e01587 | ||
![]() |
cb4ee207e1 | ||
![]() |
ca6b94d943 | ||
![]() |
6cdb6887d4 | ||
![]() |
ab6453ca8a | ||
![]() |
e8182c17ad | ||
![]() |
49beec9fc6 | ||
![]() |
3ab42a932c | ||
![]() |
4d98cbc9e8 | ||
![]() |
87bbde5e06 | ||
![]() |
8db8893ab1 | ||
![]() |
00c6ab7faf | ||
![]() |
460d62a24c | ||
![]() |
89e4b9f762 | ||
![]() |
a8fd7c00c3 | ||
![]() |
1769132a9e | ||
![]() |
6c0f0823c9 | ||
![]() |
23e897a7a9 | ||
![]() |
7e67daf878 | ||
![]() |
593c83f29f | ||
![]() |
72e123dd01 | ||
![]() |
599a401ed9 | ||
![]() |
3f8500b059 |
72
.github/ISSUE_TEMPLATE/bug-issue.yml
vendored
72
.github/ISSUE_TEMPLATE/bug-issue.yml
vendored
@@ -1,72 +0,0 @@
|
|||||||
name: 🐞 Bug report
|
|
||||||
description: Report a very clearly broken issue.
|
|
||||||
title: 'bug: <title>'
|
|
||||||
labels: [bug]
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
# ReVanced bug report
|
|
||||||
|
|
||||||
Important to note that your issue may have already been reported before. Please check for existing issues [here](https://github.com/revanced/revanced-patcher/labels/bug).
|
|
||||||
|
|
||||||
- type: dropdown
|
|
||||||
attributes:
|
|
||||||
label: Type
|
|
||||||
options:
|
|
||||||
- Crash
|
|
||||||
- Cosmetic
|
|
||||||
- Other
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Bug description
|
|
||||||
description: How did you find the bug? Any additional details that might help?
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Steps to reproduce
|
|
||||||
description: Add the steps to reproduce this bug including your environment.
|
|
||||||
placeholder: Step 1. Download some files. Step 2. ...
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Relevant log output
|
|
||||||
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
|
|
||||||
render: shell
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Screenshots or videos
|
|
||||||
description: Add screenshots or videos that show the bug here.
|
|
||||||
placeholder: Drag and drop the screenshots/videos into this box.
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Solution
|
|
||||||
description: If applicable, add a possible solution.
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Additional context
|
|
||||||
description: Add additional context here.
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: checkboxes
|
|
||||||
id: acknowledgements
|
|
||||||
attributes:
|
|
||||||
label: Acknowledgements
|
|
||||||
description: Your issue will be closed if you haven't done these steps.
|
|
||||||
options:
|
|
||||||
- label: I have searched the existing issues and this is a new and no duplicate or related to another open issue.
|
|
||||||
required: true
|
|
||||||
- label: I have written a short but informative title.
|
|
||||||
required: true
|
|
||||||
- label: I filled out all of the requested information in this issue properly.
|
|
||||||
required: true
|
|
8
.github/ISSUE_TEMPLATE/config.yml
vendored
8
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,8 +0,0 @@
|
|||||||
blank_issues_enabled: false
|
|
||||||
contact_links:
|
|
||||||
- name: 📃 Documentation
|
|
||||||
url: https://github.com/revanced/revanced-documentation/
|
|
||||||
about: Don't know how or where to start? Check out our documentation!
|
|
||||||
- name: 🗨 Discussions
|
|
||||||
url: https://github.com/revanced/revanced-suggestions/discussions
|
|
||||||
about: Got something you think should change or be added? Search for or start a new discussion!
|
|
58
.github/ISSUE_TEMPLATE/feature-issue.yml
vendored
58
.github/ISSUE_TEMPLATE/feature-issue.yml
vendored
@@ -1,58 +0,0 @@
|
|||||||
name: ⭐ Feature request
|
|
||||||
description: Create a detailed feature request.
|
|
||||||
title: 'feat: <title>'
|
|
||||||
labels: [feature-request]
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
# ReVanced feature request
|
|
||||||
|
|
||||||
Do not submit requests for patches here. Please submit them [here](https://github.com/orgs/revanced/discussions/categories/patches) instead.
|
|
||||||
Important to note that your feature request may have already been made before. Please check for existing feature requests [here](https://github.com/revanced/revanced-patcher/labels/feature-request).
|
|
||||||
|
|
||||||
- type: dropdown
|
|
||||||
attributes:
|
|
||||||
label: Type
|
|
||||||
options:
|
|
||||||
- Functionality
|
|
||||||
- Cosmetic
|
|
||||||
- Other
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Issue
|
|
||||||
description: What is the current problem. Why does it require a feature request?
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Feature
|
|
||||||
description: Describe your feature in detail. How does it solve the issue?
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Motivation
|
|
||||||
description: Why should your feature should be considered?
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Additional context
|
|
||||||
description: Add additional context here.
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: checkboxes
|
|
||||||
id: acknowledgements
|
|
||||||
attributes:
|
|
||||||
label: Acknowledgements
|
|
||||||
description: Your issue will be closed if you haven't done these steps.
|
|
||||||
options:
|
|
||||||
- label: I have searched the existing issues and this is a new and no duplicate or related to another open issue.
|
|
||||||
required: true
|
|
||||||
- label: I have written a short but informative title.
|
|
||||||
required: true
|
|
||||||
- label: I filled out all of the requested information in this issue properly.
|
|
||||||
required: true
|
|
24
.github/workflows/pull_request.yml
vendored
24
.github/workflows/pull_request.yml
vendored
@@ -1,24 +0,0 @@
|
|||||||
name: PR to main
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- dev
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
MESSAGE: merge branch \`${{ github.head_ref || github.ref_name }}\` to \`main\`
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
pull-request:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Open pull request
|
|
||||||
uses: repo-sync/pull-request@v2
|
|
||||||
with:
|
|
||||||
destination_branch: 'main'
|
|
||||||
pr_title: 'chore: ${{ env.MESSAGE }}'
|
|
||||||
pr_body: 'This pull request will ${{ env.MESSAGE }}.'
|
|
||||||
pr_draft: true
|
|
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@@ -1,6 +1,5 @@
|
|||||||
name: Release
|
name: Release
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
@@ -15,26 +14,27 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Setup JDK
|
- name: Setup JDK
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
distribution: 'zulu'
|
distribution: 'adopt'
|
||||||
cache: gradle
|
cache: gradle
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: "latest"
|
node-version: "lts/*"
|
||||||
cache: 'npm'
|
- name: Make gradlew executable
|
||||||
|
run: chmod +x gradlew
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: ./gradlew build --no-daemon
|
run: ./gradlew build
|
||||||
- name: Setup semantic-release
|
- name: Setup semantic-release
|
||||||
run: npm install semantic-release @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin -D
|
run: npm install -g semantic-release @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin -D
|
||||||
- name: Release
|
- name: Release
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -115,6 +115,3 @@ gradle-app.setting
|
|||||||
|
|
||||||
# Avoid ignoring test resources
|
# Avoid ignoring test resources
|
||||||
!src/test/resources/*
|
!src/test/resources/*
|
||||||
|
|
||||||
# Dependency directories
|
|
||||||
node_modules/
|
|
1
.idea/.gitignore
generated
vendored
1
.idea/.gitignore
generated
vendored
@@ -6,4 +6,3 @@
|
|||||||
# Datasource local storage ignored files
|
# Datasource local storage ignored files
|
||||||
/dataSources/
|
/dataSources/
|
||||||
/dataSources.local.xml
|
/dataSources.local.xml
|
||||||
/kotlinc.xml
|
|
||||||
|
@@ -7,11 +7,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
["@semantic-release/commit-analyzer", {
|
"@semantic-release/commit-analyzer",
|
||||||
"releaseRules": [
|
|
||||||
{"type": "build", "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",
|
||||||
|
909
CHANGELOG.md
909
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1 @@
|
|||||||
# Patcher
|
# Patcher
|
||||||
Patcher framework used in the ReVanced project.
|
|
@@ -1,33 +1,35 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.7.0"
|
kotlin("jvm") version "1.6.20"
|
||||||
java
|
java
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven {
|
||||||
url = uri("https://maven.pkg.github.com/revanced/multidexlib2")
|
url = uri("https://maven.pkg.github.com/revanced/multidexlib2")
|
||||||
credentials {
|
credentials {
|
||||||
username = githubUsername
|
// DO NOT set these variables in the project's gradle.properties.
|
||||||
password = githubPassword
|
// Instead, you should set them in:
|
||||||
|
// Windows: %homepath%\.gradle\gradle.properties
|
||||||
|
// Linux: ~/.gradle/gradle.properties
|
||||||
|
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR") // DO NOT CHANGE!
|
||||||
|
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN") // DO NOT CHANGE!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("xpp3:xpp3:1.1.4c")
|
implementation(kotlin("stdlib"))
|
||||||
implementation("org.smali:smali:2.5.2")
|
|
||||||
implementation("app.revanced:multidexlib2:2.5.2.r2")
|
api("org.apktool:apktool-lib:2.6.1")
|
||||||
implementation("org.apktool:apktool-lib:2.8.1-SNAPSHOT")
|
api("app.revanced:multidexlib2:2.5.2.r2")
|
||||||
|
api("org.smali:smali:2.5.2")
|
||||||
|
|
||||||
implementation(kotlin("reflect"))
|
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
|
implementation(kotlin("reflect"))
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
@@ -37,18 +39,18 @@ tasks {
|
|||||||
events("PASSED", "SKIPPED", "FAILED")
|
events("PASSED", "SKIPPED", "FAILED")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
processResources {
|
|
||||||
expand("projectVersion" to project.version)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
|
withJavadocJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val isGitHubCI = System.getenv("GITHUB_ACTOR") != null
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
repositories {
|
||||||
if (System.getenv("GITHUB_ACTOR") != null)
|
if (isGitHubCI) {
|
||||||
maven {
|
maven {
|
||||||
name = "GitHubPackages"
|
name = "GitHubPackages"
|
||||||
url = uri("https://maven.pkg.github.com/revanced/revanced-patcher")
|
url = uri("https://maven.pkg.github.com/revanced/revanced-patcher")
|
||||||
@@ -57,12 +59,13 @@ publishing {
|
|||||||
password = System.getenv("GITHUB_TOKEN")
|
password = System.getenv("GITHUB_TOKEN")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
publications {
|
publications {
|
||||||
register<MavenPublication>("gpr") {
|
register<MavenPublication>("gpr") {
|
||||||
from(components["java"])
|
from(components["java"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,2 +1,2 @@
|
|||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 6.3.1-dev.1
|
version = 1.0.0-dev.12
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
257
gradlew
vendored
Executable file → Normal file
257
gradlew
vendored
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
6107
package-lock.json
generated
6107
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"devDependencies": {
|
|
||||||
"@semantic-release/changelog": "^6.0.2",
|
|
||||||
"@semantic-release/git": "^10.0.1",
|
|
||||||
"gradle-semantic-release-plugin": "^1.7.4",
|
|
||||||
"semantic-release": "^19.0.5"
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,19 +0,0 @@
|
|||||||
package app.revanced.patcher
|
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
|
||||||
import app.revanced.patcher.data.Context
|
|
||||||
import app.revanced.patcher.data.PackageMetadata
|
|
||||||
import app.revanced.patcher.data.ResourceContext
|
|
||||||
import app.revanced.patcher.patch.Patch
|
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
data class PatcherContext(
|
|
||||||
val classes: MutableList<ClassDef>,
|
|
||||||
val resourceCacheDirectory: File,
|
|
||||||
) {
|
|
||||||
val packageMetadata = PackageMetadata()
|
|
||||||
internal val patches = mutableListOf<Class<out Patch<Context>>>()
|
|
||||||
internal val bytecodeContext = BytecodeContext(classes)
|
|
||||||
internal val resourceContext = ResourceContext(resourceCacheDirectory)
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
package app.revanced.patcher
|
|
||||||
|
|
||||||
import app.revanced.patcher.logging.Logger
|
|
||||||
import app.revanced.patcher.logging.impl.NopLogger
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Options for the [Patcher].
|
|
||||||
* @param inputFile The input file (usually an apk file).
|
|
||||||
* @param resourceCacheDirectory Directory to cache resources.
|
|
||||||
* @param aaptPath Optional path to a custom aapt binary.
|
|
||||||
* @param frameworkFolderLocation Optional path to a custom framework folder.
|
|
||||||
* @param logger Custom logger implementation for the [Patcher].
|
|
||||||
*/
|
|
||||||
data class PatcherOptions(
|
|
||||||
internal val inputFile: File,
|
|
||||||
internal val resourceCacheDirectory: String,
|
|
||||||
internal val aaptPath: String = "",
|
|
||||||
internal val frameworkFolderLocation: String? = null,
|
|
||||||
internal val logger: Logger = NopLogger
|
|
||||||
)
|
|
@@ -1,16 +0,0 @@
|
|||||||
package app.revanced.patcher
|
|
||||||
|
|
||||||
import app.revanced.patcher.util.dex.DexFile
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The result of a patcher.
|
|
||||||
* @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.
|
|
||||||
*/
|
|
||||||
data class PatcherResult(
|
|
||||||
val dexFiles: List<DexFile>,
|
|
||||||
val doNotCompress: List<String>? = null,
|
|
||||||
val resourceFile: File?
|
|
||||||
)
|
|
@@ -1,10 +1,11 @@
|
|||||||
package app.revanced.patcher.annotation
|
package app.revanced.patcher.annotation
|
||||||
|
|
||||||
import app.revanced.patcher.patch.Patch
|
import app.revanced.patcher.patch.base.Patch
|
||||||
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation to constrain a [Patch] to compatible packages.
|
* Annotation to constrain a [Patch] or [MethodSignature] to compatible packages.
|
||||||
* @param compatiblePackages A list of packages a [Patch] is compatible with.
|
* @param compatiblePackages A list of packages a [Patch] or [MethodSignature] is compatible with.
|
||||||
*/
|
*/
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
@@ -16,12 +17,12 @@ annotation class Compatibility(
|
|||||||
/**
|
/**
|
||||||
* Annotation to represent packages a patch can be compatible with.
|
* Annotation to represent packages a patch can be compatible with.
|
||||||
* @param name The package identifier name.
|
* @param name The package identifier name.
|
||||||
* @param versions The versions of the package the [Patch] is compatible with.
|
* @param versions The versions of the package the [Patch] or [MethodSignature]is compatible with.
|
||||||
*/
|
*/
|
||||||
@Target()
|
@Target()
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
@MustBeDocumented
|
@MustBeDocumented
|
||||||
annotation class Package(
|
annotation class Package(
|
||||||
val name: String,
|
val name: String,
|
||||||
val versions: Array<String> = [],
|
val versions: Array<String>
|
||||||
)
|
)
|
@@ -1,10 +1,11 @@
|
|||||||
package app.revanced.patcher.annotation
|
package app.revanced.patcher.annotation
|
||||||
|
|
||||||
import app.revanced.patcher.patch.Patch
|
import app.revanced.patcher.patch.base.Patch
|
||||||
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation to name a [Patch].
|
* Annotation to name a [Patch] or [MethodSignature].
|
||||||
* @param name A suggestive name for the [Patch].
|
* @param name A suggestive name for the [Patch] or [MethodSignature].
|
||||||
*/
|
*/
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
@@ -14,8 +15,8 @@ annotation class Name(
|
|||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation to describe a [Patch].
|
* Annotation to describe a [Patch] or [MethodSignature].
|
||||||
* @param description A description for the [Patch].
|
* @param description A description for the [Patch] or [MethodSignature].
|
||||||
*/
|
*/
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
@@ -26,8 +27,8 @@ annotation class Description(
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation to version a [Patch].
|
* Annotation to version a [Patch] or [MethodSignature].
|
||||||
* @param version The version of a [Patch].
|
* @param version The version of a [Patch] or [MethodSignature].
|
||||||
*/
|
*/
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@@ -1,181 +0,0 @@
|
|||||||
package app.revanced.patcher.data
|
|
||||||
|
|
||||||
import app.revanced.patcher.util.ProxyBackedClassList
|
|
||||||
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].
|
|
||||||
*/
|
|
||||||
|
|
||||||
sealed interface Context
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
private companion object {
|
|
||||||
inline fun <reified T> Iterable<T>.find(predicate: (T) -> Boolean): T? {
|
|
||||||
for (element in this) {
|
|
||||||
if (predicate(element)) {
|
|
||||||
return element
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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()
|
|
||||||
}
|
|
18
src/main/kotlin/app/revanced/patcher/data/PatcherData.kt
Normal file
18
src/main/kotlin/app/revanced/patcher/data/PatcherData.kt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package app.revanced.patcher.data
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.base.Data
|
||||||
|
import app.revanced.patcher.data.implementation.BytecodeData
|
||||||
|
import app.revanced.patcher.data.implementation.ResourceData
|
||||||
|
import app.revanced.patcher.patch.base.Patch
|
||||||
|
import org.jf.dexlib2.iface.ClassDef
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
internal data class PatcherData(
|
||||||
|
val internalClasses: MutableList<ClassDef>,
|
||||||
|
val resourceCacheDirectory: String
|
||||||
|
) {
|
||||||
|
internal val patches = mutableListOf<Patch<Data>>()
|
||||||
|
|
||||||
|
internal val bytecodeData = BytecodeData(patches, internalClasses)
|
||||||
|
internal val resourceData = ResourceData(File(resourceCacheDirectory))
|
||||||
|
}
|
9
src/main/kotlin/app/revanced/patcher/data/base/Data.kt
Normal file
9
src/main/kotlin/app/revanced/patcher/data/base/Data.kt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package app.revanced.patcher.data.base
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.implementation.BytecodeData
|
||||||
|
import app.revanced.patcher.data.implementation.ResourceData
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constraint interface for [BytecodeData] and [ResourceData]
|
||||||
|
*/
|
||||||
|
interface Data
|
@@ -0,0 +1,86 @@
|
|||||||
|
package app.revanced.patcher.data.implementation
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.base.Data
|
||||||
|
import app.revanced.patcher.patch.base.Patch
|
||||||
|
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||||
|
import app.revanced.patcher.signature.implementation.method.resolver.SignatureResolverResult
|
||||||
|
import app.revanced.patcher.util.ProxyBackedClassList
|
||||||
|
import app.revanced.patcher.util.method.MethodWalker
|
||||||
|
import org.jf.dexlib2.iface.ClassDef
|
||||||
|
import org.jf.dexlib2.iface.Method
|
||||||
|
|
||||||
|
class BytecodeData(
|
||||||
|
// FIXME: ugly solution due to design.
|
||||||
|
// It does not make sense for a BytecodeData instance to have access to the patches
|
||||||
|
private val patches: List<Patch<Data>>,
|
||||||
|
internalClasses: MutableList<ClassDef>
|
||||||
|
) : Data {
|
||||||
|
val classes = ProxyBackedClassList(internalClasses)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a class by a given class name
|
||||||
|
* @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
|
||||||
|
* @return A proxy for the first class that matches the predicate
|
||||||
|
*/
|
||||||
|
fun findClass(predicate: (ClassDef) -> Boolean): app.revanced.patcher.util.proxy.ClassProxy? {
|
||||||
|
// if we already proxied the class matching the predicate...
|
||||||
|
for (patch in patches) {
|
||||||
|
if (patch !is BytecodePatch) continue
|
||||||
|
for (signature in patch.signatures) {
|
||||||
|
val result = signature.result
|
||||||
|
result ?: continue
|
||||||
|
|
||||||
|
if (predicate(result.definingClassProxy.immutableClass)) return result.definingClassProxy // ...then return that proxy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// else resolve the class to a proxy and return it, if the predicate is matching a class
|
||||||
|
return classes.find(predicate)?.let {
|
||||||
|
proxy(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class MethodMap : LinkedHashMap<String, SignatureResolverResult>() {
|
||||||
|
override fun get(key: String): SignatureResolverResult {
|
||||||
|
return super.get(key) ?: throw MethodNotFoundException("Method $key was not found in the method cache")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class MethodNotFoundException(s: String) : Exception(s)
|
||||||
|
|
||||||
|
internal inline fun <reified T> Iterable<T>.find(predicate: (T) -> Boolean): T? {
|
||||||
|
for (element in this) {
|
||||||
|
if (predicate(element)) {
|
||||||
|
return element
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun BytecodeData.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
|
||||||
|
}
|
||||||
|
|
||||||
|
fun BytecodeData.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.proxies.add(proxy)
|
||||||
|
}
|
||||||
|
return proxy
|
||||||
|
}
|
@@ -0,0 +1,49 @@
|
|||||||
|
package app.revanced.patcher.data.implementation
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.base.Data
|
||||||
|
import org.w3c.dom.Document
|
||||||
|
import java.io.Closeable
|
||||||
|
import java.io.File
|
||||||
|
import javax.xml.XMLConstants
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory
|
||||||
|
import javax.xml.transform.TransformerFactory
|
||||||
|
import javax.xml.transform.dom.DOMSource
|
||||||
|
import javax.xml.transform.stream.StreamResult
|
||||||
|
|
||||||
|
class ResourceData(private val resourceCacheDirectory: File) : Data {
|
||||||
|
private fun resolve(path: String) = resourceCacheDirectory.resolve(path)
|
||||||
|
|
||||||
|
fun forEach(action: (File) -> Unit) = resourceCacheDirectory.walkTopDown().forEach(action)
|
||||||
|
fun reader(path: String) = resolve(path).reader()
|
||||||
|
fun writer(path: String) = resolve(path).writer()
|
||||||
|
|
||||||
|
fun replace(path: String, oldValue: String, newValue: String, oldValueIsRegex: Boolean = false) {
|
||||||
|
// TODO: buffer this somehow
|
||||||
|
val content = resolve(path).readText()
|
||||||
|
|
||||||
|
if (oldValueIsRegex) {
|
||||||
|
content.replace(Regex(oldValue), newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getXmlEditor(path: String) = DomFileEditor(resolve(path))
|
||||||
|
}
|
||||||
|
|
||||||
|
class DomFileEditor internal constructor(private val domFile: File) : Closeable {
|
||||||
|
val file: Document
|
||||||
|
|
||||||
|
init {
|
||||||
|
val factory = DocumentBuilderFactory.newInstance()
|
||||||
|
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true)
|
||||||
|
|
||||||
|
val builder = factory.newDocumentBuilder()
|
||||||
|
|
||||||
|
// this will expectedly throw
|
||||||
|
file = builder.parse(domFile)
|
||||||
|
file.normalize()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close() = TransformerFactory.newInstance().newTransformer()
|
||||||
|
.transform(DOMSource(file), StreamResult(domFile.outputStream()))
|
||||||
|
}
|
@@ -1,79 +0,0 @@
|
|||||||
package app.revanced.patcher.extensions
|
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.*
|
|
||||||
import app.revanced.patcher.data.Context
|
|
||||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
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 kotlin.reflect.KClass
|
|
||||||
import kotlin.reflect.KVisibility
|
|
||||||
import kotlin.reflect.full.companionObject
|
|
||||||
import kotlin.reflect.full.companionObjectInstance
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively find a given annotation on a class.
|
|
||||||
* @param targetAnnotation The annotation to find.
|
|
||||||
* @return The annotation.
|
|
||||||
*/
|
|
||||||
private fun <T : Annotation> Class<*>.findAnnotationRecursively(targetAnnotation: KClass<T>) =
|
|
||||||
this.findAnnotationRecursively(targetAnnotation.java, mutableSetOf())
|
|
||||||
|
|
||||||
|
|
||||||
private fun <T : Annotation> Class<*>.findAnnotationRecursively(
|
|
||||||
targetAnnotation: Class<T>, traversed: MutableSet<Annotation>
|
|
||||||
): T? {
|
|
||||||
val found = this.annotations.firstOrNull { it.annotationClass.java.name == targetAnnotation.name }
|
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST") if (found != null) return found as T
|
|
||||||
|
|
||||||
for (annotation in this.annotations) {
|
|
||||||
if (traversed.contains(annotation)) continue
|
|
||||||
traversed.add(annotation)
|
|
||||||
|
|
||||||
return (annotation.annotationClass.java.findAnnotationRecursively(targetAnnotation, traversed)) ?: continue
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
object PatchExtensions {
|
|
||||||
val Class<out Patch<Context>>.patchName: String
|
|
||||||
get() = findAnnotationRecursively(Name::class)?.name ?: this.simpleName
|
|
||||||
|
|
||||||
val Class<out Patch<Context>>.version
|
|
||||||
get() = findAnnotationRecursively(Version::class)?.version
|
|
||||||
|
|
||||||
val Class<out Patch<Context>>.include
|
|
||||||
get() = findAnnotationRecursively(app.revanced.patcher.patch.annotations.Patch::class)!!.include
|
|
||||||
|
|
||||||
val Class<out Patch<Context>>.description
|
|
||||||
get() = findAnnotationRecursively(Description::class)?.description
|
|
||||||
|
|
||||||
val Class<out Patch<Context>>.dependencies
|
|
||||||
get() = findAnnotationRecursively(DependsOn::class)?.dependencies
|
|
||||||
|
|
||||||
val Class<out Patch<Context>>.compatiblePackages
|
|
||||||
get() = findAnnotationRecursively(Compatibility::class)?.compatiblePackages
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object MethodFingerprintExtensions {
|
|
||||||
val MethodFingerprint.name: String
|
|
||||||
get() = this.javaClass.simpleName
|
|
||||||
|
|
||||||
val MethodFingerprint.fuzzyPatternScanMethod
|
|
||||||
get() = javaClass.findAnnotationRecursively(FuzzyPatternScanMethod::class)
|
|
||||||
|
|
||||||
val MethodFingerprint.fuzzyScanThreshold
|
|
||||||
get() = fuzzyPatternScanMethod?.threshold ?: 0
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -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
|
|
@@ -1,13 +0,0 @@
|
|||||||
package app.revanced.patcher.fingerprint.method.annotation
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotations to scan a pattern [MethodFingerprint] with fuzzy algorithm.
|
|
||||||
* @param threshold if [threshold] or more of the opcodes do not match, skip.
|
|
||||||
*/
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
|
||||||
annotation class FuzzyPatternScanMethod(
|
|
||||||
val threshold: Int = 1
|
|
||||||
)
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user