refactor(YouTube Music/Settings): reorganize settings menu

This commit is contained in:
inotia00
2024-05-05 00:22:51 +09:00
parent 1f59997e53
commit 01795e0fb4
157 changed files with 2834 additions and 3725 deletions

View File

@ -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.
*