From 3f97cc8e1fa10546d7069e01e5e66a537b0d6f7e Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 13 Apr 2022 00:19:09 +0200 Subject: [PATCH] feat: remaining mutable `EncodedValue` classes --- .../kotlin/app/revanced/patcher/Patcher.kt | 9 +++-- .../mutableTypes/MutableAnnotationElement.kt | 3 +- .../proxy/mutableTypes/MutableClass.kt | 6 ++++ .../proxy/mutableTypes/MutableEncodedValue.kt | 28 ---------------- .../proxy/mutableTypes/MutableField.kt | 4 ++- .../MutableAnnotationEncodedValue.kt | 33 +++++++++++++++++++ .../encodedValue/MutableArrayEncodedValue.kt | 22 +++++++++++++ .../MutableBooleanEncodedValue.kt | 23 +++++++++++++ .../encodedValue/MutableByteEncodedValue.kt | 22 +++++++++++++ .../encodedValue/MutableCharEncodedValue.kt | 22 +++++++++++++ .../encodedValue/MutableDoubleEncodedValue.kt | 23 +++++++++++++ .../encodedValue/MutableEncodedValue.kt | 32 ++++++++++++++++++ .../encodedValue/MutableEnumEncodedValue.kt | 23 +++++++++++++ .../encodedValue/MutableFieldEncodedValue.kt | 28 ++++++++++++++++ .../encodedValue/MutableFloatEncodedValue.kt | 22 +++++++++++++ .../encodedValue/MutableIntEncodedValue.kt | 22 +++++++++++++ .../encodedValue/MutableLongEncodedValue.kt | 22 +++++++++++++ .../encodedValue/MutableMethodEncodedValue.kt | 24 ++++++++++++++ .../MutableMethodHandleEncodedValue.kt | 27 +++++++++++++++ .../MutableMethodTypeEncodedValue.kt | 26 +++++++++++++++ .../encodedValue/MutableNullEncodedValue.kt | 12 +++++++ .../encodedValue/MutableShortEncodedValue.kt | 22 +++++++++++++ .../encodedValue/MutableStringEncodedValue.kt | 24 ++++++++++++++ .../encodedValue/MutableTypeEncodedValue.kt | 22 +++++++++++++ 24 files changed, 469 insertions(+), 32 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableAnnotationEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableArrayEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableBooleanEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableByteEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableCharEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableDoubleEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableEnumEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableFieldEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableFloatEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableIntEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableLongEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodHandleEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodTypeEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableNullEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableShortEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableStringEncodedValue.kt create mode 100644 src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableTypeEncodedValue.kt diff --git a/src/main/kotlin/app/revanced/patcher/Patcher.kt b/src/main/kotlin/app/revanced/patcher/Patcher.kt index cee9a38..956f76d 100644 --- a/src/main/kotlin/app/revanced/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/patcher/Patcher.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.cache.Cache import app.revanced.patcher.cache.findIndexed import app.revanced.patcher.patch.Patch import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.signature.resolver.SignatureResolver import app.revanced.patcher.signature.MethodSignature +import app.revanced.patcher.signature.resolver.SignatureResolver import app.revanced.patcher.util.ListBackedSet import lanchon.multidexlib2.BasicDexFileNamer import lanchon.multidexlib2.DexIO @@ -37,6 +37,7 @@ class Patcher( opcodes = dexFile.opcodes cache = Cache(dexFile.classes.toMutableList()) } + /** * Add additional dex file container to the patcher. * @param files The dex file containers to add to the patcher. @@ -66,6 +67,7 @@ class Patcher( } } } + /** * Save the patched dex file. */ @@ -113,7 +115,10 @@ class Patcher( * PatchResultSuccess will always be returned in the wrapping Result object. * If the patch failed to apply, an Exception will always be returned in the wrapping Result object. */ - fun applyPatches(stopOnError: Boolean = false, callback: (String) -> Unit = {}): Map> { + fun applyPatches( + stopOnError: Boolean = false, + callback: (String) -> Unit = {} + ): Map> { if (!sigsResolved) { SignatureResolver(cache.classes, signatures).resolve(cache.methodMap) sigsResolved = true diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableAnnotationElement.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableAnnotationElement.kt index 87f3120..85354fe 100644 --- a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableAnnotationElement.kt +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableAnnotationElement.kt @@ -1,6 +1,7 @@ package app.revanced.patcher.proxy.mutableTypes -import app.revanced.patcher.proxy.mutableTypes.MutableEncodedValue.Companion.toMutable +import app.revanced.patcher.proxy.mutableTypes.encodedValue.MutableEncodedValue +import app.revanced.patcher.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable import org.jf.dexlib2.base.BaseAnnotationElement import org.jf.dexlib2.iface.AnnotationElement import org.jf.dexlib2.iface.value.EncodedValue diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableClass.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableClass.kt index af5928f..eadab5f 100644 --- a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableClass.kt +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableClass.kt @@ -94,4 +94,10 @@ class MutableClass(classDef: ClassDef) : ClassDef, BaseTypeReference() { override fun getMethods(): MutableSet { return _methods } + + companion object { + fun ClassDef.toMutable(): MutableClass { + return MutableClass(this) + } + } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableEncodedValue.kt deleted file mode 100644 index bed7ea7..0000000 --- a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableEncodedValue.kt +++ /dev/null @@ -1,28 +0,0 @@ -package app.revanced.patcher.proxy.mutableTypes - -import org.jf.dexlib2.iface.value.EncodedValue - -// TODO: We need to create implementations for the interfaces -// TypeEncodedValue, FieldEncodedValue, MethodEncodedValue, -// EnumEncodedValue, ArrayEncodedValue and AnnotationEncodedValue or the cast back to the immutable type will fail -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) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableField.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableField.kt index cfd755a..34c445a 100644 --- a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableField.kt +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableField.kt @@ -1,7 +1,8 @@ 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 app.revanced.patcher.proxy.mutableTypes.encodedValue.MutableEncodedValue +import app.revanced.patcher.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable import org.jf.dexlib2.HiddenApiRestriction import org.jf.dexlib2.base.reference.BaseFieldReference import org.jf.dexlib2.iface.Field @@ -11,6 +12,7 @@ class MutableField(field: Field) : Field, BaseFieldReference() { private var name = field.name private var type = field.type 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 } diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableAnnotationEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableAnnotationEncodedValue.kt new file mode 100644 index 0000000..e62e573 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableAnnotationEncodedValue.kt @@ -0,0 +1,33 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import app.revanced.patcher.proxy.mutableTypes.MutableAnnotationElement.Companion.toMutable +import org.jf.dexlib2.base.value.BaseAnnotationEncodedValue +import org.jf.dexlib2.iface.AnnotationElement +import org.jf.dexlib2.iface.value.AnnotationEncodedValue + +class MutableAnnotationEncodedValue(annotationEncodedValue: AnnotationEncodedValue) : BaseAnnotationEncodedValue(), + MutableEncodedValue { + private var type = annotationEncodedValue.type + + private val _elements by lazy { + annotationEncodedValue.elements.map { annotationElement -> annotationElement.toMutable() }.toMutableSet() + } + + override fun getType(): String { + return this.type + } + + fun setType(type: String) { + this.type = type + } + + override fun getElements(): MutableSet { + return _elements + } + + companion object { + fun AnnotationEncodedValue.toMutable(): MutableAnnotationEncodedValue { + return MutableAnnotationEncodedValue(this) + } + } +} diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableArrayEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableArrayEncodedValue.kt new file mode 100644 index 0000000..268e78e --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableArrayEncodedValue.kt @@ -0,0 +1,22 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import app.revanced.patcher.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable +import org.jf.dexlib2.base.value.BaseArrayEncodedValue +import org.jf.dexlib2.iface.value.ArrayEncodedValue +import org.jf.dexlib2.iface.value.EncodedValue + +class MutableArrayEncodedValue(arrayEncodedValue: ArrayEncodedValue) : BaseArrayEncodedValue(), MutableEncodedValue { + private val _value by lazy { + arrayEncodedValue.value.map { encodedValue -> encodedValue.toMutable() }.toMutableList() + } + + override fun getValue(): MutableList { + return _value + } + + companion object { + fun ArrayEncodedValue.toMutable(): MutableArrayEncodedValue { + return MutableArrayEncodedValue(this) + } + } +} diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableBooleanEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableBooleanEncodedValue.kt new file mode 100644 index 0000000..d6377af --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableBooleanEncodedValue.kt @@ -0,0 +1,23 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseBooleanEncodedValue +import org.jf.dexlib2.iface.value.BooleanEncodedValue + +class MutableBooleanEncodedValue(booleanEncodedValue: BooleanEncodedValue) : BaseBooleanEncodedValue(), + MutableEncodedValue { + private var value = booleanEncodedValue.value + + override fun getValue(): Boolean { + return this.value + } + + fun setValue(value: Boolean) { + this.value = value + } + + companion object { + fun BooleanEncodedValue.toMutable(): MutableBooleanEncodedValue { + return MutableBooleanEncodedValue(this) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableByteEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableByteEncodedValue.kt new file mode 100644 index 0000000..61757c4 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableByteEncodedValue.kt @@ -0,0 +1,22 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseByteEncodedValue +import org.jf.dexlib2.iface.value.ByteEncodedValue + +class MutableByteEncodedValue(byteEncodedValue: ByteEncodedValue) : BaseByteEncodedValue(), MutableEncodedValue { + private var value = byteEncodedValue.value + + override fun getValue(): Byte { + return this.value + } + + fun setValue(value: Byte) { + this.value = value + } + + companion object { + fun ByteEncodedValue.toMutable(): MutableByteEncodedValue { + return MutableByteEncodedValue(this) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableCharEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableCharEncodedValue.kt new file mode 100644 index 0000000..c3cb3ee --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableCharEncodedValue.kt @@ -0,0 +1,22 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseCharEncodedValue +import org.jf.dexlib2.iface.value.CharEncodedValue + +class MutableCharEncodedValue(charEncodedValue: CharEncodedValue) : BaseCharEncodedValue(), MutableEncodedValue { + private var value = charEncodedValue.value + + override fun getValue(): Char { + return this.value + } + + fun setValue(value: Char) { + this.value = value + } + + companion object { + fun CharEncodedValue.toMutable(): MutableCharEncodedValue { + return MutableCharEncodedValue(this) + } + } +} diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableDoubleEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableDoubleEncodedValue.kt new file mode 100644 index 0000000..ddfb07b --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableDoubleEncodedValue.kt @@ -0,0 +1,23 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseDoubleEncodedValue +import org.jf.dexlib2.iface.value.DoubleEncodedValue + +class MutableDoubleEncodedValue(doubleEncodedValue: DoubleEncodedValue) : BaseDoubleEncodedValue(), + MutableEncodedValue { + private var value = doubleEncodedValue.value + + override fun getValue(): Double { + return this.value + } + + fun setValue(value: Double) { + this.value = value + } + + companion object { + fun DoubleEncodedValue.toMutable(): MutableDoubleEncodedValue { + return MutableDoubleEncodedValue(this) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableEncodedValue.kt new file mode 100644 index 0000000..0f170bf --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableEncodedValue.kt @@ -0,0 +1,32 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.ValueType +import org.jf.dexlib2.iface.value.* + +interface MutableEncodedValue : EncodedValue { + companion object { + fun EncodedValue.toMutable(): MutableEncodedValue { + return when (this.valueType) { + ValueType.TYPE -> MutableTypeEncodedValue(this as TypeEncodedValue) + ValueType.FIELD -> MutableFieldEncodedValue(this as FieldEncodedValue) + ValueType.METHOD -> MutableMethodEncodedValue(this as MethodEncodedValue) + ValueType.ENUM -> MutableEnumEncodedValue(this as EnumEncodedValue) + ValueType.ARRAY -> MutableArrayEncodedValue(this as ArrayEncodedValue) + ValueType.ANNOTATION -> MutableAnnotationEncodedValue(this as AnnotationEncodedValue) + ValueType.BYTE -> MutableByteEncodedValue(this as ByteEncodedValue) + ValueType.SHORT -> MutableShortEncodedValue(this as ShortEncodedValue) + ValueType.CHAR -> MutableCharEncodedValue(this as CharEncodedValue) + ValueType.INT -> MutableIntEncodedValue(this as IntEncodedValue) + ValueType.LONG -> MutableLongEncodedValue(this as LongEncodedValue) + ValueType.FLOAT -> MutableFloatEncodedValue(this as FloatEncodedValue) + ValueType.DOUBLE -> MutableDoubleEncodedValue(this as DoubleEncodedValue) + ValueType.METHOD_TYPE -> MutableMethodTypeEncodedValue(this as MethodTypeEncodedValue) + ValueType.METHOD_HANDLE -> MutableMethodHandleEncodedValue(this as MethodHandleEncodedValue) + ValueType.STRING -> MutableStringEncodedValue(this as StringEncodedValue) + ValueType.BOOLEAN -> MutableBooleanEncodedValue(this as BooleanEncodedValue) + ValueType.NULL -> MutableNullEncodedValue() + else -> this as MutableEncodedValue + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableEnumEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableEnumEncodedValue.kt new file mode 100644 index 0000000..d9fbdb9 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableEnumEncodedValue.kt @@ -0,0 +1,23 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseEnumEncodedValue +import org.jf.dexlib2.iface.reference.FieldReference +import org.jf.dexlib2.iface.value.EnumEncodedValue + +class MutableEnumEncodedValue(enumEncodedValue: EnumEncodedValue) : BaseEnumEncodedValue(), MutableEncodedValue { + private var value = enumEncodedValue.value + + override fun getValue(): FieldReference { + return this.value + } + + fun setValue(value: FieldReference) { + this.value = value + } + + companion object { + fun EnumEncodedValue.toMutable(): MutableEnumEncodedValue { + return MutableEnumEncodedValue(this) + } + } +} diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableFieldEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableFieldEncodedValue.kt new file mode 100644 index 0000000..34d9b90 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableFieldEncodedValue.kt @@ -0,0 +1,28 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.ValueType +import org.jf.dexlib2.base.value.BaseFieldEncodedValue +import org.jf.dexlib2.iface.reference.FieldReference +import org.jf.dexlib2.iface.value.FieldEncodedValue + +class MutableFieldEncodedValue(fieldEncodedValue: FieldEncodedValue) : BaseFieldEncodedValue(), MutableEncodedValue { + private var value = fieldEncodedValue.value + + override fun getValueType(): Int { + return ValueType.FIELD + } + + override fun getValue(): FieldReference { + return this.value + } + + fun setValue(value: FieldReference) { + this.value = value + } + + companion object { + fun FieldEncodedValue.toMutable(): MutableFieldEncodedValue { + return MutableFieldEncodedValue(this) + } + } +} diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableFloatEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableFloatEncodedValue.kt new file mode 100644 index 0000000..c2fff54 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableFloatEncodedValue.kt @@ -0,0 +1,22 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseFloatEncodedValue +import org.jf.dexlib2.iface.value.FloatEncodedValue + +class MutableFloatEncodedValue(floatEncodedValue: FloatEncodedValue) : BaseFloatEncodedValue(), MutableEncodedValue { + private var value = floatEncodedValue.value + + override fun getValue(): Float { + return this.value + } + + fun setValue(value: Float) { + this.value = value + } + + companion object { + fun FloatEncodedValue.toMutable(): MutableFloatEncodedValue { + return MutableFloatEncodedValue(this) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableIntEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableIntEncodedValue.kt new file mode 100644 index 0000000..d5918c6 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableIntEncodedValue.kt @@ -0,0 +1,22 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseIntEncodedValue +import org.jf.dexlib2.iface.value.IntEncodedValue + +class MutableIntEncodedValue(intEncodedValue: IntEncodedValue) : BaseIntEncodedValue(), MutableEncodedValue { + private var value = intEncodedValue.value + + override fun getValue(): Int { + return this.value + } + + fun setValue(value: Int) { + this.value = value + } + + companion object { + fun IntEncodedValue.toMutable(): MutableIntEncodedValue { + return MutableIntEncodedValue(this) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableLongEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableLongEncodedValue.kt new file mode 100644 index 0000000..190a2d8 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableLongEncodedValue.kt @@ -0,0 +1,22 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseLongEncodedValue +import org.jf.dexlib2.iface.value.LongEncodedValue + +class MutableLongEncodedValue(longEncodedValue: LongEncodedValue) : BaseLongEncodedValue(), MutableEncodedValue { + private var value = longEncodedValue.value + + override fun getValue(): Long { + return this.value + } + + fun setValue(value: Long) { + this.value = value + } + + companion object { + fun LongEncodedValue.toMutable(): MutableLongEncodedValue { + return MutableLongEncodedValue(this) + } + } +} diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodEncodedValue.kt new file mode 100644 index 0000000..24f0ba0 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodEncodedValue.kt @@ -0,0 +1,24 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseMethodEncodedValue +import org.jf.dexlib2.iface.reference.MethodReference +import org.jf.dexlib2.iface.value.MethodEncodedValue + +class MutableMethodEncodedValue(methodEncodedValue: MethodEncodedValue) : BaseMethodEncodedValue(), + MutableEncodedValue { + private var value = methodEncodedValue.value + + override fun getValue(): MethodReference { + return this.value + } + + fun setValue(value: MethodReference) { + this.value = value + } + + companion object { + fun MethodEncodedValue.toMutable(): MutableMethodEncodedValue { + return MutableMethodEncodedValue(this) + } + } +} diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodHandleEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodHandleEncodedValue.kt new file mode 100644 index 0000000..54ba088 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodHandleEncodedValue.kt @@ -0,0 +1,27 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseMethodHandleEncodedValue +import org.jf.dexlib2.iface.reference.MethodHandleReference +import org.jf.dexlib2.iface.value.MethodHandleEncodedValue + +class MutableMethodHandleEncodedValue(methodHandleEncodedValue: MethodHandleEncodedValue) : + BaseMethodHandleEncodedValue(), + MutableEncodedValue { + private var value = methodHandleEncodedValue.value + + override fun getValue(): MethodHandleReference { + return this.value + } + + fun setValue(value: MethodHandleReference) { + this.value = value + } + + companion object { + fun MethodHandleEncodedValue.toMutable(): MutableMethodHandleEncodedValue { + return MutableMethodHandleEncodedValue(this) + } + } + + +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodTypeEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodTypeEncodedValue.kt new file mode 100644 index 0000000..dded228 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableMethodTypeEncodedValue.kt @@ -0,0 +1,26 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseMethodTypeEncodedValue +import org.jf.dexlib2.iface.reference.MethodProtoReference +import org.jf.dexlib2.iface.value.MethodTypeEncodedValue + +class MutableMethodTypeEncodedValue(methodTypeEncodedValue: MethodTypeEncodedValue) : BaseMethodTypeEncodedValue(), + MutableEncodedValue { + private var value = methodTypeEncodedValue.value + + override fun getValue(): MethodProtoReference { + return this.value + } + + fun setValue(value: MethodProtoReference) { + this.value = value + } + + companion object { + fun MethodTypeEncodedValue.toMutable(): MutableMethodTypeEncodedValue { + return MutableMethodTypeEncodedValue(this) + } + } + + +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableNullEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableNullEncodedValue.kt new file mode 100644 index 0000000..cce128d --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableNullEncodedValue.kt @@ -0,0 +1,12 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseNullEncodedValue +import org.jf.dexlib2.iface.value.ByteEncodedValue + +class MutableNullEncodedValue : BaseNullEncodedValue(), MutableEncodedValue { + companion object { + fun ByteEncodedValue.toMutable(): MutableByteEncodedValue { + return MutableByteEncodedValue(this) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableShortEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableShortEncodedValue.kt new file mode 100644 index 0000000..e8c0f74 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableShortEncodedValue.kt @@ -0,0 +1,22 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseShortEncodedValue +import org.jf.dexlib2.iface.value.ShortEncodedValue + +class MutableShortEncodedValue(shortEncodedValue: ShortEncodedValue) : BaseShortEncodedValue(), MutableEncodedValue { + private var value = shortEncodedValue.value + + override fun getValue(): Short { + return this.value + } + + fun setValue(value: Short) { + this.value = value + } + + companion object { + fun ShortEncodedValue.toMutable(): MutableShortEncodedValue { + return MutableShortEncodedValue(this) + } + } +} diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableStringEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableStringEncodedValue.kt new file mode 100644 index 0000000..f02acc4 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableStringEncodedValue.kt @@ -0,0 +1,24 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseStringEncodedValue +import org.jf.dexlib2.iface.value.ByteEncodedValue +import org.jf.dexlib2.iface.value.StringEncodedValue + +class MutableStringEncodedValue(stringEncodedValue: StringEncodedValue) : BaseStringEncodedValue(), + MutableEncodedValue { + private var value = stringEncodedValue.value + + override fun getValue(): String { + return this.value + } + + fun setValue(value: String) { + this.value = value + } + + companion object { + fun ByteEncodedValue.toMutable(): MutableByteEncodedValue { + return MutableByteEncodedValue(this) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableTypeEncodedValue.kt b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableTypeEncodedValue.kt new file mode 100644 index 0000000..6f56a33 --- /dev/null +++ b/src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableTypeEncodedValue.kt @@ -0,0 +1,22 @@ +package app.revanced.patcher.proxy.mutableTypes.encodedValue + +import org.jf.dexlib2.base.value.BaseTypeEncodedValue +import org.jf.dexlib2.iface.value.TypeEncodedValue + +class MutableTypeEncodedValue(typeEncodedValue: TypeEncodedValue) : BaseTypeEncodedValue(), MutableEncodedValue { + private var value = typeEncodedValue.value + + override fun getValue(): String { + return this.value + } + + fun setValue(value: String) { + this.value = value + } + + companion object { + fun TypeEncodedValue.toMutable(): MutableTypeEncodedValue { + return MutableTypeEncodedValue(this) + } + } +}