diff --git a/build.gradle.kts b/build.gradle.kts index 7b793352..88bcaec7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,7 +25,7 @@ repositories { } dependencies { - implementation("app.revanced:revanced-patcher:13.0.0") + implementation("app.revanced:revanced-patcher:14.0.0") implementation("com.android.tools.smali:smali:3.0.3") // Required because build fails without it. // TODO: Find a way to remove this dependency. diff --git a/src/main/kotlin/app/revanced/extensions/Extensions.kt b/src/main/kotlin/app/revanced/extensions/Extensions.kt index 1998cf1d..649cf6c2 100644 --- a/src/main/kotlin/app/revanced/extensions/Extensions.kt +++ b/src/main/kotlin/app/revanced/extensions/Extensions.kt @@ -1,9 +1,10 @@ package app.revanced.extensions -import app.revanced.patcher.extensions.MethodFingerprintExtensions.name +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.MethodFingerprintExtensions.name import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchException import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch @@ -13,13 +14,12 @@ import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction import com.android.tools.smali.dexlib2.util.MethodUtil import org.w3c.dom.Node -// TODO: populate this to all patches /** - * Convert a [MethodFingerprint] to a [PatchResultError]. + * Return [PatchException] from a [MethodFingerprint]. * - * @return A [PatchResultError] for the [MethodFingerprint]. + * @return The [PatchException] for the [MethodFingerprint]. */ -internal fun MethodFingerprint.toErrorResult() = PatchResultError("Failed to resolve $name") +internal fun MethodFingerprint.toErrorResult() = PatchException("Failed to resolve $name") /** * Find the [MutableMethod] from a given [Method] in a [MutableClass]. @@ -82,3 +82,16 @@ fun Method.indexOfFirstConstantInstructionValue(constantValue: Long): Int { fun Method.containsConstantInstructionValue(constantValue: Long): Boolean { return indexOfFirstConstantInstructionValue(constantValue) >= 0 } + +/** + * traverse the class hierarchy starting from the given root class + * + * @param targetClass the class to start traversing the class hierarchy from + * @param callback function that is called for every class in the hierarchy + */ +fun BytecodeContext.traverseClassHierarchy(targetClass: MutableClass, callback: MutableClass.() -> Unit) { + callback(targetClass) + this.findClass(targetClass.superclass ?: return)?.mutableClass?.let { + traverseClassHierarchy(it, callback) + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/meta/JsonGenerator.kt b/src/main/kotlin/app/revanced/meta/JsonGenerator.kt index cebf57d9..3be7793f 100644 --- a/src/main/kotlin/app/revanced/meta/JsonGenerator.kt +++ b/src/main/kotlin/app/revanced/meta/JsonGenerator.kt @@ -6,7 +6,6 @@ import app.revanced.patcher.extensions.PatchExtensions.description import app.revanced.patcher.extensions.PatchExtensions.include import app.revanced.patcher.extensions.PatchExtensions.options import app.revanced.patcher.extensions.PatchExtensions.patchName -import app.revanced.patcher.extensions.PatchExtensions.version import app.revanced.patcher.patch.PatchOption import com.google.gson.GsonBuilder import java.io.File @@ -17,7 +16,6 @@ internal class JsonGenerator : PatchesFileGenerator { JsonPatch( it.patchName, it.description ?: "This patch has no description.", - it.version ?: "0.0.0", !it.include, it.options?.map { option -> JsonPatch.Option( @@ -48,7 +46,6 @@ internal class JsonGenerator : PatchesFileGenerator { private class JsonPatch( val name: String, val description: String, - val version: String, val excluded: Boolean, val options: Array