Skip to content

Commit

Permalink
fix: Use parent fingerprint
Browse files Browse the repository at this point in the history
  • Loading branch information
zainarbani committed Sep 24, 2024
1 parent 9a84771 commit d348abf
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import app.revanced.patches.all.misc.resources.AddResourcesPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.AllowSwipingUpGestureFingerprint
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.ShowSwipingUpGuideFingerprint
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SwipingUpGestureParentFingerprint
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.util.alsoResolve
import app.revanced.util.resultOrThrow

@Patch(
Expand Down Expand Up @@ -47,13 +49,15 @@ import app.revanced.util.resultOrThrow
"19.14.43",
"19.15.36",
"19.16.39",
"19.25.37",
"19.34.42",
]
)
]
)
@Suppress("unused")
object DisablePreciseSeekingGesturePatch : BytecodePatch(
setOf(AllowSwipingUpGestureFingerprint, ShowSwipingUpGuideFingerprint)
setOf(SwipingUpGestureParentFingerprint)
) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/youtube/patches/DisablePreciseSeekingGesturePatch;"
Expand All @@ -65,29 +69,37 @@ object DisablePreciseSeekingGesturePatch : BytecodePatch(
SwitchPreference("revanced_disable_precise_seeking_gesture")
)

AllowSwipingUpGestureFingerprint.resultOrThrow().mutableMethod.apply {
addInstructionsWithLabels(
0,
"""
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->isGestureDisabled()Z
move-result v0
if-eqz v0, :disabled
return-void
""", ExternalLabel("disabled", getInstruction(0))
)
}
with(SwipingUpGestureParentFingerprint.resultOrThrow()) {
val allowSwipingUpGestureMethod = AllowSwipingUpGestureFingerprint
.alsoResolve(context, SwipingUpGestureParentFingerprint).mutableMethod

val showSwipingUpGuideMethod = ShowSwipingUpGuideFingerprint
.alsoResolve(context, SwipingUpGestureParentFingerprint).mutableMethod

allowSwipingUpGestureMethod.apply {
addInstructionsWithLabels(
0,
"""
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->isGestureDisabled()Z
move-result v0
if-eqz v0, :disabled
return-void
""", ExternalLabel("disabled", getInstruction(0))
)
}

ShowSwipingUpGuideFingerprint.resultOrThrow().mutableMethod.apply {
addInstructionsWithLabels(
0,
"""
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->isGestureDisabled()Z
move-result v0
if-eqz v0, :disabled
const/4 v0, 0x0
return v0
""", ExternalLabel("disabled", getInstruction(0))
)
showSwipingUpGuideMethod.apply {
addInstructionsWithLabels(
0,
"""
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->isGestureDisabled()Z
move-result v0
if-eqz v0, :disabled
const/4 v0, 0x0
return v0
""", ExternalLabel("disabled", getInstruction(0))
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ package app.revanced.patches.youtube.interaction.seekbar.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.util.containsWideLiteralInstructionValue
import com.android.tools.smali.dexlib2.AccessFlags

internal object AllowSwipingUpGestureFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
returnType = "V",
parameters = listOf("L"),
customFingerprint = { _, classDef ->
classDef.methods.any { method ->
method.containsWideLiteralInstructionValue(45379021L)
}
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ internal object ShowSwipingUpGuideFingerprint : MethodFingerprint(
accessFlags = AccessFlags.FINAL.value,
returnType = "Z",
parameters = emptyList(),
customFingerprint = { methodDef, classDef ->
classDef.methods.any { method ->
method.containsWideLiteralInstructionValue(45379021L)
} && methodDef.containsWideLiteralInstructionValue(1L)
customFingerprint = { methodDef, _ ->
methodDef.containsWideLiteralInstructionValue(1L)
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package app.revanced.patches.youtube.interaction.seekbar.fingerprints

import app.revanced.util.patch.LiteralValueFingerprint

internal object SwipingUpGestureParentFingerprint : LiteralValueFingerprint(
literalSupplier = { 45379021 }
)

0 comments on commit d348abf

Please sign in to comment.