mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-29 14:11:03 +00:00
refactor: bump multidexlib2, dexlib2 and smali
This commit is contained in:
@@ -12,6 +12,7 @@ import lanchon.multidexlib2.MultiDexIO
|
||||
import org.jf.dexlib2.Opcodes
|
||||
import org.jf.dexlib2.iface.ClassDef
|
||||
import org.jf.dexlib2.iface.DexFile
|
||||
import org.jf.dexlib2.writer.io.MemoryDataStore
|
||||
import java.io.File
|
||||
|
||||
val NAMER = BasicDexFileNamer()
|
||||
@@ -19,12 +20,10 @@ val NAMER = BasicDexFileNamer()
|
||||
/**
|
||||
* ReVanced Patcher.
|
||||
* @param input The input file (an apk or any other multi dex container).
|
||||
* @param output The output folder.
|
||||
* @param signatures An array of method signatures for the patches
|
||||
*/
|
||||
class Patcher(
|
||||
input: File,
|
||||
private val output: File,
|
||||
signatures: Array<MethodSignature>,
|
||||
) {
|
||||
private val cache: Cache
|
||||
@@ -57,7 +56,7 @@ class Patcher(
|
||||
/**
|
||||
* Save the patched dex file.
|
||||
*/
|
||||
fun save() {
|
||||
fun save(): List<MemoryDataStore> {
|
||||
val newDexFile = object : DexFile {
|
||||
override fun getClasses(): Set<ClassDef> {
|
||||
// this is a slow workaround for now
|
||||
@@ -77,12 +76,14 @@ class Patcher(
|
||||
}
|
||||
}
|
||||
|
||||
val list = mutableListOf<MemoryDataStore>()
|
||||
MultiDexIO.writeDexFile(
|
||||
true, -1, // core count
|
||||
output, NAMER, newDexFile,
|
||||
list, NAMER, newDexFile,
|
||||
DexIO.DEFAULT_MAX_DEX_POOL_SIZE,
|
||||
null
|
||||
)
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package app.revanced.patcher.proxy.mutableTypes
|
||||
|
||||
import app.revanced.patcher.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
||||
import app.revanced.patcher.proxy.mutableTypes.MutableEncodedValue.Companion.toMutable
|
||||
import org.jf.dexlib2.HiddenApiRestriction
|
||||
import org.jf.dexlib2.base.reference.BaseFieldReference
|
||||
import org.jf.dexlib2.iface.Field
|
||||
|
||||
@@ -12,6 +13,7 @@ class MutableField(field: Field) : Field, BaseFieldReference() {
|
||||
private var accessFlags = field.accessFlags
|
||||
private var initialValue = field.initialValue?.toMutable()
|
||||
private val _annotations by lazy { field.annotations.map { annotation -> annotation.toMutable() }.toMutableSet() }
|
||||
private val _hiddenApiRestrictions by lazy { field.hiddenApiRestrictions }
|
||||
|
||||
fun setDefiningClass(definingClass: String) {
|
||||
this.definingClass = definingClass
|
||||
@@ -53,6 +55,10 @@ class MutableField(field: Field) : Field, BaseFieldReference() {
|
||||
return this.accessFlags
|
||||
}
|
||||
|
||||
override fun getHiddenApiRestrictions(): MutableSet<HiddenApiRestriction> {
|
||||
return this._hiddenApiRestrictions
|
||||
}
|
||||
|
||||
override fun getInitialValue(): MutableEncodedValue? {
|
||||
return this.initialValue
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package app.revanced.patcher.proxy.mutableTypes
|
||||
|
||||
import app.revanced.patcher.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
||||
import app.revanced.patcher.proxy.mutableTypes.MutableMethodParameter.Companion.toMutable
|
||||
import org.jf.dexlib2.HiddenApiRestriction
|
||||
import org.jf.dexlib2.base.reference.BaseMethodReference
|
||||
import org.jf.dexlib2.builder.MutableMethodImplementation
|
||||
import org.jf.dexlib2.iface.Method
|
||||
@@ -17,9 +18,10 @@ class MutableMethod(method: Method) : Method, BaseMethodReference() {
|
||||
private val _annotations by lazy { method.annotations.map { annotation -> annotation.toMutable() }.toMutableSet() }
|
||||
private val _parameters by lazy { method.parameters.map { parameter -> parameter.toMutable() }.toMutableList() }
|
||||
private val _parameterTypes by lazy { method.parameterTypes.toMutableList() }
|
||||
private val _hiddenApiRestrictions by lazy { method.hiddenApiRestrictions }
|
||||
|
||||
override fun getDefiningClass(): String {
|
||||
return this.definingClass
|
||||
return definingClass
|
||||
}
|
||||
|
||||
override fun getName(): String {
|
||||
@@ -42,6 +44,10 @@ class MutableMethod(method: Method) : Method, BaseMethodReference() {
|
||||
return accessFlags
|
||||
}
|
||||
|
||||
override fun getHiddenApiRestrictions(): MutableSet<HiddenApiRestriction> {
|
||||
return _hiddenApiRestrictions
|
||||
}
|
||||
|
||||
override fun getParameters(): MutableList<MutableMethodParameter> {
|
||||
return _parameters
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user