mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
feat(YouTube/Enable tablet mini player): add Enable modern mini player
settings
This commit is contained in:
@ -24,12 +24,15 @@ import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction31i
|
||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
import com.android.tools.smali.dexlib2.iface.reference.Reference
|
||||
import com.android.tools.smali.dexlib2.immutable.ImmutableField
|
||||
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||
|
||||
const val REGISTER_TEMPLATE_REPLACEMENT: String = "REGISTER_INDEX"
|
||||
|
||||
fun MethodFingerprint.resultOrThrow() = result ?: throw exception
|
||||
|
||||
/**
|
||||
@ -136,7 +139,7 @@ fun MethodFingerprint.literalInstructionBooleanHook(
|
||||
}
|
||||
}
|
||||
|
||||
fun MethodFingerprint.literalInstructionViewHook(
|
||||
fun MethodFingerprint.literalInstructionHook(
|
||||
literal: Long,
|
||||
descriptor: String
|
||||
) {
|
||||
@ -152,6 +155,37 @@ fun MethodFingerprint.literalInstructionViewHook(
|
||||
}
|
||||
}
|
||||
|
||||
fun BytecodeContext.literalInstructionHook(
|
||||
literal: Long,
|
||||
smaliInstruction: String
|
||||
) {
|
||||
val context = this
|
||||
context.classes.forEach { classDef ->
|
||||
classDef.methods.forEach { method ->
|
||||
method.implementation.apply {
|
||||
this?.instructions?.forEachIndexed { _, instruction ->
|
||||
if (instruction.opcode != Opcode.CONST)
|
||||
return@forEachIndexed
|
||||
if ((instruction as Instruction31i).wideLiteral != literal)
|
||||
return@forEachIndexed
|
||||
|
||||
context.proxy(classDef)
|
||||
.mutableClass
|
||||
.findMutableMethodOf(method).apply {
|
||||
val index = getWideLiteralInstructionIndex(literal)
|
||||
val register = (instruction as OneRegisterInstruction).registerA.toString()
|
||||
|
||||
addInstructions(
|
||||
index + 1,
|
||||
smaliInstruction.replace(REGISTER_TEMPLATE_REPLACEMENT, register)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the index of the first wide literal instruction with the given value.
|
||||
*
|
||||
|
Reference in New Issue
Block a user