build: Bump ReVanced Patcher (#3862)
Co-authored-by: Ushie <ushiekane@gmail.com>
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package app.revanced.util
|
||||
|
||||
import app.revanced.patcher.Fingerprint
|
||||
import app.revanced.patcher.FingerprintBuilder
|
||||
import app.revanced.patcher.Match
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
@@ -24,17 +22,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.Reference
|
||||
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||
|
||||
val Fingerprint.matchOrThrow
|
||||
get() = match ?: throw exception
|
||||
|
||||
/**
|
||||
* The [PatchException] of failing to match a [Fingerprint].
|
||||
*
|
||||
* @return The [PatchException].
|
||||
*/
|
||||
val Fingerprint.exception
|
||||
get() = PatchException("Failed to match the fingerprint: $this")
|
||||
|
||||
/**
|
||||
* Find the [MutableMethod] from a given [Method] in a [MutableClass].
|
||||
*
|
||||
@@ -358,13 +345,11 @@ fun Method.indexOfFirstInstructionReversedOrThrow(startIndex: Int? = null, filte
|
||||
* _Returns an empty list if no indices are found_
|
||||
* @see findInstructionIndicesReversedOrThrow
|
||||
*/
|
||||
fun Method.findInstructionIndicesReversed(filter: Instruction.() -> Boolean): List<Int> {
|
||||
return instructions
|
||||
.withIndex()
|
||||
.filter { (_, instruction) -> filter(instruction) }
|
||||
.map { (index, _) -> index }
|
||||
.asReversed()
|
||||
}
|
||||
fun Method.findInstructionIndicesReversed(filter: Instruction.() -> Boolean): List<Int> = instructions
|
||||
.withIndex()
|
||||
.filter { (_, instruction) -> filter(instruction) }
|
||||
.map { (index, _) -> index }
|
||||
.asReversed()
|
||||
|
||||
/**
|
||||
* @return An immutable list of indices of the instructions in reverse order.
|
||||
@@ -417,12 +402,6 @@ fun BytecodePatchContext.forEachLiteralValueInstruction(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the matched method early.
|
||||
*/
|
||||
fun Fingerprint.returnEarly(bool: Boolean = false) =
|
||||
matchOrThrow.mutableMethod. returnEarly(bool)
|
||||
|
||||
/**
|
||||
* Return the method early.
|
||||
*/
|
||||
@@ -435,31 +414,20 @@ fun MutableMethod.returnEarly(bool: Boolean = false) {
|
||||
const/4 v0, $const
|
||||
return-object v0
|
||||
"""
|
||||
|
||||
'V' -> "return-void"
|
||||
'I', 'Z' ->
|
||||
"""
|
||||
const/4 v0, $const
|
||||
return v0
|
||||
"""
|
||||
|
||||
else -> throw Exception("This case should never happen.")
|
||||
}
|
||||
|
||||
addInstructions(0, stringInstructions)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the matched methods early.
|
||||
*/
|
||||
fun Iterable<Fingerprint>.returnEarly(bool: Boolean = false) = forEach { fingerprint ->
|
||||
fingerprint.returnEarly(bool)
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches this fingerprint using the classDef of a parent fingerprint match.
|
||||
*/
|
||||
fun Fingerprint.applyMatch(context: BytecodePatchContext, parentMatch: Match) =
|
||||
apply { match(context, parentMatch.classDef) }.matchOrThrow
|
||||
|
||||
/**
|
||||
* Set the custom condition for this fingerprint to check for a literal value.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package app.revanced.util
|
||||
|
||||
import app.revanced.patcher.patch.ResourcePatchContext
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.ResourcePatchContext
|
||||
import app.revanced.patcher.util.Document
|
||||
import app.revanced.util.resource.BaseResource
|
||||
import org.w3c.dom.Attr
|
||||
@@ -23,7 +23,8 @@ fun NodeList.asSequence() = (0 until this.length).asSequence().map { this.item(i
|
||||
* Returns a sequence for all child nodes.
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun Node.childElementsSequence() = this.childNodes.asSequence().filter { it.nodeType == Node.ELEMENT_NODE } as Sequence<Element>
|
||||
fun Node.childElementsSequence() =
|
||||
this.childNodes.asSequence().filter { it.nodeType == Node.ELEMENT_NODE } as Sequence<Element>
|
||||
|
||||
/**
|
||||
* Performs the given [action] on each child element.
|
||||
@@ -97,7 +98,7 @@ fun ResourcePatchContext.iterateXmlNodeChildren(
|
||||
resource: String,
|
||||
targetTag: String,
|
||||
callback: (node: Node) -> Unit,
|
||||
) = document[classLoader.getResourceAsStream(resource)!!].use { document ->
|
||||
) = document(classLoader.getResourceAsStream(resource)!!).use { document ->
|
||||
val stringsNode = document.getElementsByTagName(targetTag).item(0).childNodes
|
||||
for (i in 1 until stringsNode.length - 1) callback(stringsNode.item(i))
|
||||
}
|
||||
@@ -164,9 +165,8 @@ internal fun NodeList.findElementByAttributeValue(attributeName: String, value:
|
||||
return null
|
||||
}
|
||||
|
||||
internal fun NodeList.findElementByAttributeValueOrThrow(attributeName: String, value: String): Element {
|
||||
return findElementByAttributeValue(attributeName, value) ?: throw PatchException("Could not find: $attributeName $value")
|
||||
}
|
||||
internal fun NodeList.findElementByAttributeValueOrThrow(attributeName: String, value: String) =
|
||||
findElementByAttributeValue(attributeName, value) ?: throw PatchException("Could not find: $attributeName $value")
|
||||
|
||||
internal fun Element.copyAttributesFrom(oldContainer: Element) {
|
||||
// Copy attributes from the old element to the new element
|
||||
|
||||
Reference in New Issue
Block a user