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

View File

@ -191,9 +191,6 @@ Is it ready to submit?"</string>
<string name="revanced_disable_haptic_feedback_zoom_summary_off">Zoom haptic feedback is enabled</string> <string name="revanced_disable_haptic_feedback_zoom_summary_off">Zoom haptic feedback is enabled</string>
<string name="revanced_disable_haptic_feedback_zoom_summary_on">Zoom haptic feedback is disabled</string> <string name="revanced_disable_haptic_feedback_zoom_summary_on">Zoom haptic feedback is disabled</string>
<string name="revanced_disable_haptic_feedback_zoom_title">Disable zoom haptic feedback</string> <string name="revanced_disable_haptic_feedback_zoom_title">Disable zoom haptic feedback</string>
<string name="revanced_disable_shorts_player_pip_summary_off">PiP mode in shorts player is enabled</string>
<string name="revanced_disable_shorts_player_pip_summary_on">PiP mode in shorts player is disabled</string>
<string name="revanced_disable_shorts_player_pip_title">Disable pip mode in shorts player</string>
<string name="revanced_copytimestamp_success">Time Stamp copied to clipboard</string> <string name="revanced_copytimestamp_success">Time Stamp copied to clipboard</string>
<string name="revanced_enable_always_auto_repeat_summary_off">Always auto repeat is disabled</string> <string name="revanced_enable_always_auto_repeat_summary_off">Always auto repeat is disabled</string>
<string name="revanced_enable_always_auto_repeat_summary_on">Always auto repeat is enabled</string> <string name="revanced_enable_always_auto_repeat_summary_on">Always auto repeat is enabled</string>
@ -473,9 +470,6 @@ Are you sure you want to continue though?"</string>
<string name="revanced_reboot_warning_oldlayout">"Tricks the YouTube client version to v17.28.35 to load the old layout <string name="revanced_reboot_warning_oldlayout">"Tricks the YouTube client version to v17.28.35 to load the old layout
In the app settings, the YouTube version may be marked as v17.28.35"</string> In the app settings, the YouTube version may be marked as v17.28.35"</string>
<string name="revanced_reboot_warning_pip">"Disable pip mode on shorts players
This option is not valid on certain Android versions or certain OS"</string>
<string name="revanced_reboot_warning_phone">"Tricks the dpi to change some layouts to phone layouts. <string name="revanced_reboot_warning_phone">"Tricks the dpi to change some layouts to phone layouts.
If you enable this setting, the following features are available: If you enable this setting, the following features are available:

View File

@ -349,8 +349,6 @@
<SwitchPreference android:title="@string/revanced_enable_phone_layout_title" android:key="revanced_enable_phone_layout" android:summary="@string/revanced_enable_phone_layout_summary" android:defaultValue="false" />SETTINGS: LAYOUT_SWITCH --> <SwitchPreference android:title="@string/revanced_enable_phone_layout_title" android:key="revanced_enable_phone_layout" android:summary="@string/revanced_enable_phone_layout_summary" android:defaultValue="false" />SETTINGS: LAYOUT_SWITCH -->
<!-- SETTINGS: ENABLE_VP9_CODEC <!-- SETTINGS: ENABLE_VP9_CODEC
<SwitchPreference android:title="@string/revanced_enable_vp9_codec_title" android:key="revanced_enable_vp9_codec" android:defaultValue="false" android:summary="@string/revanced_enable_vp9_codec_summary" />SETTINGS: ENABLE_VP9_CODEC --> <SwitchPreference android:title="@string/revanced_enable_vp9_codec_title" android:key="revanced_enable_vp9_codec" android:defaultValue="false" android:summary="@string/revanced_enable_vp9_codec_summary" />SETTINGS: ENABLE_VP9_CODEC -->
<!-- SETTINGS: DISABLE_SHORTS_PLAYER_PIP
<SwitchPreference android:title="@string/revanced_disable_shorts_player_pip_title" android:key="revanced_disable_shorts_player_pip" android:defaultValue="false" android:summaryOn="@string/revanced_disable_shorts_player_pip_summary_on" android:summaryOff="@string/revanced_disable_shorts_player_pip_summary_off" />SETTINGS: DISABLE_SHORTS_PLAYER_PIP -->
<!-- SETTINGS: ABOUT <!-- SETTINGS: ABOUT
<Preference android:title=" " android:selectable="false" android:summary="@string/pref_about_category" /> <Preference android:title=" " android:selectable="false" android:summary="@string/pref_about_category" />
@ -430,7 +428,6 @@
<Preference android:title="enable-old-layout" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="enable-old-layout" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="layout-switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="layout-switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="force-vp9-codec" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="force-vp9-codec" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="disable-shorts-player-pip" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_others_title" /> <Preference android:title=" " android:selectable="false" android:summary="@string/revanced_others_title" />
<Preference android:title="return-youtube-dislike" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="return-youtube-dislike" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>