From cdbbe8f78d26f24e58362c7ef1da83bf689d52bb Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 1 Dec 2023 23:50:19 +0100 Subject: [PATCH] fix(YouTube - Enable tablet layout): Respect the original device layout --- .../layout/tablet/EnableTabletLayoutPatch.kt | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt index d505b37d6..2bece0ab7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt @@ -2,11 +2,9 @@ package app.revanced.patches.youtube.layout.tablet import app.revanced.extensions.exception import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstructions -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch @@ -16,8 +14,6 @@ import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.tablet.fingerprints.GetFormFactorFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction10x @Patch( name = "Enable tablet layout", @@ -42,20 +38,11 @@ object EnableTabletLayoutPatch : BytecodePatch( GetFormFactorFingerprint.result?.let { it.mutableMethod.apply { - val returnCurrentFormFactorIndex = getInstructions().lastIndex - 2 + val returnIsLargeFormFactorIndex = getInstructions().lastIndex - 4 + val returnIsLargeFormFactorLabel = getInstruction(returnIsLargeFormFactorIndex) - 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 { }, Lapp/revanced/integrations/patches/EnableTabletLayoutPatch;->enableTabletLayout()Z move-result v0 # Free register