fix(YouTube/Hide seek message): force closes in YouTube v18.36.39

This commit is contained in:
inotia00
2023-10-27 12:40:53 +09:00
parent 8ea39970f8
commit 570aa0b0fd
2 changed files with 36 additions and 3 deletions

View File

@ -94,8 +94,12 @@ object SeekMessagePatch : BytecodePatch(
if (((targetInstruction as Instruction35c).reference as MethodReference).name != "setOnClickListener")
continue
// Force close occurs only in YouTube v18.36.xx unless we add this.
if (SettingsPatch.is1836)
addComponent(insertIndex, index - 1)
addInstructionsWithLabels(
insertIndex, """
insertIndex, fixComponent + """
invoke-static {}, $PLAYER->hideSeekUndoMessage()Z
move-result v$insertRegister
if-nez v$insertRegister, :default
@ -130,4 +134,31 @@ object SeekMessagePatch : BytecodePatch(
SettingsPatch.updatePatchStatus("Hide seek message")
}
private var fixComponent: String = ""
private fun MutableMethod.addComponent(
startIndex: Int,
endIndex: Int
) {
val fixRegister =
getInstruction<FiveRegisterInstruction>(endIndex).registerE
for (index in endIndex downTo startIndex) {
val opcode = getInstruction(index).opcode
if (opcode != Opcode.CONST_16)
continue
val register = getInstruction<OneRegisterInstruction>(index).registerA
if (register != fixRegister)
continue
val fixValue = getInstruction<WideLiteralInstruction>(index).wideLiteral.toInt()
fixComponent = "const/16 v$fixRegister, $fixValue"
break
}
}
}

View File

@ -90,8 +90,9 @@ object SettingsPatch : AbstractSettingsResourcePatch(
val playServicesVersion = node.textContent.toInt()
upward1828 = playServicesVersion >= 232900000
upward1834 = playServicesVersion >= 233502000
upward1828 = 232900000 <= playServicesVersion
upward1834 = 233502000 <= playServicesVersion
is1836 = playServicesVersion in 233700000..233801999
break
}
@ -198,6 +199,7 @@ object SettingsPatch : AbstractSettingsResourcePatch(
private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT)
internal lateinit var contexts: ResourceContext
internal var is1836: Boolean = false
internal var upward1828: Boolean = false
internal var upward1834: Boolean = false