From e5b861f49e06788861ab65c5060b2582be509a39 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:52:32 +0400 Subject: [PATCH 01/15] feat(YouTube): Add `Open Shorts in player` patch --- .../patches/OpenShortsInRegularPlayer.java | 40 ++++++++++ .../extension/youtube/settings/Settings.java | 1 + patches/api/patches.api | 4 + .../layout/shortsbypass/Fingerprints.kt | 36 +++++++++ .../shortsbypass/OpenShortsInRegularPlayer.kt | 77 +++++++++++++++++++ .../resources/addresources/values/strings.xml | 5 ++ 6 files changed, 163 insertions(+) create mode 100644 extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java create mode 100644 patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt create mode 100644 patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java new file mode 100644 index 0000000000..d60a1be8dd --- /dev/null +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java @@ -0,0 +1,40 @@ +package app.revanced.extension.youtube.patches; + +import android.content.Intent; +import android.net.Uri; + +import app.revanced.extension.shared.Logger; +import app.revanced.extension.shared.Utils; +import app.revanced.extension.youtube.settings.Settings; + +@SuppressWarnings("unused") +public class OpenShortsInRegularPlayer { + + /** + * Injection point. + */ + public static boolean openShorts(String shortsVideoID) { + try { + if (!Settings.OPEN_SHORTS_IN_REGULAR_PLAYER.get()) { + return false; + } + + var context = Utils.getContext(); + + Intent videoPlayerIntent = new Intent( + Intent.ACTION_VIEW, + Uri.parse("https://www.youtube.com/watch?v=" + shortsVideoID) + ); + videoPlayerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + videoPlayerIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + videoPlayerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + videoPlayerIntent.setPackage(context.getPackageName()); + + context.startActivity(videoPlayerIntent); + return true; + } catch (Exception ex) { + Logger.printException(() -> "openShorts failure", ex); + return false; + } + } +} diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java index 0c0a06721f..987fea9865 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java @@ -224,6 +224,7 @@ public class Settings extends BaseSettings { // Shorts public static final BooleanSetting DISABLE_RESUMING_SHORTS_PLAYER = new BooleanSetting("revanced_disable_resuming_shorts_player", FALSE); public static final BooleanSetting DISABLE_SHORTS_BACKGROUND_PLAYBACK = new BooleanSetting("revanced_shorts_disable_background_playback", FALSE); + public static final BooleanSetting OPEN_SHORTS_IN_REGULAR_PLAYER = new BooleanSetting("revanced_open_shorts_in_regular_player", FALSE); public static final BooleanSetting HIDE_SHORTS_CHANNEL_BAR = new BooleanSetting("revanced_hide_shorts_channel_bar", FALSE); public static final BooleanSetting HIDE_SHORTS_COMMENTS_BUTTON = new BooleanSetting("revanced_hide_shorts_comments_button", FALSE); public static final BooleanSetting HIDE_SHORTS_DISLIKE_BUTTON = new BooleanSetting("revanced_hide_shorts_dislike_button", FALSE); diff --git a/patches/api/patches.api b/patches/api/patches.api index c76a2d38fb..ad8502ceb9 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -1210,6 +1210,10 @@ public final class app/revanced/patches/youtube/layout/shortsautoplay/ShortsAuto public static final fun getShortsAutoplayPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerKt { + public static final fun getOpenShortsInRegularPlayer ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatchKt { public static final fun getSponsorBlockPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt new file mode 100644 index 0000000000..3fcc114464 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt @@ -0,0 +1,36 @@ +package app.revanced.patches.youtube.layout.shortsbypass + +import app.revanced.patcher.fingerprint +import app.revanced.util.literal + +/** + * Purpose of this method is not clear, and it's only used to identify + * the obfuscated name of the videoId() method in PlaybackStartDescriptor. + */ +internal val playbackStartFeatureFlagFingerprint = fingerprint { + returns("Z") + parameters( + "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;", + ) + literal { + 45380134L + } +} + +internal val playbackStartDescriptorFingerprint = fingerprint { + returns("V") + parameters( + "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;", + "Ljava/util/Map;", + "J", + "Ljava/lang/String;" + ) + strings( + // None of these strings are unique. + "com.google.android.apps.youtube.PlaybackStartDescriptor", + "PLAYBACK_START_DESCRIPTOR_MUTATOR", + "ReelWatchFragmentArgs" + ) +} + + diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt new file mode 100644 index 0000000000..4a95b22200 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt @@ -0,0 +1,77 @@ +package app.revanced.patches.youtube.layout.shortsbypass + +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patches.all.misc.resources.addResources +import app.revanced.patches.all.misc.resources.addResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference +import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch +import app.revanced.patches.youtube.misc.settings.PreferenceScreen +import app.revanced.patches.youtube.misc.settings.settingsPatch +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstructionOrThrow +import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction +import com.android.tools.smali.dexlib2.iface.reference.MethodReference + +private const val EXTENSION_CLASS_DESCRIPTOR = + "Lapp/revanced/extension/youtube/patches/OpenShortsInRegularPlayer;" + +val openShortsInRegularPlayer = bytecodePatch( + name = "Open Shorts in player", + description = "Adds an option to open Shorts in the regular video player.", +) { + dependsOn( + sharedExtensionPatch, + settingsPatch, + addResourcesPatch, + ) + + compatibleWith( + "com.google.android.youtube"( + "18.38.44", + "18.49.37", + "19.16.39", + "19.25.37", + "19.34.42", + "19.43.41", + "19.45.38", + "19.46.42", + ), + ) + + execute { + addResources("youtube", "layout.shortsbypass.openShortsInRegularPlayer") + + PreferenceScreen.SHORTS.addPreferences( + SwitchPreference("revanced_open_shorts_in_regular_player"), + ) + + // Find the obfuscated method name for PlaybackStartDescriptor.videoId() + val playbackStartVideoIdMethodName = playbackStartFeatureFlagFingerprint.method.let { + val stringMethodIndex = it.indexOfFirstInstructionOrThrow { + val reference = getReference() + reference?.definingClass == "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;" + && reference.returnType == "Ljava/lang/String;" + } + + it.getInstruction(stringMethodIndex).getReference()!!.name + } + + playbackStartDescriptorFingerprint.method.addInstructions( + 0, + """ + move-object/from16 v0, p1 + invoke-virtual { v0 }, Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;->$playbackStartVideoIdMethodName()Ljava/lang/String; + move-result-object v0 + invoke-static { v0 }, $EXTENSION_CLASS_DESCRIPTOR->openShorts(Ljava/lang/String;)Z + move-result v0 + + if-eqz v0, :disabled + return-void + :disabled + nop + """ + ) + } +} diff --git a/patches/src/main/resources/addresources/values/strings.xml b/patches/src/main/resources/addresources/values/strings.xml index bb502a992b..b9d4e835cf 100644 --- a/patches/src/main/resources/addresources/values/strings.xml +++ b/patches/src/main/resources/addresources/values/strings.xml @@ -1058,6 +1058,11 @@ If later turned off, it is recommended to clear the app data to prevent UI bugs. Shorts player will not resume on app startup Shorts player will resume on app startup + + Open Shorts in regular player + Shorts will open in the regular video player + Shorts will open in the Shorts player + Autoplay Shorts Shorts will autoplay From 9b7e9d5d0838f774c5842738fa441b8b4624ddce Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:45:55 +0400 Subject: [PATCH 02/15] fix pre 19.45 --- .../patches/OpenShortsInRegularPlayer.java | 4 +- .../layout/shortsbypass/Fingerprints.kt | 31 ++++++++++--- .../shortsbypass/OpenShortsInRegularPlayer.kt | 46 +++++++++++++++---- 3 files changed, 63 insertions(+), 18 deletions(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java index d60a1be8dd..80bcd8b6d0 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java @@ -13,7 +13,7 @@ public class OpenShortsInRegularPlayer { /** * Injection point. */ - public static boolean openShorts(String shortsVideoID) { + public static boolean openShort(String videoID) { try { if (!Settings.OPEN_SHORTS_IN_REGULAR_PLAYER.get()) { return false; @@ -23,7 +23,7 @@ public static boolean openShorts(String shortsVideoID) { Intent videoPlayerIntent = new Intent( Intent.ACTION_VIEW, - Uri.parse("https://www.youtube.com/watch?v=" + shortsVideoID) + Uri.parse("https://www.youtube.com/watch?v=" + videoID) ); videoPlayerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); videoPlayerIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt index 3fcc114464..3e52d47d4d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt @@ -2,6 +2,7 @@ package app.revanced.patches.youtube.layout.shortsbypass import app.revanced.patcher.fingerprint import app.revanced.util.literal +import com.android.tools.smali.dexlib2.AccessFlags /** * Purpose of this method is not clear, and it's only used to identify @@ -17,6 +18,26 @@ internal val playbackStartFeatureFlagFingerprint = fingerprint { } } +// Pre 19.45 +internal val playbackStartDescriptorLegacyFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + returns("V") + parameters( + "L", + "Ljava/util/Map;", + "J", + "Ljava/lang/String;", + "Z", + "Ljava/util/Map;" + ) + strings( + // None of these strings are unique. + "com.google.android.apps.youtube.app.endpoint.flags", + "ReelWatchFragmentArgs", + "reels_fragment_descriptor" + ) +} + internal val playbackStartDescriptorFingerprint = fingerprint { returns("V") parameters( @@ -27,10 +48,8 @@ internal val playbackStartDescriptorFingerprint = fingerprint { ) strings( // None of these strings are unique. - "com.google.android.apps.youtube.PlaybackStartDescriptor", - "PLAYBACK_START_DESCRIPTOR_MUTATOR", - "ReelWatchFragmentArgs" + "com.google.android.apps.youtube.app.endpoint.flags", + "ReelWatchFragmentArgs", + "reels_fragment_descriptor" ) -} - - +} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt index 4a95b22200..a57ee45665 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt @@ -1,16 +1,19 @@ package app.revanced.patches.youtube.layout.shortsbypass -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch +import app.revanced.patches.youtube.misc.playservice.is_19_46_or_greater import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow +import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.reference.MethodReference @@ -58,20 +61,43 @@ val openShortsInRegularPlayer = bytecodePatch( it.getInstruction(stringMethodIndex).getReference()!!.name } - playbackStartDescriptorFingerprint.method.addInstructions( - 0, + fun extensionInstructions(descriptorRegister: Int, freeRegister: Int) = """ - move-object/from16 v0, p1 - invoke-virtual { v0 }, Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;->$playbackStartVideoIdMethodName()Ljava/lang/String; - move-result-object v0 - invoke-static { v0 }, $EXTENSION_CLASS_DESCRIPTOR->openShorts(Ljava/lang/String;)Z - move-result v0 - - if-eqz v0, :disabled + invoke-virtual { v$descriptorRegister }, Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;->$playbackStartVideoIdMethodName()Ljava/lang/String; + move-result-object v$freeRegister + invoke-static { v$freeRegister }, $EXTENSION_CLASS_DESCRIPTOR->openShort(Ljava/lang/String;)Z + move-result v$freeRegister + if-eqz v$freeRegister, :disabled return-void + :disabled nop """ + + if (!is_19_46_or_greater) { + playbackStartDescriptorLegacyFingerprint.method.apply { + val index = indexOfFirstInstructionOrThrow { + getReference()?.returnType == + "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;" + } + val freeRegister = getInstruction(index).registerC + val descriptorRegister = getInstruction(index + 1).registerA + + addInstructionsWithLabels( + index + 2, + extensionInstructions(descriptorRegister, freeRegister) + ) + } + + return@execute + } + + playbackStartDescriptorFingerprint.method.addInstructionsWithLabels( + 0, + """ + move-object/from16 v0, p1 + ${extensionInstructions(0, 0)} + """ ) } } From 429183a139e853cc6e1e1e3adea601add91f7ad3 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:02:09 +0400 Subject: [PATCH 03/15] refactor --- .../patches/OpenShortsInRegularPlayer.java | 2 +- .../shortsbypass/OpenShortsInRegularPlayer.kt | 16 ++++++++-------- .../resources/addresources/values/strings.xml | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java index 80bcd8b6d0..2b8294f250 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java @@ -33,7 +33,7 @@ public static boolean openShort(String videoID) { context.startActivity(videoPlayerIntent); return true; } catch (Exception ex) { - Logger.printException(() -> "openShorts failure", ex); + Logger.printException(() -> "openShort failure", ex); return false; } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt index a57ee45665..42538bd437 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt @@ -7,19 +7,19 @@ import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch -import app.revanced.patches.youtube.misc.playservice.is_19_46_or_greater +import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/OpenShortsInRegularPlayer;" +@Suppress("unused") val openShortsInRegularPlayer = bytecodePatch( name = "Open Shorts in player", description = "Adds an option to open Shorts in the regular video player.", @@ -58,12 +58,12 @@ val openShortsInRegularPlayer = bytecodePatch( && reference.returnType == "Ljava/lang/String;" } - it.getInstruction(stringMethodIndex).getReference()!!.name + navigate(it).to(stringMethodIndex).stop().name } - fun extensionInstructions(descriptorRegister: Int, freeRegister: Int) = + fun extensionInstructions(playbackStartRegister: Int, freeRegister: Int) = """ - invoke-virtual { v$descriptorRegister }, Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;->$playbackStartVideoIdMethodName()Ljava/lang/String; + invoke-virtual { v$playbackStartRegister }, Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;->$playbackStartVideoIdMethodName()Ljava/lang/String; move-result-object v$freeRegister invoke-static { v$freeRegister }, $EXTENSION_CLASS_DESCRIPTOR->openShort(Ljava/lang/String;)Z move-result v$freeRegister @@ -74,18 +74,18 @@ val openShortsInRegularPlayer = bytecodePatch( nop """ - if (!is_19_46_or_greater) { + if (!is_19_25_or_greater) { playbackStartDescriptorLegacyFingerprint.method.apply { val index = indexOfFirstInstructionOrThrow { getReference()?.returnType == "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;" } val freeRegister = getInstruction(index).registerC - val descriptorRegister = getInstruction(index + 1).registerA + val playbackStartRegister = getInstruction(index + 1).registerA addInstructionsWithLabels( index + 2, - extensionInstructions(descriptorRegister, freeRegister) + extensionInstructions(playbackStartRegister, freeRegister) ) } diff --git a/patches/src/main/resources/addresources/values/strings.xml b/patches/src/main/resources/addresources/values/strings.xml index b9d4e835cf..4201140d7d 100644 --- a/patches/src/main/resources/addresources/values/strings.xml +++ b/patches/src/main/resources/addresources/values/strings.xml @@ -1060,8 +1060,8 @@ If later turned off, it is recommended to clear the app data to prevent UI bugs. Open Shorts in regular player - Shorts will open in the regular video player - Shorts will open in the Shorts player + Shorts open in the regular video player + Shorts open in the Shorts player Autoplay Shorts From 9e774a18cba62c7b539ebde04314137ed4a112f5 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:35:17 +0400 Subject: [PATCH 04/15] fix app crash on opening some Shorts links outside the app --- .../patches/OpenShortsInRegularPlayer.java | 27 ++++++++++++++----- .../shortsbypass/OpenShortsInRegularPlayer.kt | 9 +++++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java index 2b8294f250..6e0e04179f 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java @@ -1,15 +1,26 @@ package app.revanced.extension.youtube.patches; +import android.app.Activity; import android.content.Intent; import android.net.Uri; +import java.lang.ref.WeakReference; + import app.revanced.extension.shared.Logger; -import app.revanced.extension.shared.Utils; import app.revanced.extension.youtube.settings.Settings; @SuppressWarnings("unused") public class OpenShortsInRegularPlayer { + private static WeakReference mainActivityRef = new WeakReference<>(null); + + /** + * Injection point. + */ + public static void setMainActivity(Activity activity) { + mainActivityRef = new WeakReference<>(activity); + } + /** * Injection point. */ @@ -19,15 +30,17 @@ public static boolean openShort(String videoID) { return false; } - var context = Utils.getContext(); + // Can use the application context and add intent flags of + // FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TOP + // But the activity context seems to fix random app crashes + // if Shorts urls are opened outside the app. + var context = mainActivityRef.get(); - Intent videoPlayerIntent = new Intent( + Intent videoPlayerIntent = new Intent( Intent.ACTION_VIEW, - Uri.parse("https://www.youtube.com/watch?v=" + videoID) + Uri.parse("https://youtube.com/watch?v=" + videoID) ); - videoPlayerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - videoPlayerIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - videoPlayerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + videoPlayerIntent.setPackage(context.getPackageName()); context.startActivity(videoPlayerIntent); diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt index 42538bd437..f66f3739fc 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt @@ -1,5 +1,6 @@ package app.revanced.patches.youtube.layout.shortsbypass +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.bytecodePatch @@ -10,6 +11,7 @@ import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch +import app.revanced.patches.youtube.shared.mainActivityOnCreateFingerprint import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction @@ -50,6 +52,13 @@ val openShortsInRegularPlayer = bytecodePatch( SwitchPreference("revanced_open_shorts_in_regular_player"), ) + // Main activity is used to open Shorts links. + mainActivityOnCreateFingerprint.method.addInstructions( + 1, + "invoke-static/range { p0 .. p0 }, ${EXTENSION_CLASS_DESCRIPTOR}->" + + "setMainActivity(Landroid/app/Activity;)V", + ) + // Find the obfuscated method name for PlaybackStartDescriptor.videoId() val playbackStartVideoIdMethodName = playbackStartFeatureFlagFingerprint.method.let { val stringMethodIndex = it.indexOfFirstInstructionOrThrow { From 958ddd4b56cf8280526ac978bd842e4b48ceddc5 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:02:51 +0400 Subject: [PATCH 05/15] refactor --- ...larPlayer.java => OpenShortsInRegularPlayerPatch.java} | 8 +++++++- patches/api/patches.api | 4 ++-- .../patches/youtube/layout/shortsbypass/Fingerprints.kt | 4 ++-- ...RegularPlayer.kt => OpenShortsInRegularPlayerPatch.kt} | 8 +++++--- 4 files changed, 16 insertions(+), 8 deletions(-) rename extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/{OpenShortsInRegularPlayer.java => OpenShortsInRegularPlayerPatch.java} (84%) rename patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/{OpenShortsInRegularPlayer.kt => OpenShortsInRegularPlayerPatch.kt} (93%) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java similarity index 84% rename from extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java rename to extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java index 6e0e04179f..bc3403ab0a 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayer.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java @@ -1,5 +1,7 @@ package app.revanced.extension.youtube.patches; +import static app.revanced.extension.youtube.shared.NavigationBar.NavigationButton; + import android.app.Activity; import android.content.Intent; import android.net.Uri; @@ -10,7 +12,7 @@ import app.revanced.extension.youtube.settings.Settings; @SuppressWarnings("unused") -public class OpenShortsInRegularPlayer { +public class OpenShortsInRegularPlayerPatch { private static WeakReference mainActivityRef = new WeakReference<>(null); @@ -29,6 +31,10 @@ public static boolean openShort(String videoID) { if (!Settings.OPEN_SHORTS_IN_REGULAR_PLAYER.get()) { return false; } + + if (NavigationButton.getSelectedNavigationButton() == NavigationButton.SHORTS) { + return false; + } // Can use the application context and add intent flags of // FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TOP diff --git a/patches/api/patches.api b/patches/api/patches.api index ad8502ceb9..68e4506a4b 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -1210,8 +1210,8 @@ public final class app/revanced/patches/youtube/layout/shortsautoplay/ShortsAuto public static final fun getShortsAutoplayPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } -public final class app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerKt { - public static final fun getOpenShortsInRegularPlayer ()Lapp/revanced/patcher/patch/BytecodePatch; +public final class app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatchKt { + public static final fun getOpenShortsInRegularPlayerPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } public final class app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatchKt { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt index 3e52d47d4d..a33cc5a5c7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt @@ -19,7 +19,7 @@ internal val playbackStartFeatureFlagFingerprint = fingerprint { } // Pre 19.45 -internal val playbackStartDescriptorLegacyFingerprint = fingerprint { +internal val shortsPlaybackIntentLegacyFingerprint = fingerprint { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returns("V") parameters( @@ -38,7 +38,7 @@ internal val playbackStartDescriptorLegacyFingerprint = fingerprint { ) } -internal val playbackStartDescriptorFingerprint = fingerprint { +internal val shortsPlaybackIntentFingerprint = fingerprint { returns("V") parameters( "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;", diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatch.kt similarity index 93% rename from patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt rename to patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatch.kt index f66f3739fc..7e25e1e3ac 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayer.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatch.kt @@ -8,6 +8,7 @@ import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch +import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch @@ -22,7 +23,7 @@ private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/OpenShortsInRegularPlayer;" @Suppress("unused") -val openShortsInRegularPlayer = bytecodePatch( +val openShortsInRegularPlayerPatch = bytecodePatch( name = "Open Shorts in player", description = "Adds an option to open Shorts in the regular video player.", ) { @@ -30,6 +31,7 @@ val openShortsInRegularPlayer = bytecodePatch( sharedExtensionPatch, settingsPatch, addResourcesPatch, + navigationBarHookPatch ) compatibleWith( @@ -84,7 +86,7 @@ val openShortsInRegularPlayer = bytecodePatch( """ if (!is_19_25_or_greater) { - playbackStartDescriptorLegacyFingerprint.method.apply { + shortsPlaybackIntentLegacyFingerprint.method.apply { val index = indexOfFirstInstructionOrThrow { getReference()?.returnType == "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;" @@ -101,7 +103,7 @@ val openShortsInRegularPlayer = bytecodePatch( return@execute } - playbackStartDescriptorFingerprint.method.addInstructionsWithLabels( + shortsPlaybackIntentFingerprint.method.addInstructionsWithLabels( 0, """ move-object/from16 v0, p1 From de2acda1ca0d4a2a290e058b0b170b0118a66280 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:04:50 +0400 Subject: [PATCH 06/15] refactor: Add access flags --- .../revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt index a33cc5a5c7..122933ae8c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt @@ -39,6 +39,7 @@ internal val shortsPlaybackIntentLegacyFingerprint = fingerprint { } internal val shortsPlaybackIntentFingerprint = fingerprint { + accessFlags(AccessFlags.PROTECTED, AccessFlags.FINAL) returns("V") parameters( "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;", From 3207e36af58000cde8fd4cf1428fd6e8e59708a8 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:06:29 +0400 Subject: [PATCH 07/15] comments --- .../youtube/patches/OpenShortsInRegularPlayerPatch.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java index bc3403ab0a..59b2bc5111 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java @@ -33,7 +33,7 @@ public static boolean openShort(String videoID) { } if (NavigationButton.getSelectedNavigationButton() == NavigationButton.SHORTS) { - return false; + return false; // Always use Shorts player for the Shorts nav button. } // Can use the application context and add intent flags of @@ -46,7 +46,6 @@ public static boolean openShort(String videoID) { Intent.ACTION_VIEW, Uri.parse("https://youtube.com/watch?v=" + videoID) ); - videoPlayerIntent.setPackage(context.getPackageName()); context.startActivity(videoPlayerIntent); From 821fe2e7426f6fd6f7e86d9b333fcbbb2b448baf Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:07:03 +0400 Subject: [PATCH 08/15] fix: Add missing dependency --- .../layout/shortsbypass/OpenShortsInRegularPlayerPatch.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatch.kt index 7e25e1e3ac..db2c53a031 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatch.kt @@ -10,6 +10,7 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater +import app.revanced.patches.youtube.misc.playservice.versionCheckPatch import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch import app.revanced.patches.youtube.shared.mainActivityOnCreateFingerprint @@ -31,7 +32,8 @@ val openShortsInRegularPlayerPatch = bytecodePatch( sharedExtensionPatch, settingsPatch, addResourcesPatch, - navigationBarHookPatch + navigationBarHookPatch, + versionCheckPatch ) compatibleWith( From 1f952879cb8551dd55b311ba6f2f93419a77b9b0 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:47:32 +0400 Subject: [PATCH 09/15] fix: Allow using fullscreen regular player just for Shorts --- .../youtube/patches/OpenVideosFullscreen.java | 14 ------- .../OpenVideosFullscreenHookPatch.java | 41 +++++++++++++++++++ ...rPatch.java => ShortsPlayerTypePatch.java} | 28 +++++++++++-- .../youtube/patches/VersionCheckPatch.java | 1 + .../extension/youtube/settings/Settings.java | 3 +- patches/api/patches.api | 6 +-- .../layout/player/fullscreen/Fingerprints.kt | 12 ++++++ .../OpenVideosFullscreenHookPatch.kt | 32 +++++++++++++++ ...screen.kt => OpenVideosFullscreenPatch.kt} | 22 +++++----- .../Fingerprints.kt | 2 +- .../ShortsPlayerTypePatch.kt} | 31 ++++++++++---- .../resources/addresources/values/arrays.xml | 22 ++++++++++ .../resources/addresources/values/strings.xml | 9 ++-- 13 files changed, 177 insertions(+), 46 deletions(-) delete mode 100644 extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreen.java create mode 100644 extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java rename extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/{OpenShortsInRegularPlayerPatch.java => ShortsPlayerTypePatch.java} (61%) create mode 100644 patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt rename patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/{OpenVideosFullscreen.kt => OpenVideosFullscreenPatch.kt} (63%) rename patches/src/main/kotlin/app/revanced/patches/youtube/layout/{shortsbypass => shortsplayer}/Fingerprints.kt (96%) rename patches/src/main/kotlin/app/revanced/patches/youtube/layout/{shortsbypass/OpenShortsInRegularPlayerPatch.kt => shortsplayer/ShortsPlayerTypePatch.kt} (78%) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreen.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreen.java deleted file mode 100644 index a15d7f6414..0000000000 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreen.java +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.extension.youtube.patches; - -import app.revanced.extension.youtube.settings.Settings; - -@SuppressWarnings("unused") -public class OpenVideosFullscreen { - - /** - * Injection point. - */ - public static boolean openVideoFullscreenPortrait(boolean original) { - return Settings.OPEN_VIDEOS_FULLSCREEN_PORTRAIT.get(); - } -} diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java new file mode 100644 index 0000000000..f209850914 --- /dev/null +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java @@ -0,0 +1,41 @@ +package app.revanced.extension.youtube.patches; + +import androidx.annotation.Nullable; + +import app.revanced.extension.youtube.settings.Settings; + +@SuppressWarnings("unused") +public class OpenVideosFullscreenHookPatch { + + @Nullable + private static volatile Boolean openNextShortFullscreen; + + public static void setOpenNextShortFullscreen(@Nullable Boolean forceFullScreen) { + openNextShortFullscreen = forceFullScreen; + } + + /** + * Changed by 'Open videos fullscreen' patch, + * as this class is also used by 'Open Shorts in regular player' patch. + */ + private static boolean fullScreenPatchIncluded() { + return false; // Modified by patches + } + + /** + * Injection point. + */ + public static boolean openVideoFullscreenPortrait(boolean original) { + Boolean openFullscreen = openNextShortFullscreen; + if (openFullscreen != null) { + openNextShortFullscreen = null; + return openFullscreen; + } + + if (!fullScreenPatchIncluded()) { + return false; + } + + return Settings.OPEN_VIDEOS_FULLSCREEN_PORTRAIT.get(); + } +} diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ShortsPlayerTypePatch.java similarity index 61% rename from extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java rename to extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ShortsPlayerTypePatch.java index 59b2bc5111..ee7a635346 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ShortsPlayerTypePatch.java @@ -12,7 +12,22 @@ import app.revanced.extension.youtube.settings.Settings; @SuppressWarnings("unused") -public class OpenShortsInRegularPlayerPatch { +public class ShortsPlayerTypePatch { + + public enum ShortsPlayerType { + SHORTS_PLAYER, + REGULAR_PLAYER, + REGULAR_PLAYER_FULLSCREEN + } + + static { + if (!VersionCheckPatch.IS_19_46_OR_GREATER + && Settings.SHORTS_PLAYER_TYPE.get() == ShortsPlayerType.REGULAR_PLAYER_FULLSCREEN) { + // User imported newer settings to an older app target. + Logger.printInfo(() -> "Resetting " + Settings.SHORTS_PLAYER_TYPE); + Settings.SHORTS_PLAYER_TYPE.resetToDefault(); + } + } private static WeakReference mainActivityRef = new WeakReference<>(null); @@ -28,21 +43,25 @@ public static void setMainActivity(Activity activity) { */ public static boolean openShort(String videoID) { try { - if (!Settings.OPEN_SHORTS_IN_REGULAR_PLAYER.get()) { - return false; + ShortsPlayerType type = Settings.SHORTS_PLAYER_TYPE.get(); + if (type == ShortsPlayerType.SHORTS_PLAYER) { + return false; // Default unpatched behavior. } if (NavigationButton.getSelectedNavigationButton() == NavigationButton.SHORTS) { return false; // Always use Shorts player for the Shorts nav button. } + final boolean forceFullScreen = (type == ShortsPlayerType.REGULAR_PLAYER_FULLSCREEN); + OpenVideosFullscreenHookPatch.setOpenNextShortFullscreen(forceFullScreen); + // Can use the application context and add intent flags of // FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TOP // But the activity context seems to fix random app crashes // if Shorts urls are opened outside the app. var context = mainActivityRef.get(); - Intent videoPlayerIntent = new Intent( + Intent videoPlayerIntent = new Intent( Intent.ACTION_VIEW, Uri.parse("https://youtube.com/watch?v=" + videoID) ); @@ -51,6 +70,7 @@ public static boolean openShort(String videoID) { context.startActivity(videoPlayerIntent); return true; } catch (Exception ex) { + OpenVideosFullscreenHookPatch.setOpenNextShortFullscreen(null); Logger.printException(() -> "openShort failure", ex); return false; } diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/VersionCheckPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/VersionCheckPatch.java index 74f082bf4c..c825b88d3d 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/VersionCheckPatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/VersionCheckPatch.java @@ -9,4 +9,5 @@ public class VersionCheckPatch { public static final boolean IS_19_26_OR_GREATER = Utils.getAppVersionName().compareTo("19.26.00") >= 0; public static final boolean IS_19_29_OR_GREATER = Utils.getAppVersionName().compareTo("19.29.00") >= 0; public static final boolean IS_19_34_OR_GREATER = Utils.getAppVersionName().compareTo("19.34.00") >= 0; + public static final boolean IS_19_46_OR_GREATER = Utils.getAppVersionName().compareTo("19.46.00") >= 0; } diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java index 987fea9865..d837d12bf8 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java @@ -16,6 +16,7 @@ import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_2; import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_3; import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_4; +import static app.revanced.extension.youtube.patches.ShortsPlayerTypePatch.ShortsPlayerType; import static app.revanced.extension.youtube.patches.SeekbarThumbnailsPatch.SeekbarThumbnailsHighQualityAvailability; import static app.revanced.extension.youtube.patches.VersionCheckPatch.IS_19_17_OR_GREATER; import static app.revanced.extension.youtube.sponsorblock.objects.CategoryBehaviour.IGNORE; @@ -224,7 +225,7 @@ public class Settings extends BaseSettings { // Shorts public static final BooleanSetting DISABLE_RESUMING_SHORTS_PLAYER = new BooleanSetting("revanced_disable_resuming_shorts_player", FALSE); public static final BooleanSetting DISABLE_SHORTS_BACKGROUND_PLAYBACK = new BooleanSetting("revanced_shorts_disable_background_playback", FALSE); - public static final BooleanSetting OPEN_SHORTS_IN_REGULAR_PLAYER = new BooleanSetting("revanced_open_shorts_in_regular_player", FALSE); + public static final EnumSetting SHORTS_PLAYER_TYPE = new EnumSetting<>("revanced_shorts_player_type", ShortsPlayerType.SHORTS_PLAYER); public static final BooleanSetting HIDE_SHORTS_CHANNEL_BAR = new BooleanSetting("revanced_hide_shorts_channel_bar", FALSE); public static final BooleanSetting HIDE_SHORTS_COMMENTS_BUTTON = new BooleanSetting("revanced_hide_shorts_comments_button", FALSE); public static final BooleanSetting HIDE_SHORTS_DISLIKE_BUTTON = new BooleanSetting("revanced_hide_shorts_dislike_button", FALSE); diff --git a/patches/api/patches.api b/patches/api/patches.api index 68e4506a4b..6ef3d46d2b 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -1176,7 +1176,7 @@ public final class app/revanced/patches/youtube/layout/player/background/PlayerC public static final fun getPlayerControlsBackgroundPatch ()Lapp/revanced/patcher/patch/ResourcePatch; } -public final class app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenKt { +public final class app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatchKt { public static final fun getOpenVideosFullscreenPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } @@ -1210,8 +1210,8 @@ public final class app/revanced/patches/youtube/layout/shortsautoplay/ShortsAuto public static final fun getShortsAutoplayPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } -public final class app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatchKt { - public static final fun getOpenShortsInRegularPlayerPatch ()Lapp/revanced/patcher/patch/BytecodePatch; +public final class app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatchKt { + public static final fun getShortsPlayerTypePatch ()Lapp/revanced/patcher/patch/BytecodePatch; } public final class app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatchKt { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/Fingerprints.kt index d188d8442b..83b81c40b0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/Fingerprints.kt @@ -14,3 +14,15 @@ internal val openVideosFullscreenPortraitFingerprint = fingerprint { OPEN_VIDEOS_FULLSCREEN_PORTRAIT_FEATURE_FLAG } } + +/** + * Used to enable opening regular videos fullscreen. + */ +internal val openVideosFullscreenHookPatchExtensionFingerprint = fingerprint { + accessFlags(AccessFlags.PRIVATE, AccessFlags.STATIC) + returns("Z") + parameters() + custom { methodDef, classDef -> + methodDef.name == "fullScreenPatchIncluded" && classDef.type == EXTENSION_CLASS_DESCRIPTOR + } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt new file mode 100644 index 0000000000..a4daf92c9a --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt @@ -0,0 +1,32 @@ +package app.revanced.patches.youtube.layout.player.fullscreen + +import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patches.youtube.layout.shortsplayer.shortsPlayerTypePatch +import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch +import app.revanced.patches.youtube.misc.playservice.is_19_46_or_greater +import app.revanced.patches.youtube.misc.playservice.versionCheckPatch +import app.revanced.util.insertFeatureFlagBooleanOverride + +internal const val EXTENSION_CLASS_DESCRIPTOR = + "Lapp/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch;" + +/** + * Used by both [openVideosFullscreenPatch] and [shortsPlayerTypePatch]. + */ +internal val openVideosFullscreenHookPatch = bytecodePatch { + dependsOn( + sharedExtensionPatch, + versionCheckPatch + ) + + execute { + if (!is_19_46_or_greater) { + return@execute + } + + openVideosFullscreenPortraitFingerprint.method.insertFeatureFlagBooleanOverride( + OPEN_VIDEOS_FULLSCREEN_PORTRAIT_FEATURE_FLAG, + "$EXTENSION_CLASS_DESCRIPTOR->openVideoFullscreenPortrait(Z)Z" + ) + } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreen.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt similarity index 63% rename from patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreen.kt rename to patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt index 621381ae5c..6d2fb31c92 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreen.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt @@ -1,16 +1,15 @@ package app.revanced.patches.youtube.layout.player.fullscreen +import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch import app.revanced.patches.shared.misc.settings.preference.SwitchPreference -import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch +import app.revanced.patches.youtube.misc.playservice.is_19_46_or_greater +import app.revanced.patches.youtube.misc.playservice.versionCheckPatch import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch -import app.revanced.util.insertFeatureFlagBooleanOverride - -private const val EXTENSION_CLASS_DESCRIPTOR = - "Lapp/revanced/extension/youtube/patches/OpenVideosFullscreen;" +import app.revanced.util.returnEarly @Suppress("unused") val openVideosFullscreenPatch = bytecodePatch( @@ -18,9 +17,10 @@ val openVideosFullscreenPatch = bytecodePatch( description = "Adds an option to open videos in full screen portrait mode.", ) { dependsOn( - sharedExtensionPatch, + openVideosFullscreenHookPatch, settingsPatch, addResourcesPatch, + versionCheckPatch ) compatibleWith( @@ -30,12 +30,12 @@ val openVideosFullscreenPatch = bytecodePatch( ) execute { - openVideosFullscreenPortraitFingerprint.method.insertFeatureFlagBooleanOverride( - OPEN_VIDEOS_FULLSCREEN_PORTRAIT_FEATURE_FLAG, - "$EXTENSION_CLASS_DESCRIPTOR->openVideoFullscreenPortrait(Z)Z" - ) + if (!is_19_46_or_greater) { + throw PatchException("Patch requires 19.46.42 or greater") + } - // Add resources and setting last, in case the user force patches an old incompatible version. + // Enable the logic for the user Setting to open regular videos fullscreen. + openVideosFullscreenHookPatchExtensionFingerprint.method.returnEarly(true) addResources("youtube", "layout.player.fullscreen.openVideosFullscreen") diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/Fingerprints.kt similarity index 96% rename from patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt rename to patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/Fingerprints.kt index 122933ae8c..af484bc6eb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/Fingerprints.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.shortsbypass +package app.revanced.patches.youtube.layout.shortsplayer import app.revanced.patcher.fingerprint import app.revanced.util.literal diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatch.kt similarity index 78% rename from patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatch.kt rename to patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatch.kt index db2c53a031..7caa669ac9 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsbypass/OpenShortsInRegularPlayerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.shortsbypass +package app.revanced.patches.youtube.layout.shortsplayer import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels @@ -6,10 +6,12 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch -import app.revanced.patches.shared.misc.settings.preference.SwitchPreference +import app.revanced.patches.shared.misc.settings.preference.ListPreference +import app.revanced.patches.youtube.layout.player.fullscreen.openVideosFullscreenHookPatch import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater +import app.revanced.patches.youtube.misc.playservice.is_19_46_or_greater import app.revanced.patches.youtube.misc.playservice.versionCheckPatch import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch @@ -21,17 +23,18 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = - "Lapp/revanced/extension/youtube/patches/OpenShortsInRegularPlayer;" + "Lapp/revanced/extension/youtube/patches/ShortsPlayerTypePatch;" @Suppress("unused") -val openShortsInRegularPlayerPatch = bytecodePatch( - name = "Open Shorts in player", - description = "Adds an option to open Shorts in the regular video player.", +val shortsPlayerTypePatch = bytecodePatch( + name = "Shorts player type", + description = "Adds options to open Shorts in the regular video player.", ) { dependsOn( sharedExtensionPatch, settingsPatch, addResourcesPatch, + openVideosFullscreenHookPatch, navigationBarHookPatch, versionCheckPatch ) @@ -50,10 +53,22 @@ val openShortsInRegularPlayerPatch = bytecodePatch( ) execute { - addResources("youtube", "layout.shortsbypass.openShortsInRegularPlayer") + addResources("youtube", "layout.shortsplayer.shortsPlayerTypePatch") PreferenceScreen.SHORTS.addPreferences( - SwitchPreference("revanced_open_shorts_in_regular_player"), + if (is_19_46_or_greater) { + ListPreference( + key = "revanced_shorts_player_type", + summaryKey = null, + ) + } else { + ListPreference( + key = "revanced_shorts_player_type", + summaryKey = null, + entriesKey = "revanced_shorts_player_type_legacy_entries", + entryValuesKey = "revanced_shorts_player_type_legacy_entry_values" + ) + } ) // Main activity is used to open Shorts links. diff --git a/patches/src/main/resources/addresources/values/arrays.xml b/patches/src/main/resources/addresources/values/arrays.xml index c600e86b7e..b11c1f9c35 100644 --- a/patches/src/main/resources/addresources/values/arrays.xml +++ b/patches/src/main/resources/addresources/values/arrays.xml @@ -221,6 +221,28 @@ BROWSE + + + @string/revanced_shorts_player_type_shorts + @string/revanced_shorts_player_type_regular_player + + + + SHORTS_PLAYER + REGULAR_PLAYER + + + @string/revanced_shorts_player_type_shorts + @string/revanced_shorts_player_type_regular_player + @string/revanced_shorts_player_type_regular_player_fullscreen + + + + SHORTS_PLAYER + REGULAR_PLAYER + REGULAR_PLAYER_FULLSCREEN + + @string/revanced_alt_thumbnail_options_entry_1 diff --git a/patches/src/main/resources/addresources/values/strings.xml b/patches/src/main/resources/addresources/values/strings.xml index 4201140d7d..deec1b5ce7 100644 --- a/patches/src/main/resources/addresources/values/strings.xml +++ b/patches/src/main/resources/addresources/values/strings.xml @@ -1058,10 +1058,11 @@ If later turned off, it is recommended to clear the app data to prevent UI bugs. Shorts player will not resume on app startup Shorts player will resume on app startup - - Open Shorts in regular player - Shorts open in the regular video player - Shorts open in the Shorts player + + Shorts player type + Shorts player + Regular player + Regular player fullscreen Autoplay Shorts From 7fef2aa651afb2c8db4de997b74c02202cac51f6 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 17 Dec 2024 23:01:27 +0400 Subject: [PATCH 10/15] fix: keep binary compatibility --- .../youtube/patches/OpenVideosFullscreenHookPatch.java | 6 +++--- patches/api/patches.api | 4 ++++ .../youtube/layout/player/fullscreen/Fingerprints.kt | 2 +- .../layout/player/fullscreen/OpenVideosFullscreen.kt | 9 +++++++++ .../player/fullscreen/OpenVideosFullscreenPatch.kt | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreen.kt diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java index f209850914..89773b66c1 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java @@ -18,8 +18,8 @@ public static void setOpenNextShortFullscreen(@Nullable Boolean forceFullScreen) * Changed by 'Open videos fullscreen' patch, * as this class is also used by 'Open Shorts in regular player' patch. */ - private static boolean fullScreenPatchIncluded() { - return false; // Modified by patches + private static boolean isFullScreenPatchIncluded() { + return false; // Modified by patches. } /** @@ -32,7 +32,7 @@ public static boolean openVideoFullscreenPortrait(boolean original) { return openFullscreen; } - if (!fullScreenPatchIncluded()) { + if (!isFullScreenPatchIncluded()) { return false; } diff --git a/patches/api/patches.api b/patches/api/patches.api index 6ef3d46d2b..c125e8def3 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -1176,6 +1176,10 @@ public final class app/revanced/patches/youtube/layout/player/background/PlayerC public static final fun getPlayerControlsBackgroundPatch ()Lapp/revanced/patcher/patch/ResourcePatch; } +public final class app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenKt { + public static final fun getOpenVideosFullscreen ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatchKt { public static final fun getOpenVideosFullscreenPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/Fingerprints.kt index 83b81c40b0..096ed695da 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/Fingerprints.kt @@ -23,6 +23,6 @@ internal val openVideosFullscreenHookPatchExtensionFingerprint = fingerprint { returns("Z") parameters() custom { methodDef, classDef -> - methodDef.name == "fullScreenPatchIncluded" && classDef.type == EXTENSION_CLASS_DESCRIPTOR + methodDef.name == "isFullScreenPatchIncluded" && classDef.type == EXTENSION_CLASS_DESCRIPTOR } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreen.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreen.kt new file mode 100644 index 0000000000..89311b08c0 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreen.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.youtube.layout.player.fullscreen + +import app.revanced.patcher.patch.bytecodePatch + +@Suppress("unused") +@Deprecated("Renamed to openVideosFullscreenPatch", ReplaceWith("openVideosFullscreenPatch")) +val openVideosFullscreen = bytecodePatch{ + dependsOn(openVideosFullscreenPatch) +} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt index 6d2fb31c92..defd98902b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt @@ -43,4 +43,4 @@ val openVideosFullscreenPatch = bytecodePatch( SwitchPreference("revanced_open_videos_fullscreen_portrait") ) } -} +} \ No newline at end of file From 532049b026bd61b1d36d9025a043cfad16ddbded Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 17 Dec 2024 23:09:14 +0400 Subject: [PATCH 11/15] Adjust settings text --- patches/src/main/resources/addresources/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/src/main/resources/addresources/values/strings.xml b/patches/src/main/resources/addresources/values/strings.xml index deec1b5ce7..f7f95f6e5a 100644 --- a/patches/src/main/resources/addresources/values/strings.xml +++ b/patches/src/main/resources/addresources/values/strings.xml @@ -1059,7 +1059,7 @@ If later turned off, it is recommended to clear the app data to prevent UI bugs. Shorts player will resume on app startup - Shorts player type + Open Shorts with Shorts player Regular player Regular player fullscreen From 4b1fb5d1ba92a3655e951f9b6a114cc0d221be8a Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:33:30 +0400 Subject: [PATCH 12/15] fix launcher Shorts app shortcut --- .../youtube/patches/OpenVideosFullscreenHookPatch.java | 10 +++++----- .../youtube/patches/ShortsPlayerTypePatch.java | 10 ++++++++-- .../youtube/layout/shortsplayer/Fingerprints.kt | 2 +- .../layout/shortsplayer/ShortsPlayerTypePatch.kt | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java index 89773b66c1..556edcb320 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java @@ -8,10 +8,10 @@ public class OpenVideosFullscreenHookPatch { @Nullable - private static volatile Boolean openNextShortFullscreen; + private static volatile Boolean openNextVideoFullscreen; - public static void setOpenNextShortFullscreen(@Nullable Boolean forceFullScreen) { - openNextShortFullscreen = forceFullScreen; + public static void setOpenNextVideoFullscreen(@Nullable Boolean forceFullScreen) { + openNextVideoFullscreen = forceFullScreen; } /** @@ -26,9 +26,9 @@ private static boolean isFullScreenPatchIncluded() { * Injection point. */ public static boolean openVideoFullscreenPortrait(boolean original) { - Boolean openFullscreen = openNextShortFullscreen; + Boolean openFullscreen = openNextVideoFullscreen; if (openFullscreen != null) { - openNextShortFullscreen = null; + openNextVideoFullscreen = null; return openFullscreen; } diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ShortsPlayerTypePatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ShortsPlayerTypePatch.java index ee7a635346..0c22034163 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ShortsPlayerTypePatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ShortsPlayerTypePatch.java @@ -47,13 +47,19 @@ public static boolean openShort(String videoID) { if (type == ShortsPlayerType.SHORTS_PLAYER) { return false; // Default unpatched behavior. } + + if (videoID.isEmpty()) { + // Shorts was opened using launcher app shortcut. + Logger.printDebug(() -> "Ignoring Short with no videoId"); + return false; + } if (NavigationButton.getSelectedNavigationButton() == NavigationButton.SHORTS) { return false; // Always use Shorts player for the Shorts nav button. } final boolean forceFullScreen = (type == ShortsPlayerType.REGULAR_PLAYER_FULLSCREEN); - OpenVideosFullscreenHookPatch.setOpenNextShortFullscreen(forceFullScreen); + OpenVideosFullscreenHookPatch.setOpenNextVideoFullscreen(forceFullScreen); // Can use the application context and add intent flags of // FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TOP @@ -70,7 +76,7 @@ public static boolean openShort(String videoID) { context.startActivity(videoPlayerIntent); return true; } catch (Exception ex) { - OpenVideosFullscreenHookPatch.setOpenNextShortFullscreen(null); + OpenVideosFullscreenHookPatch.setOpenNextVideoFullscreen(null); Logger.printException(() -> "openShort failure", ex); return false; } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/Fingerprints.kt index af484bc6eb..961ddef023 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/Fingerprints.kt @@ -18,7 +18,7 @@ internal val playbackStartFeatureFlagFingerprint = fingerprint { } } -// Pre 19.45 +// Pre 19.25 internal val shortsPlaybackIntentLegacyFingerprint = fingerprint { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returns("V") diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatch.kt index 7caa669ac9..cc06e5894f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatch.kt @@ -124,7 +124,7 @@ val shortsPlayerTypePatch = bytecodePatch( 0, """ move-object/from16 v0, p1 - ${extensionInstructions(0, 0)} + ${extensionInstructions(0, 1)} """ ) } From f1073e31e182825f4beab2fb0428e3c976d84d98 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:32:27 +0400 Subject: [PATCH 13/15] refactor --- ...ePatch.java => OpenShortsInRegularPlayerPatch.java} | 2 +- .../revanced/extension/youtube/settings/Settings.java | 2 +- patches/api/patches.api | 4 ++-- .../shared/misc/checks/BaseCheckEnvironmentPatch.kt | 4 ++-- .../player/fullscreen/OpenVideosFullscreenHookPatch.kt | 4 ++-- .../player/fullscreen/OpenVideosFullscreenPatch.kt | 8 ++++---- .../layout/shortsautoplay/ShortsAutoplayPatch.kt | 3 ++- ...rTypePatch.kt => OpenShortsInRegularPlayerPatch.kt} | 10 +++++----- .../youtube/misc/announcements/AnnouncementsPatch.kt | 4 ++-- .../dns/CheckWatchHistoryDomainNameResolutionPatch.kt | 4 ++-- 10 files changed, 23 insertions(+), 22 deletions(-) rename extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/{ShortsPlayerTypePatch.java => OpenShortsInRegularPlayerPatch.java} (98%) rename patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/{ShortsPlayerTypePatch.kt => OpenShortsInRegularPlayerPatch.kt} (95%) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ShortsPlayerTypePatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java similarity index 98% rename from extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ShortsPlayerTypePatch.java rename to extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java index 0c22034163..cdea9196f9 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/ShortsPlayerTypePatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java @@ -12,7 +12,7 @@ import app.revanced.extension.youtube.settings.Settings; @SuppressWarnings("unused") -public class ShortsPlayerTypePatch { +public class OpenShortsInRegularPlayerPatch { public enum ShortsPlayerType { SHORTS_PLAYER, diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java index d837d12bf8..92b9ba8432 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java @@ -16,7 +16,7 @@ import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_2; import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_3; import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_4; -import static app.revanced.extension.youtube.patches.ShortsPlayerTypePatch.ShortsPlayerType; +import static app.revanced.extension.youtube.patches.OpenShortsInRegularPlayerPatch.ShortsPlayerType; import static app.revanced.extension.youtube.patches.SeekbarThumbnailsPatch.SeekbarThumbnailsHighQualityAvailability; import static app.revanced.extension.youtube.patches.VersionCheckPatch.IS_19_17_OR_GREATER; import static app.revanced.extension.youtube.sponsorblock.objects.CategoryBehaviour.IGNORE; diff --git a/patches/api/patches.api b/patches/api/patches.api index c125e8def3..25d3d50601 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -1214,8 +1214,8 @@ public final class app/revanced/patches/youtube/layout/shortsautoplay/ShortsAuto public static final fun getShortsAutoplayPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } -public final class app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatchKt { - public static final fun getShortsPlayerTypePatch ()Lapp/revanced/patcher/patch/BytecodePatch; +public final class app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatchKt { + public static final fun getOpenShortsInRegularPlayerPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } public final class app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatchKt { diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/checks/BaseCheckEnvironmentPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/checks/BaseCheckEnvironmentPatch.kt index 3ede5d48af..bd5a80f707 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/checks/BaseCheckEnvironmentPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/checks/BaseCheckEnvironmentPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.shared.misc.checks import android.os.Build.* import app.revanced.patcher.Fingerprint -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.Patch import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableEncodedValue @@ -82,7 +82,7 @@ fun checkEnvironmentPatch( } } - fun invokeCheck() = mainActivityOnCreateFingerprint.method.addInstructions( + fun invokeCheck() = mainActivityOnCreateFingerprint.method.addInstruction( 0, "invoke-static/range { p0 .. p0 },$EXTENSION_CLASS_DESCRIPTOR->check(Landroid/app/Activity;)V", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt index a4daf92c9a..24896be997 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.layout.player.fullscreen import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.youtube.layout.shortsplayer.shortsPlayerTypePatch +import app.revanced.patches.youtube.layout.shortsplayer.openShortsInRegularPlayerPatch import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.misc.playservice.is_19_46_or_greater import app.revanced.patches.youtube.misc.playservice.versionCheckPatch @@ -11,7 +11,7 @@ internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch;" /** - * Used by both [openVideosFullscreenPatch] and [shortsPlayerTypePatch]. + * Used by both [openVideosFullscreenPatch] and [openShortsInRegularPlayerPatch]. */ internal val openVideosFullscreenHookPatch = bytecodePatch { dependsOn( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt index defd98902b..a196f65e8b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt @@ -31,16 +31,16 @@ val openVideosFullscreenPatch = bytecodePatch( execute { if (!is_19_46_or_greater) { - throw PatchException("Patch requires 19.46.42 or greater") + throw PatchException("'Open videos fullscreen' requires 19.46.42 or greater") } - // Enable the logic for the user Setting to open regular videos fullscreen. - openVideosFullscreenHookPatchExtensionFingerprint.method.returnEarly(true) - addResources("youtube", "layout.player.fullscreen.openVideosFullscreen") PreferenceScreen.PLAYER.addPreferences( SwitchPreference("revanced_open_videos_fullscreen_portrait") ) + + // Enable the logic for the user Setting to open regular videos fullscreen. + openVideosFullscreenHookPatchExtensionFingerprint.method.returnEarly(true) } } \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt index d667729e91..06a66a7bfb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.youtube.layout.shortsautoplay +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.bytecodePatch @@ -56,7 +57,7 @@ val shortsAutoplayPatch = bytecodePatch( } // Main activity is used to check if app is in pip mode. - mainActivityOnCreateFingerprint.method.addInstructions( + mainActivityOnCreateFingerprint.method.addInstruction( 1, "invoke-static/range { p0 .. p0 }, $EXTENSION_CLASS_DESCRIPTOR->" + "setMainActivity(Landroid/app/Activity;)V", diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt similarity index 95% rename from patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatch.kt rename to patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt index cc06e5894f..3e6d2822f0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/ShortsPlayerTypePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.shortsplayer -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.bytecodePatch @@ -23,11 +23,11 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = - "Lapp/revanced/extension/youtube/patches/ShortsPlayerTypePatch;" + "Lapp/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch;" @Suppress("unused") -val shortsPlayerTypePatch = bytecodePatch( - name = "Shorts player type", +val openShortsInRegularPlayerPatch = bytecodePatch( + name = "Open Shorts in regular player", description = "Adds options to open Shorts in the regular video player.", ) { dependsOn( @@ -72,7 +72,7 @@ val shortsPlayerTypePatch = bytecodePatch( ) // Main activity is used to open Shorts links. - mainActivityOnCreateFingerprint.method.addInstructions( + mainActivityOnCreateFingerprint.method.addInstruction( 1, "invoke-static/range { p0 .. p0 }, ${EXTENSION_CLASS_DESCRIPTOR}->" + "setMainActivity(Landroid/app/Activity;)V", diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt index f318d838a1..e0d3a44f62 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.announcements -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch @@ -41,7 +41,7 @@ val announcementsPatch = bytecodePatch( SwitchPreference("revanced_announcements"), ) - mainActivityOnCreateFingerprint.method.addInstructions( + mainActivityOnCreateFingerprint.method.addInstruction( // Insert index must be greater than the insert index used by GmsCoreSupport, // as both patch the same method and GmsCore check should be first. 1, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt index 6437b12991..827c669033 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.dns -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch @@ -31,7 +31,7 @@ val checkWatchHistoryDomainNameResolutionPatch = bytecodePatch( execute { addResources("youtube", "misc.dns.checkWatchHistoryDomainNameResolutionPatch") - mainActivityOnCreateFingerprint.method.addInstructions( + mainActivityOnCreateFingerprint.method.addInstruction( // FIXME: Insert index must be greater than the insert index used by GmsCoreSupport, // as both patch the same method and GmsCoreSupport check should be first, // but the patch does not depend on GmsCoreSupport, so it should not be possible to enforce this From 8fcd3cb6a71c1de6f126e016b7060f09797412ae Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 19 Dec 2024 01:31:27 +0400 Subject: [PATCH 14/15] Comments --- .../youtube/patches/OpenVideosFullscreenHookPatch.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java index 556edcb320..62f9bbff9c 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch.java @@ -15,11 +15,11 @@ public static void setOpenNextVideoFullscreen(@Nullable Boolean forceFullScreen) } /** - * Changed by 'Open videos fullscreen' patch, - * as this class is also used by 'Open Shorts in regular player' patch. + * Changed during patching since this class is also + * used by {@link OpenVideosFullscreenHookPatch}. */ private static boolean isFullScreenPatchIncluded() { - return false; // Modified by patches. + return false; } /** From 3d2165efddf1295fd1539fa263e012d8905da026 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 19 Dec 2024 12:04:43 +0400 Subject: [PATCH 15/15] Comments --- .../patches/OpenShortsInRegularPlayerPatch.java | 10 ++++++++++ .../shortsplayer/OpenShortsInRegularPlayerPatch.kt | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java index cdea9196f9..6d5fbd9cd6 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch.java @@ -50,6 +50,16 @@ public static boolean openShort(String videoID) { if (videoID.isEmpty()) { // Shorts was opened using launcher app shortcut. + // + // This check will not detect if the Shorts app shortcut is used + // while the app is running in the background (instead the regular player is opened). + // To detect that the hooked method map parameter can be checked + // if integer key 'com.google.android.apps.youtube.app.endpoint.flags' + // has bitmask 16 set. + // + // This use case seems unlikely if the user has the Shorts + // set to open in the regular player, so it's ignored as + // checking the map makes the patch more complicated. Logger.printDebug(() -> "Ignoring Short with no videoId"); return false; } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt index 3e6d2822f0..5041b87e7f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt @@ -71,7 +71,7 @@ val openShortsInRegularPlayerPatch = bytecodePatch( } ) - // Main activity is used to open Shorts links. + // Activity is used as the context to launch an Intent. mainActivityOnCreateFingerprint.method.addInstruction( 1, "invoke-static/range { p0 .. p0 }, ${EXTENSION_CLASS_DESCRIPTOR}->" +