mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-02 23:32:54 +01:00
fix(youtube/minimized-playback): disable when playing shorts
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
4033e4da85
commit
cd48030cad
@ -5,7 +5,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object MinimizedPlaybackKidsFingerprint : MethodFingerprint(
|
||||
object KidsMinimizedPlaybackPolicyControllerFingerprint : MethodFingerprint(
|
||||
"V",
|
||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
listOf("I", "L", "L"),
|
@ -0,0 +1,16 @@
|
||||
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 PipControllerFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.IGET_BOOLEAN
|
||||
),
|
||||
customFingerprint = { it.definingClass.endsWith("DefaultPipController;") }
|
||||
)
|
@ -1,38 +1,46 @@
|
||||
package app.revanced.patches.youtube.misc.minimizedplayback.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
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.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
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.MinimizedPlaybackKidsFingerprint
|
||||
import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint
|
||||
import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackSettingsFingerprint
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
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.minimizedplayback.fingerprints.PipControllerFingerprint
|
||||
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
import org.jf.dexlib2.iface.reference.MethodReference
|
||||
|
||||
|
||||
@Patch
|
||||
@Name("minimized-playback")
|
||||
@Description("Enables minimized and background playback.")
|
||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
||||
@DependsOn([IntegrationsPatch::class, PlayerTypeHookPatch::class, SettingsPatch::class])
|
||||
@MinimizedPlaybackCompatibility
|
||||
@Version("0.0.1")
|
||||
class MinimizedPlaybackPatch : BytecodePatch(
|
||||
listOf(
|
||||
MinimizedPlaybackKidsFingerprint, MinimizedPlaybackManagerFingerprint, MinimizedPlaybackSettingsFingerprint
|
||||
KidsMinimizedPlaybackPolicyControllerFingerprint,
|
||||
MinimizedPlaybackManagerFingerprint,
|
||||
MinimizedPlaybackSettingsFingerprint,
|
||||
PipControllerFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
@ -46,15 +54,15 @@ class MinimizedPlaybackPatch : BytecodePatch(
|
||||
)
|
||||
)
|
||||
|
||||
// Instead of removing all instructions like Vanced,
|
||||
// we return the method at the beginning instead
|
||||
MinimizedPlaybackManagerFingerprint.result!!.mutableMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static {}, Lapp/revanced/integrations/patches/MinimizedPlaybackPatch;->isMinimizedPlaybackEnabled()Z
|
||||
MinimizedPlaybackManagerFingerprint.result?.apply {
|
||||
mutableMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->isMinimizedPlaybackEnabled()Z
|
||||
move-result v0
|
||||
return v0
|
||||
"""
|
||||
)
|
||||
)
|
||||
} ?: return MinimizedPlaybackManagerFingerprint.toErrorResult()
|
||||
|
||||
val method = MinimizedPlaybackSettingsFingerprint.result!!.mutableMethod
|
||||
val booleanCalls = method.implementation!!.instructions.withIndex()
|
||||
@ -66,23 +74,42 @@ class MinimizedPlaybackPatch : BytecodePatch(
|
||||
|
||||
settingsBooleanMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static {}, Lapp/revanced/integrations/patches/MinimizedPlaybackPatch;->isMinimizedPlaybackEnabled()Z
|
||||
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->isMinimizedPlaybackEnabled()Z
|
||||
move-result v0
|
||||
return v0
|
||||
"""
|
||||
)
|
||||
|
||||
MinimizedPlaybackKidsFingerprint.result!!.mutableMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static {}, Lapp/revanced/integrations/patches/MinimizedPlaybackPatch;->isMinimizedPlaybackEnabled()Z
|
||||
KidsMinimizedPlaybackPolicyControllerFingerprint.result?.apply {
|
||||
mutableMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->isMinimizedPlaybackEnabled()Z
|
||||
move-result v0
|
||||
if-eqz v0, :enable
|
||||
return-void
|
||||
:enable
|
||||
nop
|
||||
"""
|
||||
)
|
||||
)
|
||||
} ?: return KidsMinimizedPlaybackPolicyControllerFingerprint.toErrorResult()
|
||||
|
||||
PipControllerFingerprint.result?.apply {
|
||||
val insertIndex = scanResult.patternScanResult!!.endIndex + 1
|
||||
val pipEnabledRegister = (mutableMethod.instruction(insertIndex - 1) as TwoRegisterInstruction).registerA
|
||||
|
||||
mutableMethod.addInstructions(
|
||||
insertIndex,
|
||||
"""
|
||||
invoke-static {v$pipEnabledRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->isNotPlayingShorts(Z)Z
|
||||
move-result v$pipEnabledRegister
|
||||
"""
|
||||
)
|
||||
|
||||
} ?: return PipControllerFingerprint.toErrorResult()
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/MinimizedPlaybackPatch;"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user