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

Compare commits

...

7 Commits

Author SHA1 Message Date
semantic-release-bot
76c262ff12 chore(release): 20.0.0-dev.2 [skip ci]
# [20.0.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v20.0.0-dev.1...v20.0.0-dev.2) (2024-07-31)

### Bug Fixes

* Downgrade smali to fix dex compilation issue ([714447d](714447de70))
* Merge all extensions before initializing lookup maps ([328aa87](328aa876d8))
* Use null for compatible package version when adding packages only ([a8e8fa4](a8e8fa4093))
2024-07-31 00:27:24 +00:00
oSumAtrIX
714447de70 fix: Downgrade smali to fix dex compilation issue 2024-07-31 02:25:32 +02:00
oSumAtrIX
328aa876d8 fix: Merge all extensions before initializing lookup maps 2024-07-26 04:45:31 +02:00
oSumAtrIX
a8e8fa4093 fix: Use null for compatible package version when adding packages only 2024-07-26 03:41:32 +02:00
oSumAtrIX
c482dff17c refactor: Convert method bodies to single expression functions 2024-07-26 03:10:08 +02:00
oSumAtrIX
e6de1f6b4c build(Needs bump): Bump dependencies 2024-07-26 03:09:32 +02:00
oSumAtrIX
82a2b3c371 docs: Fix syntax issues and improve wording 2024-07-23 19:55:30 +02:00
34 changed files with 269 additions and 328 deletions

View File

