From 5ef4760f472846847c49c12e8aae50715488682c Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Fri, 1 Dec 2023 21:48:22 +0900 Subject: [PATCH] fix(YouTube/Enable tablet layout): rollback to previous commit --- .../misc/layoutswitch/LayoutSwitchPatch.kt | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/layoutswitch/LayoutSwitchPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/layoutswitch/LayoutSwitchPatch.kt index 7da8000c1..c72df0c35 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/layoutswitch/LayoutSwitchPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/layoutswitch/LayoutSwitchPatch.kt @@ -61,27 +61,17 @@ object LayoutSwitchPatch : BytecodePatch( GetFormFactorFingerprint.result?.let { it.mutableMethod.apply { - val returnCurrentFormFactorIndex = getInstructions().lastIndex - 2 + val jumpIndex = it.scanResult.patternScanResult!!.endIndex - 4 - val returnIsLargeFormFactorLabel = getInstruction(returnCurrentFormFactorIndex - 2) - val returnFormFactorIndex = getInstruction(returnCurrentFormFactorIndex) - - val insertIndex = returnCurrentFormFactorIndex + 1 - - // Replace the labeled instruction with a nop and add the preserved instructions back - replaceInstruction(returnCurrentFormFactorIndex, BuilderInstruction10x(Opcode.NOP)) - addInstruction(insertIndex, returnFormFactorIndex) - - // Because the labeled instruction is now a nop, we can add our own instructions right after it addInstructionsWithLabels( - insertIndex, """ + 0, """ invoke-static { }, $MISC_PATH/LayoutOverridePatch;->enableTabletLayout()Z move-result v0 # Free register if-nez v0, :is_large_form_factor """, ExternalLabel( "is_large_form_factor", - returnIsLargeFormFactorLabel + getInstruction(jumpIndex) ) ) }