diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/shortspip/bytecode/patch/DisableShortsPiPBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/extended/shortspip/bytecode/patch/DisableShortsPiPBytecodePatch.kt
deleted file mode 100644
index e893f71de..000000000
--- a/src/main/kotlin/app/revanced/patches/youtube/extended/shortspip/bytecode/patch/DisableShortsPiPBytecodePatch.kt
+++ /dev/null
@@ -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()
- }
-}
\ No newline at end of file
diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/shortspip/resource/patch/DisableShortsPiPPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/extended/shortspip/resource/patch/DisableShortsPiPPatch.kt
deleted file mode 100644
index 5c1afedee..000000000
--- a/src/main/kotlin/app/revanced/patches/youtube/extended/shortspip/resource/patch/DisableShortsPiPPatch.kt
+++ /dev/null
@@ -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()
- }
-}
\ No newline at end of file
diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/MinimizedPlaybackKidsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt
similarity index 90%
rename from src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/MinimizedPlaybackKidsFingerprint.kt
rename to src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt
index 9df8947ba..b560b0df4 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/MinimizedPlaybackKidsFingerprint.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt
@@ -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"),
diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/shortspip/bytecode/fingerprints/DisableShortsPiPFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/PipControllerFingerprint.kt
similarity index 77%
rename from src/main/kotlin/app/revanced/patches/youtube/extended/shortspip/bytecode/fingerprints/DisableShortsPiPFingerprint.kt
rename to src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/PipControllerFingerprint.kt
index f7093fe86..53c21092c 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/extended/shortspip/bytecode/fingerprints/DisableShortsPiPFingerprint.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/PipControllerFingerprint.kt
@@ -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"),
diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/patch/MinimizedPlaybackBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/patch/MinimizedPlaybackBytecodePatch.kt
index 5b6d79674..c6ded94b7 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/patch/MinimizedPlaybackBytecodePatch.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/patch/MinimizedPlaybackBytecodePatch.kt
@@ -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
+ """
+ )
+ }
+ }
}
}
diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml
index 3a234c15a..493353280 100644
--- a/src/main/resources/youtube/settings/host/values/strings.xml
+++ b/src/main/resources/youtube/settings/host/values/strings.xml
@@ -191,9 +191,6 @@ Is it ready to submit?"
Zoom haptic feedback is enabled
Zoom haptic feedback is disabled
Disable zoom haptic feedback
- PiP mode in shorts player is enabled
- PiP mode in shorts player is disabled
- Disable pip mode in shorts player
Time Stamp copied to clipboard
Always auto repeat is disabled
Always auto repeat is enabled
@@ -473,9 +470,6 @@ Are you sure you want to continue though?"
"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"
- "Disable pip mode on shorts players
-
-This option is not valid on certain Android versions or certain OS"
"Tricks the dpi to change some layouts to phone layouts.
If you enable this setting, the following features are available:
diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
index c2e6347dc..154c8fcd4 100644
--- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml
+++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
@@ -349,8 +349,6 @@
SETTINGS: LAYOUT_SWITCH -->
-