@@ -1,3 +1,12 @@
# [20.0.0-dev.2](https://github.com/ReVanced/revanced-patcher/compare/v20.0.0-dev.1...v20.0.0-dev.2) (2024-07-31)
### Bug Fixes
* Downgrade smali to fix dex compilation issue ([714447d](https://github.com/ReVanced/revanced-patcher/commit/714447de70096bf736e8e1d31c14bb5f24195070))
* Merge all extensions before initializing lookup maps ([328aa87](https://github.com/ReVanced/revanced-patcher/commit/328aa876d8ed7826be3713754b6404195e9fe84b))
* Use null for compatible package version when adding packages only ([a8e8fa4](https://github.com/ReVanced/revanced-patcher/commit/a8e8fa4093deb8cffbd7a582409f41867f6b568b))
# [20.0.0-dev.1](https://github.com/ReVanced/revanced-patcher/compare/v19.3.1...v20.0.0-dev.1) (2024-07-22)

View File

@@ -67,7 +67,8 @@ public final class app/revanced/patcher/PatcherConfig {
public synthetic fun <init> (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
}
public final class app/revanced/patcher/PatcherContext {
public final class app/revanced/patcher/PatcherContext : java/io/Closeable {
public fun close ()V
public final fun getPackageMetadata ()Lapp/revanced/patcher/PackageMetadata;
}
@@ -152,9 +153,10 @@ public final class app/revanced/patcher/patch/BytecodePatchBuilder$InvokedFinger
public final fun getValue (Ljava/lang/Void;Lkotlin/reflect/KProperty;)Lapp/revanced/patcher/Match;
}
public final class app/revanced/patcher/patch/BytecodePatchContext : app/revanced/patcher/patch/PatchContext {
public final class app/revanced/patcher/patch/BytecodePatchContext : app/revanced/patcher/patch/PatchContext, java/io/Closeable {
public final fun classBy (Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/util/proxy/ClassProxy;
public final fun classByType (Ljava/lang/String;)Lapp/revanced/patcher/util/proxy/ClassProxy;
public fun close ()V
public synthetic fun get ()Ljava/lang/Object;
public fun get ()Ljava/util/Set;
public final fun getClasses ()Lapp/revanced/patcher/util/ProxyClassList;

View File

@@ -115,9 +115,9 @@ val disableAdsPatch = bytecodePatch(
Patches can have options to get and set before a patch is executed.
Options are useful for making patches configurable.
After loading the patches using `PatchLoader`, options can be set for a patch.
Multiple types are already inbuilt in ReVanced Patcher and are supported by any application that uses ReVanced Patcher.
Multiple types are already built into ReVanced Patcher and are supported by any application that uses ReVanced Patcher.
To define an option, use available `option` functions:
To define an option, use the available `option` functions:
```kt
val patch = bytecodePatch(name = "Patch") {
@@ -151,7 +151,7 @@ option.type // The KType of the option.
### 🧩 Extensions
An extension is a precompiled DEX file that is merged into the patched app before a patch is executed.
An extension is a precompiled DEX file merged into the patched app before a patch is executed.
While patches are compile-time constructs, extensions are runtime constructs
that extend the patched app with additional classes.
@@ -232,13 +232,13 @@ The same order is followed for multiple patches depending on the patch.
## 💡 Additional tips
- When using ´PatchLoader` to load patches, only patches with a name are loaded.
- When using `PatchLoader` to load patches, only patches with a name are loaded.
Refer to the inline documentation of `PatchLoader` for detailed information.
- Patches can depend on others. Dependencies are executed first.
The dependent patch will not be executed if a dependency raises an exception while executing.
- A patch can declare compatibility with specific packages and versions,
but patches can still be executed on any package or version.
It is recommended to declare compatibility to present known compatible packages and versions.
It is recommended that compatibility is specified to present known compatible packages and versions.
- If `compatibleWith` is not used, the patch is treated as compatible with any package
- If a package is specified with no versions, the patch is compatible with any version of the package
- If an empty array of versions is specified, the patch is not compatible with any version of the package.

View File

@@ -1,3 +1,3 @@
org.gradle.parallel = true
org.gradle.caching = true
version = 20.0.0-dev.1
version = 20.0.0-dev.2

View File

@@ -1,12 +1,14 @@
[versions]
android = "4.1.1.4"
apktool-lib = "2.9.3"
kotlin = "1.9.22"
kotlinx-coroutines-core = "1.7.3"
kotlin = "2.0.0"
kotlinx-coroutines-core = "1.8.1"
mockk = "1.13.10"
multidexlib2 = "3.0.3.r3"
# Tracking https://github.com/google/smali/issues/64.
#noinspection GradleDependency
smali = "3.0.5"
binary-compatibility-validator = "0.14.0"
binary-compatibility-validator = "0.15.1"
xpp3 = "1.1.4c"
[libraries]

View File

@@ -39,9 +39,6 @@ class Patcher(private val config: PatcherConfig) : Closeable {
patch.addRecursively()
}
fun Patch<*>.anyRecursively(predicate: (Patch<*>) -> Boolean): Boolean =
predicate(this) || dependencies.any { dependency -> dependency.anyRecursively(predicate) }
context.allPatches.let { allPatches ->
// Check, if what kind of resource mode is required.
config.resourceMode = if (allPatches.any { patch -> patch.anyRecursively { it is ResourcePatch } }) {
@@ -99,6 +96,17 @@ class Patcher(private val config: PatcherConfig) : Closeable {
context.resourceContext.decodeResources(config.resourceMode)
}
logger.info("Merging extensions")
context.executablePatches.forEachRecursively { patch ->
if (patch is BytecodePatch && patch.extension != null) {
context.bytecodeContext.merge(patch.extension)
}
}
// Initialize lookup maps.
context.bytecodeContext.lookupMaps
logger.info("Executing patches")
val executedPatches = LinkedHashMap<Patch<*>, PatchResult>()
@@ -146,7 +154,7 @@ class Patcher(private val config: PatcherConfig) : Closeable {
}
}
override fun close() = context.bytecodeContext.lookupMaps.close()
override fun close() = context.close()
/**
* Compile and save patched APK files.

View File

@@ -5,6 +5,7 @@ import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.ResourcePatchContext
import brut.androlib.apk.ApkInfo
import brut.directory.ExtFile
import java.io.Closeable
/**
* A context for the patcher containing the current state of the patcher.
@@ -12,7 +13,7 @@ import brut.directory.ExtFile
* @param config The configuration for the patcher.
*/
@Suppress("MemberVisibilityCanBePrivate")
class PatcherContext internal constructor(config: PatcherConfig) {
class PatcherContext internal constructor(config: PatcherConfig): Closeable {
/**
* [PackageMetadata] of the supplied [PatcherConfig.apkFile].
*/
@@ -37,4 +38,6 @@ class PatcherContext internal constructor(config: PatcherConfig) {
* The context for patches containing the current state of the bytecode.
*/
internal val bytecodeContext = BytecodePatchContext(config)
override fun close() = bytecodeContext.close()
}

View File

@@ -31,7 +31,9 @@ import java.util.logging.Logger
* @param config The [PatcherConfig] used to create this context.
*/
@Suppress("MemberVisibilityCanBePrivate")
class BytecodePatchContext internal constructor(private val config: PatcherConfig) : PatchContext<Set<PatcherResult.PatchedDexFile>> {
class BytecodePatchContext internal constructor(private val config: PatcherConfig) :
PatchContext<Set<PatcherResult.PatchedDexFile>>,
Closeable {
private val logger = Logger.getLogger(BytecodePatchContext::class.java.name)
/**
@@ -57,6 +59,13 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
*/
internal val lookupMaps by lazy { LookupMaps(classes) }
/**
* A map for lookup by [merge].
*/
internal val classesByType = mutableMapOf<String, ClassDef>().apply {
classes.forEach { classDef -> put(classDef.type, classDef) }
}
/**
* Merge an extension to [classes].
*
@@ -66,11 +75,11 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
val extension = extensionInputStream.readAllBytes()
RawDexIO.readRawDexFile(extension, 0, null).classes.forEach { classDef ->
val existingClass = lookupMaps.classesByType[classDef.type] ?: run {
val existingClass = classesByType[classDef.type] ?: run {
logger.fine("Adding class \"$classDef\"")
lookupMaps.classesByType[classDef.type] = classDef
classes += classDef
classesByType[classDef.type] = classDef
return@forEach
}
@@ -254,6 +263,12 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
methodsByStrings.clear()
}
}
override fun close() {
lookupMaps.close()
classesByType.clear()
classes.clear()
}
}
/**

View File

@@ -85,6 +85,31 @@ sealed class Patch<C : PatchContext<*>>(
override fun toString() = name ?: "Patch"
}
internal fun Patch<*>.anyRecursively(
visited: MutableSet<Patch<*>> = mutableSetOf(),
predicate: (Patch<*>) -> Boolean,
): Boolean {
if (this in visited) return false
if (predicate(this)) return true
visited += this
return dependencies.any { it.anyRecursively(visited, predicate) }
}
internal fun Iterable<Patch<*>>.forEachRecursively(
visited: MutableSet<Patch<*>> = mutableSetOf(),
action: (Patch<*>) -> Unit,
): Unit = forEach {
if (it in visited) return@forEach
visited += it
action(it)
it.dependencies.forEachRecursively(visited, action)
}
/**
* A bytecode patch.
*
@@ -127,7 +152,6 @@ class BytecodePatch internal constructor(
finalizeBlock,
) {
override fun execute(context: PatcherContext) = with(context.bytecodeContext) {
extension?.let(::merge)
fingerprints.forEach { it.match(this) }
execute(this)
@@ -268,7 +292,14 @@ sealed class PatchBuilder<C : PatchContext<*>>(
*
* @param versions The versions of the package.
*/
operator fun String.invoke(vararg versions: String) = this to versions.toSet()
operator fun String.invoke(vararg versions: String) = invoke(versions.toSet())
/**
* Create a package a patch is compatible with.
*
* @param versions The versions of the package.
*/
private operator fun String.invoke(versions: Set<String>? = null) = this to versions
/**
* Add packages the patch is compatible with.
@@ -325,6 +356,16 @@ sealed class PatchBuilder<C : PatchContext<*>>(
internal abstract fun build(): Patch<C>
}
/**
* Builds a [Patch].
*
* @param B The [PatchBuilder] to build the patch with.
* @param block The block to build the patch.
*
* @return The built [Patch].
*/
private fun <B : PatchBuilder<*>> B.buildPatch(block: B.() -> Unit = {}) = apply(block).build()
/**
* A [BytecodePatchBuilder] builder.
*
@@ -358,7 +399,7 @@ class BytecodePatchBuilder internal constructor(
// It may be likely to forget invoking it. By wrapping the fingerprint into this class,
// the compiler will throw an error if the fingerprint was not invoked if attempting to delegate the match.
operator fun getValue(nothing: Nothing?, property: KProperty<*>) = fingerprint.match
?: throw PatchException("No fingerprint match to delegate to ${property.name}.")
?: throw PatchException("No fingerprint match to delegate to \"${property.name}\".")
}
// Must be internal for the inlined function "extendWith".
@@ -372,9 +413,10 @@ class BytecodePatchBuilder internal constructor(
*
* @param extension The name of the extension resource.
*/
@Suppress("NOTHING_TO_INLINE")
inline fun extendWith(extension: String) = apply {
this.extension = object {}.javaClass.classLoader.getResourceAsStream(extension)
?: throw PatchException("Extension resource \"$extension\" not found")
?: throw PatchException("Extension \"$extension\" not found")
}
override fun build() = BytecodePatch(
@@ -391,6 +433,24 @@ class BytecodePatchBuilder internal constructor(
)
}
/**
* Create a new [BytecodePatch].
*
* @param name The name of the patch.
* If null, the patch is named "Patch" and will not be loaded by [PatchLoader].
* @param description The description of the patch.
* @param use Weather or not the patch should be used.
* @param block The block to build the patch.
*
* @return The created [BytecodePatch].
*/
fun bytecodePatch(
name: String? = null,
description: String? = null,
use: Boolean = true,
block: BytecodePatchBuilder.() -> Unit = {},
) = BytecodePatchBuilder(name, description, use).buildPatch(block) as BytecodePatch
/**
* A [RawResourcePatch] builder.
*
@@ -418,6 +478,23 @@ class RawResourcePatchBuilder internal constructor(
)
}
/**
* Create a new [RawResourcePatch].
*
* @param name The name of the patch.
* If null, the patch is named "Patch" and will not be loaded by [PatchLoader].
* @param description The description of the patch.
* @param use Weather or not the patch should be used.
* @param block The block to build the patch.
* @return The created [RawResourcePatch].
*/
fun rawResourcePatch(
name: String? = null,
description: String? = null,
use: Boolean = true,
block: RawResourcePatchBuilder.() -> Unit = {},
) = RawResourcePatchBuilder(name, description, use).buildPatch(block) as RawResourcePatch
/**
* A [ResourcePatch] builder.
*
@@ -445,51 +522,6 @@ class ResourcePatchBuilder internal constructor(
)
}
/**
* Builds a [Patch].
*
* @param B The [PatchBuilder] to build the patch with.
* @param block The block to build the patch.
*
* @return The built [Patch].
*/
private fun <B : PatchBuilder<*>> B.buildPatch(block: B.() -> Unit = {}) = apply(block).build()
/**
* Create a new [BytecodePatch].
*
* @param name The name of the patch.
* If null, the patch is named "Patch" and will not be loaded by [PatchLoader].
* @param description The description of the patch.
* @param use Weather or not the patch should be used.
* @param block The block to build the patch.
*
* @return The created [BytecodePatch].
*/
fun bytecodePatch(
name: String? = null,
description: String? = null,
use: Boolean = true,
block: BytecodePatchBuilder.() -> Unit = {},
) = BytecodePatchBuilder(name, description, use).buildPatch(block) as BytecodePatch
/**
* Create a new [RawResourcePatch].
*
* @param name The name of the patch.
* If null, the patch is named "Patch" and will not be loaded by [PatchLoader].
* @param description The description of the patch.
* @param use Weather or not the patch should be used.
* @param block The block to build the patch.
* @return The created [RawResourcePatch].
*/
fun rawResourcePatch(
name: String? = null,
description: String? = null,
use: Boolean = true,
block: RawResourcePatchBuilder.() -> Unit = {},
) = RawResourcePatchBuilder(name, description, use).buildPatch(block) as RawResourcePatch
/**
* Create a new [ResourcePatch].
*

View File

@@ -9,21 +9,13 @@ class MutableAnnotation(annotation: Annotation) : BaseAnnotation() {
private val type = annotation.type
private val _elements by lazy { annotation.elements.map { element -> element.toMutable() }.toMutableSet() }
override fun getType(): String {
return type
}
override fun getType(): String = type
override fun getElements(): MutableSet<MutableAnnotationElement> {
return _elements
}
override fun getElements(): MutableSet<MutableAnnotationElement> = _elements
override fun getVisibility(): Int {
return visibility
}
override fun getVisibility(): Int = visibility
companion object {
fun Annotation.toMutable(): MutableAnnotation {
return MutableAnnotation(this)
}
fun Annotation.toMutable(): MutableAnnotation = MutableAnnotation(this)
}
}

View File

@@ -18,17 +18,11 @@ class MutableAnnotationElement(annotationElement: AnnotationElement) : BaseAnnot
this.value = value
}
override fun getName(): String {
return name
}
override fun getName(): String = name
override fun getValue(): EncodedValue {
return value
}
override fun getValue(): EncodedValue = value
companion object {
fun AnnotationElement.toMutable(): MutableAnnotationElement {
return MutableAnnotationElement(this)
}
fun AnnotationElement.toMutable(): MutableAnnotationElement = MutableAnnotationElement(this)
}
}

View File

@@ -7,9 +7,10 @@ import com.android.tools.smali.dexlib2.base.reference.BaseTypeReference
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.util.FieldUtil
import com.android.tools.smali.dexlib2.util.MethodUtil
import com.google.common.collect.Iterables
class MutableClass(classDef: ClassDef) : ClassDef, BaseTypeReference() {
class MutableClass(classDef: ClassDef) :
BaseTypeReference(),
ClassDef {
// Class
private var type = classDef.type
private var sourceFile = classDef.sourceFile
@@ -23,13 +24,13 @@ class MutableClass(classDef: ClassDef) : ClassDef, BaseTypeReference() {
// Methods
private val _methods by lazy { classDef.methods.map { method -> method.toMutable() }.toMutableSet() }
private val _directMethods by lazy { Iterables.filter(_methods, MethodUtil.METHOD_IS_DIRECT).toMutableSet() }
private val _virtualMethods by lazy { Iterables.filter(_methods, MethodUtil.METHOD_IS_VIRTUAL).toMutableSet() }
private val _directMethods by lazy { _methods.filter { method -> MethodUtil.isDirect(method) }.toMutableSet() }
private val _virtualMethods by lazy { _methods.filter { method -> !MethodUtil.isDirect(method) }.toMutableSet() }
// Fields
private val _fields by lazy { classDef.fields.map { field -> field.toMutable() }.toMutableSet() }
private val _staticFields by lazy { Iterables.filter(_fields, FieldUtil.FIELD_IS_STATIC).toMutableSet() }
private val _instanceFields by lazy { Iterables.filter(_fields, FieldUtil.FIELD_IS_INSTANCE).toMutableSet() }
private val _staticFields by lazy { _fields.filter { field -> FieldUtil.isStatic(field) }.toMutableSet() }
private val _instanceFields by lazy { _fields.filter { field -> !FieldUtil.isStatic(field) }.toMutableSet() }
fun setType(type: String) {
this.type = type
@@ -47,57 +48,31 @@ class MutableClass(classDef: ClassDef) : ClassDef, BaseTypeReference() {
this.superclass = superclass
}
override fun getType(): String {
return type
}
override fun getType(): String = type
override fun getAccessFlags(): Int {
return accessFlags
}
override fun getAccessFlags(): Int = accessFlags
override fun getSourceFile(): String? {
return sourceFile
}
override fun getSourceFile(): String? = sourceFile
override fun getSuperclass(): String? {
return superclass
}
override fun getSuperclass(): String? = superclass
override fun getInterfaces(): MutableList<String> {
return _interfaces
}
override fun getInterfaces(): MutableList<String> = _interfaces
override fun getAnnotations(): MutableSet<MutableAnnotation> {
return _annotations
}
override fun getAnnotations(): MutableSet<MutableAnnotation> = _annotations
override fun getStaticFields(): MutableSet<MutableField> {
return _staticFields
}
override fun getStaticFields(): MutableSet<MutableField> = _staticFields
override fun getInstanceFields(): MutableSet<MutableField> {
return _instanceFields
}
override fun getInstanceFields(): MutableSet<MutableField> = _instanceFields
override fun getFields(): MutableSet<MutableField> {
return _fields
}
override fun getFields(): MutableSet<MutableField> = _fields
override fun getDirectMethods(): MutableSet<MutableMethod> {
return _directMethods
}
override fun getDirectMethods(): MutableSet<MutableMethod> = _directMethods
override fun getVirtualMethods(): MutableSet<MutableMethod> {
return _virtualMethods
}
override fun getVirtualMethods(): MutableSet<MutableMethod> = _virtualMethods
override fun getMethods(): MutableSet<MutableMethod> {
return _methods
}
override fun getMethods(): MutableSet<MutableMethod> = _methods
companion object {
fun ClassDef.toMutable(): MutableClass {
return MutableClass(this)
}
fun ClassDef.toMutable(): MutableClass = MutableClass(this)
}
}

View File

@@ -7,7 +7,9 @@ import com.android.tools.smali.dexlib2.HiddenApiRestriction
import com.android.tools.smali.dexlib2.base.reference.BaseFieldReference
import com.android.tools.smali.dexlib2.iface.Field
class MutableField(field: Field) : Field, BaseFieldReference() {
class MutableField(field: Field) :
BaseFieldReference(),
Field {
private var definingClass = field.definingClass
private var name = field.name
private var type = field.type
@@ -37,37 +39,21 @@ class MutableField(field: Field) : Field, BaseFieldReference() {
this.initialValue = initialValue
}
override fun getDefiningClass(): String {
return this.definingClass
}
override fun getDefiningClass(): String = this.definingClass
override fun getName(): String {
return this.name
}
override fun getName(): String = this.name
override fun getType(): String {
return this.type
}
override fun getType(): String = this.type
override fun getAnnotations(): MutableSet<MutableAnnotation> {
return this._annotations
}
override fun getAnnotations(): MutableSet<MutableAnnotation> = this._annotations
override fun getAccessFlags(): Int {
return this.accessFlags
}
override fun getAccessFlags(): Int = this.accessFlags
override fun getHiddenApiRestrictions(): MutableSet<HiddenApiRestriction> {
return this._hiddenApiRestrictions
}
override fun getHiddenApiRestrictions(): MutableSet<HiddenApiRestriction> = this._hiddenApiRestrictions
override fun getInitialValue(): MutableEncodedValue? {
return this.initialValue
}
override fun getInitialValue(): MutableEncodedValue? = this.initialValue
companion object {
fun Field.toMutable(): MutableField {
return MutableField(this)
}
fun Field.toMutable(): MutableField = MutableField(this)
}
}

View File

@@ -7,7 +7,9 @@ import com.android.tools.smali.dexlib2.base.reference.BaseMethodReference
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
import com.android.tools.smali.dexlib2.iface.Method
class MutableMethod(method: Method) : Method, BaseMethodReference() {
class MutableMethod(method: Method) :
BaseMethodReference(),
Method {
private var definingClass = method.definingClass
private var name = method.name
private var accessFlags = method.accessFlags
@@ -36,45 +38,25 @@ class MutableMethod(method: Method) : Method, BaseMethodReference() {
this.returnType = returnType
}
override fun getDefiningClass(): String {
return definingClass
}
override fun getDefiningClass(): String = definingClass
override fun getName(): String {
return name
}
override fun getName(): String = name
override fun getParameterTypes(): MutableList<CharSequence> {
return _parameterTypes
}
override fun getParameterTypes(): MutableList<CharSequence> = _parameterTypes
override fun getReturnType(): String {
return returnType
}
override fun getReturnType(): String = returnType
override fun getAnnotations(): MutableSet<MutableAnnotation> {
return _annotations
}
override fun getAnnotations(): MutableSet<MutableAnnotation> = _annotations
override fun getAccessFlags(): Int {
return accessFlags
}
override fun getAccessFlags(): Int = accessFlags
override fun getHiddenApiRestrictions(): MutableSet<HiddenApiRestriction> {
return _hiddenApiRestrictions
}
override fun getHiddenApiRestrictions(): MutableSet<HiddenApiRestriction> = _hiddenApiRestrictions
override fun getParameters(): MutableList<MutableMethodParameter> {
return _parameters
}
override fun getParameters(): MutableList<MutableMethodParameter> = _parameters
override fun getImplementation(): MutableMethodImplementation? {
return _implementation
}
override fun getImplementation(): MutableMethodImplementation? = _implementation
companion object {
fun Method.toMutable(): MutableMethod {
return MutableMethod(this)
}
fun Method.toMutable(): MutableMethod = MutableMethod(this)
}
}

View File

@@ -5,7 +5,9 @@ import com.android.tools.smali.dexlib2.base.BaseMethodParameter
import com.android.tools.smali.dexlib2.iface.MethodParameter
// TODO: finish overriding all members if necessary
class MutableMethodParameter(parameter: MethodParameter) : MethodParameter, BaseMethodParameter() {
class MutableMethodParameter(parameter: MethodParameter) :
BaseMethodParameter(),
MethodParameter {
private var type = parameter.type
private var name = parameter.name
private var signature = parameter.signature
@@ -13,25 +15,15 @@ class MutableMethodParameter(parameter: MethodParameter) : MethodParameter, Base
parameter.annotations.map { annotation -> annotation.toMutable() }.toMutableSet()
}
override fun getType(): String {
return type
}
override fun getType(): String = type
override fun getName(): String? {
return name
}
override fun getName(): String? = name
override fun getSignature(): String? {
return signature
}
override fun getSignature(): String? = signature
override fun getAnnotations(): MutableSet<MutableAnnotation> {
return _annotations
}
override fun getAnnotations(): MutableSet<MutableAnnotation> = _annotations
companion object {
fun MethodParameter.toMutable(): MutableMethodParameter {
return MutableMethodParameter(this)
}
fun MethodParameter.toMutable(): MutableMethodParameter = MutableMethodParameter(this)
}
}

View File

@@ -14,21 +14,15 @@ class MutableAnnotationEncodedValue(annotationEncodedValue: AnnotationEncodedVal
annotationEncodedValue.elements.map { annotationElement -> annotationElement.toMutable() }.toMutableSet()
}
override fun getType(): String {
return this.type
}
override fun getType(): String = this.type
fun setType(type: String) {
this.type = type
}
override fun getElements(): MutableSet<out AnnotationElement> {
return _elements
}
override fun getElements(): MutableSet<out AnnotationElement> = _elements
companion object {
fun AnnotationEncodedValue.toMutable(): MutableAnnotationEncodedValue {
return MutableAnnotationEncodedValue(this)
}
fun AnnotationEncodedValue.toMutable(): MutableAnnotationEncodedValue = MutableAnnotationEncodedValue(this)
}
}

View File

@@ -5,18 +5,16 @@ import com.android.tools.smali.dexlib2.base.value.BaseArrayEncodedValue
import com.android.tools.smali.dexlib2.iface.value.ArrayEncodedValue
import com.android.tools.smali.dexlib2.iface.value.EncodedValue
class MutableArrayEncodedValue(arrayEncodedValue: ArrayEncodedValue) : BaseArrayEncodedValue(), MutableEncodedValue {
class MutableArrayEncodedValue(arrayEncodedValue: ArrayEncodedValue) :
BaseArrayEncodedValue(),
MutableEncodedValue {
private val _value by lazy {
arrayEncodedValue.value.map { encodedValue -> encodedValue.toMutable() }.toMutableList()
}
override fun getValue(): MutableList<out EncodedValue> {
return _value
}
override fun getValue(): MutableList<out EncodedValue> = _value
companion object {
fun ArrayEncodedValue.toMutable(): MutableArrayEncodedValue {
return MutableArrayEncodedValue(this)
}
fun ArrayEncodedValue.toMutable(): MutableArrayEncodedValue = MutableArrayEncodedValue(this)
}
}

View File

@@ -8,17 +8,13 @@ class MutableBooleanEncodedValue(booleanEncodedValue: BooleanEncodedValue) :
MutableEncodedValue {
private var value = booleanEncodedValue.value
override fun getValue(): Boolean {
return this.value
}
override fun getValue(): Boolean = this.value
fun setValue(value: Boolean) {
this.value = value
}
companion object {
fun BooleanEncodedValue.toMutable(): MutableBooleanEncodedValue {
return MutableBooleanEncodedValue(this)
}
fun BooleanEncodedValue.toMutable(): MutableBooleanEncodedValue = MutableBooleanEncodedValue(this)
}
}

View File

@@ -3,20 +3,18 @@ package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
import com.android.tools.smali.dexlib2.base.value.BaseByteEncodedValue
import com.android.tools.smali.dexlib2.iface.value.ByteEncodedValue
class MutableByteEncodedValue(byteEncodedValue: ByteEncodedValue) : BaseByteEncodedValue(), MutableEncodedValue {
class MutableByteEncodedValue(byteEncodedValue: ByteEncodedValue) :
BaseByteEncodedValue(),
MutableEncodedValue {
private var value = byteEncodedValue.value
override fun getValue(): Byte {
return this.value
}
override fun getValue(): Byte = this.value
fun setValue(value: Byte) {
this.value = value
}
companion object {
fun ByteEncodedValue.toMutable(): MutableByteEncodedValue {
return MutableByteEncodedValue(this)
}
fun ByteEncodedValue.toMutable(): MutableByteEncodedValue = MutableByteEncodedValue(this)
}
}

View File

@@ -3,20 +3,18 @@ package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
import com.android.tools.smali.dexlib2.base.value.BaseCharEncodedValue
import com.android.tools.smali.dexlib2.iface.value.CharEncodedValue
class MutableCharEncodedValue(charEncodedValue: CharEncodedValue) : BaseCharEncodedValue(), MutableEncodedValue {
class MutableCharEncodedValue(charEncodedValue: CharEncodedValue) :
BaseCharEncodedValue(),
MutableEncodedValue {
private var value = charEncodedValue.value
override fun getValue(): Char {
return this.value
}
override fun getValue(): Char = this.value
fun setValue(value: Char) {
this.value = value
}
companion object {
fun CharEncodedValue.toMutable(): MutableCharEncodedValue {
return MutableCharEncodedValue(this)
}
fun CharEncodedValue.toMutable(): MutableCharEncodedValue = MutableCharEncodedValue(this)
}
}

View File

@@ -8,17 +8,13 @@ class MutableDoubleEncodedValue(doubleEncodedValue: DoubleEncodedValue) :
MutableEncodedValue {
private var value = doubleEncodedValue.value
override fun getValue(): Double {
return this.value
}
override fun getValue(): Double = this.value
fun setValue(value: Double) {
this.value = value
}
companion object {
fun DoubleEncodedValue.toMutable(): MutableDoubleEncodedValue {
return MutableDoubleEncodedValue(this)
}
fun DoubleEncodedValue.toMutable(): MutableDoubleEncodedValue = MutableDoubleEncodedValue(this)
}
}

View File

@@ -4,20 +4,18 @@ import com.android.tools.smali.dexlib2.base.value.BaseEnumEncodedValue
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.value.EnumEncodedValue
class MutableEnumEncodedValue(enumEncodedValue: EnumEncodedValue) : BaseEnumEncodedValue(), MutableEncodedValue {
class MutableEnumEncodedValue(enumEncodedValue: EnumEncodedValue) :
BaseEnumEncodedValue(),
MutableEncodedValue {
private var value = enumEncodedValue.value
override fun getValue(): FieldReference {
return this.value
}
override fun getValue(): FieldReference = this.value
fun setValue(value: FieldReference) {
this.value = value
}
companion object {
fun EnumEncodedValue.toMutable(): MutableEnumEncodedValue {
return MutableEnumEncodedValue(this)
}
fun EnumEncodedValue.toMutable(): MutableEnumEncodedValue = MutableEnumEncodedValue(this)
}
}

View File

@@ -5,24 +5,20 @@ import com.android.tools.smali.dexlib2.base.value.BaseFieldEncodedValue
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.value.FieldEncodedValue
class MutableFieldEncodedValue(fieldEncodedValue: FieldEncodedValue) : BaseFieldEncodedValue(), MutableEncodedValue {
class MutableFieldEncodedValue(fieldEncodedValue: FieldEncodedValue) :
BaseFieldEncodedValue(),
MutableEncodedValue {
private var value = fieldEncodedValue.value
override fun getValueType(): Int {
return ValueType.FIELD
}
override fun getValueType(): Int = ValueType.FIELD
override fun getValue(): FieldReference {
return this.value
}
override fun getValue(): FieldReference = this.value
fun setValue(value: FieldReference) {
this.value = value
}
companion object {
fun FieldEncodedValue.toMutable(): MutableFieldEncodedValue {
return MutableFieldEncodedValue(this)
}
fun FieldEncodedValue.toMutable(): MutableFieldEncodedValue = MutableFieldEncodedValue(this)
}
}

View File

@@ -3,20 +3,18 @@ package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
import com.android.tools.smali.dexlib2.base.value.BaseFloatEncodedValue
import com.android.tools.smali.dexlib2.iface.value.FloatEncodedValue
class MutableFloatEncodedValue(floatEncodedValue: FloatEncodedValue) : BaseFloatEncodedValue(), MutableEncodedValue {
class MutableFloatEncodedValue(floatEncodedValue: FloatEncodedValue) :
BaseFloatEncodedValue(),
MutableEncodedValue {
private var value = floatEncodedValue.value
override fun getValue(): Float {
return this.value
}
override fun getValue(): Float = this.value
fun setValue(value: Float) {
this.value = value
}
companion object {
fun FloatEncodedValue.toMutable(): MutableFloatEncodedValue {
return MutableFloatEncodedValue(this)
}
fun FloatEncodedValue.toMutable(): MutableFloatEncodedValue = MutableFloatEncodedValue(this)
}
}

View File

@@ -3,20 +3,18 @@ package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
import com.android.tools.smali.dexlib2.base.value.BaseIntEncodedValue
import com.android.tools.smali.dexlib2.iface.value.IntEncodedValue
class MutableIntEncodedValue(intEncodedValue: IntEncodedValue) : BaseIntEncodedValue(), MutableEncodedValue {
class MutableIntEncodedValue(intEncodedValue: IntEncodedValue) :
BaseIntEncodedValue(),
MutableEncodedValue {
private var value = intEncodedValue.value
override fun getValue(): Int {
return this.value
}
override fun getValue(): Int = this.value
fun setValue(value: Int) {
this.value = value
}
companion object {
fun IntEncodedValue.toMutable(): MutableIntEncodedValue {
return MutableIntEncodedValue(this)
}
fun IntEncodedValue.toMutable(): MutableIntEncodedValue = MutableIntEncodedValue(this)
}
}

View File

@@ -3,20 +3,18 @@ package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
import com.android.tools.smali.dexlib2.base.value.BaseLongEncodedValue
import com.android.tools.smali.dexlib2.iface.value.LongEncodedValue
class MutableLongEncodedValue(longEncodedValue: LongEncodedValue) : BaseLongEncodedValue(), MutableEncodedValue {
class MutableLongEncodedValue(longEncodedValue: LongEncodedValue) :
BaseLongEncodedValue(),
MutableEncodedValue {
private var value = longEncodedValue.value
override fun getValue(): Long {
return this.value
}
override fun getValue(): Long = this.value
fun setValue(value: Long) {
this.value = value
}
companion object {
fun LongEncodedValue.toMutable(): MutableLongEncodedValue {
return MutableLongEncodedValue(this)
}
fun LongEncodedValue.toMutable(): MutableLongEncodedValue = MutableLongEncodedValue(this)
}
}

View File

@@ -9,17 +9,13 @@ class MutableMethodEncodedValue(methodEncodedValue: MethodEncodedValue) :
MutableEncodedValue {
private var value = methodEncodedValue.value
override fun getValue(): MethodReference {
return this.value
}
override fun getValue(): MethodReference = this.value
fun setValue(value: MethodReference) {
this.value = value
}
companion object {
fun MethodEncodedValue.toMutable(): MutableMethodEncodedValue {
return MutableMethodEncodedValue(this)
}
fun MethodEncodedValue.toMutable(): MutableMethodEncodedValue = MutableMethodEncodedValue(this)
}
}

View File

@@ -9,17 +9,13 @@ class MutableMethodHandleEncodedValue(methodHandleEncodedValue: MethodHandleEnco
MutableEncodedValue {
private var value = methodHandleEncodedValue.value
override fun getValue(): MethodHandleReference {
return this.value
}
override fun getValue(): MethodHandleReference = this.value
fun setValue(value: MethodHandleReference) {
this.value = value
}
companion object {
fun MethodHandleEncodedValue.toMutable(): MutableMethodHandleEncodedValue {
return MutableMethodHandleEncodedValue(this)
}
fun MethodHandleEncodedValue.toMutable(): MutableMethodHandleEncodedValue = MutableMethodHandleEncodedValue(this)
}
}

View File

@@ -9,17 +9,13 @@ class MutableMethodTypeEncodedValue(methodTypeEncodedValue: MethodTypeEncodedVal
MutableEncodedValue {
private var value = methodTypeEncodedValue.value
override fun getValue(): MethodProtoReference {
return this.value
}
override fun getValue(): MethodProtoReference = this.value
fun setValue(value: MethodProtoReference) {
this.value = value
}
companion object {
fun MethodTypeEncodedValue.toMutable(): MutableMethodTypeEncodedValue {
return MutableMethodTypeEncodedValue(this)
}
fun MethodTypeEncodedValue.toMutable(): MutableMethodTypeEncodedValue = MutableMethodTypeEncodedValue(this)
}
}

View File

@@ -3,10 +3,10 @@ package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
import com.android.tools.smali.dexlib2.base.value.BaseNullEncodedValue
import com.android.tools.smali.dexlib2.iface.value.ByteEncodedValue
class MutableNullEncodedValue : BaseNullEncodedValue(), MutableEncodedValue {
class MutableNullEncodedValue :
BaseNullEncodedValue(),
MutableEncodedValue {
companion object {
fun ByteEncodedValue.toMutable(): MutableByteEncodedValue {
return MutableByteEncodedValue(this)
}
fun ByteEncodedValue.toMutable(): MutableByteEncodedValue = MutableByteEncodedValue(this)
}
}

View File

@@ -3,20 +3,18 @@ package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
import com.android.tools.smali.dexlib2.base.value.BaseShortEncodedValue
import com.android.tools.smali.dexlib2.iface.value.ShortEncodedValue
class MutableShortEncodedValue(shortEncodedValue: ShortEncodedValue) : BaseShortEncodedValue(), MutableEncodedValue {
class MutableShortEncodedValue(shortEncodedValue: ShortEncodedValue) :
BaseShortEncodedValue(),
MutableEncodedValue {
private var value = shortEncodedValue.value
override fun getValue(): Short {
return this.value
}
override fun getValue(): Short = this.value
fun setValue(value: Short) {
this.value = value
}
companion object {
fun ShortEncodedValue.toMutable(): MutableShortEncodedValue {
return MutableShortEncodedValue(this)
}
fun ShortEncodedValue.toMutable(): MutableShortEncodedValue = MutableShortEncodedValue(this)
}
}

View File

@@ -9,17 +9,13 @@ class MutableStringEncodedValue(stringEncodedValue: StringEncodedValue) :
MutableEncodedValue {
private var value = stringEncodedValue.value
override fun getValue(): String {
return this.value
}
override fun getValue(): String = this.value
fun setValue(value: String) {
this.value = value
}
companion object {
fun ByteEncodedValue.toMutable(): MutableByteEncodedValue {
return MutableByteEncodedValue(this)
}
fun ByteEncodedValue.toMutable(): MutableByteEncodedValue = MutableByteEncodedValue(this)
}
}

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