feat(YouTube/Enable tablet mini player): add Enable modern mini player settings

This commit is contained in:
inotia00
2024-04-29 19:34:41 +09:00
parent 9aecec0df8
commit f66ac24f55
7 changed files with 144 additions and 37 deletions

View File

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