mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-01 21:54:24 +02:00
feat: use annotations instead of metadata objects
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
ebbcf78e56
commit
d20f7fd6e1
@ -29,6 +29,7 @@ dependencies {
|
|||||||
api("org.smali:smali:2.5.2")
|
api("org.smali:smali:2.5.2")
|
||||||
|
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
|
implementation(kotlin("reflect"))
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package app.revanced.patcher
|
package app.revanced.patcher
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.data.PatcherData
|
import app.revanced.patcher.data.PatcherData
|
||||||
import app.revanced.patcher.data.base.Data
|
import app.revanced.patcher.data.base.Data
|
||||||
import app.revanced.patcher.data.implementation.findIndexed
|
import app.revanced.patcher.data.implementation.findIndexed
|
||||||
|
import app.revanced.patcher.extensions.findAnnotationRecursively
|
||||||
import app.revanced.patcher.patch.base.Patch
|
import app.revanced.patcher.patch.base.Patch
|
||||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||||
import app.revanced.patcher.patch.implementation.ResourcePatch
|
import app.revanced.patcher.patch.implementation.ResourcePatch
|
||||||
import app.revanced.patcher.patch.implementation.metadata.PatchMetadata
|
|
||||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||||
import app.revanced.patcher.signature.MethodSignature
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
import app.revanced.patcher.signature.resolver.SignatureResolver
|
import app.revanced.patcher.signature.implementation.method.resolver.MethodSignatureResolver
|
||||||
import app.revanced.patcher.util.ListBackedSet
|
import app.revanced.patcher.util.ListBackedSet
|
||||||
import brut.androlib.Androlib
|
import brut.androlib.Androlib
|
||||||
import brut.androlib.meta.UsesFramework
|
import brut.androlib.meta.UsesFramework
|
||||||
@ -159,11 +160,12 @@ class Patcher(
|
|||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
SignatureResolver(patcherData.bytecodeData.classes.internalClasses, signatures).resolve(patcherData)
|
MethodSignatureResolver(patcherData.bytecodeData.classes.internalClasses, signatures).resolve(patcherData)
|
||||||
signaturesResolved = true
|
signaturesResolved = true
|
||||||
return signatures
|
return signatures
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply patches loaded into the patcher.
|
* Apply patches loaded into the patcher.
|
||||||
* @param stopOnError If true, the patches will stop on the first error.
|
* @param stopOnError If true, the patches will stop on the first error.
|
||||||
@ -174,7 +176,7 @@ class Patcher(
|
|||||||
fun applyPatches(
|
fun applyPatches(
|
||||||
stopOnError: Boolean = false,
|
stopOnError: Boolean = false,
|
||||||
callback: (String) -> Unit = {}
|
callback: (String) -> Unit = {}
|
||||||
): Map<PatchMetadata, Result<PatchResultSuccess>> {
|
): Map<String, Result<PatchResultSuccess>> {
|
||||||
if (!signaturesResolved) {
|
if (!signaturesResolved) {
|
||||||
resolveSignatures()
|
resolveSignatures()
|
||||||
}
|
}
|
||||||
@ -183,7 +185,12 @@ class Patcher(
|
|||||||
val resourcePatch = patch is ResourcePatch
|
val resourcePatch = patch is ResourcePatch
|
||||||
if (!patchResources && resourcePatch) continue
|
if (!patchResources && resourcePatch) continue
|
||||||
|
|
||||||
callback(patch.metadata.shortName)
|
val patchNameAnnotation = patch::class.java.findAnnotationRecursively(Name::class.java)
|
||||||
|
|
||||||
|
patchNameAnnotation?.let {
|
||||||
|
callback(it.name)
|
||||||
|
}
|
||||||
|
|
||||||
val result: Result<PatchResultSuccess> = try {
|
val result: Result<PatchResultSuccess> = try {
|
||||||
val data = if (resourcePatch) {
|
val data = if (resourcePatch) {
|
||||||
patcherData.resourceData
|
patcherData.resourceData
|
||||||
@ -201,7 +208,11 @@ class Patcher(
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Result.failure(e)
|
Result.failure(e)
|
||||||
}
|
}
|
||||||
this[patch.metadata] = result
|
|
||||||
|
patchNameAnnotation?.let {
|
||||||
|
this[patchNameAnnotation.name] = result
|
||||||
|
}
|
||||||
|
|
||||||
if (result.isFailure && stopOnError) break
|
if (result.isFailure && stopOnError) break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package app.revanced.patcher.annotation
|
||||||
|
|
||||||
|
import app.revanced.patcher.patch.base.Patch
|
||||||
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation to constrain a [Patch] or [MethodSignature] to compatible packages.
|
||||||
|
* @param compatiblePackages A list of packages a [Patch] or [MethodSignature] is compatible with.
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@MustBeDocumented
|
||||||
|
annotation class Compatibility(
|
||||||
|
val compatiblePackages: Array<Package>,
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation to represent packages a patch can be compatible with.
|
||||||
|
* @param name The package identifier name.
|
||||||
|
* @param versions The versions of the package the [Patch] or [MethodSignature]is compatible with.
|
||||||
|
*/
|
||||||
|
@Target()
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@MustBeDocumented
|
||||||
|
annotation class Package(
|
||||||
|
val name: String,
|
||||||
|
val versions: Array<String>
|
||||||
|
)
|
@ -0,0 +1,38 @@
|
|||||||
|
package app.revanced.patcher.annotation
|
||||||
|
|
||||||
|
import app.revanced.patcher.patch.base.Patch
|
||||||
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation to name a [Patch] or [MethodSignature].
|
||||||
|
* @param name A suggestive name for the [Patch] or [MethodSignature].
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@MustBeDocumented
|
||||||
|
annotation class Name(
|
||||||
|
val name: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation to describe a [Patch] or [MethodSignature].
|
||||||
|
* @param description A description for the [Patch] or [MethodSignature].
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@MustBeDocumented
|
||||||
|
annotation class Description(
|
||||||
|
val description: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation to version a [Patch] or [MethodSignature].
|
||||||
|
* @param version The version of a [Patch] or [MethodSignature].
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@MustBeDocumented
|
||||||
|
annotation class Version(
|
||||||
|
val version: String,
|
||||||
|
)
|
@ -1,12 +1,11 @@
|
|||||||
package app.revanced.patcher.data.implementation
|
package app.revanced.patcher.data.implementation
|
||||||
|
|
||||||
import app.revanced.patcher.data.base.Data
|
import app.revanced.patcher.data.base.Data
|
||||||
import app.revanced.patcher.methodWalker.MethodWalker
|
|
||||||
import app.revanced.patcher.patch.base.Patch
|
import app.revanced.patcher.patch.base.Patch
|
||||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||||
import app.revanced.patcher.proxy.ClassProxy
|
import app.revanced.patcher.signature.implementation.method.resolver.SignatureResolverResult
|
||||||
import app.revanced.patcher.signature.SignatureResolverResult
|
|
||||||
import app.revanced.patcher.util.ProxyBackedClassList
|
import app.revanced.patcher.util.ProxyBackedClassList
|
||||||
|
import app.revanced.patcher.util.method.MethodWalker
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import org.jf.dexlib2.iface.ClassDef
|
||||||
import org.jf.dexlib2.iface.Method
|
import org.jf.dexlib2.iface.Method
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ class BytecodeData(
|
|||||||
* Find a class by a given predicate
|
* Find a class by a given predicate
|
||||||
* @return A proxy for the first class that matches the predicate
|
* @return A proxy for the first class that matches the predicate
|
||||||
*/
|
*/
|
||||||
fun findClass(predicate: (ClassDef) -> Boolean): ClassProxy? {
|
fun findClass(predicate: (ClassDef) -> Boolean): app.revanced.patcher.util.proxy.ClassProxy? {
|
||||||
// if we already proxied the class matching the predicate...
|
// if we already proxied the class matching the predicate...
|
||||||
for (patch in patches) {
|
for (patch in patches) {
|
||||||
if (patch !is BytecodePatch) continue
|
if (patch !is BytecodePatch) continue
|
||||||
@ -77,10 +76,10 @@ internal inline fun <T> Iterable<T>.findIndexed(predicate: (T) -> Boolean): Pair
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun BytecodeData.proxy(classDef: ClassDef): ClassProxy {
|
fun BytecodeData.proxy(classDef: ClassDef): app.revanced.patcher.util.proxy.ClassProxy {
|
||||||
var proxy = this.classes.proxies.find { it.immutableClass.type == classDef.type }
|
var proxy = this.classes.proxies.find { it.immutableClass.type == classDef.type }
|
||||||
if (proxy == null) {
|
if (proxy == null) {
|
||||||
proxy = ClassProxy(classDef)
|
proxy = app.revanced.patcher.util.proxy.ClassProxy(classDef)
|
||||||
this.classes.proxies.add(proxy)
|
this.classes.proxies.add(proxy)
|
||||||
}
|
}
|
||||||
return proxy
|
return proxy
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package app.revanced.patcher.extensions
|
package app.revanced.patcher.extensions
|
||||||
|
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.builder.BuilderInstruction
|
import org.jf.dexlib2.builder.BuilderInstruction
|
||||||
import org.jf.dexlib2.builder.MutableMethodImplementation
|
import org.jf.dexlib2.builder.MutableMethodImplementation
|
||||||
@ -10,6 +10,33 @@ import org.jf.dexlib2.immutable.ImmutableMethod
|
|||||||
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
|
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
|
||||||
import org.jf.dexlib2.util.MethodUtil
|
import org.jf.dexlib2.util.MethodUtil
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively find a given annotation on a class
|
||||||
|
* @param targetAnnotation The annotation to find
|
||||||
|
* @return The annotation
|
||||||
|
*/
|
||||||
|
fun <T : Annotation> Class<*>.findAnnotationRecursively(targetAnnotation: Class<T>) =
|
||||||
|
this.findAnnotationRecursively(targetAnnotation, mutableSetOf())
|
||||||
|
|
||||||
|
private fun <T : Annotation> Class<*>.findAnnotationRecursively(
|
||||||
|
targetAnnotation: Class<T>,
|
||||||
|
traversed: MutableSet<Annotation>
|
||||||
|
): T? {
|
||||||
|
val found = this.annotations.firstOrNull { it.annotationClass.java.name == targetAnnotation.name }
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
if (found != null) return found as T
|
||||||
|
|
||||||
|
for (annotation in this.annotations) {
|
||||||
|
if (traversed.contains(annotation)) continue
|
||||||
|
traversed.add(annotation)
|
||||||
|
|
||||||
|
return (annotation.annotationClass.java.findAnnotationRecursively(targetAnnotation, traversed)) ?: continue
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
infix fun AccessFlags.or(other: AccessFlags) = this.value or other.value
|
infix fun AccessFlags.or(other: AccessFlags) = this.value or other.value
|
||||||
infix fun Int.or(other: AccessFlags) = this or other.value
|
infix fun Int.or(other: AccessFlags) = this or other.value
|
||||||
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package app.revanced.patcher.patch.annotations
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation to mark a Class as a patch.
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@MustBeDocumented
|
||||||
|
annotation class Patch
|
@ -3,20 +3,16 @@ package app.revanced.patcher.patch.base
|
|||||||
import app.revanced.patcher.data.base.Data
|
import app.revanced.patcher.data.base.Data
|
||||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||||
import app.revanced.patcher.patch.implementation.ResourcePatch
|
import app.revanced.patcher.patch.implementation.ResourcePatch
|
||||||
import app.revanced.patcher.patch.implementation.metadata.PatchMetadata
|
|
||||||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ReVanced patch.
|
* A ReVanced patch.
|
||||||
* Can either be a [ResourcePatch] or a [BytecodePatch]
|
* Can either be a [ResourcePatch] or a [BytecodePatch].
|
||||||
*/
|
*/
|
||||||
abstract class Patch<out T : Data>(
|
abstract class Patch<out T : Data> {
|
||||||
open val metadata: PatchMetadata
|
|
||||||
) {
|
|
||||||
/**
|
/**
|
||||||
* The main function of the [Patch] which the patcher will call.
|
* The main function of the [Patch] which the patcher will call.
|
||||||
*/
|
*/
|
||||||
abstract fun execute(data: @UnsafeVariance T): PatchResult // FIXME: remove the UnsafeVariance annotation
|
abstract fun execute(data: @UnsafeVariance T): PatchResult // FIXME: remove the UnsafeVariance annotation
|
||||||
|
|
||||||
}
|
}
|
@ -2,15 +2,12 @@ package app.revanced.patcher.patch.implementation
|
|||||||
|
|
||||||
import app.revanced.patcher.data.implementation.BytecodeData
|
import app.revanced.patcher.data.implementation.BytecodeData
|
||||||
import app.revanced.patcher.patch.base.Patch
|
import app.revanced.patcher.patch.base.Patch
|
||||||
import app.revanced.patcher.patch.implementation.metadata.PatchMetadata
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
import app.revanced.patcher.signature.MethodSignature
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bytecode patch for the Patcher.
|
* Bytecode patch for the Patcher.
|
||||||
* @param metadata [PatchMetadata] for the patch.
|
|
||||||
* @param signatures A list of [MethodSignature] this patch relies on.
|
* @param signatures A list of [MethodSignature] this patch relies on.
|
||||||
*/
|
*/
|
||||||
abstract class BytecodePatch(
|
abstract class BytecodePatch(
|
||||||
override val metadata: PatchMetadata,
|
|
||||||
val signatures: Iterable<MethodSignature>
|
val signatures: Iterable<MethodSignature>
|
||||||
) : Patch<BytecodeData>(metadata)
|
) : Patch<BytecodeData>()
|
@ -2,12 +2,8 @@ package app.revanced.patcher.patch.implementation
|
|||||||
|
|
||||||
import app.revanced.patcher.data.implementation.ResourceData
|
import app.revanced.patcher.data.implementation.ResourceData
|
||||||
import app.revanced.patcher.patch.base.Patch
|
import app.revanced.patcher.patch.base.Patch
|
||||||
import app.revanced.patcher.patch.implementation.metadata.PatchMetadata
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource patch for the Patcher.
|
* Resource patch for the Patcher.
|
||||||
* @param metadata [PatchMetadata] for the patch.
|
|
||||||
*/
|
*/
|
||||||
abstract class ResourcePatch(
|
abstract class ResourcePatch : Patch<ResourceData>()
|
||||||
override val metadata: PatchMetadata
|
|
||||||
) : Patch<ResourceData>(metadata)
|
|
@ -1,29 +0,0 @@
|
|||||||
package app.revanced.patcher.patch.implementation.metadata
|
|
||||||
|
|
||||||
import app.revanced.patcher.patch.base.Patch
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata about a [Patch].
|
|
||||||
* @param shortName A suggestive short name for the [Patch].
|
|
||||||
* @param name A suggestive name for the [Patch].
|
|
||||||
* @param description A description for the [Patch].
|
|
||||||
* @param compatiblePackages A list of packages this [Patch] is compatible with.
|
|
||||||
* @param version The version of the [Patch].
|
|
||||||
*/
|
|
||||||
data class PatchMetadata(
|
|
||||||
val shortName: String,
|
|
||||||
val name: String,
|
|
||||||
val description: String,
|
|
||||||
val compatiblePackages: Iterable<PackageMetadata>,
|
|
||||||
val version: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata about a package.
|
|
||||||
* @param name The package name.
|
|
||||||
* @param versions Compatible versions of the package.
|
|
||||||
*/
|
|
||||||
data class PackageMetadata(
|
|
||||||
val name: String,
|
|
||||||
val versions: Iterable<String>
|
|
||||||
)
|
|
@ -1,111 +0,0 @@
|
|||||||
package app.revanced.patcher.signature
|
|
||||||
|
|
||||||
import app.revanced.patcher.data.implementation.MethodNotFoundException
|
|
||||||
import app.revanced.patcher.patch.implementation.metadata.PackageMetadata
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the [MethodSignature] for a method.
|
|
||||||
* @param metadata Metadata for this [MethodSignature].
|
|
||||||
* @param returnType The return type of the method.
|
|
||||||
* @param accessFlags The access flags of the method.
|
|
||||||
* @param methodParameters The parameters of the method.
|
|
||||||
* @param opcodes The list of opcodes of the method.
|
|
||||||
* @param strings A list of strings which a method contains.
|
|
||||||
* A `null` opcode is equals to an unknown opcode.
|
|
||||||
*/
|
|
||||||
class MethodSignature(
|
|
||||||
val metadata: MethodSignatureMetadata,
|
|
||||||
internal val returnType: String?,
|
|
||||||
internal val accessFlags: Int?,
|
|
||||||
internal val methodParameters: Iterable<String>?,
|
|
||||||
internal val opcodes: Iterable<Opcode?>?,
|
|
||||||
internal val strings: Iterable<String>? = null
|
|
||||||
) {
|
|
||||||
/**
|
|
||||||
* The result of the signature
|
|
||||||
*/
|
|
||||||
var result: SignatureResolverResult? = null
|
|
||||||
get() {
|
|
||||||
return field ?: throw MethodNotFoundException(
|
|
||||||
"Could not resolve required signature ${metadata.name}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val resolved: Boolean
|
|
||||||
get() {
|
|
||||||
var resolved = false
|
|
||||||
try {
|
|
||||||
resolved = result != null
|
|
||||||
} catch (_: Exception) {
|
|
||||||
}
|
|
||||||
return resolved
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata about a [MethodSignature].
|
|
||||||
* @param name A suggestive name for the [MethodSignature].
|
|
||||||
* @param methodMetadata Metadata about the method for the [MethodSignature].
|
|
||||||
* @param patternScanMethod The pattern scanning method the pattern scanner should rely on.
|
|
||||||
* Can either be [PatternScanMethod.Fuzzy] or [PatternScanMethod.Direct].
|
|
||||||
* @param description An optional description for the [MethodSignature].
|
|
||||||
* @param compatiblePackages The list of packages the [MethodSignature] is compatible with.
|
|
||||||
* @param version The version of this signature.
|
|
||||||
*/
|
|
||||||
data class MethodSignatureMetadata(
|
|
||||||
val name: String,
|
|
||||||
val methodMetadata: MethodMetadata?,
|
|
||||||
val patternScanMethod: PatternScanMethod,
|
|
||||||
val compatiblePackages: Iterable<PackageMetadata>,
|
|
||||||
val description: String?,
|
|
||||||
val version: String
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata about the method for a [MethodSignature].
|
|
||||||
* @param definingClass The defining class name of the method.
|
|
||||||
* @param name A suggestive name for the method which the [MethodSignature] was created for.
|
|
||||||
*/
|
|
||||||
data class MethodMetadata(
|
|
||||||
val definingClass: String?,
|
|
||||||
val name: String?
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The method, the patcher should rely on when scanning the opcode pattern of a [MethodSignature]
|
|
||||||
*/
|
|
||||||
interface PatternScanMethod {
|
|
||||||
/**
|
|
||||||
* When comparing the signature, if one or more of the opcodes do not match, skip.
|
|
||||||
*/
|
|
||||||
class Direct : PatternScanMethod
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When comparing the signature, if [threshold] or more of the opcodes do not match, skip.
|
|
||||||
*/
|
|
||||||
class Fuzzy(internal val threshold: Int) : PatternScanMethod {
|
|
||||||
/**
|
|
||||||
* A list of warnings the resolver found.
|
|
||||||
*
|
|
||||||
* This list will be allocated when the signature has been found.
|
|
||||||
* Meaning, if the signature was not found,
|
|
||||||
* or the signature was not yet resolved,
|
|
||||||
* the list will be null.
|
|
||||||
*/
|
|
||||||
var warnings: List<Warning>? = null
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a resolver warning.
|
|
||||||
* @param correctOpcode The opcode the instruction list has.
|
|
||||||
* @param wrongOpcode The opcode the pattern list of the signature currently has.
|
|
||||||
* @param instructionIndex The index of the opcode relative to the instruction list.
|
|
||||||
* @param patternIndex The index of the opcode relative to the pattern list from the signature.
|
|
||||||
*/
|
|
||||||
data class Warning(
|
|
||||||
val correctOpcode: Opcode,
|
|
||||||
val wrongOpcode: Opcode,
|
|
||||||
val instructionIndex: Int,
|
|
||||||
val patternIndex: Int,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,9 @@
|
|||||||
|
package app.revanced.patcher.signature.base
|
||||||
|
|
||||||
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A ReVanced signature.
|
||||||
|
* Can be a [MethodSignature].
|
||||||
|
*/
|
||||||
|
interface Signature
|
@ -0,0 +1,47 @@
|
|||||||
|
package app.revanced.patcher.signature.implementation.method
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.data.implementation.MethodNotFoundException
|
||||||
|
import app.revanced.patcher.signature.base.Signature
|
||||||
|
import app.revanced.patcher.signature.implementation.method.resolver.SignatureResolverResult
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the [MethodSignature] for a method.
|
||||||
|
* @param returnType The return type of the method.
|
||||||
|
* @param accessFlags The access flags of the method.
|
||||||
|
* @param methodParameters The parameters of the method.
|
||||||
|
* @param opcodes The list of opcodes of the method.
|
||||||
|
* @param strings A list of strings which a method contains.
|
||||||
|
* A `null` opcode is equals to an unknown opcode.
|
||||||
|
*/
|
||||||
|
abstract class MethodSignature(
|
||||||
|
internal val returnType: String?,
|
||||||
|
internal val accessFlags: Int?,
|
||||||
|
internal val methodParameters: Iterable<String>?,
|
||||||
|
internal val opcodes: Iterable<Opcode?>?,
|
||||||
|
internal val strings: Iterable<String>? = null
|
||||||
|
) : Signature {
|
||||||
|
/**
|
||||||
|
* The result of the signature
|
||||||
|
*/
|
||||||
|
var result: SignatureResolverResult? = null
|
||||||
|
get() {
|
||||||
|
return field ?: throw MethodNotFoundException(
|
||||||
|
"Could not resolve required signature ${
|
||||||
|
(this::class.annotations.find { it is Name }?.let {
|
||||||
|
(it as Name).name
|
||||||
|
})
|
||||||
|
}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val resolved: Boolean
|
||||||
|
get() {
|
||||||
|
var resolved = false
|
||||||
|
try {
|
||||||
|
resolved = result != null
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
|
return resolved
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package app.revanced.patcher.signature.implementation.method.annotation
|
||||||
|
|
||||||
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotations for a method which matches to a [MethodSignature].
|
||||||
|
* @param definingClass The defining class name of the method.
|
||||||
|
* @param name A suggestive name for the method which the [MethodSignature] was created for.
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
annotation class MatchingMethod(
|
||||||
|
val definingClass: String = "L<empty>",
|
||||||
|
val name: String = "<method>"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotations to scan a pattern [MethodSignature] with fuzzy algorithm.
|
||||||
|
* @param threshold if [threshold] or more of the opcodes do not match, skip.
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
annotation class FuzzyPatternScanMethod(
|
||||||
|
val threshold: Int = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotations to scan a pattern [MethodSignature] directly.
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
annotation class DirectPatternScanMethod
|
@ -1,13 +1,11 @@
|
|||||||
package app.revanced.patcher.signature.resolver
|
package app.revanced.patcher.signature.implementation.method.resolver
|
||||||
|
|
||||||
import app.revanced.patcher.data.PatcherData
|
import app.revanced.patcher.data.PatcherData
|
||||||
import app.revanced.patcher.data.implementation.proxy
|
import app.revanced.patcher.data.implementation.proxy
|
||||||
|
import app.revanced.patcher.extensions.findAnnotationRecursively
|
||||||
import app.revanced.patcher.extensions.parametersEqual
|
import app.revanced.patcher.extensions.parametersEqual
|
||||||
import app.revanced.patcher.proxy.ClassProxy
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
import app.revanced.patcher.signature.MethodSignature
|
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
|
||||||
import app.revanced.patcher.signature.PatternScanMethod
|
|
||||||
import app.revanced.patcher.signature.PatternScanResult
|
|
||||||
import app.revanced.patcher.signature.SignatureResolverResult
|
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import org.jf.dexlib2.iface.ClassDef
|
||||||
import org.jf.dexlib2.iface.Method
|
import org.jf.dexlib2.iface.Method
|
||||||
@ -15,7 +13,7 @@ import org.jf.dexlib2.iface.instruction.Instruction
|
|||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
|
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
|
||||||
import org.jf.dexlib2.iface.reference.StringReference
|
import org.jf.dexlib2.iface.reference.StringReference
|
||||||
|
|
||||||
internal class SignatureResolver(
|
internal class MethodSignatureResolver(
|
||||||
private val classes: List<ClassDef>,
|
private val classes: List<ClassDef>,
|
||||||
private val methodSignatures: Iterable<MethodSignature>
|
private val methodSignatures: Iterable<MethodSignature>
|
||||||
) {
|
) {
|
||||||
@ -39,7 +37,10 @@ internal class SignatureResolver(
|
|||||||
|
|
||||||
// These functions do not require the constructor values, so they can be static.
|
// These functions do not require the constructor values, so they can be static.
|
||||||
companion object {
|
companion object {
|
||||||
fun resolveFromProxy(classProxy: ClassProxy, signature: MethodSignature): SignatureResolverResult? {
|
fun resolveFromProxy(
|
||||||
|
classProxy: app.revanced.patcher.util.proxy.ClassProxy,
|
||||||
|
signature: MethodSignature
|
||||||
|
): SignatureResolverResult? {
|
||||||
for (method in classProxy.immutableClass.methods) {
|
for (method in classProxy.immutableClass.methods) {
|
||||||
val result = compareSignatureToMethod(signature, method) ?: continue
|
val result = compareSignatureToMethod(signature, method) ?: continue
|
||||||
return SignatureResolverResult(
|
return SignatureResolverResult(
|
||||||
@ -107,9 +108,10 @@ internal class SignatureResolver(
|
|||||||
val count = instructions.count()
|
val count = instructions.count()
|
||||||
val pattern = signature.opcodes!!
|
val pattern = signature.opcodes!!
|
||||||
val size = pattern.count()
|
val size = pattern.count()
|
||||||
val method = signature.metadata.patternScanMethod
|
|
||||||
val threshold = if (method is PatternScanMethod.Fuzzy)
|
val threshold =
|
||||||
method.threshold else 0
|
signature::class.java.findAnnotationRecursively(FuzzyPatternScanMethod::class.java)?.threshold
|
||||||
|
?: 0
|
||||||
|
|
||||||
for (instructionIndex in 0 until count) {
|
for (instructionIndex in 0 until count) {
|
||||||
var patternIndex = 0
|
var patternIndex = 0
|
||||||
@ -126,11 +128,9 @@ internal class SignatureResolver(
|
|||||||
patternIndex-- // fix pattern offset
|
patternIndex-- // fix pattern offset
|
||||||
|
|
||||||
val result = PatternScanResult(instructionIndex, instructionIndex + patternIndex)
|
val result = PatternScanResult(instructionIndex, instructionIndex + patternIndex)
|
||||||
if (method is PatternScanMethod.Fuzzy) {
|
|
||||||
method.warnings = generateWarnings(
|
result.warnings = generateWarnings(signature, instructions, result)
|
||||||
signature, instructions, result
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ internal class SignatureResolver(
|
|||||||
correctOpcode != patternOpcode
|
correctOpcode != patternOpcode
|
||||||
) {
|
) {
|
||||||
this.add(
|
this.add(
|
||||||
PatternScanMethod.Fuzzy.Warning(
|
PatternScanResult.Warning(
|
||||||
correctOpcode, patternOpcode,
|
correctOpcode, patternOpcode,
|
||||||
instructionIndex, patternIndex,
|
instructionIndex, patternIndex,
|
||||||
)
|
)
|
@ -1,12 +1,13 @@
|
|||||||
package app.revanced.patcher.signature
|
package app.revanced.patcher.signature.implementation.method.resolver
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.softCompareTo
|
import app.revanced.patcher.extensions.softCompareTo
|
||||||
import app.revanced.patcher.proxy.ClassProxy
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
import app.revanced.patcher.signature.resolver.SignatureResolver
|
import app.revanced.patcher.util.proxy.ClassProxy
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.Method
|
import org.jf.dexlib2.iface.Method
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the result of a [SignatureResolver].
|
* Represents the result of a [MethodSignatureResolver].
|
||||||
* @param definingClassProxy The [ClassProxy] that the matching method was found in.
|
* @param definingClassProxy The [ClassProxy] that the matching method was found in.
|
||||||
* @param resolvedMethod The actual matching method.
|
* @param resolvedMethod The actual matching method.
|
||||||
* @param scanData Opcodes pattern scan result.
|
* @param scanData Opcodes pattern scan result.
|
||||||
@ -32,17 +33,43 @@ data class SignatureResolverResult(
|
|||||||
*
|
*
|
||||||
* If you need to modify the method, use [method] instead.
|
* If you need to modify the method, use [method] instead.
|
||||||
*/
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
val immutableMethod: Method
|
val immutableMethod: Method
|
||||||
get() = definingClassProxy.immutableClass.methods.first {
|
get() = definingClassProxy.immutableClass.methods.first {
|
||||||
it.softCompareTo(resolvedMethod)
|
it.softCompareTo(resolvedMethod)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findParentMethod(signature: MethodSignature): SignatureResolverResult? {
|
fun findParentMethod(signature: MethodSignature): SignatureResolverResult? {
|
||||||
return SignatureResolver.resolveFromProxy(definingClassProxy, signature)
|
return MethodSignatureResolver.resolveFromProxy(definingClassProxy, signature)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class PatternScanResult(
|
data class PatternScanResult(
|
||||||
val startIndex: Int,
|
val startIndex: Int,
|
||||||
val endIndex: Int
|
val endIndex: Int
|
||||||
|
) {
|
||||||
|
/**
|
||||||
|
* A list of warnings the resolver found.
|
||||||
|
*
|
||||||
|
* This list will be allocated when the signature has been found.
|
||||||
|
* Meaning, if the signature was not found,
|
||||||
|
* or the signature was not yet resolved,
|
||||||
|
* the list will be null.
|
||||||
|
*/
|
||||||
|
var warnings: List<Warning>? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a resolver warning.
|
||||||
|
* @param correctOpcode The opcode the instruction list has.
|
||||||
|
* @param wrongOpcode The opcode the pattern list of the signature currently has.
|
||||||
|
* @param instructionIndex The index of the opcode relative to the instruction list.
|
||||||
|
* @param patternIndex The index of the opcode relative to the pattern list from the signature.
|
||||||
|
*/
|
||||||
|
data class Warning(
|
||||||
|
val correctOpcode: Opcode,
|
||||||
|
val wrongOpcode: Opcode,
|
||||||
|
val instructionIndex: Int,
|
||||||
|
val patternIndex: Int,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
package app.revanced.patcher.util
|
package app.revanced.patcher.util
|
||||||
|
|
||||||
class ListBackedSet<E>(private val list: MutableList<E>) : MutableSet<E> {
|
internal class ListBackedSet<E>(private val list: MutableList<E>) : MutableSet<E> {
|
||||||
override val size get() = list.size
|
override val size get() = list.size
|
||||||
override fun add(element: E) = list.add(element)
|
override fun add(element: E) = list.add(element)
|
||||||
override fun addAll(elements: Collection<E>) = list.addAll(elements)
|
override fun addAll(elements: Collection<E>) = list.addAll(elements)
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package app.revanced.patcher.util
|
package app.revanced.patcher.util
|
||||||
|
|
||||||
import app.revanced.patcher.proxy.ClassProxy
|
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import org.jf.dexlib2.iface.ClassDef
|
||||||
|
|
||||||
class ProxyBackedClassList(internal val internalClasses: MutableList<ClassDef>) : List<ClassDef> {
|
class ProxyBackedClassList(internal val internalClasses: MutableList<ClassDef>) : List<ClassDef> {
|
||||||
internal val proxies = mutableListOf<ClassProxy>()
|
internal val proxies = mutableListOf<app.revanced.patcher.util.proxy.ClassProxy>()
|
||||||
|
|
||||||
fun add(classDef: ClassDef) {
|
fun add(classDef: ClassDef) {
|
||||||
internalClasses.add(classDef)
|
internalClasses.add(classDef)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun add(classProxy: ClassProxy) {
|
fun add(classProxy: app.revanced.patcher.util.proxy.ClassProxy) {
|
||||||
proxies.add(classProxy)
|
proxies.add(classProxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package app.revanced.patcher.methodWalker
|
package app.revanced.patcher.util.method
|
||||||
|
|
||||||
import app.revanced.patcher.data.implementation.BytecodeData
|
import app.revanced.patcher.data.implementation.BytecodeData
|
||||||
import app.revanced.patcher.data.implementation.MethodNotFoundException
|
import app.revanced.patcher.data.implementation.MethodNotFoundException
|
||||||
import app.revanced.patcher.extensions.softCompareTo
|
import app.revanced.patcher.extensions.softCompareTo
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import org.jf.dexlib2.Format
|
import org.jf.dexlib2.Format
|
||||||
import org.jf.dexlib2.iface.Method
|
import org.jf.dexlib2.iface.Method
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
@ -1,6 +1,6 @@
|
|||||||
package app.revanced.patcher.proxy
|
package app.revanced.patcher.util.proxy
|
||||||
|
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableClass
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import org.jf.dexlib2.iface.ClassDef
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,6 +1,6 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes
|
package app.revanced.patcher.util.proxy.mutableTypes
|
||||||
|
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableAnnotationElement.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotationElement.Companion.toMutable
|
||||||
import org.jf.dexlib2.base.BaseAnnotation
|
import org.jf.dexlib2.base.BaseAnnotation
|
||||||
import org.jf.dexlib2.iface.Annotation
|
import org.jf.dexlib2.iface.Annotation
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes
|
package app.revanced.patcher.util.proxy.mutableTypes
|
||||||
|
|
||||||
import app.revanced.patcher.proxy.mutableTypes.encodedValue.MutableEncodedValue
|
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue
|
||||||
import app.revanced.patcher.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
||||||
import org.jf.dexlib2.base.BaseAnnotationElement
|
import org.jf.dexlib2.base.BaseAnnotationElement
|
||||||
import org.jf.dexlib2.iface.AnnotationElement
|
import org.jf.dexlib2.iface.AnnotationElement
|
||||||
import org.jf.dexlib2.iface.value.EncodedValue
|
import org.jf.dexlib2.iface.value.EncodedValue
|
@ -1,8 +1,8 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes
|
package app.revanced.patcher.util.proxy.mutableTypes
|
||||||
|
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableField.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
import com.google.common.collect.Iterables
|
import com.google.common.collect.Iterables
|
||||||
import org.jf.dexlib2.base.reference.BaseTypeReference
|
import org.jf.dexlib2.base.reference.BaseTypeReference
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import org.jf.dexlib2.iface.ClassDef
|
@ -1,8 +1,8 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes
|
package app.revanced.patcher.util.proxy.mutableTypes
|
||||||
|
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
||||||
import app.revanced.patcher.proxy.mutableTypes.encodedValue.MutableEncodedValue
|
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue
|
||||||
import app.revanced.patcher.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
||||||
import org.jf.dexlib2.HiddenApiRestriction
|
import org.jf.dexlib2.HiddenApiRestriction
|
||||||
import org.jf.dexlib2.base.reference.BaseFieldReference
|
import org.jf.dexlib2.base.reference.BaseFieldReference
|
||||||
import org.jf.dexlib2.iface.Field
|
import org.jf.dexlib2.iface.Field
|
@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes
|
package app.revanced.patcher.util.proxy.mutableTypes
|
||||||
|
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableMethodParameter.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethodParameter.Companion.toMutable
|
||||||
import org.jf.dexlib2.HiddenApiRestriction
|
import org.jf.dexlib2.HiddenApiRestriction
|
||||||
import org.jf.dexlib2.base.reference.BaseMethodReference
|
import org.jf.dexlib2.base.reference.BaseMethodReference
|
||||||
import org.jf.dexlib2.builder.MutableMethodImplementation
|
import org.jf.dexlib2.builder.MutableMethodImplementation
|
@ -1,6 +1,6 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes
|
package app.revanced.patcher.util.proxy.mutableTypes
|
||||||
|
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotation.Companion.toMutable
|
||||||
import org.jf.dexlib2.base.BaseMethodParameter
|
import org.jf.dexlib2.base.BaseMethodParameter
|
||||||
import org.jf.dexlib2.iface.MethodParameter
|
import org.jf.dexlib2.iface.MethodParameter
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableAnnotationElement.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableAnnotationElement.Companion.toMutable
|
||||||
import org.jf.dexlib2.base.value.BaseAnnotationEncodedValue
|
import org.jf.dexlib2.base.value.BaseAnnotationEncodedValue
|
||||||
import org.jf.dexlib2.iface.AnnotationElement
|
import org.jf.dexlib2.iface.AnnotationElement
|
||||||
import org.jf.dexlib2.iface.value.AnnotationEncodedValue
|
import org.jf.dexlib2.iface.value.AnnotationEncodedValue
|
@ -1,6 +1,6 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import app.revanced.patcher.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable
|
||||||
import org.jf.dexlib2.base.value.BaseArrayEncodedValue
|
import org.jf.dexlib2.base.value.BaseArrayEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.ArrayEncodedValue
|
import org.jf.dexlib2.iface.value.ArrayEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.EncodedValue
|
import org.jf.dexlib2.iface.value.EncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseBooleanEncodedValue
|
import org.jf.dexlib2.base.value.BaseBooleanEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.BooleanEncodedValue
|
import org.jf.dexlib2.iface.value.BooleanEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseByteEncodedValue
|
import org.jf.dexlib2.base.value.BaseByteEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.ByteEncodedValue
|
import org.jf.dexlib2.iface.value.ByteEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseCharEncodedValue
|
import org.jf.dexlib2.base.value.BaseCharEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.CharEncodedValue
|
import org.jf.dexlib2.iface.value.CharEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseDoubleEncodedValue
|
import org.jf.dexlib2.base.value.BaseDoubleEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.DoubleEncodedValue
|
import org.jf.dexlib2.iface.value.DoubleEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.ValueType
|
import org.jf.dexlib2.ValueType
|
||||||
import org.jf.dexlib2.iface.value.*
|
import org.jf.dexlib2.iface.value.*
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseEnumEncodedValue
|
import org.jf.dexlib2.base.value.BaseEnumEncodedValue
|
||||||
import org.jf.dexlib2.iface.reference.FieldReference
|
import org.jf.dexlib2.iface.reference.FieldReference
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.ValueType
|
import org.jf.dexlib2.ValueType
|
||||||
import org.jf.dexlib2.base.value.BaseFieldEncodedValue
|
import org.jf.dexlib2.base.value.BaseFieldEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseFloatEncodedValue
|
import org.jf.dexlib2.base.value.BaseFloatEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.FloatEncodedValue
|
import org.jf.dexlib2.iface.value.FloatEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseIntEncodedValue
|
import org.jf.dexlib2.base.value.BaseIntEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.IntEncodedValue
|
import org.jf.dexlib2.iface.value.IntEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseLongEncodedValue
|
import org.jf.dexlib2.base.value.BaseLongEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.LongEncodedValue
|
import org.jf.dexlib2.iface.value.LongEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseMethodEncodedValue
|
import org.jf.dexlib2.base.value.BaseMethodEncodedValue
|
||||||
import org.jf.dexlib2.iface.reference.MethodReference
|
import org.jf.dexlib2.iface.reference.MethodReference
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseMethodHandleEncodedValue
|
import org.jf.dexlib2.base.value.BaseMethodHandleEncodedValue
|
||||||
import org.jf.dexlib2.iface.reference.MethodHandleReference
|
import org.jf.dexlib2.iface.reference.MethodHandleReference
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseMethodTypeEncodedValue
|
import org.jf.dexlib2.base.value.BaseMethodTypeEncodedValue
|
||||||
import org.jf.dexlib2.iface.reference.MethodProtoReference
|
import org.jf.dexlib2.iface.reference.MethodProtoReference
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseNullEncodedValue
|
import org.jf.dexlib2.base.value.BaseNullEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.ByteEncodedValue
|
import org.jf.dexlib2.iface.value.ByteEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseShortEncodedValue
|
import org.jf.dexlib2.base.value.BaseShortEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.ShortEncodedValue
|
import org.jf.dexlib2.iface.value.ShortEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseStringEncodedValue
|
import org.jf.dexlib2.base.value.BaseStringEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.ByteEncodedValue
|
import org.jf.dexlib2.iface.value.ByteEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.proxy.mutableTypes.encodedValue
|
package app.revanced.patcher.util.proxy.mutableTypes.encodedValue
|
||||||
|
|
||||||
import org.jf.dexlib2.base.value.BaseTypeEncodedValue
|
import org.jf.dexlib2.base.value.BaseTypeEncodedValue
|
||||||
import org.jf.dexlib2.iface.value.TypeEncodedValue
|
import org.jf.dexlib2.iface.value.TypeEncodedValue
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.smali
|
package app.revanced.patcher.util.smali
|
||||||
|
|
||||||
import org.antlr.runtime.CommonTokenStream
|
import org.antlr.runtime.CommonTokenStream
|
||||||
import org.antlr.runtime.TokenSource
|
import org.antlr.runtime.TokenSource
|
||||||
@ -32,7 +32,11 @@ class InlineSmaliCompiler {
|
|||||||
* be messed up and results in broken Dalvik bytecode.
|
* be messed up and results in broken Dalvik bytecode.
|
||||||
* FIXME: Fix the above issue. When this is fixed, add the proper conversions in [InstructionConverter].
|
* FIXME: Fix the above issue. When this is fixed, add the proper conversions in [InstructionConverter].
|
||||||
*/
|
*/
|
||||||
fun compileMethodInstructions(instructions: String, parameters: String, registers: Int): List<BuilderInstruction> {
|
fun compileMethodInstructions(
|
||||||
|
instructions: String,
|
||||||
|
parameters: String,
|
||||||
|
registers: Int
|
||||||
|
): List<BuilderInstruction> {
|
||||||
val input = METHOD_TEMPLATE.format(parameters, registers, instructions)
|
val input = METHOD_TEMPLATE.format(parameters, registers, instructions)
|
||||||
val reader = InputStreamReader(input.byteInputStream())
|
val reader = InputStreamReader(input.byteInputStream())
|
||||||
val lexer: LexerErrorInterface = smaliFlexLexer(reader, 15)
|
val lexer: LexerErrorInterface = smaliFlexLexer(reader, 15)
|
||||||
@ -54,5 +58,8 @@ class InlineSmaliCompiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.toInstructions(parameters: String = "", registers: Int = 1) = InlineSmaliCompiler.compileMethodInstructions(this, parameters, registers)
|
fun String.toInstructions(parameters: String = "", registers: Int = 1) =
|
||||||
fun String.toInstruction(parameters: String = "", registers: Int = 1) = this.toInstructions(parameters, registers).first()
|
InlineSmaliCompiler.compileMethodInstructions(this, parameters, registers)
|
||||||
|
|
||||||
|
fun String.toInstruction(parameters: String = "", registers: Int = 1) =
|
||||||
|
this.toInstructions(parameters, registers).first()
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher.smali
|
package app.revanced.patcher.util.smali
|
||||||
|
|
||||||
import org.jf.dexlib2.Format
|
import org.jf.dexlib2.Format
|
||||||
import org.jf.dexlib2.builder.instruction.*
|
import org.jf.dexlib2.builder.instruction.*
|
@ -1,16 +1,12 @@
|
|||||||
package app.revanced.patcher
|
package app.revanced.patcher
|
||||||
|
|
||||||
import app.revanced.patcher.signature.PatternScanMethod
|
|
||||||
import app.revanced.patcher.usage.ExampleBytecodePatch
|
|
||||||
import app.revanced.patcher.usage.ExampleResourcePatch
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import java.io.File
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
internal class PatcherTest {
|
internal class PatcherTest {
|
||||||
@Test
|
@Test
|
||||||
fun testPatcher() {
|
fun testPatcher() {
|
||||||
return // FIXME: create a proper resource to pass this test
|
return // FIXME: create a proper resource to pass this test
|
||||||
|
/**
|
||||||
val patcher = Patcher(
|
val patcher = Patcher(
|
||||||
File(PatcherTest::class.java.getResource("/example.apk")!!.toURI()),
|
File(PatcherTest::class.java.getResource("/example.apk")!!.toURI()),
|
||||||
"exampleCacheDirectory",
|
"exampleCacheDirectory",
|
||||||
@ -45,5 +41,6 @@ internal class PatcherTest {
|
|||||||
}
|
}
|
||||||
val out = patcher.save()
|
val out = patcher.save()
|
||||||
assertTrue(out.isNotEmpty(), "Expected the output of Patcher#save() to not be empty.")
|
assertTrue(out.isNotEmpty(), "Expected the output of Patcher#save() to not be empty.")
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package app.revanced.patcher.usage.bytecode.annotation
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
|
import app.revanced.patcher.annotation.Package
|
||||||
|
|
||||||
|
@Compatibility(
|
||||||
|
[Package(
|
||||||
|
"com.example.examplePackage", arrayOf("0.0.1", "0.0.2")
|
||||||
|
)]
|
||||||
|
)
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
internal annotation class ExampleBytecodeCompatibility
|
||||||
|
|
@ -1,21 +1,21 @@
|
|||||||
package app.revanced.patcher.usage
|
package app.revanced.patcher.usage.bytecode.patch
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Description
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.implementation.BytecodeData
|
import app.revanced.patcher.data.implementation.BytecodeData
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||||
import app.revanced.patcher.patch.implementation.metadata.PackageMetadata
|
|
||||||
import app.revanced.patcher.patch.implementation.metadata.PatchMetadata
|
|
||||||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableField.Companion.toMutable
|
import app.revanced.patcher.usage.bytecode.signatures.ExampleSignature
|
||||||
import app.revanced.patcher.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
import app.revanced.patcher.usage.resource.annotation.ExampleResourceCompatibility
|
||||||
import app.revanced.patcher.signature.MethodMetadata
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
||||||
import app.revanced.patcher.signature.MethodSignature
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
import app.revanced.patcher.signature.MethodSignatureMetadata
|
import app.revanced.patcher.util.smali.toInstruction
|
||||||
import app.revanced.patcher.signature.PatternScanMethod
|
import app.revanced.patcher.util.smali.toInstructions
|
||||||
import app.revanced.patcher.smali.toInstruction
|
|
||||||
import app.revanced.patcher.smali.toInstructions
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Format
|
import org.jf.dexlib2.Format
|
||||||
@ -32,45 +32,15 @@ import org.jf.dexlib2.immutable.reference.ImmutableStringReference
|
|||||||
import org.jf.dexlib2.immutable.value.ImmutableFieldEncodedValue
|
import org.jf.dexlib2.immutable.value.ImmutableFieldEncodedValue
|
||||||
import org.jf.dexlib2.util.Preconditions
|
import org.jf.dexlib2.util.Preconditions
|
||||||
|
|
||||||
val packageMetadata = listOf(
|
@Patch
|
||||||
PackageMetadata(
|
@Name("example-bytecode-patch")
|
||||||
"com.example.examplePackage",
|
@Description("Example demonstration of a bytecode patch.")
|
||||||
listOf("0.0.1", "0.0.2")
|
@ExampleResourceCompatibility
|
||||||
)
|
@Version("0.0.1")
|
||||||
)
|
|
||||||
|
|
||||||
class ExampleBytecodePatch : BytecodePatch(
|
class ExampleBytecodePatch : BytecodePatch(
|
||||||
PatchMetadata(
|
|
||||||
"example-patch",
|
|
||||||
"ReVanced example patch",
|
|
||||||
"A demonstrative patch to feature the core features of the ReVanced patcher",
|
|
||||||
packageMetadata,
|
|
||||||
"0.0.1"
|
|
||||||
),
|
|
||||||
setOf(
|
|
||||||
MethodSignature(
|
|
||||||
MethodSignatureMetadata(
|
|
||||||
"Example signature",
|
|
||||||
MethodMetadata(
|
|
||||||
"TestClass",
|
|
||||||
"main",
|
|
||||||
),
|
|
||||||
PatternScanMethod.Fuzzy(1),
|
|
||||||
packageMetadata,
|
|
||||||
"The main method of TestClass",
|
|
||||||
"1.0.0"
|
|
||||||
),
|
|
||||||
"V",
|
|
||||||
AccessFlags.PUBLIC or AccessFlags.STATIC,
|
|
||||||
listOf("[L"),
|
|
||||||
listOf(
|
listOf(
|
||||||
Opcode.SGET_OBJECT,
|
ExampleSignature
|
||||||
null, // Testing unknown opcodes.
|
|
||||||
Opcode.INVOKE_STATIC, // This is intentionally wrong to test the Fuzzy resolver.
|
|
||||||
Opcode.RETURN_VOID
|
|
||||||
),
|
|
||||||
null
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
// This function will be executed by the patcher.
|
// This function will be executed by the patcher.
|
@ -0,0 +1,32 @@
|
|||||||
|
package app.revanced.patcher.usage.bytecode.signatures
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
|
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
|
||||||
|
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
|
||||||
|
import app.revanced.patcher.usage.bytecode.annotation.ExampleBytecodeCompatibility
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
@Name("example-signature")
|
||||||
|
@MatchingMethod(
|
||||||
|
"LexampleClass;",
|
||||||
|
"exampleMehod"
|
||||||
|
)
|
||||||
|
@FuzzyPatternScanMethod(2)
|
||||||
|
@ExampleBytecodeCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
object ExampleSignature : MethodSignature(
|
||||||
|
"V",
|
||||||
|
AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||||
|
listOf("[L"),
|
||||||
|
listOf(
|
||||||
|
Opcode.SGET_OBJECT,
|
||||||
|
null, // Testing unknown opcodes.
|
||||||
|
Opcode.INVOKE_STATIC, // This is intentionally wrong to test the Fuzzy resolver.
|
||||||
|
Opcode.RETURN_VOID
|
||||||
|
),
|
||||||
|
null
|
||||||
|
)
|
@ -0,0 +1,14 @@
|
|||||||
|
package app.revanced.patcher.usage.resource.annotation
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
|
import app.revanced.patcher.annotation.Package
|
||||||
|
|
||||||
|
@Compatibility(
|
||||||
|
[Package(
|
||||||
|
"com.example.examplePackage", arrayOf("0.0.1", "0.0.2")
|
||||||
|
)]
|
||||||
|
)
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
internal annotation class ExampleResourceCompatibility
|
||||||
|
|
@ -1,21 +1,22 @@
|
|||||||
package app.revanced.patcher.usage
|
package app.revanced.patcher.usage.resource.patch
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Description
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.implementation.ResourceData
|
import app.revanced.patcher.data.implementation.ResourceData
|
||||||
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patcher.patch.implementation.ResourcePatch
|
import app.revanced.patcher.patch.implementation.ResourcePatch
|
||||||
import app.revanced.patcher.patch.implementation.metadata.PatchMetadata
|
|
||||||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||||
|
import app.revanced.patcher.usage.resource.annotation.ExampleResourceCompatibility
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
class ExampleResourcePatch : ResourcePatch(
|
@Patch
|
||||||
PatchMetadata(
|
@Name("example-resource-patch")
|
||||||
"example-patch",
|
@Description("Example demonstration of a resource patch.")
|
||||||
"Example Resource Patch",
|
@ExampleResourceCompatibility
|
||||||
"Example demonstration of a resource patch.",
|
@Version("0.0.1")
|
||||||
packageMetadata,
|
class ExampleResourcePatch : ResourcePatch() {
|
||||||
"0.0.1"
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
override fun execute(data: ResourceData): PatchResult {
|
override fun execute(data: ResourceData): PatchResult {
|
||||||
val editor = data.getXmlEditor("AndroidManifest.xml")
|
val editor = data.getXmlEditor("AndroidManifest.xml")
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user