mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-19 20:29:23 +01:00
fix(youtube/minimized-playback): fix background play of kids videos (#2016)
This commit is contained in:
parent
47d8d678d2
commit
89b1484d1d
@ -0,0 +1,23 @@
|
||||
package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object KidsMinimizedPlaybackPolicyControllerFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("I", "L", "L"),
|
||||
opcodes = listOf(
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.SGET_OBJECT,
|
||||
Opcode.IF_NE,
|
||||
Opcode.CONST_4,
|
||||
Opcode.IPUT_BOOLEAN,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.IGET,
|
||||
Opcode.INVOKE_STATIC
|
||||
),
|
||||
customFingerprint = { it.definingClass.endsWith("MinimizedPlaybackPolicyController;") }
|
||||
)
|
@ -6,6 +6,7 @@ import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.data.toMethodWalker
|
||||
import app.revanced.patcher.extensions.addInstruction
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
@ -17,6 +18,7 @@ import app.revanced.patches.shared.settings.preference.impl.NonInteractivePrefer
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.minimizedplayback.annotations.MinimizedPlaybackCompatibility
|
||||
import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.KidsMinimizedPlaybackPolicyControllerFingerprint
|
||||
import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint
|
||||
import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackSettingsFingerprint
|
||||
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
||||
@ -33,7 +35,8 @@ import org.jf.dexlib2.iface.reference.MethodReference
|
||||
class MinimizedPlaybackPatch : BytecodePatch(
|
||||
listOf(
|
||||
MinimizedPlaybackManagerFingerprint,
|
||||
MinimizedPlaybackSettingsFingerprint
|
||||
MinimizedPlaybackSettingsFingerprint,
|
||||
KidsMinimizedPlaybackPolicyControllerFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
@ -73,6 +76,15 @@ class MinimizedPlaybackPatch : BytecodePatch(
|
||||
)
|
||||
} ?: return MinimizedPlaybackSettingsFingerprint.toErrorResult()
|
||||
|
||||
// Force allowing background play for videos labeled for kids.
|
||||
// Some regions and YouTube accounts do not require this patch.
|
||||
KidsMinimizedPlaybackPolicyControllerFingerprint.result?.apply {
|
||||
mutableMethod.addInstruction(
|
||||
0,
|
||||
"return-void"
|
||||
)
|
||||
} ?: return KidsMinimizedPlaybackPolicyControllerFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user