remove disable-shorts-player-pip patch

This commit is contained in:
inotia00
2023-02-13 17:17:18 +09:00
parent e3b11f2680
commit 745b5f0f22
7 changed files with 50 additions and 134 deletions

View File

@ -1,48 +0,0 @@
package app.revanced.patches.youtube.extended.shortspip.bytecode.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
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.patches.youtube.extended.shortspip.bytecode.fingerprints.DisableShortsPiPFingerprint
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.extensions.toErrorResult
import app.revanced.shared.util.integrations.Constants.EXTENDED_PATH
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@Name("disable-shorts-pip-bytecode-patch")
@DependsOn(
[
PlayerTypeHookPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class DisableShortsPiPBytecodePatch : BytecodePatch(
listOf(
DisableShortsPiPFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
DisableShortsPiPFingerprint.result?.let {
with (it.mutableMethod) {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val register = (implementation!!.instructions[endIndex] as TwoRegisterInstruction).registerA
this.addInstructions(
endIndex + 1, """
invoke-static {v$register}, $EXTENDED_PATH/DisableShortsPiPPatch;->disableShortsPlayerPiP(Z)Z
move-result v$register
"""
)
}
} ?: return DisableShortsPiPFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View File

@ -1,49 +0,0 @@
package app.revanced.patches.youtube.extended.shortspip.resource.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.youtube.extended.shortspip.bytecode.patch.DisableShortsPiPBytecodePatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.util.resources.ResourceHelper
@Patch
@Name("disable-shorts-player-pip")
@Description("Disable PiP mode in YouTube Shorts player.")
@DependsOn(
[
DisableShortsPiPBytecodePatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class DisableShortsPiPPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
add settings
*/
ResourceHelper.addSettings2(
context,
"PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS",
"PREFERENCE: EXTENDED_SETTINGS",
"SETTINGS: EXPERIMENTAL_FLAGS",
"SETTINGS: DISABLE_SHORTS_PLAYER_PIP"
)
ResourceHelper.patchSuccess(
context,
"disable-shorts-player-pip"
)
return PatchResultSuccess()
}
}

View File

@ -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(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("I", "L", "L"),

View File

@ -1,11 +1,11 @@
package app.revanced.patches.youtube.extended.shortspip.bytecode.fingerprints
package app.revanced.patches.youtube.misc.minimizedplayback.bytecode.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 DisableShortsPiPFingerprint : MethodFingerprint(
object PipControllerFingerprint : MethodFingerprint(
returnType = "L",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),

View File

@ -6,6 +6,7 @@ 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.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
@ -13,35 +14,46 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.misc.minimizedplayback.bytecode.fingerprints.*
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.extensions.toErrorResult
import app.revanced.shared.util.integrations.Constants.MISC_PATH
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
import org.jf.dexlib2.iface.reference.MethodReference
@Name("enable-minimized-playback-bytecode-patch")
@DependsOn([SharedResourcdIdPatch::class])
@DependsOn(
[
PlayerTypeHookPatch::class,
SharedResourcdIdPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class MinimizedPlaybackBytecodePatch : BytecodePatch(
listOf(
MinimizedPlaybackKidsFingerprint,
KidsMinimizedPlaybackPolicyControllerFingerprint,
MinimizedPlaybackManagerFingerprint,
MinimizedPlaybackSettingsFingerprint
MinimizedPlaybackSettingsFingerprint,
PipControllerFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
val methods = arrayOf(
MinimizedPlaybackKidsFingerprint,
KidsMinimizedPlaybackPolicyControllerFingerprint,
MinimizedPlaybackManagerFingerprint,
MinimizedPlaybackSettingsFingerprint
).map {
it.result!!.mutableMethod
it.result?.mutableMethod?: return it.toErrorResult()
}
hookPlaybackController(methods[0])
hookPlayback(methods[1])
walkMutable(context, methods[2])
methods[0].hookPlaybackController()
methods[1].hookPlayback()
methods[2].walkMutable(context)
PipControllerFingerprint.result?.hookShortsPiP()?:return PipControllerFingerprint.toErrorResult()
return PatchResultSuccess()
}
@ -50,26 +62,25 @@ class MinimizedPlaybackBytecodePatch : BytecodePatch(
const val INTEGRATIONS_PLAYBACK_METHOD_REFERENCE =
"$MISC_PATH/MinimizedPlaybackPatch;->enableMinimizedPlayback()Z"
fun walkMutable(
context: BytecodeContext,
insertMethod: MutableMethod
) {
val booleanCalls = insertMethod.implementation!!.instructions.withIndex()
const val INTEGRATIONS_PIP_METHOD_REFERENCE =
"$MISC_PATH/MinimizedPlaybackPatch;->isNotPlayingShorts(Z)Z"
fun MutableMethod.walkMutable(
context: BytecodeContext) {
val booleanCalls = implementation!!.instructions.withIndex()
.filter { ((it.value as? ReferenceInstruction)?.reference as? MethodReference)?.returnType == "Z" }
val booleanIndex = booleanCalls.elementAt(1).index
val booleanMethod =
context.toMethodWalker(insertMethod)
context.toMethodWalker(this)
.nextMethod(booleanIndex, true)
.getMethod() as MutableMethod
hookPlayback(booleanMethod)
booleanMethod.hookPlayback()
}
fun hookPlayback(
insertMethod: MutableMethod
) {
insertMethod.addInstructions(
fun MutableMethod.hookPlayback() {
addInstructions(
0, """
invoke-static {}, $INTEGRATIONS_PLAYBACK_METHOD_REFERENCE
move-result v0
@ -78,17 +89,28 @@ class MinimizedPlaybackBytecodePatch : BytecodePatch(
)
}
fun hookPlaybackController(
insertMethod: MutableMethod
) {
insertMethod.addInstructions(
fun MutableMethod.hookPlaybackController() {
addInstructions(
0, """
invoke-static {}, $INTEGRATIONS_PLAYBACK_METHOD_REFERENCE
move-result v0
if-eqz v0, :default
return-void
""", listOf(ExternalLabel("default", insertMethod.instruction(0)))
""", listOf(ExternalLabel("default", instruction(0)))
)
}
fun MethodFingerprintResult.hookShortsPiP() {
val endIndex = scanResult.patternScanResult!!.endIndex
with (mutableMethod) {
val register = (implementation!!.instructions[endIndex] as TwoRegisterInstruction).registerA
addInstructions(
endIndex + 1, """
invoke-static {v$register}, $INTEGRATIONS_PIP_METHOD_REFERENCE
move-result v$register
"""
)
}
}
}
}