From 0cad26998ff880f9bae5934a70137666ef1855aa Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 3 Nov 2024 08:46:20 -0400 Subject: [PATCH] feat(YouTube): Support version `19.43.41` (#3854) --- .../DisableFullscreenAmbientModePatch.java | 19 ++++- .../youtube/patches/EnableDebuggingPatch.java | 24 ++++++ patches/api/patches.api | 10 +-- .../youtube/ad/general/HideAdsPatch.kt | 1 + .../ad/getpremium/HideGetPremiumPatch.kt | 1 + .../patches/youtube/ad/video/VideoAdsPatch.kt | 1 + .../copyvideourl/CopyVideoUrlPatch.kt | 1 + .../RemoveViewerDiscretionDialogPatch.kt | 1 + .../interaction/downloads/DownloadsPatch.kt | 1 + .../DisablePreciseSeekingGesturePatch.kt | 1 + .../seekbar/EnableSeekbarTappingPatch.kt | 1 + .../seekbar/EnableSlideToSeekPatch.kt | 1 + .../seekbar/SeekbarThumbnailsPatch.kt | 4 +- .../swipecontrols/SwipeControlsPatch.kt | 1 + .../layout/autocaptions/AutoCaptionsPatch.kt | 1 + .../layout/buttons/action/HideButtonsPatch.kt | 1 + .../navigation/NavigationButtonsPatch.kt | 1 + .../overlay/HidePlayerOverlayButtonsPatch.kt | 1 + .../endscreencards/HideEndscreenCardsPatch.kt | 1 + .../DisableFullscreenAmbientModePatch.kt | 39 +++++----- .../fullscreenambientmode/Fingerprints.kt | 15 ++-- .../hide/general/HideLayoutComponentsPatch.kt | 1 + .../hide/infocards/HideInfoCardsPatch.kt | 1 + .../HidePlayerFlyoutMenuPatch.kt | 1 + .../DisableRollingNumberAnimationPatch.kt | 1 + .../layout/hide/seekbar/HideSeekbarPatch.kt | 1 + .../hide/shorts/HideShortsComponentsPatch.kt | 1 + .../DisableSuggestedVideoEndScreenPatch.kt | 1 + .../layout/hide/time/HideTimestampPatch.kt | 1 + .../layout/miniplayer/MiniplayerPatch.kt | 1 + .../panels/popup/PlayerPopupPanelsPatch.kt | 1 + .../PlayerControlsBackgroundPatch.kt | 1 + .../ReturnYouTubeDislikePatch.kt | 1 + .../layout/searchbar/WideSearchbarPatch.kt | 1 + .../shortsautoplay/ShortsAutoplayPatch.kt | 1 + .../layout/sponsorblock/SponsorBlockPatch.kt | 1 + .../spoofappversion/SpoofAppVersionPatch.kt | 1 + .../layout/startpage/ChangeStartPagePatch.kt | 1 + .../DisableResumingShortsOnStartupPatch.kt | 1 + .../layout/tablet/EnableTabletLayoutPatch.kt | 1 + .../youtube/layout/theme/ThemePatch.kt | 1 + .../thumbnails/AlternativeThumbnailsPatch.kt | 1 + .../BypassImageRegionRestrictionsPatch.kt | 1 + .../misc/autorepeat/AutoRepeatPatch.kt | 1 + .../BackgroundPlaybackPatch.kt | 1 + .../misc/debugging/EnableDebuggingPatch.kt | 44 ++++++++++- .../youtube/misc/debugging/Fingerprints.kt | 17 ++++ .../spoof/SpoofDeviceDimensionsPatch.kt | 1 + ...ckWatchHistoryDomainNameResolutionPatch.kt | 1 + .../fix/playback/SpoofVideoStreamsPatch.kt | 1 + .../youtube/misc/gms/GmsCoreSupportPatch.kt | 1 + .../misc/links/BypassURLRedirectsPatch.kt | 1 + .../misc/links/OpenLinksExternallyPatch.kt | 1 + .../youtube/misc/litho/filter/Fingerprints.kt | 15 ++++ .../misc/litho/filter/LithoFilterPatch.kt | 77 +++++++++++++------ .../RemoveTrackingQueryParameterPatch.kt | 1 + .../quality/RememberVideoQualityPatch.kt | 1 + .../youtube/video/speed/PlaybackSpeedPatch.kt | 1 + .../RestoreOldVideoQualityMenuPatch.kt | 1 + 59 files changed, 249 insertions(+), 64 deletions(-) create mode 100644 extensions/shared/src/main/java/app/revanced/extension/youtube/patches/EnableDebuggingPatch.java create mode 100644 patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/Fingerprints.kt diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/DisableFullscreenAmbientModePatch.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/DisableFullscreenAmbientModePatch.java index 962a0d7b74..3566342944 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/DisableFullscreenAmbientModePatch.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/DisableFullscreenAmbientModePatch.java @@ -4,7 +4,22 @@ /** @noinspection unused*/ public final class DisableFullscreenAmbientModePatch { - public static boolean enableFullScreenAmbientMode() { - return !Settings.DISABLE_FULLSCREEN_AMBIENT_MODE.get(); + + private static final boolean DISABLE_FULLSCREEN_AMBIENT_MODE = Settings.DISABLE_FULLSCREEN_AMBIENT_MODE.get(); + + /** + * Constant found in: androidx.window.embedding.DividerAttributes + */ + private static final int DIVIDER_ATTRIBUTES_COLOR_SYSTEM_DEFAULT = -16777216; + + /** + * Injection point. + */ + public static int getFullScreenBackgroundColor(int originalColor) { + if (DISABLE_FULLSCREEN_AMBIENT_MODE) { + return DIVIDER_ATTRIBUTES_COLOR_SYSTEM_DEFAULT; + } + + return originalColor; } } diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/EnableDebuggingPatch.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/EnableDebuggingPatch.java new file mode 100644 index 0000000000..3154867421 --- /dev/null +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/EnableDebuggingPatch.java @@ -0,0 +1,24 @@ +package app.revanced.extension.youtube.patches; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import app.revanced.extension.shared.Logger; +import app.revanced.extension.shared.settings.BaseSettings; + +@SuppressWarnings("unused") +public final class EnableDebuggingPatch { + + private static final ConcurrentMap featureFlags + = new ConcurrentHashMap<>(150, 0.75f, 1); + + public static boolean isFeatureFlagEnabled(long flag, boolean value) { + if (value && BaseSettings.DEBUG.get()) { + if (featureFlags.putIfAbsent(flag, true) == null) { + Logger.printDebug(() -> "feature is enabled: " + flag); + } + } + + return value; + } +} diff --git a/patches/api/patches.api b/patches/api/patches.api index 49739e3bb8..d950a583e2 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -1053,6 +1053,10 @@ public final class app/revanced/patches/youtube/interaction/seekbar/EnableSlideT public static final fun getEnableSlideToSeekPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatchKt { + public static final fun getSeekbarThumbnailsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatchKt { public static final fun getSwipeControlsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } @@ -1196,10 +1200,6 @@ public final class app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch public static final fun getSeekbarColorPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } -public final class app/revanced/patches/youtube/layout/seekbar/SeekbarThumbnailsPatchKt { - public static final fun getSeekbarThumbnailsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; -} - public final class app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatchKt { public static final fun getShortsAutoplayPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } @@ -1263,7 +1263,7 @@ public final class app/revanced/patches/youtube/misc/check/CheckEnvironmentPatch } public final class app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatchKt { - public static final fun getEnableDebuggingPatch ()Lapp/revanced/patcher/patch/ResourcePatch; + public static final fun getEnableDebuggingPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } public final class app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatchKt { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt index 7abaeda887..3d5384ac4c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt @@ -74,6 +74,7 @@ val hideAdsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt index db83ea6f86..67817d4105 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt @@ -30,6 +30,7 @@ val hideGetPremiumPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt index 5c098d5512..1f9ce8aa9d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt @@ -29,6 +29,7 @@ val videoAdsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlPatch.kt index 0c9fe544cf..ecfb1eddaf 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlPatch.kt @@ -58,6 +58,7 @@ val copyVideoUrlPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt index caccae3822..b930c977e4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt @@ -30,6 +30,7 @@ val removeViewerDiscretionDialogPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt index 34b64a8ad2..2bdda2fe52 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt @@ -73,6 +73,7 @@ val downloadsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt index df2f161e41..121616c9b6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt @@ -30,6 +30,7 @@ val disablePreciseSeekingGesturePatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt index f07aeeca04..f88753e921 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt @@ -32,6 +32,7 @@ val enableSeekbarTappingPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt index 8ca2ff0020..f61947609e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt @@ -42,6 +42,7 @@ val enableSlideToSeekPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatch.kt index 9a49d0e012..08501859dd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatch.kt @@ -1,11 +1,10 @@ -package app.revanced.patches.youtube.layout.seekbar +package app.revanced.patches.youtube.interaction.seekbar import app.revanced.patcher.extensions.InstructionExtensions.addInstructions 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.interaction.seekbar.fullscreenSeekbarThumbnailsQualityFingerprint import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.misc.playservice.is_19_17_or_greater import app.revanced.patches.youtube.misc.playservice.versionCheckPatch @@ -32,6 +31,7 @@ val seekbarThumbnailsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ) ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt index 3cee8b4539..8ffbb27703 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt @@ -73,6 +73,7 @@ val swipeControlsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt index 8a46798d47..0e98533552 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt @@ -28,6 +28,7 @@ val autoCaptionsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt index e0ee582732..5508e9e23e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt @@ -28,6 +28,7 @@ val hideButtonsPatch = resourcePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt index 0b50eb5ed1..f793410d3b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt @@ -41,6 +41,7 @@ val navigationButtonsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt index ce66ab8dc6..d0a2e1f6da 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt @@ -62,6 +62,7 @@ val hidePlayerOverlayButtonsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt index e63f8950d5..7b5eb1ff42 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt @@ -61,6 +61,7 @@ val hideEndscreenCardsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt index a286d70fd7..90d6225401 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt @@ -1,16 +1,18 @@ package app.revanced.patches.youtube.layout.hide.fullscreenambientmode -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 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_43_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 java.util.logging.Logger +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstructionReversedOrThrow +import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction +import com.android.tools.smali.dexlib2.iface.reference.MethodReference internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/DisableFullscreenAmbientModePatch;" @@ -24,7 +26,6 @@ val disableFullscreenAmbientModePatch = bytecodePatch( settingsPatch, sharedExtensionPatch, addResourcesPatch, - versionCheckPatch, ) compatibleWith( @@ -34,33 +35,31 @@ val disableFullscreenAmbientModePatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) - val initializeAmbientModeMatch by initializeAmbientModeFingerprint() + val setFullScreenBackgroundColorMatch by setFullScreenBackgroundColorFingerprint() execute { - // TODO: fix this patch when 19.43+ is eventually supported. - if (is_19_43_or_greater) { - // 19.43+ the feature flag was inlined as false and no longer exists. - // This patch can be updated to change a single method, but for now show a more descriptive error. - return@execute Logger.getLogger(this::class.java.name) - .severe("'Disable fullscreen ambient mode' does not yet support 19.43+") - } - addResources("youtube", "layout.hide.fullscreenambientmode.disableFullscreenAmbientModePatch") PreferenceScreen.PLAYER.addPreferences( SwitchPreference("revanced_disable_fullscreen_ambient_mode"), ) - initializeAmbientModeMatch.mutableMethod.apply { - val moveIsEnabledIndex = initializeAmbientModeMatch.patternMatch!!.endIndex + setFullScreenBackgroundColorMatch.mutableMethod.apply { + val insertIndex = indexOfFirstInstructionReversedOrThrow { + getReference()?.name == "setBackgroundColor" + } + val register = getInstruction(insertIndex).registerD - addInstruction( - moveIsEnabledIndex, - "invoke-static { }, " + - "$EXTENSION_CLASS_DESCRIPTOR->enableFullScreenAmbientMode()Z", + addInstructions( + insertIndex, + """ + invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getFullScreenBackgroundColor(I)I + move-result v$register + """ ) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/Fingerprints.kt index 7f20c1433b..b619020878 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/Fingerprints.kt @@ -1,13 +1,14 @@ package app.revanced.patches.youtube.layout.hide.fullscreenambientmode -import app.revanced.util.literal -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.AccessFlags import app.revanced.patcher.fingerprint +import com.android.tools.smali.dexlib2.AccessFlags -internal val initializeAmbientModeFingerprint = fingerprint { +internal val setFullScreenBackgroundColorFingerprint = fingerprint { returns("V") - accessFlags(AccessFlags.CONSTRUCTOR, AccessFlags.PUBLIC) - opcodes(Opcode.MOVE_RESULT) - literal { 45389368 } + accessFlags(AccessFlags.PROTECTED, AccessFlags.FINAL) + parameters("Z", "I", "I", "I", "I") + custom { method, classDef -> + classDef.type.endsWith("/YouTubePlayerViewNotForReflection;") + && method.name == "onLayout" + } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt index 26401c57f7..60c973c329 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt @@ -128,6 +128,7 @@ val hideLayoutComponentsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt index 8cfd5765de..e591199746 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt @@ -63,6 +63,7 @@ val hideInfoCardsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt index 7a01bbfba0..dc9662d1f4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt @@ -30,6 +30,7 @@ val hidePlayerFlyoutMenuPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt index 2c8ac9d053..dbd1c8549c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt @@ -35,6 +35,7 @@ val disableRollingNumberAnimationPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt index 0759935cd4..565c80439f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt @@ -32,6 +32,7 @@ val hideSeekbarPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt index 3813ebc12d..689c70f43a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt @@ -187,6 +187,7 @@ val hideShortsComponentsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt index 436f3db2f5..cf10a805f6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt @@ -59,6 +59,7 @@ val disableSuggestedVideoEndScreenPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt index ae9604807f..313d39e473 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt @@ -27,6 +27,7 @@ val hideTimestampPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt index b08672b712..1432caa070 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt @@ -167,6 +167,7 @@ val miniplayerPatch = bytecodePatch( // 19.32.36 // 19.32+ and beyond all work without issues. // 19.33.35 "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt index 3914d53e2a..f9ff7e3783 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt @@ -27,6 +27,7 @@ val playerPopupPanelsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt index 433cce068b..15188223a1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt @@ -17,6 +17,7 @@ val playerControlsBackgroundPatch = resourcePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt index 93a497c1cc..e755afb51d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt @@ -60,6 +60,7 @@ val returnYouTubeDislikePatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt index 7f39f9bb52..07dcd64d59 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt @@ -35,6 +35,7 @@ val wideSearchbarPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) 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 be814a96b5..ed25560134 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 @@ -37,6 +37,7 @@ val shortsAutoplayPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt index f8dd9e7ba2..e2da6c9600 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt @@ -117,6 +117,7 @@ val sponsorBlockPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt index 3ec97ea958..4560905f6c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt @@ -34,6 +34,7 @@ val spoofAppVersionPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt index 5c62ff3b2f..3e4c2e0f76 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt @@ -35,6 +35,7 @@ val changeStartPagePatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt index 17886eb77b..2bdfaff20d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt @@ -37,6 +37,7 @@ val disableResumingShortsOnStartupPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt index 7b07f5ecfb..5a96d78c57 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt @@ -32,6 +32,7 @@ val enableTabletLayoutPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt index 8a7cff34b9..04fcfdcc5e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt @@ -198,6 +198,7 @@ val themePatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt index 614ae90527..39df4a6308 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt @@ -39,6 +39,7 @@ val alternativeThumbnailsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictionsPatch.kt index cdb7dc4ed8..f8400ed259 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictionsPatch.kt @@ -33,6 +33,7 @@ val bypassImageRegionRestrictionsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt index 9558b965c1..b7d3597212 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt @@ -31,6 +31,7 @@ val autoRepeatPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt index a7911af0ee..78229a8096 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt @@ -56,6 +56,7 @@ val backgroundPlaybackPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt index 6ca90db90d..c11bd6a0b4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt @@ -1,6 +1,7 @@ package app.revanced.patches.youtube.misc.debugging -import app.revanced.patcher.patch.resourcePatch +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +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.PreferenceScreenPreference @@ -9,9 +10,15 @@ 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.applyMatch +import app.revanced.util.indexOfFirstInstructionOrThrow +import com.android.tools.smali.dexlib2.Opcode + +private const val EXTENSION_CLASS_DESCRIPTOR = + "Lapp/revanced/extension/youtube/patches/EnableDebuggingPatch;" @Suppress("unused") -val enableDebuggingPatch = resourcePatch( +val enableDebuggingPatch = bytecodePatch( name = "Enable debugging", description = "Adds options for debugging.", ) { @@ -21,9 +28,20 @@ val enableDebuggingPatch = resourcePatch( addResourcesPatch, ) - compatibleWith("com.google.android.youtube") + compatibleWith( + "com.google.android.youtube"( + "18.38.44", + "18.49.37", + "19.16.39", + "19.25.37", + "19.34.42", + "19.43.41", + ) + ) + + val experimentalFeatureFlagParentMatch by experimentalFeatureFlagParentFingerprint() - execute { + execute { context -> addResources("youtube", "misc.debugging.enableDebuggingPatch") PreferenceScreen.MISC.addPreferences( @@ -38,5 +56,23 @@ val enableDebuggingPatch = resourcePatch( ), ), ) + + // Hook the method that looks up if a feature flag is active or not. + experimentalFeatureFlagFingerprint.applyMatch( + context, + experimentalFeatureFlagParentMatch + ).mutableMethod.apply { + val insertIndex = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT) + + addInstructions( + insertIndex, + """ + move-result v0 + invoke-static { p1, p2, v0 }, $EXTENSION_CLASS_DESCRIPTOR->isFeatureFlagEnabled(JZ)Z + move-result v0 + return v0 + """ + ) + } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/Fingerprints.kt new file mode 100644 index 0000000000..51cc6bac91 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/Fingerprints.kt @@ -0,0 +1,17 @@ +package app.revanced.patches.youtube.misc.debugging + +import app.revanced.patcher.fingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +internal val experimentalFeatureFlagParentFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) + returns("L") + parameters("L", "J", "[B") + strings("Unable to parse proto typed experiment flag: ") +} + +internal val experimentalFeatureFlagFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + returns("Z") + parameters("J", "Z") +} diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt index c82d363e14..af018b643c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt @@ -30,6 +30,7 @@ val spoofDeviceDimensionsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) 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 f4433fe29e..f980303443 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 @@ -20,6 +20,7 @@ val checkWatchHistoryDomainNameResolutionPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofVideoStreamsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofVideoStreamsPatch.kt index 32e25b18c1..c654cf91a3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofVideoStreamsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofVideoStreamsPatch.kt @@ -42,6 +42,7 @@ val spoofVideoStreamsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt index 1fea1f9bd6..3e808b1d25 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt @@ -40,6 +40,7 @@ val gmsCoreSupportPatch = gmsCoreSupportPatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt index 002c6e8639..7112d43e2f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt @@ -36,6 +36,7 @@ val bypassURLRedirectsPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt index 15e7b3c6e4..c2d24915f7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt @@ -47,6 +47,7 @@ val openLinksExternallyPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/Fingerprints.kt index 8957226a82..ac158ee120 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/Fingerprints.kt @@ -1,6 +1,7 @@ package app.revanced.patches.youtube.misc.litho.filter import app.revanced.patcher.fingerprint +import app.revanced.util.literal import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode @@ -48,3 +49,17 @@ internal val emptyComponentFingerprint = fingerprint { classDef.methods.filter { AccessFlags.STATIC.isSet(it.accessFlags) }.size == 1 } } + +internal val lithoComponentNameUpbFeatureFlagFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + returns("Z") + parameters() + literal { 45631264L } +} + +internal val lithoConverterBufferUpbFeatureFlagFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) + returns("L") + parameters("L") + literal { 45419603L } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt index a3936d54d2..e0db2c821d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt @@ -13,6 +13,7 @@ import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.misc.playservice.is_19_18_or_greater +import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater import app.revanced.patches.youtube.misc.playservice.versionCheckPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow @@ -41,6 +42,8 @@ val lithoFilterPatch = bytecodePatch( val protobufBufferReferenceMatch by protobufBufferReferenceFingerprint() val readComponentIdentifierMatch by readComponentIdentifierFingerprint() val emptyComponentMatch by emptyComponentFingerprint() + val lithoComponentNameUpbFeatureFlagMatch by lithoComponentNameUpbFeatureFlagFingerprint() + val lithoConverterBufferUpbFeatureFlagMatch by lithoConverterBufferUpbFeatureFlagFingerprint() var filterCount = 0 @@ -135,9 +138,19 @@ val lithoFilterPatch = bytecodePatch( builderMethodDescriptor.returnType == classDef.type }!!.immutableClass.fields.single() + // Returns an empty component instead of the original component. + fun createReturnEmptyComponentInstructions(register : Int) : String = + """ + move-object/from16 v$register, p1 + invoke-static { v$register }, $builderMethodDescriptor + move-result-object v$register + iget-object v$register, v$register, $emptyComponentField + return-object v$register + """ + componentContextParserMatch.mutableMethod.apply { // 19.18 and later require patching 2 methods instead of one. - // Otherwise, the patched code is the same. + // Otherwise the modifications done here are the same for all targets. if (is_19_18_or_greater) { // Get the method name of the ReadComponentIdentifierFingerprint call. val readComponentMethodCallIndex = indexOfFirstInstructionOrThrow { @@ -156,15 +169,11 @@ val lithoFilterPatch = bytecodePatch( addInstructionsWithLabels( insertHookIndex, """ - if-nez v$register, :unfiltered - - # Component was filtered in ReadComponentIdentifierFingerprint hook - move-object/from16 v$register, p1 - invoke-static { v$register }, $builderMethodDescriptor - move-result-object v$register - iget-object v$register, v$register, $emptyComponentField - return-object v$register - """, + if-nez v$register, :unfiltered + + # Component was filtered in ReadComponentIdentifierFingerprint hook + ${createReturnEmptyComponentInstructions(register)} + """, ExternalLabel("unfiltered", getInstruction(insertHookIndex)), ) } @@ -190,20 +199,20 @@ val lithoFilterPatch = bytecodePatch( ).registerA // Find a free temporary register. - val register = getInstruction( + val freeRegister = getInstruction( // Immediately before is a StringBuilder append constant character. indexOfFirstInstructionReversedOrThrow(insertHookIndex, Opcode.CONST_16), ).registerA // Verify the temp register will not clobber the method result register. - if (stringBuilderRegister == register) { + if (stringBuilderRegister == freeRegister) { throw PatchException("Free register will clobber StringBuilder register") } val invokeFilterInstructions = """ invoke-static { v$identifierRegister, v$stringBuilderRegister }, $EXTENSION_CLASS_DESCRIPTOR->filter(Ljava/lang/String;Ljava/lang/StringBuilder;)Z - move-result v$register - if-eqz v$register, :unfiltered + move-result v$freeRegister + if-eqz v$freeRegister, :unfiltered """ addInstructionsWithLabels( @@ -214,20 +223,14 @@ val lithoFilterPatch = bytecodePatch( # Return null, and the ComponentContextParserFingerprint hook # handles returning an empty component. - const/4 v$register, 0x0 - return-object v$register + const/4 v$freeRegister, 0x0 + return-object v$freeRegister """ } else { """ $invokeFilterInstructions - - # Exact same code as ComponentContextParserFingerprint hook, - # but with the free register of this method. - move-object/from16 v$register, p1 - invoke-static { v$register }, $builderMethodDescriptor - move-result-object v$register - iget-object v$register, v$register, $emptyComponentField - return-object v$register + + ${createReturnEmptyComponentInstructions(freeRegister)} """ }, ExternalLabel("unfiltered", getInstruction(insertHookIndex)), @@ -235,6 +238,32 @@ val lithoFilterPatch = bytecodePatch( } // endregion + + // region A/B test of new Litho native code. + + // Turn off native code that handles litho component names. If this feature is on then nearly + // all litho components have a null name and identifier/path filtering is completely broken. + if (is_19_25_or_greater) { + lithoComponentNameUpbFeatureFlagMatch.mutableMethod.apply { + // Don't use return early, so the debug patch logs if this was originally on. + val insertIndex = indexOfFirstInstructionOrThrow(Opcode.RETURN) + val register = getInstruction(insertIndex).registerA + + addInstruction(insertIndex, "const/4 v$register, 0x0") + } + } + + // Turn off a feature flag that enables native code of protobuf parsing (Upb protobuf). + // If this is enabled, then the litho protobuffer hook will always show an empty buffer + // since it's no longer handled by the hooked Java code. + lithoConverterBufferUpbFeatureFlagMatch.mutableMethod.apply { + val index = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT) + val register = getInstruction(index).registerA + + addInstruction(index + 1, "const/4 v$register, 0x0") + } + + // endregion } finalize { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt index 04da4a967c..ee397c8f0d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt @@ -35,6 +35,7 @@ val removeTrackingQueryParameterPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt index 79ca86a4d4..61c466a64f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt @@ -42,6 +42,7 @@ val rememberVideoQualityPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt index 592335bfc8..42caa99ad1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt @@ -24,6 +24,7 @@ val playbackSpeedPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt index 182e88996e..6e4e47a016 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt @@ -79,6 +79,7 @@ val restoreOldVideoQualityMenuPatch = bytecodePatch( "19.16.39", "19.25.37", "19.34.42", + "19.43.41", ), )