mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
refactor(YouTube Music/Settings): reorganize settings menu
This commit is contained in:
@ -98,29 +98,11 @@ fun MethodFingerprint.literalInstructionBooleanHook(
|
||||
descriptor: String
|
||||
) = literalInstructionBooleanHook(literal.toLong(), descriptor)
|
||||
|
||||
fun MethodFingerprint.literalInstructionBooleanHook(
|
||||
literal: Int,
|
||||
descriptor: String,
|
||||
message: String
|
||||
) = literalInstructionBooleanHook(literal.toLong(), descriptor, message)
|
||||
|
||||
fun MethodFingerprint.literalInstructionBooleanHook(
|
||||
literal: Long,
|
||||
descriptor: String
|
||||
) = literalInstructionBooleanHook(literal, descriptor, "")
|
||||
|
||||
fun MethodFingerprint.literalInstructionBooleanHook(
|
||||
literal: Long,
|
||||
descriptor: String,
|
||||
message: String
|
||||
) {
|
||||
val method = result?.mutableMethod
|
||||
?: if (message.isEmpty())
|
||||
throw exception
|
||||
else
|
||||
throw PatchException("This version is not supported. $message")
|
||||
|
||||
method.apply {
|
||||
resultOrThrow().mutableMethod.apply {
|
||||
val literalIndex = getWideLiteralInstructionIndex(literal)
|
||||
val targetIndex = getTargetIndex(literalIndex, Opcode.MOVE_RESULT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
@ -224,13 +206,15 @@ fun Method.getWideLiteralInstructionIndex(literal: Long) = implementation?.let {
|
||||
}
|
||||
} ?: -1
|
||||
|
||||
fun MutableMethod.getEmptyStringInstructionIndex()
|
||||
fun Method.getEmptyStringInstructionIndex()
|
||||
= getStringInstructionIndex("")
|
||||
|
||||
fun MutableMethod.getStringInstructionIndex(value: String) = indexOfFirstInstruction {
|
||||
opcode == Opcode.CONST_STRING
|
||||
&& (this as? BuilderInstruction21c)?.reference.toString() == value
|
||||
}
|
||||
fun Method.getStringInstructionIndex(value: String) = implementation?.let {
|
||||
it.instructions.indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.CONST_STRING
|
||||
&& (instruction as? BuilderInstruction21c)?.reference.toString() == value
|
||||
}
|
||||
} ?: -1
|
||||
|
||||
/**
|
||||
* Check if the method contains a literal with the given value.
|
||||
@ -246,7 +230,6 @@ fun Method.containsMethodReferenceNameInstructionIndex(methodName: String) =
|
||||
fun Method.containsReferenceInstructionIndex(reference: String) =
|
||||
getTargetIndexWithReference(reference) >= 0
|
||||
|
||||
|
||||
/**
|
||||
* Traverse the class hierarchy starting from the given root class.
|
||||
*
|
||||
|
Reference in New Issue
Block a user