Skip to content

Commit

Permalink
fix(youtube/overlay-button): overlay button not hidden when scrubbing…
Browse files Browse the repository at this point in the history
… seekbar
  • Loading branch information
inotia00 committed Sep 5, 2023
1 parent 47b2ed2 commit 7164f72
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package app.revanced.patches.youtube.utils.playercontrols.fingerprints

import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction

object QuickSeekVisibleFingerprint : MethodFingerprint(
returnType = "V",
parameters = listOf("Z"),
opcodes = listOf(Opcode.OR_INT_LIT16),
customFingerprint = { methodDef, _ ->
methodDef.implementation!!.instructions.any {
((it as? NarrowLiteralInstruction)?.narrowLiteral == 128)
}
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import app.revanced.patches.youtube.utils.playercontrols.fingerprints.Fullscreen
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.FullscreenEngagementSpeedEduVisibleParentFingerprint
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsVisibilityFingerprint
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsVisibilityModelFingerprint
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.QuickSeekVisibleFingerprint
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.SeekEDUVisibleFingerprint
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.UserScrubbingFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
Expand All @@ -42,19 +43,34 @@ class PlayerControlsPatch : BytecodePatch(

fun MutableMethod.findReference(targetString: String): Reference {
val targetIndex = getStringIndex(targetString) + 2
val targetRegister = getInstruction<Instruction35c>(targetIndex).registerD
val targetOpcode = getInstruction(targetIndex).opcode

val instructions = implementation!!.instructions
for ((index, instruction) in instructions.withIndex()) {
if (instruction.opcode != Opcode.IGET_BOOLEAN) continue
if (targetOpcode == Opcode.INVOKE_VIRTUAL) {
val targetRegister = getInstruction<Instruction35c>(targetIndex).registerD

if (getInstruction<TwoRegisterInstruction>(index).registerA == targetRegister)
return getInstruction<ReferenceInstruction>(index).reference
val instructions = implementation!!.instructions
for ((index, instruction) in instructions.withIndex()) {
if (instruction.opcode != Opcode.IGET_BOOLEAN) continue

if (getInstruction<TwoRegisterInstruction>(index).registerA == targetRegister)
return getInstruction<ReferenceInstruction>(index).reference
}
} else if (targetOpcode == Opcode.IGET_BOOLEAN) {
return getInstruction<ReferenceInstruction>(targetIndex).reference
}

throw PatchException("Reference not found: $targetString")
}

PlayerControlsVisibilityModelFingerprint.result?.classDef?.let { classDef ->
quickSeekVisibleMutableMethod =
QuickSeekVisibleFingerprint.also {
it.resolve(
context,
classDef
)
}.result?.mutableMethod ?: throw QuickSeekVisibleFingerprint.exception

seekEDUVisibleMutableMethod =
SeekEDUVisibleFingerprint.also {
it.resolve(
Expand Down Expand Up @@ -115,6 +131,7 @@ class PlayerControlsPatch : BytecodePatch(
lateinit var inflateResult: MethodFingerprintResult

lateinit var playerControlsVisibilityMutableMethod: MutableMethod
lateinit var quickSeekVisibleMutableMethod: MutableMethod
lateinit var seekEDUVisibleMutableMethod: MutableMethod
lateinit var userScrubbingMutableMethod: MutableMethod

Expand Down Expand Up @@ -171,6 +188,10 @@ class PlayerControlsPatch : BytecodePatch(
descriptor,
"changeVisibility"
)
quickSeekVisibleMutableMethod.injectVisibilityCall(
descriptor,
"changeVisibilityNegatedImmediate"
)
seekEDUVisibleMutableMethod.injectVisibilityCall(
descriptor,
"changeVisibilityNegatedImmediate"
Expand Down

0 comments on commit 7164f72

Please sign in to comment.