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

Compare commits

...

35 Commits

Author SHA1 Message Date
semantic-release-bot
64dd1526cd chore(release): 19.2.1-dev.1 [skip ci]
## [19.2.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.2.0...v19.2.1-dev.1) (2024-01-27)

### Bug Fixes

* Use `Patch#toString` to get patch class name, when no name available ([c9a8260](c9a82608f7))
2024-01-27 03:08:34 +00:00
oSumAtrIX
c9a82608f7 fix: Use Patch#toString to get patch class name, when no name available 2024-01-27 04:06:15 +01:00
oSumAtrIX
9fc42e132c ci: Use latest Node.js LTS version to fix builds
(cherry picked from commit 23b3eb1325704c39db1a99bb169047f4879766d1)
2024-01-27 04:06:15 +01:00
oSumAtrIX
efa98ece45 ci: Add dependabot 2024-01-26 01:45:43 +01:00
oSumAtrIX
68e2acebba build: Bump dependencies 2024-01-26 01:42:02 +01:00
semantic-release-bot
7a7a8fc353 chore(release): 19.2.0 [skip ci]
# [19.2.0](https://github.com/ReVanced/revanced-patcher/compare/v19.1.0...v19.2.0) (2023-12-28)

### Bug Fixes

* Accept `PatchSet` in `PatchesConsumer#acceptPatches` ([716825f](716825f232))

### Features

