mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 01:02:22 +01:00
chore: merge branch dev
to main
(#139)
This commit is contained in:
commit
26b8621ac8
10 changed files with 6211 additions and 25 deletions
24
.github/workflows/pull_request.yml
vendored
Normal file
24
.github/workflows/pull_request.yml
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
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
|
9
.github/workflows/release.yml
vendored
9
.github/workflows/release.yml
vendored
|
@ -22,18 +22,19 @@ jobs:
|
|||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
distribution: 'zulu'
|
||||
cache: gradle
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
node-version: "latest"
|
||||
cache: 'npm'
|
||||
- name: Build with Gradle
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew build
|
||||
run: ./gradlew build --no-daemon
|
||||
- name: Setup semantic-release
|
||||
run: npm install -g semantic-release @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin -D
|
||||
run: npm install semantic-release @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin -D
|
||||
- name: Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -115,3 +115,6 @@ gradle-app.setting
|
|||
|
||||
# Avoid ignoring test resources
|
||||
!src/test/resources/*
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
|
@ -1,3 +1,10 @@
|
|||
## [6.3.1-dev.1](https://github.com/revanced/revanced-patcher/compare/v6.3.0...v6.3.1-dev.1) (2022-12-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* publicize types when merging files if necessary ([#137](https://github.com/revanced/revanced-patcher/issues/137)) ([9ec720e](https://github.com/revanced/revanced-patcher/commit/9ec720e983785d8b1dde330cc0e0e0f914c1803c))
|
||||
|
||||
# [6.3.0](https://github.com/revanced/revanced-patcher/compare/v6.2.0...v6.3.0) (2022-12-02)
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
kotlin.code.style = official
|
||||
version = 6.3.0
|
||||
version = 6.3.1-dev.1
|
||||
|
|
6107
package-lock.json
generated
Normal file
6107
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
8
package.json
Normal file
8
package.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"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"
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import app.revanced.patcher.extensions.PatchExtensions.patchName
|
|||
import app.revanced.patcher.extensions.nullOutputStream
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.patch.*
|
||||
import app.revanced.patcher.util.TypeUtil.traverseClassHierarchy
|
||||
import app.revanced.patcher.util.VersionReader
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass.Companion.toMutable
|
||||
|
@ -25,6 +26,7 @@ import brut.directory.ExtFile
|
|||
import lanchon.multidexlib2.BasicDexFileNamer
|
||||
import lanchon.multidexlib2.DexIO
|
||||
import lanchon.multidexlib2.MultiDexIO
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcodes
|
||||
import org.jf.dexlib2.iface.ClassDef
|
||||
import org.jf.dexlib2.iface.DexFile
|
||||
|
@ -105,6 +107,27 @@ class Patcher(private val options: PatcherOptions) {
|
|||
return transform(toMutableClass())
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the [AccessFlags.PUBLIC] flag is set.
|
||||
*
|
||||
* @return True, if the flag is set.
|
||||
*/
|
||||
fun Int.isPublic() = AccessFlags.PUBLIC.isSet(this)
|
||||
|
||||
/**
|
||||
* Make a class and its super class public recursively.
|
||||
*/
|
||||
fun MutableClass.publicize() {
|
||||
context.bytecodeContext.traverseClassHierarchy(this) {
|
||||
if (accessFlags.isPublic()) return@traverseClassHierarchy
|
||||
|
||||
accessFlags = accessFlags.or(AccessFlags.PUBLIC.value)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add missing methods to the class, considering to publicise the [ClassDef] if necessary.
|
||||
*/
|
||||
fun ClassDef.addMissingMethods(): ClassDef {
|
||||
fun getMissingMethods() = from.methods.filterNot {
|
||||
this@addMissingMethods.methods.any { original ->
|
||||
|
@ -120,11 +143,20 @@ class Patcher(private val options: PatcherOptions) {
|
|||
.map { it.toMutable() }
|
||||
.let { missingMethods ->
|
||||
this@addMissingMethods.transformClass { classDef ->
|
||||
classDef.apply { methods.addAll(missingMethods) }
|
||||
classDef.apply {
|
||||
// make sure the class is public, if the class contains public methods
|
||||
if (missingMethods.any { it.accessFlags.isPublic() })
|
||||
classDef.publicize()
|
||||
|
||||
methods.addAll(missingMethods)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add missing fields to the class, considering to publicise the [ClassDef] if necessary.
|
||||
*/
|
||||
fun ClassDef.addMissingFields(): ClassDef {
|
||||
fun getMissingFields() = from.fields.filterNot {
|
||||
this@addMissingFields.fields.any { original -> original.name == it.name }
|
||||
|
@ -137,6 +169,10 @@ class Patcher(private val options: PatcherOptions) {
|
|||
.map { it.toMutable() }
|
||||
.let { missingFields ->
|
||||
this@addMissingFields.transformClass { classDef ->
|
||||
// make sure the class is public, if the class contains public fields
|
||||
if (missingFields.any { it.accessFlags.isPublic() })
|
||||
classDef.publicize()
|
||||
|
||||
classDef.apply { fields.addAll(missingFields) }
|
||||
}
|
||||
}
|
||||
|
|
19
src/main/kotlin/app/revanced/patcher/util/TypeUtil.kt
Normal file
19
src/main/kotlin/app/revanced/patcher/util/TypeUtil.kt
Normal file
|
@ -0,0 +1,19 @@
|
|||
package app.revanced.patcher.util
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
||||
|
||||
object TypeUtil {
|
||||
/**
|
||||
* traverse the class hierarchy starting from the given root class
|
||||
*
|
||||
* @param targetClass the class to start traversing the class hierarchy from
|
||||
* @param callback function that is called for every class in the hierarchy
|
||||
*/
|
||||
fun BytecodeContext.traverseClassHierarchy(targetClass: MutableClass, callback: MutableClass.() -> Unit) {
|
||||
callback(targetClass)
|
||||
this.findClass(targetClass.superclass ?: return)?.mutableClass?.let {
|
||||
traverseClassHierarchy(it, callback)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package app.revanced.patcher.util
|
||||
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class VersionReaderTest {
|
||||
@Test
|
||||
fun read() {
|
||||
val version = VersionReader.read()
|
||||
assertNotNull(version)
|
||||
assertTrue(version.isNotEmpty())
|
||||
val parts = version.split(".")
|
||||
assertEquals(3, parts.size)
|
||||
parts.forEach {
|
||||
assertTrue(it.toInt() >= 0)
|
||||
}
|
||||
println(version)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue