-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: Removed usage of ASM library
- Loading branch information
Showing
25 changed files
with
591 additions
and
542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/app/revanced/patcher/cache/proxy/ClassProxy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package app.revanced.patcher.cache.proxy | ||
|
||
import app.revanced.patcher.cache.proxy.mutableTypes.MutableClass | ||
import org.jf.dexlib2.iface.ClassDef | ||
|
||
|
||
class ClassProxy( | ||
val immutableClass: ClassDef, | ||
val originalClassIndex: Int, | ||
) { | ||
internal var proxyused = false | ||
internal lateinit var mutatedClass: MutableClass | ||
|
||
fun resolve(): MutableClass { | ||
if (!proxyused) { | ||
proxyused = true | ||
mutatedClass = MutableClass(immutableClass) | ||
} | ||
return mutatedClass | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/app/revanced/patcher/cache/proxy/mutableTypes/MutableAnnotation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package app.revanced.patcher.cache.proxy.mutableTypes | ||
|
||
import app.revanced.patcher.cache.proxy.mutableTypes.MutableAnnotationElement.Companion.toMutable | ||
import org.jf.dexlib2.base.BaseAnnotation | ||
import org.jf.dexlib2.iface.Annotation | ||
|
||
class MutableAnnotation(annotation: Annotation) : BaseAnnotation() { | ||
private val visibility = annotation.visibility | ||
private val type = annotation.type | ||
private val elements = annotation.elements.map { element -> element.toMutable() }.toMutableSet() | ||
|
||
override fun getType(): String { | ||
return type | ||
} | ||
|
||
override fun getElements(): MutableSet<MutableAnnotationElement> { | ||
return elements | ||
} | ||
|
||
override fun getVisibility(): Int { | ||
return visibility | ||
} | ||
|
||
companion object { | ||
fun Annotation.toMutable(): MutableAnnotation { | ||
return MutableAnnotation(this) | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/app/revanced/patcher/cache/proxy/mutableTypes/MutableAnnotationElement.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package app.revanced.patcher.cache.proxy.mutableTypes | ||
|
||
import app.revanced.patcher.cache.proxy.mutableTypes.MutableEncodedValue.Companion.toMutable | ||
import org.jf.dexlib2.base.BaseAnnotationElement | ||
import org.jf.dexlib2.iface.AnnotationElement | ||
import org.jf.dexlib2.iface.value.EncodedValue | ||
|
||
class MutableAnnotationElement(annotationElement: AnnotationElement) : BaseAnnotationElement() { | ||
private var name = annotationElement.name | ||
private var value = annotationElement.value.toMutable() | ||
|
||
fun setName(name: String) { | ||
this.name = name | ||
} | ||
|
||
fun setValue(value: MutableEncodedValue) { | ||
this.value = value | ||
} | ||
|
||
override fun getName(): String { | ||
return name | ||
} | ||
|
||
override fun getValue(): EncodedValue { | ||
return value | ||
} | ||
|
||
companion object { | ||
fun AnnotationElement.toMutable(): MutableAnnotationElement { | ||
return MutableAnnotationElement(this) | ||
} | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
src/main/kotlin/app/revanced/patcher/cache/proxy/mutableTypes/MutableClass.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package app.revanced.patcher.cache.proxy.mutableTypes | ||
|
||
import app.revanced.patcher.cache.proxy.mutableTypes.MutableAnnotation.Companion.toMutable | ||
import app.revanced.patcher.cache.proxy.mutableTypes.MutableField.Companion.toMutable | ||
import app.revanced.patcher.cache.proxy.mutableTypes.MutableMethod.Companion.toMutable | ||
import org.jf.dexlib2.base.reference.BaseTypeReference | ||
import org.jf.dexlib2.iface.ClassDef | ||
|
||
class MutableClass(classDef: ClassDef) : ClassDef, BaseTypeReference() { | ||
// Class | ||
private var type = classDef.type | ||
private var sourceFile = classDef.sourceFile | ||
private var accessFlags = classDef.accessFlags | ||
private var superclass = classDef.superclass | ||
|
||
private val interfaces = classDef.interfaces.toMutableList() | ||
private val annotations = classDef.annotations.map { annotation -> annotation.toMutable() }.toMutableSet() | ||
|
||
// Methods | ||
private val methods = classDef.methods.map { method -> method.toMutable() }.toMutableSet() | ||
private val directMethods = classDef.directMethods.map { directMethod -> directMethod.toMutable() }.toMutableSet() | ||
private val virtualMethods = | ||
classDef.virtualMethods.map { virtualMethod -> virtualMethod.toMutable() }.toMutableSet() | ||
|
||
// Fields | ||
private val fields = classDef.fields.map { field -> field.toMutable() }.toMutableSet() | ||
private val staticFields = classDef.staticFields.map { staticField -> staticField.toMutable() }.toMutableSet() | ||
private val instanceFields = | ||
classDef.instanceFields.map { instanceFields -> instanceFields.toMutable() }.toMutableSet() | ||
|
||
fun setType(type: String) { | ||
this.type = type | ||
} | ||
|
||
fun setSourceFile(sourceFile: String?) { | ||
this.sourceFile = sourceFile | ||
} | ||
|
||
fun setAccessFlags(accessFlags: Int) { | ||
this.accessFlags = accessFlags | ||
} | ||
|
||
fun setSuperClass(superclass: String?) { | ||
this.superclass = superclass | ||
} | ||
|
||
override fun getType(): String { | ||
return type | ||
} | ||
|
||
override fun getAccessFlags(): Int { | ||
return accessFlags | ||
} | ||
|
||
override fun getSourceFile(): String? { | ||
return sourceFile | ||
} | ||
|
||
override fun getSuperclass(): String? { | ||
return superclass | ||
} | ||
|
||
override fun getInterfaces(): MutableList<String> { | ||
return interfaces | ||
} | ||
|
||
override fun getAnnotations(): MutableSet<MutableAnnotation> { | ||
return annotations | ||
} | ||
|
||
override fun getStaticFields(): MutableSet<MutableField> { | ||
return staticFields | ||
} | ||
|
||
override fun getInstanceFields(): MutableSet<MutableField> { | ||
return instanceFields | ||
} | ||
|
||
override fun getFields(): MutableSet<MutableField> { | ||
return fields | ||
} | ||
|
||
override fun getDirectMethods(): MutableSet<MutableMethod> { | ||
return directMethods | ||
} | ||
|
||
override fun getVirtualMethods(): MutableSet<MutableMethod> { | ||
return virtualMethods | ||
} | ||
|
||
override fun getMethods(): MutableSet<MutableMethod> { | ||
return methods | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/app/revanced/patcher/cache/proxy/mutableTypes/MutableEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package app.revanced.patcher.cache.proxy.mutableTypes | ||
|
||
import org.jf.dexlib2.iface.value.EncodedValue | ||
|
||
class MutableEncodedValue(encodedValue: EncodedValue) : EncodedValue { | ||
private var valueType = encodedValue.valueType | ||
|
||
fun setValueType(valueType: Int) { | ||
this.valueType = valueType | ||
} | ||
|
||
override fun compareTo(other: EncodedValue): Int { | ||
return valueType - other.valueType | ||
|
||
} | ||
|
||
override fun getValueType(): Int { | ||
return valueType | ||
} | ||
|
||
companion object { | ||
fun EncodedValue.toMutable(): MutableEncodedValue { | ||
return MutableEncodedValue(this) | ||
} | ||
} | ||
} |
Oops, something went wrong.