* Add `PatchExtensions#registerNewPatchOption` function to simplify instantiation and registration of patch options ([4a91845](4a9184597b))
2023-12-28 21:35:22 +00:00
oSumAtrIX
f8306ac43d chore: Merge branch dev to main (#264) 2023-12-28 22:33:35 +01:00
semantic-release-bot
d03591b735 chore(release): 19.2.0-dev.1 [skip ci]
# [19.2.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.1.1-dev.1...v19.2.0-dev.1) (2023-12-22)

### Features

* Add `PatchExtensions#registerNewPatchOption` function to simplify instantiation and registration of patch options ([4a91845](4a9184597b))
2023-12-22 02:23:04 +00:00
oSumAtrIX
4a9184597b feat: Add PatchExtensions#registerNewPatchOption function to simplify instantiation and registration of patch options 2023-12-22 03:20:50 +01:00
oSumAtrIX
0a482f8c9a refactor: Reduce duplicate code by using a common function to register options 2023-12-22 03:09:42 +01:00
oSumAtrIX
e7dacfba8c build: Simplify enabling local build cache 2023-12-10 21:57:10 +01:00
semantic-release-bot
2d7fffd4ec chore(release): 19.1.1-dev.1 [skip ci]
## [19.1.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.1.0...v19.1.1-dev.1) (2023-12-01)

### Bug Fixes

* Accept `PatchSet` in `PatchesConsumer#acceptPatches` ([716825f](716825f232))
2023-12-01 22:15:43 +00:00
oSumAtrIX
f8baabbcec build: Bump dependencies 2023-12-01 23:13:49 +01:00
oSumAtrIX
716825f232 fix: Accept PatchSet in PatchesConsumer#acceptPatches
This deprecates accepting `List<Patch<*>>`
2023-12-01 23:10:23 +01:00
semantic-release-bot
58bd46750b chore(release): 19.1.0 [skip ci]
# [19.1.0](https://github.com/ReVanced/revanced-patcher/compare/v19.0.0...v19.1.0) (2023-12-01)

### Features

* Add constructor to initialize patches without annotations ([462fbe2](462fbe2cad))
* Retrieve annotations in super and interface classes ([7aeae93](7aeae93f3d))

### Performance Improvements

* Use a hash set for fast lookup ([f1de9b3](f1de9b39ef))
2023-12-01 00:19:54 +00:00
oSumAtrIX
288240f163 chore: Merge branch dev to main (#260) 2023-12-01 01:17:47 +01:00
semantic-release-bot
ff02452cb8 chore(release): 19.1.0-dev.1 [skip ci]
# [19.1.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.0.0...v19.1.0-dev.1) (2023-11-29)

### Features

* Add constructor to initialize patches without annotations ([462fbe2](462fbe2cad))
* Retrieve annotations in super and interface classes ([7aeae93](7aeae93f3d))

### Performance Improvements

* Use a hash set for fast lookup ([f1de9b3](f1de9b39ef))
2023-11-29 19:28:24 +00:00
oSumAtrIX
462fbe2cad feat: Add constructor to initialize patches without annotations 2023-11-29 20:26:20 +01:00
oSumAtrIX
7aeae93f3d feat: Retrieve annotations in super and interface classes 2023-11-29 01:14:46 +01:00
oSumAtrIX
f1de9b39ef perf: Use a hash set for fast lookup 2023-11-28 20:17:46 +01:00
oSumAtrIX
db5b0ed7be refactor: Convert extension property to member 2023-11-28 20:17:02 +01:00
oSumAtrIX
9f28a01c03 refactor: Group related extension functions together 2023-11-28 19:59:18 +01:00
oSumAtrIX
80407b6102 chore: Lint code 2023-11-26 05:57:41 +01:00
oSumAtrIX
287841d806 chore: Add heading to issue templates 2023-11-23 00:56:53 +01:00
oSumAtrIX
10c3be1195 build: Bump Gradle wrapper 2023-11-22 01:04:49 +01:00
oSumAtrIX
0c0e22013b build: Use dedicated Gradle cache action 2023-11-22 01:04:49 +01:00
oSumAtrIX
f35c8d4446 build: Use Gradle build cache 2023-11-22 01:04:48 +01:00
oSumAtrIX
17418d4b9c ci: Simplify cache paths 2023-11-22 01:04:48 +01:00
oSumAtrIX
ec1fbdf2ae chore: Reword comment for first PR merge 2023-11-22 01:04:48 +01:00
oSumAtrIX
56e5a46fd5 chore: Add a newline between steps 2023-11-22 01:04:48 +01:00
oSumAtrIX
32e86d44a3 chore: Simplify issue templates 2023-11-22 01:04:47 +01:00
oSumAtrIX
7100606dfc build: Bump dependencies 2023-11-22 01:04:47 +01:00
oSumAtrIX
d7eb111460 ci: Update cache key 2023-11-22 01:04:47 +01:00
oSumAtrIX
27ea46653e chore: Update packages 2023-11-22 01:04:46 +01:00
oSumAtrIX
12c43072cb refactor: Include class of method in call expression 2023-11-03 23:31:15 +01:00
78 changed files with 4489 additions and 3509 deletions

View File

@@ -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

108
.github/ISSUE_TEMPLATE/bug-report.yml vendored Normal file
View File

@@ -0,0 +1,108 @@
name: 🐞 Bug report
description: Report a bug or an issue.
title: 'bug: '
labels: ['Bug report']
body:
- type: markdown
attributes:
value: |
<p align="center">
<picture>
<source
width="256px"
media="(prefers-color-scheme: dark)"
srcset="https://raw.githubusercontent.com/revanced/revanced-patcher/main/assets/revanced-headline/revanced-headline-vertical-dark.svg"
>
<img
width="256px"
src="https://raw.githubusercontent.com/revanced/revanced-patcher/main/assets/revanced-headline/revanced-headline-vertical-light.svg"
>
</picture>
<br>
<a href="https://revanced.app/">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/revanced/revanced-patcher/main/assets/revanced-logo/revanced-logo.svg" />
<img height="24px" src="https://raw.githubusercontent.com/revanced/revanced-patcher/main/assets/revanced-logo/revanced-logo.svg" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://github.com/ReVanced">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://i.ibb.co/dMMmCrW/Git-Hub-Mark.png" />
<img height="24px" src="https://i.ibb.co/9wV3HGF/Git-Hub-Mark-Light.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="http://revanced.app/discord">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032563-d4e084b7-244e-4358-af50-26bde6dd4996.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032563-d4e084b7-244e-4358-af50-26bde6dd4996.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://reddit.com/r/revancedapp">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032351-9d9d5619-8ef7-470a-9eec-2744ece54553.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032351-9d9d5619-8ef7-470a-9eec-2744ece54553.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://t.me/app_revanced">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032213-faf25ab8-0bc3-4a94-a730-b524c96df124.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032213-faf25ab8-0bc3-4a94-a730-b524c96df124.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://x.com/revancedapp">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/93124920/270180600-7c1b38bf-889b-4d68-bd5e-b9d86f91421a.png">
<img height="24px" src="https://user-images.githubusercontent.com/93124920/270108715-d80743fa-b330-4809-b1e6-79fbdc60d09c.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://www.youtube.com/@ReVanced">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032714-c51c7492-0666-44ac-99c2-f003a695ab50.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032714-c51c7492-0666-44ac-99c2-f003a695ab50.png" />
</picture>
</a>
<br>
<br>
Continuing the legacy of Vanced
</p>
# ReVanced Patcher bug report
Before creating a new bug report, please keep the following in mind:
- **Do not submit a duplicate bug report**: You can review existing bug reports [here](https://github.com/ReVanced/revanced-patcher/labels/Bug%20report).
- **Do not use the issue page for support**: If you need help or have questions, check out other platforms on [revanced.app](https://revanced.app).
- type: textarea
attributes:
label: Bug description
description: |
- Describe your bug in detail
- Add steps to reproduce the bug if possible (Step 1. ... Step 2. ...)
- Add images and videos if possible
validations:
required: true
- type: textarea
attributes:
label: Error logs
description: Exceptions can be captured by running `logcat | grep AndroidRuntime` in a shell.
render: shell
- type: textarea
attributes:
label: Solution
description: If applicable, add a possible solution to the bug.
- type: textarea
attributes:
label: Additional context
description: Add additional context here.
- type: checkboxes
id: acknowledgements
attributes:
label: Acknowledgements
description: Your bug report will be closed if you don't follow the checklist below.
options:
- label: This issue is not a duplicate of an existing bug report.
required: true
- label: I have chosen an appropriate title.
required: true
- label: All requested information has been provided properly.
required: true

View File

@@ -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

View File

@@ -0,0 +1,106 @@
name: ⭐ Feature request
description: Create a detailed request for a new feature.
title: 'feat: '
labels: ['Feature request']
body:
- type: markdown
attributes:
value: |
<p align="center">
<picture>
<source
width="256px"
media="(prefers-color-scheme: dark)"
srcset="https://raw.githubusercontent.com/revanced/revanced-patcher/main/assets/revanced-headline/revanced-headline-vertical-dark.svg"
>
<img
width="256px"
src="https://raw.githubusercontent.com/revanced/revanced-patcher/main/assets/revanced-headline/revanced-headline-vertical-light.svg"
>
</picture>
<br>
<a href="https://revanced.app/">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/revanced/revanced-patcher/main/assets/revanced-logo/revanced-logo.svg" />
<img height="24px" src="https://raw.githubusercontent.com/revanced/revanced-patcher/main/assets/revanced-logo/revanced-logo.svg" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://github.com/ReVanced">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://i.ibb.co/dMMmCrW/Git-Hub-Mark.png" />
<img height="24px" src="https://i.ibb.co/9wV3HGF/Git-Hub-Mark-Light.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="http://revanced.app/discord">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032563-d4e084b7-244e-4358-af50-26bde6dd4996.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032563-d4e084b7-244e-4358-af50-26bde6dd4996.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://reddit.com/r/revancedapp">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032351-9d9d5619-8ef7-470a-9eec-2744ece54553.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032351-9d9d5619-8ef7-470a-9eec-2744ece54553.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://t.me/app_revanced">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032213-faf25ab8-0bc3-4a94-a730-b524c96df124.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032213-faf25ab8-0bc3-4a94-a730-b524c96df124.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://x.com/revancedapp">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/93124920/270180600-7c1b38bf-889b-4d68-bd5e-b9d86f91421a.png">
<img height="24px" src="https://user-images.githubusercontent.com/93124920/270108715-d80743fa-b330-4809-b1e6-79fbdc60d09c.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://www.youtube.com/@ReVanced">
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032714-c51c7492-0666-44ac-99c2-f003a695ab50.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032714-c51c7492-0666-44ac-99c2-f003a695ab50.png" />
</picture>
</a>
<br>
<br>
Continuing the legacy of Vanced
</p>
# ReVanced Patcher feature request
Before creating a new feature request, please keep the following in mind:
- **Do not submit a duplicate feature request**: You can review existing feature requests [here](https://github.com/ReVanced/revanced-patcher/labels/Feature%20request).
- **Do not use the issue page for support**: If you need help or have questions, check out other platforms on [revanced.app](https://revanced.app).
- type: textarea
attributes:
label: Feature description
description: |
- Describe your feature in detail
- Add images, videos, links, examples, references, etc. if possible
- Add the target application name in case you request a new patch
- type: textarea
attributes:
label: Motivation
description: |
A strong motivation is necessary for a feature request to be considered.
- Why should this feature be implemented?
- What is the explicit use case?
- What are the benefits?
- What makes this feature important?
validations:
required: true
- type: checkboxes
id: acknowledgements
attributes:
label: Acknowledgements
description: Your feature request will be closed if you don't follow the checklist below.
options:
- label: This issue is not a duplicate of an existing feature request.
required: true
- label: I have chosen an appropriate title.
required: true
- label: All requested information has been provided properly.
required: true

2
.github/config.yml vendored
View File

@@ -1,2 +1,2 @@
firstPRMergeComment: > firstPRMergeComment: >
Thank you for contributing to ReVanced. Join us on [Discord](https://revanced.app/discord) if you want to receive a contributor role. Thank you for contributing to ReVanced. Join us on [Discord](https://revanced.app/discord) to receive a role for your contribution.

22
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: github-actions
labels: []
directory: /
target-branch: dev
schedule:
interval: monthly
- package-ecosystem: npm
labels: []
directory: /
target-branch: dev
schedule:
interval: monthly
- package-ecosystem: gradle
labels: []
directory: /
target-branch: dev
schedule:
interval: monthly

View File

@@ -16,6 +16,7 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 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:

View File

@@ -23,22 +23,24 @@ jobs:
# https://github.com/cycjimmy/semantic-release-action#private-packages # https://github.com/cycjimmy/semantic-release-action#private-packages
persist-credentials: false persist-credentials: false
fetch-depth: 0 fetch-depth: 0
- name: Cache
uses: actions/cache@v3 - name: Cache Gradle
with: uses: burrunan/gradle-cache-action@v1
path: |
${{ runner.home }}/.gradle/caches - name: Build
${{ runner.home }}/.gradle/wrapper
.gradle
build
node_modules
key: ${{ runner.os }}-gradle-npm-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'package-lock.json') }}
- name: Build with Gradle
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build clean --no-daemon run: ./gradlew build clean
- name: Setup semantic-release
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
cache: 'npm'
- name: Install dependencies
run: npm install run: npm install
- name: Release - name: Release
env: env:
GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }} GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }}

