fix: disable-fullscreen-panels patch not working (#213)

This commit is contained in:
TheJeterLP 2022-07-21 00:19:04 +02:00 committed by GitHub
parent 7b70b8555b
commit 5372105e72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 22 deletions

View file

@ -2,7 +2,7 @@ package app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version import app.revanced.patcher.annotation.Version
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility
@ -12,21 +12,14 @@ import org.jf.dexlib2.Opcode
@MatchingMethod( @MatchingMethod(
"LFullscreenEngagementPanelOverlay;", "e" "LFullscreenEngagementPanelOverlay;", "e"
) )
@FuzzyPatternScanMethod(2) @DirectPatternScanMethod
@ShortsButtonCompatibility @ShortsButtonCompatibility
@Version("0.0.1") @Version("0.0.1")
object FullscreenViewAdderFingerprint : MethodFingerprint( object FullscreenViewAdderFingerprint : MethodFingerprint(
null, null,
null, null,
listOf("L", "L"),
listOf(
Opcode.GOTO,
Opcode.IGET_BOOLEAN,
Opcode.IF_EQ,
Opcode.GOTO,
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL,
),
null, null,
{ it.definingClass.endsWith("FullscreenEngagementPanelOverlay;") } listOf(
Opcode.IGET_BOOLEAN
)
) )

View file

@ -0,0 +1,32 @@
package app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility
import org.jf.dexlib2.Opcode
@Name("fullscreen-view-adder-parent-fingerprint")
@MatchingMethod(
"LFullscreenEngagementPanelOverlay;", "e"
)
@DirectPatternScanMethod
@ShortsButtonCompatibility
@Version("0.0.1")
object FullscreenViewAdderParentFingerprint : MethodFingerprint(
null,
null,
listOf("L", "L"),
listOf(
Opcode.GOTO,
Opcode.IGET_BOOLEAN,
Opcode.IF_EQ,
Opcode.GOTO,
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL,
),
null,
{ it.definingClass.endsWith("FullscreenEngagementPanelOverlay;") }
)

View file

@ -5,6 +5,8 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.data.impl.BytecodeData
import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.removeInstruction
import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.PatchResultSuccess
@ -13,9 +15,8 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.patch.impl.BytecodePatch
import app.revanced.patches.youtube.layout.fullscreenpanels.annotations.FullscreenPanelsCompatibility import app.revanced.patches.youtube.layout.fullscreenpanels.annotations.FullscreenPanelsCompatibility
import app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints.FullscreenViewAdderFingerprint import app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints.FullscreenViewAdderFingerprint
import app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints.FullscreenViewAdderParentFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.MethodReference
@Patch @Patch
@Name("disable-fullscreen-panels") @Name("disable-fullscreen-panels")
@ -25,23 +26,23 @@ import org.jf.dexlib2.iface.reference.MethodReference
@Version("0.0.1") @Version("0.0.1")
class FullscreenPanelsRemoverPatch : BytecodePatch( class FullscreenPanelsRemoverPatch : BytecodePatch(
listOf( listOf(
FullscreenViewAdderFingerprint FullscreenViewAdderParentFingerprint
) )
) { ) {
override fun execute(data: BytecodeData): PatchResult { override fun execute(data: BytecodeData): PatchResult {
val result = FullscreenViewAdderFingerprint.result val parentResult = FullscreenViewAdderParentFingerprint.result!!
FullscreenViewAdderFingerprint.resolve(data, parentResult.method, parentResult.classDef)
val result = FullscreenViewAdderParentFingerprint.result
?: return PatchResultError("Fingerprint not resolved!") ?: return PatchResultError("Fingerprint not resolved!")
val method = result.mutableMethod val method = result.mutableMethod
val implementation = method.implementation
?: return PatchResultError("Implementation not found!")
val visibilityCallIndex = implementation.instructions.withIndex() val ifIndex = result.patternScanResult!!.startIndex + 2
.first { ((it.value as? ReferenceInstruction)?.reference as? MethodReference)?.name == ("setVisibility") }.index
method.removeInstruction(ifIndex)
method.addInstructions( method.addInstructions(
visibilityCallIndex - 1, """ ifIndex, """
invoke-static { }, Lapp/revanced/integrations/patches/FullscreenPanelsRemoverPatch;->getFullsceenPanelsVisibility()I invoke-static {}, Lapp/revanced/integrations/patches/FullscreenPanelsRemoverPatch;->getFullscreenPanelsVisibility()I
move-result p1 move-result p1
""" """
) )