Skip to content

Commit

Permalink
feat: Merge branch feat/yt-sleep-timer to dev
Browse files Browse the repository at this point in the history
  • Loading branch information
zainarbani committed Oct 4, 2024
1 parent bd1f336 commit 1a9c126
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/revanced-patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,12 @@ public final class app/revanced/patches/youtube/layout/buttons/navigation/Naviga
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/layout/buttons/player/flyout/SleepTimerMenuPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/layout/buttons/player/flyout/SleepTimerMenuPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package app.revanced.patches.youtube.layout.buttons.player.flyout

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.youtube.layout.buttons.player.flyout.fingerprints.SleepTimerFeatureFingerprint
import app.revanced.patches.youtube.layout.buttons.player.flyout.fingerprints.SleepTimerFlyoutMenuFeatureFingerprint
import app.revanced.util.resultOrThrow
import app.revanced.util.returnEarly

@Patch(
name = "Remove sleep timer menu restrictions",
description = "Show sleep timer options in player flyout menu.",
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
[
"19.30.39", // Only enable this patch on 19.30+ for now.
]
)
]
)
@Suppress("unused")
object SleepTimerMenuPatch : BytecodePatch(
setOf(SleepTimerFeatureFingerprint, SleepTimerFlyoutMenuFeatureFingerprint)
) {
override fun execute(context: BytecodeContext) {
SleepTimerFeatureFingerprint.returnEarly(true)

// Feature is experimental, and this fingerprint may change in the future.
SleepTimerFlyoutMenuFeatureFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex

addInstruction(
targetIndex, "const/4 p1, 0x1"
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package app.revanced.patches.youtube.layout.buttons.player.flyout.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

internal object SleepTimerFeatureFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
returnType = "Z",
parameters = listOf(),
literalSupplier = { 45630421 }
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package app.revanced.patches.youtube.layout.buttons.player.flyout.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode

internal object SleepTimerFlyoutMenuFeatureFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
opcodes = listOf(
Opcode.IPUT_BOOLEAN,
Opcode.RETURN_VOID
),
literalSupplier = { 45640654 }
)

0 comments on commit 1a9c126

Please sign in to comment.