View File

@@ -1,3 +1,62 @@
## [19.2.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.2.0...v19.2.1-dev.1) (2024-01-27)
### Bug Fixes
* Use `Patch#toString` to get patch class name, when no name available ([c9a8260](https://github.com/ReVanced/revanced-patcher/commit/c9a82608f7f2d6b3e64c0c949ea5d9f76fa46165))
# [19.2.0](https://github.com/ReVanced/revanced-patcher/compare/v19.1.0...v19.2.0) (2023-12-28)
### Bug Fixes
* Accept `PatchSet` in `PatchesConsumer#acceptPatches` ([716825f](https://github.com/ReVanced/revanced-patcher/commit/716825f232bf1aab3a97723968562aa6dbdb20b1))
### Features
* Add `PatchExtensions#registerNewPatchOption` function to simplify instantiation and registration of patch options ([4a91845](https://github.com/ReVanced/revanced-patcher/commit/4a9184597be99cd458496cce0ee68994e6b8735c))
# [19.2.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.1.1-dev.1...v19.2.0-dev.1) (2023-12-22)
### Features
* Add `PatchExtensions#registerNewPatchOption` function to simplify instantiation and registration of patch options ([4a91845](https://github.com/ReVanced/revanced-patcher/commit/4a9184597be99cd458496cce0ee68994e6b8735c))
## [19.1.1-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.1.0...v19.1.1-dev.1) (2023-12-01)
### Bug Fixes
* Accept `PatchSet` in `PatchesConsumer#acceptPatches` ([716825f](https://github.com/ReVanced/revanced-patcher/commit/716825f232bf1aab3a97723968562aa6dbdb20b1))
# [19.1.0](https://github.com/ReVanced/revanced-patcher/compare/v19.0.0...v19.1.0) (2023-12-01)
### Features
* Add constructor to initialize patches without annotations ([462fbe2](https://github.com/ReVanced/revanced-patcher/commit/462fbe2cadf56d8b0dde33319256021093bd39d5))
* Retrieve annotations in super and interface classes ([7aeae93](https://github.com/ReVanced/revanced-patcher/commit/7aeae93f3d9a13e294fe1bdb2586f79908af60af))
### Performance Improvements
* Use a hash set for fast lookup ([f1de9b3](https://github.com/ReVanced/revanced-patcher/commit/f1de9b39eff1db44c00acd3e41902b3ec6124776))
# [19.1.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.0.0...v19.1.0-dev.1) (2023-11-29)
### Features
* Add constructor to initialize patches without annotations ([462fbe2](https://github.com/ReVanced/revanced-patcher/commit/462fbe2cadf56d8b0dde33319256021093bd39d5))
* Retrieve annotations in super and interface classes ([7aeae93](https://github.com/ReVanced/revanced-patcher/commit/7aeae93f3d9a13e294fe1bdb2586f79908af60af))
### Performance Improvements
* Use a hash set for fast lookup ([f1de9b3](https://github.com/ReVanced/revanced-patcher/commit/f1de9b39eff1db44c00acd3e41902b3ec6124776))
# [19.0.0](https://github.com/ReVanced/revanced-patcher/compare/v18.0.0...v19.0.0) (2023-10-24) # [19.0.0](https://github.com/ReVanced/revanced-patcher/compare/v18.0.0...v19.0.0) (2023-10-24)

View File

@@ -44,6 +44,7 @@ public final class app/revanced/patcher/Patcher : app/revanced/patcher/Integrati
public fun <init> (Lapp/revanced/patcher/PatcherOptions;)V public fun <init> (Lapp/revanced/patcher/PatcherOptions;)V
public fun acceptIntegrations (Ljava/util/List;)V public fun acceptIntegrations (Ljava/util/List;)V
public fun acceptPatches (Ljava/util/List;)V public fun acceptPatches (Ljava/util/List;)V
public fun acceptPatches (Ljava/util/Set;)V
public synthetic fun apply (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun apply (Ljava/lang/Object;)Ljava/lang/Object;
public fun apply (Z)Lkotlinx/coroutines/flow/Flow; public fun apply (Z)Lkotlinx/coroutines/flow/Flow;
public fun close ()V public fun close ()V
@@ -99,6 +100,11 @@ public final class app/revanced/patcher/PatcherResult$PatchedDexFile {
public abstract interface class app/revanced/patcher/PatchesConsumer { public abstract interface class app/revanced/patcher/PatchesConsumer {
public abstract fun acceptPatches (Ljava/util/List;)V public abstract fun acceptPatches (Ljava/util/List;)V
public abstract fun acceptPatches (Ljava/util/Set;)V
}
public final class app/revanced/patcher/PatchesConsumer$DefaultImpls {
public static fun acceptPatches (Lapp/revanced/patcher/PatchesConsumer;Ljava/util/List;)V
} }
public final class app/revanced/patcher/data/BytecodeContext : app/revanced/patcher/data/Context { public final class app/revanced/patcher/data/BytecodeContext : app/revanced/patcher/data/Context {
@@ -175,6 +181,7 @@ public abstract class app/revanced/patcher/fingerprint/MethodFingerprint {
public fun <init> ()V 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 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 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 getFuzzyPatternScanMethod ()Lapp/revanced/patcher/fingerprint/annotation/FuzzyPatternScanMethod;
public final fun getResult ()Lapp/revanced/patcher/fingerprint/MethodFingerprintResult; 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/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 fun resolve (Lapp/revanced/patcher/data/BytecodeContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Z
@@ -233,11 +240,14 @@ public abstract interface annotation class app/revanced/patcher/fingerprint/anno
public abstract class app/revanced/patcher/patch/BytecodePatch : app/revanced/patcher/patch/Patch { public abstract class app/revanced/patcher/patch/BytecodePatch : app/revanced/patcher/patch/Patch {
public fun <init> ()V public fun <init> ()V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;ZZLjava/util/Set;)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;ZZLjava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/util/Set;)V public fun <init> (Ljava/util/Set;)V
public synthetic fun <init> (Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
} }
public abstract class app/revanced/patcher/patch/Patch { public abstract class app/revanced/patcher/patch/Patch {
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;ZZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public abstract fun execute (Lapp/revanced/patcher/data/Context;)V public abstract fun execute (Lapp/revanced/patcher/data/Context;)V
public final fun getCompatiblePackages ()Ljava/util/Set; public final fun getCompatiblePackages ()Ljava/util/Set;
@@ -271,6 +281,8 @@ public final class app/revanced/patcher/patch/PatchResult {
public abstract class app/revanced/patcher/patch/ResourcePatch : app/revanced/patcher/patch/Patch { public abstract class app/revanced/patcher/patch/ResourcePatch : app/revanced/patcher/patch/Patch {
public fun <init> ()V public fun <init> ()V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;ZZ)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
} }
public abstract interface annotation class app/revanced/patcher/patch/annotation/CompatiblePackage : java/lang/annotation/Annotation { public abstract interface annotation class app/revanced/patcher/patch/annotation/CompatiblePackage : java/lang/annotation/Annotation {
@@ -323,6 +335,8 @@ public final class app/revanced/patcher/patch/options/PatchOption$PatchExtension
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 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 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 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 registerNewPatchOption (Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;Lkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/options/PatchOption;
public static synthetic fun registerNewPatchOption$default (Lapp/revanced/patcher/patch/options/PatchOption$PatchExtensions;Lapp/revanced/patcher/patch/Patch;Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;Lkotlin/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 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 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 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;

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -83,4 +83,4 @@ publishing {
} }
} }
} }
} }

View File

@@ -1,4 +1,4 @@
org.gradle.parallel = true org.gradle.parallel = true
org.gradle.caching = true org.gradle.caching = true
kotlin.code.style = official kotlin.code.style = official
version = 19.0.0 version = 19.2.1-dev.1

View File

@@ -1,8 +1,8 @@
[versions] [versions]
android = "4.1.1.4" android = "4.1.1.4"
kotlin-reflect = "1.9.0" kotlin-reflect = "1.9.10"
apktool-lib = "2.9.1" apktool-lib = "2.9.1"
kotlin-test = "1.8.20-RC" kotlin-test = "1.9.20"
kotlinx-coroutines-core = "1.7.3" kotlinx-coroutines-core = "1.7.3"
multidexlib2 = "3.0.3.r3" multidexlib2 = "3.0.3.r3"
smali = "3.0.3" smali = "3.0.3"

View File

@@ -1,7 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000 distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dist

5199
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,9 @@
{ {
"devDependencies": { "devDependencies": {
"@saithodev/semantic-release-backmerge": "^3.1.0", "@saithodev/semantic-release-backmerge": "^4.0.1",
"@semantic-release/changelog": "^6.0.2", "@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1", "@semantic-release/git": "^10.0.1",
"gradle-semantic-release-plugin": "^1.7.6", "gradle-semantic-release-plugin": "^1.9.1",
"semantic-release": "^20.1.0" "semantic-release": "^23.0.0"
} }
} }

View File

@@ -1 +1,7 @@
rootProject.name = "revanced-patcher" rootProject.name = "revanced-patcher"
buildCache {
local {
isEnabled = "CI" !in System.getenv()
}
}

View File

@@ -5,4 +5,4 @@ import java.io.File
@FunctionalInterface @FunctionalInterface
interface IntegrationsConsumer { interface IntegrationsConsumer {
fun acceptIntegrations(integrations: List<File>) fun acceptIntegrations(integrations: List<File>)
} }

View File

@@ -12,6 +12,7 @@ import java.util.jar.JarFile
import java.util.logging.Logger import java.util.logging.Logger
import kotlin.reflect.KClass import kotlin.reflect.KClass
/** /**
* A set of [Patch]es. * A set of [Patch]es.
*/ */
@@ -37,7 +38,7 @@ sealed class PatchBundleLoader private constructor(
// This constructor parameter is unfortunately necessary, // 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. // 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. // because the instance itself is a PatchSet, which is immutable, that is delegated by the parameter.
private val patchSet: MutableSet<Patch<*>> = mutableSetOf() private val patchSet: MutableSet<Patch<*>> = mutableSetOf(),
) : PatchSet by patchSet { ) : PatchSet by patchSet {
private val logger = Logger.getLogger(PatchBundleLoader::class.java.name) private val logger = Logger.getLogger(PatchBundleLoader::class.java.name)
@@ -63,22 +64,29 @@ sealed class PatchBundleLoader private constructor(
* @param silent Whether to suppress logging. * @param silent Whether to suppress logging.
* @return The instantiated [Patch] or `null` if the [Patch] could not be instantiated. * @return The instantiated [Patch] or `null` if the [Patch] could not be instantiated.
*/ */
internal fun Class<*>.getInstance(logger: Logger, silent: Boolean = false): Patch<*>? { internal fun Class<*>.getInstance(
logger: Logger,
silent: Boolean = false,
): Patch<*>? {
return try { return try {
getField("INSTANCE").get(null) getField("INSTANCE").get(null)
} catch (exception: NoSuchFieldException) { } catch (exception: NoSuchFieldException) {
if (!silent) logger.fine( if (!silent) {
"Patch class '${name}' has no INSTANCE field, therefor not a singleton. " + logger.fine(
"Will try to instantiate it." "Patch class '$name' has no INSTANCE field, therefor not a singleton. " +
) "Attempting to instantiate it.",
)
}
try { try {
getDeclaredConstructor().newInstance() getDeclaredConstructor().newInstance()
} catch (exception: Exception) { } catch (exception: Exception) {
if (!silent) logger.severe( if (!silent) {
"Patch class '${name}' is not singleton and has no suitable constructor, " + logger.severe(
"therefor cannot be instantiated and will be ignored." "Patch class '$name' is not singleton and has no suitable constructor, " +
) "therefor cannot be instantiated and is ignored.",
)
}
return null return null
} }
@@ -97,7 +105,7 @@ sealed class PatchBundleLoader private constructor(
{ patchBundle -> { patchBundle ->
JarFile(patchBundle).entries().toList().filter { it.name.endsWith(".class") } JarFile(patchBundle).entries().toList().filter { it.name.endsWith(".class") }
.map { it.name.replace('/', '.').replace(".class", "") } .map { it.name.replace('/', '.').replace(".class", "") }
} },
) )
/** /**
@@ -109,9 +117,10 @@ sealed class PatchBundleLoader private constructor(
*/ */
class Dex(vararg patchBundles: File, optimizedDexDirectory: File? = null) : PatchBundleLoader( class Dex(vararg patchBundles: File, optimizedDexDirectory: File? = null) : PatchBundleLoader(
DexClassLoader( DexClassLoader(
patchBundles.joinToString(File.pathSeparator) { it.absolutePath }, optimizedDexDirectory?.absolutePath, patchBundles.joinToString(File.pathSeparator) { it.absolutePath },
optimizedDexDirectory?.absolutePath,
null, null,
PatchBundleLoader::class.java.classLoader PatchBundleLoader::class.java.classLoader,
), ),
patchBundles, patchBundles,
{ patchBundle -> { patchBundle ->
@@ -119,9 +128,9 @@ sealed class PatchBundleLoader private constructor(
.map { classDef -> .map { classDef ->
classDef.type.substring(1, classDef.length - 1) classDef.type.substring(1, classDef.length - 1)
} }
} },
) { ) {
@Deprecated("This constructor is deprecated. Use the constructor with the second parameter instead.") @Deprecated("This constructor is deprecated. Use the constructor with the second parameter instead.")
constructor(vararg patchBundles: File) : this(*patchBundles, optimizedDexDirectory = null) constructor(vararg patchBundles: File) : this(*patchBundles, optimizedDexDirectory = null)
} }
} }

View File

@@ -5,4 +5,4 @@ import kotlinx.coroutines.flow.Flow
import java.util.function.Function import java.util.function.Function
@FunctionalInterface @FunctionalInterface
interface PatchExecutorFunction : Function<Boolean, Flow<PatchResult>> interface PatchExecutorFunction : Function<Boolean, Flow<PatchResult>>

File diff suppressed because it is too large Load Diff

View File

@@ -38,4 +38,4 @@ class PatcherContext internal constructor(options: PatcherOptions) {
* This holds the current state of the bytecode. * This holds the current state of the bytecode.
*/ */
internal val bytecodeContext = BytecodeContext(options) internal val bytecodeContext = BytecodeContext(options)
} }

View File

@@ -9,8 +9,7 @@ package app.revanced.patcher
sealed class PatcherException(errorMessage: String?, cause: Throwable?) : Exception(errorMessage, cause) { sealed class PatcherException(errorMessage: String?, cause: Throwable?) : Exception(errorMessage, cause) {
constructor(errorMessage: String) : this(errorMessage, null) constructor(errorMessage: String) : this(errorMessage, null)
class CircularDependencyException internal constructor(dependant: String) : PatcherException( class CircularDependencyException internal constructor(dependant: String) : PatcherException(
"Patch '$dependant' causes a circular dependency" "Patch '$dependant' causes a circular dependency",
) )
} }

View File

@@ -32,20 +32,23 @@ data class PatcherOptions(
/** /**
* The configuration to use for resource decoding and compiling. * The configuration to use for resource decoding and compiling.
*/ */
internal val resourceConfig = Config.getDefaultConfig().apply { internal val resourceConfig =
useAapt2 = true Config.getDefaultConfig().apply {
aaptPath = aaptBinaryPath ?: "" useAapt2 = true
frameworkDirectory = frameworkFileDirectory 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() 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()
}
} }

View File

@@ -12,7 +12,7 @@ import java.io.InputStream
data class PatcherResult( data class PatcherResult(
val dexFiles: List<PatchedDexFile>, val dexFiles: List<PatchedDexFile>,
val resourceFile: File?, val resourceFile: File?,
val doNotCompress: List<String>? = null val doNotCompress: List<String>? = null,
) { ) {
/** /**
* Wrapper for dex files. * Wrapper for dex files.
@@ -20,4 +20,4 @@ data class PatcherResult(
* @param stream The dex file as [InputStream]. * @param stream The dex file as [InputStream].
*/ */
class PatchedDexFile(val name: String, val stream: InputStream) class PatchedDexFile(val name: String, val stream: InputStream)
} }

View File

@@ -4,5 +4,7 @@ import app.revanced.patcher.patch.Patch
@FunctionalInterface @FunctionalInterface
interface PatchesConsumer { interface PatchesConsumer {
fun acceptPatches(patches: List<Patch<*>>) @Deprecated("Use acceptPatches(PatchSet) instead.", ReplaceWith("acceptPatches(patches.toSet())"))
} fun acceptPatches(patches: List<Patch<*>>) = acceptPatches(patches.toSet())
fun acceptPatches(patches: PatchSet)
}

File diff suppressed because it is too large Load Diff

View File

@@ -6,4 +6,4 @@ import java.util.function.Supplier
* A common interface for contexts such as [ResourceContext] and [BytecodeContext]. * A common interface for contexts such as [ResourceContext] and [BytecodeContext].
*/ */
sealed interface Context<T> : Supplier<T> sealed interface Context<T> : Supplier<T>

View File

@@ -26,7 +26,7 @@ import java.util.logging.Logger
*/ */
class ResourceContext internal constructor( class ResourceContext internal constructor(
private val context: PatcherContext, private val context: PatcherContext,
private val options: PatcherOptions private val options: PatcherOptions,
) : Context<File?>, Iterable<File> { ) : Context<File?>, Iterable<File> {
private val logger = Logger.getLogger(ResourceContext::class.java.name) private val logger = Logger.getLogger(ResourceContext::class.java.name)
@@ -37,52 +37,54 @@ class ResourceContext internal constructor(
* *
* @param mode The [ResourceDecodingMode] to use when decoding. * @param mode The [ResourceDecodingMode] to use when decoding.
*/ */
internal fun decodeResources(mode: ResourceDecodingMode) = with(context.packageMetadata.apkInfo) { internal fun decodeResources(mode: ResourceDecodingMode) =
// Needed to decode resources. with(context.packageMetadata.apkInfo) {
val resourcesDecoder = ResourcesDecoder(options.resourceConfig, this) // Needed to decode resources.
val resourcesDecoder = ResourcesDecoder(options.resourceConfig, this)
when (mode) { when (mode) {
ResourceDecodingMode.FULL -> { ResourceDecodingMode.FULL -> {
val outDir = options.recreateResourceCacheDirectory() val outDir = options.recreateResourceCacheDirectory()
logger.info("Decoding resources") logger.info("Decoding resources")
resourcesDecoder.decodeResources(outDir) resourcesDecoder.decodeResources(outDir)
resourcesDecoder.decodeManifest(outDir) resourcesDecoder.decodeManifest(outDir)
// Needed to record uncompressed files. // Needed to record uncompressed files.
val apkDecoder = ApkDecoder(options.resourceConfig, this) val apkDecoder = ApkDecoder(options.resourceConfig, this)
apkDecoder.recordUncompressedFiles(resourcesDecoder.resFileMapping) apkDecoder.recordUncompressedFiles(resourcesDecoder.resFileMapping)
usesFramework = UsesFramework().apply { usesFramework =
ids = resourcesDecoder.resTable.listFramePackages().map { it.id } 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. ResourceDecodingMode.MANIFEST_ONLY -> {
// XmlPullStreamDecoder.decodeManifest() sets metadata.apkInfo. logger.info("Decoding app manifest")
context.packageMetadata.let { metadata ->
metadata.packageName = resourcesDecoder.resTable.packageRenamed // Decode manually instead of using resourceDecoder.decodeManifest
versionInfo.let { // because it does not support decoding to an OutputStream.
metadata.packageVersion = it.versionName ?: it.versionCode 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, The ResTable if flagged as sparse if the main package is not loaded, which is the case here,
@@ -92,18 +94,16 @@ class ResourceContext internal constructor(
Set this to false again to prevent the ResTable from being flagged as sparse falsely. Set this to false again to prevent the ResTable from being flagged as sparse falsely.
*/ */
metadata.apkInfo.sparseResources = false metadata.apkInfo.sparseResources = false
}
} }
} }
} }
}
operator fun get(path: String) = options.resourceCachePath.resolve(path) operator fun get(path: String) = options.resourceCachePath.resolve(path)
override fun iterator() = options.resourceCachePath.walkTopDown().iterator() override fun iterator() = options.resourceCachePath.walkTopDown().iterator()
/** /**
* Compile resources from the [ResourceContext]. * Compile resources from the [ResourceContext].
* *
@@ -116,14 +116,17 @@ class ResourceContext internal constructor(
logger.info("Compiling modified resources") logger.info("Compiling modified resources")
val cacheDirectory = ExtFile(options.resourceCachePath) val cacheDirectory = ExtFile(options.resourceCachePath)
val aaptFile = cacheDirectory.resolve("aapt_temp_file").also { val aaptFile =
Files.deleteIfExists(it.toPath()) cacheDirectory.resolve("aapt_temp_file").also {
}.also { resourceFile = it } Files.deleteIfExists(it.toPath())
}.also { resourceFile = it }
try { try {
AaptInvoker( AaptInvoker(
options.resourceConfig, context.packageMetadata.apkInfo options.resourceConfig,
).invokeAapt(aaptFile, context.packageMetadata.apkInfo,
).invokeAapt(
aaptFile,
cacheDirectory.resolve("AndroidManifest.xml").also { cacheDirectory.resolve("AndroidManifest.xml").also {
ResXmlPatcher.fixingPublicAttrsInProviderAttributes(it) ResXmlPatcher.fixingPublicAttrsInProviderAttributes(it)
}, },
@@ -134,7 +137,8 @@ class ResourceContext internal constructor(
usesFramework.ids.map { id -> usesFramework.ids.map { id ->
Framework(options.resourceConfig).getFrameworkApk(id, usesFramework.tag) Framework(options.resourceConfig).getFrameworkApk(id, usesFramework.tag)
}.toTypedArray() }.toTypedArray()
}) },
)
} finally { } finally {
cacheDirectory.close() cacheDirectory.close()
} }
@@ -159,12 +163,10 @@ class ResourceContext internal constructor(
} }
inner class XmlFileHolder { inner class XmlFileHolder {
operator fun get(inputStream: InputStream) = operator fun get(inputStream: InputStream) = DomFileEditor(inputStream)
DomFileEditor(inputStream)
operator fun get(path: String): DomFileEditor { operator fun get(path: String): DomFileEditor {
return DomFileEditor(this@ResourceContext[path]) return DomFileEditor(this@ResourceContext[path])
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More