From 1026a8fbd730d839699588642208c2b4d62b9491 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 25 Jan 2026 20:30:19 +0100 Subject: [PATCH] original -> immutable --- .../patches/music/ad/video/HideVideoAds.kt | 2 +- .../miniplayercolor/ChangeMiniplayerColor.kt | 2 +- .../spotify/layout/theme/CustomThemePatch.kt | 2 +- .../misc/fix/login/FixFacebookLoginPatch.kt | 2 +- .../misc/lyrics/ChangeLyricsProviderPatch.kt | 2 +- .../misc/privacy/SanitizeSharingLinksPatch.kt | 6 ++-- .../DisableSubscriptionSuggestionsPatch.kt | 8 ++--- .../interaction/speed/PlaybackSpeedPatch.kt | 2 +- .../featureflags/OverrideFeatureFlagsPatch.kt | 6 ++-- .../DisableChapterSkipDoubleTapPatch.kt | 2 +- .../formfactor/ChangeFormFactorPatch.kt | 2 +- .../HideEndScreenSuggestedVideoPatch.kt | 4 +-- .../hide/general/HideLayoutComponentsPatch.kt | 2 +- .../hide/infocards/HideInfoCardsPatch.kt | 2 +- .../HideRelatedVideoOverlayPatch.kt | 2 +- .../hide/shorts/HideShortsComponentsPatch.kt | 4 +-- .../layout/miniplayer/MiniplayerPatch.kt | 6 ++-- .../ReturnYouTubeDislikePatch.kt | 10 +++---- .../layout/searchbar/WideSearchbarPatch.kt | 2 +- .../layout/seekbar/SeekbarColorPatch.kt | 14 ++++----- .../BackgroundPlaybackPatch.kt | 2 +- .../misc/imageurlhook/CronetImageUrlHook.kt | 6 ++-- .../misc/litho/filter/LithoFilterPatch.kt | 2 +- .../misc/navigation/NavigationBarHookPatch.kt | 2 +- .../speed/custom/CustomPlaybackSpeedPatch.kt | 18 +++++------ .../video/speed/custom/Fingerprints.kt | 30 ++++++++----------- .../youtube/video/videoid/VideoIdPatch.kt | 2 +- 27 files changed, 69 insertions(+), 75 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/music/ad/video/HideVideoAds.kt b/patches/src/main/kotlin/app/revanced/patches/music/ad/video/HideVideoAds.kt index dd046d84e..5621023b4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/ad/video/HideVideoAds.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/ad/video/HideVideoAds.kt @@ -35,7 +35,7 @@ val `Hide music video ads` by creatingBytecodePatch( SwitchPreference("revanced_music_hide_video_ads"), ) - navigate(showVideoAdsParentMethod.originalMethod) + navigate(showVideoAdsParentMethod.immutableMethod) .to(showVideoAdsParentMethod.instructionMatches.first().index + 1) .stop() .addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/miniplayercolor/ChangeMiniplayerColor.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/miniplayercolor/ChangeMiniplayerColor.kt index 99afceb05..c272a7bad 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/miniplayercolor/ChangeMiniplayerColor.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/miniplayercolor/ChangeMiniplayerColor.kt @@ -75,7 +75,7 @@ val `Change miniplayer color` by creatingBytecodePatch( miniPlayerConstructorMethod.classDef.methods.single { method -> method.accessFlags == AccessFlags.PUBLIC.value or AccessFlags.FINAL.value && method.returnType == "V" && - method.parameters == it.originalMethod.parameters + method.parameters == it.immutableMethod.parameters }.apply { val insertIndex = indexOfFirstInstructionReversedOrThrow(Opcode.INVOKE_DIRECT) val freeRegister = findFreeRegister(insertIndex) diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt index 30330f7b7..028355fbd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt @@ -19,7 +19,7 @@ private val customThemeBytecodePatch = bytecodePatch { dependsOn(sharedExtensionPatch) apply { - val colorSpaceUtilsClassDef = colorSpaceUtilsClassMethod.originalClassDef + val colorSpaceUtilsClassDef = colorSpaceUtilsClassMethod.immutableClassDef // Hook a util method that converts ARGB to RGBA in the sRGB color space to replace hardcoded accent colors. convertArgbToRgbaMethod.match(colorSpaceUtilsClassDef).method.apply { diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/login/FixFacebookLoginPatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/login/FixFacebookLoginPatch.kt index 2af6207ba..39bc134d5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/login/FixFacebookLoginPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/login/FixFacebookLoginPatch.kt @@ -17,7 +17,7 @@ val `Fix Facebook login` by creatingBytecodePatch( // Override the Facebook SDK to always handle the login using the web browser, which does not perform // signature checks. - val katanaProxyLoginMethodHandlerClass = katanaProxyLoginMethodHandlerClassMethod.originalClassDef + val katanaProxyLoginMethodHandlerClass = katanaProxyLoginMethodHandlerClassMethod.immutableClassDef // Always return 0 (no Intent was launched) as the result of trying to authorize with the Facebook app to // make the login fallback to a web browser window. katanaProxyLoginMethodTryAuthorizeMethod diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/ChangeLyricsProviderPatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/ChangeLyricsProviderPatch.kt index 4e0679c73..ce711bfd1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/ChangeLyricsProviderPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/ChangeLyricsProviderPatch.kt @@ -59,7 +59,7 @@ val `Change lyrics provider` by creatingBytecodePatch( } apply { - val httpClientBuilderMethod = httpClientBuilderMethod.originalMethod + val httpClientBuilderMethod = httpClientBuilderMethod.immutableMethod // region Create a modified copy of the HTTP client builder method with the custom lyrics provider host. diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt index c3f578b07..b5644a3f8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt @@ -25,7 +25,7 @@ val `Sanitize sharing links` by creatingBytecodePatch( val extensionMethodDescriptor = "$EXTENSION_CLASS_DESCRIPTOR->" + "sanitizeSharingLink(Ljava/lang/String;)Ljava/lang/String;" - val copyFingerprint = if (shareCopyUrlMethod.originalMethodOrNull != null) { + val copyFingerprint = if (shareCopyUrlMethod.immutableMethodOrNull != null) { shareCopyUrlMethod } else { oldShareCopyUrlMethod @@ -48,8 +48,8 @@ val `Sanitize sharing links` by creatingBytecodePatch( // Android native share sheet is used for all other quick share types (X, WhatsApp, etc). val shareUrlParameter: String - val shareSheetFingerprint = if (formatAndroidShareSheetUrlMethod.originalMethodOrNull != null) { - val methodAccessFlags = formatAndroidShareSheetUrlMethod.originalMethod + val shareSheetFingerprint = if (formatAndroidShareSheetUrlMethod.immutableMethodOrNull != null) { + val methodAccessFlags = formatAndroidShareSheetUrlMethod.immutableMethod shareUrlParameter = if (AccessFlags.STATIC.isSet(methodAccessFlags.accessFlags)) { // In newer implementations the method is static, so p0 is not `this`. "p1" diff --git a/patches/src/main/kotlin/app/revanced/patches/strava/upselling/DisableSubscriptionSuggestionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/strava/upselling/DisableSubscriptionSuggestionsPatch.kt index 0061f6e69..f230ab525 100644 --- a/patches/src/main/kotlin/app/revanced/patches/strava/upselling/DisableSubscriptionSuggestionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/strava/upselling/DisableSubscriptionSuggestionsPatch.kt @@ -18,8 +18,8 @@ val `Disable subscription suggestions` by creatingBytecodePatch { val label = "original" val className = getModulesMethodMatch.classDef.type - val originalMethod = getModulesMethodMatch.method - val returnType = originalMethod.returnType + val immutableMethod = getModulesMethodMatch.method + val returnType = immutableMethod.returnType getModulesMethodMatch.classDef.methods.add( ImmutableMethod( @@ -51,8 +51,8 @@ val `Disable subscription suggestions` by creatingBytecodePatch { ) val getModulesIndex = getModulesMethodMatch.indices.first() - originalMethod.removeInstruction(getModulesIndex) - originalMethod.addInstructions( + immutableMethod.removeInstruction(getModulesIndex) + immutableMethod.addInstructions( getModulesIndex, """ invoke-direct {p0}, $className->$helperMethodName()$returnType diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt index 596203e34..c971796fc 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt @@ -43,7 +43,7 @@ val `Playback speed` by creatingBytecodePatch( """ # Video playback location (e.g. home page, following page or search result page) retrieved using getEnterFrom method. const/4 v0, 0x1 - invoke-virtual { p0, v0 }, ${getEnterFromMethod.originalMethod} + invoke-virtual { p0, v0 }, ${getEnterFromMethod.immutableMethod} move-result-object v0 # Model of current video retrieved using getCurrentAweme method. diff --git a/patches/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt index 3510cb515..3bf34cd64 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt @@ -24,15 +24,15 @@ val overrideFeatureFlagsPatch = bytecodePatch( ) { apply { - val configurationClass = getFeatureValueMethod.originalMethod.definingClass - val featureClass = getFeatureValueMethod.originalMethod.parameterTypes[0].toString() + val configurationClass = getFeatureValueMethod.immutableMethod.definingClass + val featureClass = getFeatureValueMethod.immutableMethod.parameterTypes[0].toString() // The method we want to inject into does not have enough registers, so we inject a helper method // and inject more instructions into it later, see addOverride. // This is not in an extension since the unused variable would get compiled away and the method would // get compiled to only have one register, which is not enough for our later injected instructions. val helperMethod = ImmutableMethod( - getFeatureValueMethod.originalMethod.definingClass, + getFeatureValueMethod.immutableMethod.definingClass, "getValueOverride", listOf(ImmutableMethodParameter(featureClass, null, "feature")), "Ljava/lang/String;", diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/doubletap/DisableChapterSkipDoubleTapPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/doubletap/DisableChapterSkipDoubleTapPatch.kt index a14b2e6f5..3c205f385 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/doubletap/DisableChapterSkipDoubleTapPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/doubletap/DisableChapterSkipDoubleTapPatch.kt @@ -56,7 +56,7 @@ val `Disable double tap actions` by creatingBytecodePatch( val doubleTapInfoGetSeekSourceFingerprint = fingerprint { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) parameterTypes("Z") - returnType(seekTypeEnumMethod.originalClassDef.type) + returnType(seekTypeEnumMethod.immutableClassDef.type) opcodes( Opcode.IF_EQZ, Opcode.SGET_OBJECT, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt index 6948fd62a..402cd6d60 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt @@ -53,7 +53,7 @@ val `Change form factor` by creatingBytecodePatch( instructions( fieldAccess(smali = "Landroid/os/Build;->MODEL:Ljava/lang/String;"), fieldAccess( - definingClass = formFactorEnumConstructorMethod.originalClassDef.type, + definingClass = formFactorEnumConstructorMethod.immutableClassDef.type, type = "I", afterAtMost(50), ), diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt index ed47aaac9..dd8947b29 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt @@ -45,12 +45,12 @@ val `Hide end screen suggested video` by creatingBytecodePatch( ) removeOnLayoutChangeListenerMethod.let { - val endScreenMethod = navigate(it.originalMethod).to(it.indices.last()).stop() // TODO + val endScreenMethod = navigate(it.immutableMethod).to(it.indices.last()).stop() // TODO endScreenMethod.apply { val autoNavStatusMethodName = autoNavStatusMethod.match( autoNavConstructorMethod.classDef, - ).originalMethod.name + ).immutableMethod.name val invokeIndex = indexOfFirstInstructionOrThrow { val reference = getReference() 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 c90f0c7cd..7895e5f0c 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 @@ -270,7 +270,7 @@ val `Hide layout components` by creatingBytecodePatch( // region Watermark (legacy code for old versions of YouTube) showWatermarkMethod.match( - playerOverlayMethod.originalClassDef, + playerOverlayMethod.immutableClassDef, ).method.apply { val index = implementation!!.instructions.size - 5 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 33785d896..e23b41e68 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,7 +63,7 @@ val `Hide info cards` by creatingBytecodePatch( ) // Edit: This old non litho code may be obsolete and no longer used by any supported versions. - infocardsIncognitoMethod.match(infocardsIncognitoParentMethod.originalClassDef).method.apply { + infocardsIncognitoMethod.match(infocardsIncognitoParentMethod.immutableClassDef).method.apply { val invokeInstructionIndex = implementation!!.instructions.indexOfFirst { it.opcode.ordinal == Opcode.INVOKE_VIRTUAL.ordinal && ((it as ReferenceInstruction).reference.toString() == "Landroid/view/View;->setVisibility(I)V") diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/relatedvideooverlay/HideRelatedVideoOverlayPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/relatedvideooverlay/HideRelatedVideoOverlayPatch.kt index 27915c234..05241188a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/relatedvideooverlay/HideRelatedVideoOverlayPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/relatedvideooverlay/HideRelatedVideoOverlayPatch.kt @@ -43,7 +43,7 @@ val `Hide related video overlay` by creatingBytecodePatch( ) relatedEndScreenResultsMethod.match( - relatedEndScreenResultsParentMethod.originalClassDef, + relatedEndScreenResultsParentMethod.immutableClassDef, ).method.apply { addInstructionsWithLabels( 0, 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 b65858f9e..11d6d473b 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 @@ -207,7 +207,7 @@ val `Hide Shorts componentsby creatingBytecodePatch( // Hook to get the pivotBar view. setPivotBarVisibilityMethod.match( - setPivotBarVisibilityParentMethod.originalClassDef, + setPivotBarVisibilityParentMethod.immutableClassDef, ).let { result -> result.method.apply { val insertIndex = result.indices.last() @@ -230,7 +230,7 @@ val `Hide Shorts componentsby creatingBytecodePatch( } else { legacyRenderBottomNavigationBarLegacyParentMethod } - ).originalClassDef, + ).immutableClassDef, ).method.addInstruction( 0, "invoke-static { p1 }, $FILTER_CLASS_DESCRIPTOR->hideNavigationBar(Ljava/lang/String;)V", 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 d2b225f1a..3845da80e 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 @@ -236,7 +236,7 @@ val Miniplayer by creatingBytecodePatch( if (!is_20_37_or_greater) { miniplayerOverrideNoContextMethod.match( - miniplayerDimensionsCalculatorParentMethod.originalClassDef, + miniplayerDimensionsCalculatorParentMethod.immutableClassDef, ).method.apply { findReturnIndicesReversed().forEach { index -> insertLegacyTabletMiniplayerOverride( @@ -250,7 +250,7 @@ val Miniplayer by creatingBytecodePatch( // region Legacy tablet miniplayer hooks. miniplayerOverrideMethod.let { val appNameStringIndex = it.indices.last() - navigate(it.originalMethod).to(appNameStringIndex).stop().apply { + navigate(it.immutableMethod).to(appNameStringIndex).stop().apply { findReturnIndicesReversed().forEach { index -> insertLegacyTabletMiniplayerOverride( index, @@ -368,7 +368,7 @@ val Miniplayer by creatingBytecodePatch( // Fix this, by swapping the drawable resource values with each other. if (!is_19_17_or_greater) { miniplayerModernExpandCloseDrawablesMethod.match( - miniplayerModernViewParentMethod.originalClassDef, + miniplayerModernViewParentMethod.immutableClassDef, ).method.apply { listOf( ytOutlinePictureInPictureWhite24 to ytOutlineXWhite24, 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 435f55531..68f9c32db 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 @@ -121,16 +121,16 @@ val `Return YouTube Dislike` by creatingBytecodePatch( // This hook handles all situations, as it's where the created Spans are stored and later reused. // Find the field name of the conversion context. - val conversionContextClass = conversionContextToStringMethod.originalClassDef - val textComponentConversionContextField = textComponentConstructorMethod.originalClassDef.fields.find { + val conversionContextClass = conversionContextToStringMethod.immutableClassDef + val textComponentConversionContextField = textComponentConstructorMethod.immutableClassDef.fields.find { it.type == conversionContextClass.type || // 20.41+ uses superclass field type. it.type == conversionContextClass.superclass } ?: throw PatchException("Could not find conversion context field") - textComponentLookupMethod.match(textComponentConstructorMethod.originalClassDef).method.apply { + textComponentLookupMethod.match(textComponentConstructorMethod.immutableClassDef).method.apply { // Find the instruction for creating the text data object. - val textDataClassType = textComponentDataMethod.originalClassDef.type + val textDataClassType = textComponentDataMethod.immutableClassDef.type val insertIndex: Int val charSequenceRegister: Int @@ -267,7 +267,7 @@ val `Return YouTube Dislike` by creatingBytecodePatch( // Additional text measurement method. Used if YouTube decides not to animate the likes count // and sometimes used for initial video load. rollingNumberMeasureStaticLabelMethod.match( - rollingNumberMeasureStaticLabelParentMethod.originalClassDef, + rollingNumberMeasureStaticLabelParentMethod.immutableClassDef, ).let { val measureTextIndex = it.instructionMatches.first().index + 1 it.method.apply { 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 1d2e6a405..6bf0f32a4 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 @@ -64,7 +64,7 @@ val `Wide search bar` by creatingBytecodePatch( setWordmarkHeaderMethod.let { // Navigate to the method that checks if the YT logo is shown beside the search bar. - val shouldShowLogoMethod = with(it.originalMethod) { + val shouldShowLogoMethod = with(it.immutableMethod) { val invokeStaticIndex = indexOfFirstInstructionOrThrow { opcode == Opcode.INVOKE_STATIC && getReference()?.returnType == "Z" diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt index 7a4943d9c..43ef8f4ca 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt @@ -58,7 +58,7 @@ val seekbarColorPatch = bytecodePatch( it.method.addColorChangeInstructions(it.instructionMatches.first().index) } - setSeekbarClickedColorMethod.originalMethod.let { + setSeekbarClickedColorMethod.immutableMethod.let { val setColorMethodIndex = setSeekbarClickedColorMethod.instructionMatches.first().index + 1 navigate(it).to(setColorMethodIndex).stop().apply { @@ -154,7 +154,7 @@ val seekbarColorPatch = bytecodePatch( // Hook the splash animation to set the a seekbar color. mainActivityOnCreateMethod.apply { val setAnimationIntMethodName = - lottieAnimationViewSetAnimationIntMethod.originalMethod.name + lottieAnimationViewSetAnimationIntMethod.immutableMethod.name findInstructionIndicesReversedOrThrow { val reference = getReference() @@ -176,7 +176,7 @@ val seekbarColorPatch = bytecodePatch( lottieAnimationViewSetAnimationIntMethod.classDef.methods.apply { val addedMethodName = "patch_setAnimation" val setAnimationIntName = lottieAnimationViewSetAnimationIntMethod - .originalMethod.name + .immutableMethod.name add( ImmutableMethod( @@ -202,8 +202,8 @@ val seekbarColorPatch = bytecodePatch( val factoryStreamName: CharSequence val factoryStreamReturnType: CharSequence lottieCompositionFactoryFromJsonInputStreamMethod.match( - lottieCompositionFactoryZipMethod.originalClassDef, - ).originalMethod.apply { + lottieCompositionFactoryZipMethod.immutableClassDef, + ).immutableMethod.apply { factoryStreamClass = definingClass factoryStreamName = name factoryStreamReturnType = returnType @@ -214,11 +214,11 @@ val seekbarColorPatch = bytecodePatch( parameterTypes(factoryStreamReturnType.toString()) returnType("V") custom { _, classDef -> - classDef.type == lottieAnimationViewSetAnimationIntMethod.originalClassDef.type + classDef.type == lottieAnimationViewSetAnimationIntMethod.immutableClassDef.type } } val setAnimationStreamName = lottieAnimationViewSetAnimationStreamFingerprint - .originalMethod.name + .immutableMethod.name add( ImmutableMethod( 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 e0c86058c..65d8836d4 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 @@ -81,7 +81,7 @@ val `Remove background playback restrictions` by creatingBytecodePatch( } // Enable background playback option in YouTube settings - backgroundPlaybackSettingsMethod.originalMethod.apply { + backgroundPlaybackSettingsMethod.immutableMethod.apply { val booleanCalls = instructions.withIndex().filter { it.value.getReference()?.returnType == "Z" } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt index 242c1d6dd..5645573d2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt @@ -31,13 +31,13 @@ val cronetImageUrlHookPatch = bytecodePatch( apply { loadImageUrlMethod = messageDigestImageUrlMethod - .match(messageDigestImageUrlParentMethod.originalClassDef).method + .match(messageDigestImageUrlParentMethod.immutableClassDef).method loadImageSuccessCallbackMethod = onSucceededMethod - .match(onResponseStartedMethod.originalClassDef).method + .match(onResponseStartedMethod.immutableClassDef).method loadImageErrorCallbackMethod = onFailureMethod - .match(onResponseStartedMethod.originalClassDef).method + .match(onResponseStartedMethod.immutableClassDef).method // The URL is required for the failure callback hook, but the URL field is obfuscated. // Add a helper get method that returns the URL field. 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 fd6820372..968aa1edb 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 @@ -115,7 +115,7 @@ val lithoFilterPatch = bytecodePatch( val conversionContextIdentifierField = conversionContextToStringMethod.method .findFieldFromToString("identifierProperty=") - val conversionContextPathBuilderField = conversionContextToStringMethod.originalClassDef + val conversionContextPathBuilderField = conversionContextToStringMethod.immutableClassDef .fields.single { field -> field.type == "Ljava/lang/StringBuilder;" } // Find class and methods to create an empty component. diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt index c449140b8..6bdbb13ec 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt @@ -169,7 +169,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig interfaces.add(EXTENSION_TOOLBAR_INTERFACE) val definingClass = type - val obfuscatedMethodName = it.originalMethod.name + val obfuscatedMethodName = it.immutableMethod.name val returnType = "Landroid/graphics/drawable/Drawable;" methods.add( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt index 1b25f67d6..a5b57c68f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt @@ -6,6 +6,7 @@ import app.revanced.patcher.extensions.addInstructionsWithLabels import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.instructions import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.immutableClassDef import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch @@ -90,21 +91,20 @@ internal val customPlaybackSpeedPatch = bytecodePatch( // region Force old video quality menu. // Replace the speeds float array with custom speeds. - speedArrayGeneratorMethod.let { - val matches = it.instructionMatches + speedArrayGeneratorMethodMatch.let { it.method.apply { val playbackSpeedsArrayType = "$EXTENSION_CLASS_DESCRIPTOR->customPlaybackSpeeds:[F" // Apply changes from last index to first to preserve indexes. - val originalArrayFetchIndex = matches[5].index - val originalArrayFetchDestination = matches[5].getInstruction().registerA + val originalArrayFetchIndex = it.indices[5] + val originalArrayFetchDestination = getInstruction(it.indices[5]).registerA replaceInstruction( originalArrayFetchIndex, "sget-object v$originalArrayFetchDestination, $playbackSpeedsArrayType", ) - val arrayLengthConstDestination = matches[3].getInstruction().registerA - val newArrayIndex = matches[4].index + val arrayLengthConstDestination = getInstruction(it.indices[3]).registerA + val newArrayIndex = it.indices[4] addInstructions( newArrayIndex, """ @@ -113,7 +113,7 @@ internal val customPlaybackSpeedPatch = bytecodePatch( """, ) - val sizeCallIndex = matches[0].index + 1 + val sizeCallIndex = it.indices[0] + 1 val sizeCallResultRegister = getInstruction(sizeCallIndex).registerA replaceInstruction(sizeCallIndex, "const/4 v$sizeCallResultRegister, 0x0") } @@ -123,9 +123,9 @@ internal val customPlaybackSpeedPatch = bytecodePatch( // This is later used to call "showOldPlaybackSpeedMenu" on the instance. val instanceField = ImmutableField( - getOldPlaybackSpeedsMethod.originalClassDef.type, + getOldPlaybackSpeedsMethod.immutableClassDef.type, "INSTANCE", - getOldPlaybackSpeedsMethod.originalClassDef.type, + getOldPlaybackSpeedsMethod.immutableClassDef.type, AccessFlags.PUBLIC.value or AccessFlags.STATIC.value, null, null, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/Fingerprints.kt index 4066718d5..2bc3c472c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/Fingerprints.kt @@ -1,21 +1,15 @@ package app.revanced.patches.youtube.video.speed.custom -import app.revanced.patcher.accessFlags -import app.revanced.patcher.gettingFirstMethodDeclaratively -import app.revanced.patcher.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke -import app.revanced.patcher.opcodes -import app.revanced.patcher.parameterTypes +import app.revanced.patcher.* import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType import app.revanced.patches.shared.misc.mapping.ResourceType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal val BytecodePatchContext.getOldPlaybackSpeedsMethod by gettingFirstMethodDeclaratively { +internal val BytecodePatchContext.getOldPlaybackSpeedsMethod by gettingFirstMutableMethodDeclaratively( + "menu_item_playback_speed", +) { parameterTypes("[L", "I") - strings("menu_item_playback_speed") } internal val BytecodePatchContext.showOldPlaybackSpeedMenuMethod by gettingFirstMethodDeclaratively { @@ -25,10 +19,10 @@ internal val BytecodePatchContext.showOldPlaybackSpeedMenuMethod by gettingFirst } internal val BytecodePatchContext.showOldPlaybackSpeedMenuExtensionMethod by gettingFirstMethodDeclaratively { - custom { method, _ -> method.name == "showOldPlaybackSpeedMenu" } + name("showOldPlaybackSpeedMenu") } -internal val BytecodePatchContext.serverSideMaxSpeedFeatureFlagMethod by gettingFirstMethodDeclaratively { +internal val BytecodePatchContext.serverSideMaxSpeedFeatureFlagMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returnType("Z") instructions( @@ -36,17 +30,17 @@ internal val BytecodePatchContext.serverSideMaxSpeedFeatureFlagMethod by getting ) } -internal val BytecodePatchContext.speedArrayGeneratorMethod by gettingFirstMethodDeclaratively { +internal val speedArrayGeneratorMethodMatch = firstMethodComposite { accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) returnType("[L") parameterTypes("Lcom/google/android/libraries/youtube/innertube/model/player/PlayerResponseModel;") instructions( - methodCall(name = "size", returnType = "I"), - newInstance("Ljava/text/DecimalFormat;"), + method { name == "size" && returnType == "I" }, + allOf(Opcode.NEW_INSTANCE(), type("Ljava/text/DecimalFormat;")), "0.0#"(), 7L(), Opcode.NEW_ARRAY(), - fieldAccess(definingClass = "/PlayerConfigModel;", type = "[F"), + field { definingClass == "/PlayerConfigModel;" && type == "[F" }, ) } @@ -58,8 +52,8 @@ internal val BytecodePatchContext.speedLimiterMethod by gettingFirstMutableMetho returnType("V") parameterTypes("F", "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;") instructions( - 0.25f(), - 4.0f(), + 0.25f.toRawBits().toLong()(), + 4.0f.toRawBits().toLong()(), ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt index 18511432c..2f034656a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt @@ -92,7 +92,7 @@ val videoIdPatch = bytecodePatch( ) apply { - videoIdMethod.match(videoIdParentFingerprint.originalClassDef).let { + videoIdMethod.match(videoIdParentFingerprint.immutableClassDef).let { it.method.apply { videoIdMethod = this val index = it.instructionMatches.first().index