From 77bb761b0bb38613ad9d5017c881396afa471558 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 28 Jun 2023 17:43:45 +0400 Subject: [PATCH] fix(youtube): improve patching speed (#2514) --- .../app/revanced/extensions/Extensions.kt | 27 +++++++++++----- .../CheckCertificateFingerprint.kt | 7 ++--- .../WatchWhileActivityFingerprint.kt | 7 +++-- .../CanScrollVerticallyFingerprint.kt | 5 ++- .../misc/settings/patch/SettingsPatch.kt | 1 + .../fingerprints/GetPremiumViewFingerprint.kt | 5 +++ ...essibilityPlayerProgressTimeFingerprint.kt | 17 ++-------- .../SwipeControlsHostActivityFingerprint.kt | 7 +++-- .../StartVideoInformerFingerprint.kt | 3 -- .../SubtitleButtonControllerFingerprint.kt | 10 ++++-- .../fingerprints/SubtitleTrackFingerprint.kt | 5 ++- .../autoplay/patch/HideAutoplayButtonPatch.kt | 13 ++------ .../InitializeButtonsFingerprint.kt | 18 +++++------ ...layerControlsVisibilityModelFingerprint.kt | 2 +- .../fingerprints/AlbumCardsFingerprint.kt | 15 ++++----- .../fingerprints/BreakingNewsFingerprint.kt | 15 ++++----- .../CrowdfundingBoxFingerprint.kt | 15 ++++----- .../fingerprints/LayoutCircleFingerprint.kt | 13 +++----- .../fingerprints/LayoutIconFingerprint.kt | 13 +++----- .../fingerprints/LayoutVideoFingerprint.kt | 13 +++----- .../FilterBarHeightFingerprint.kt | 11 +++++-- .../fingerprints/LiteralOpcodesFingerprint.kt | 19 ------------ .../RelatedChipCloudFingerprint.kt | 11 +++++-- .../SearchResultsChipBarFingerprint.kt | 11 +++++-- ...ShowFloatingMicrophoneButtonFingerprint.kt | 16 +++++----- .../InfocardsIncognitoFingerprint.kt | 5 +-- .../InfocardsMethodCallFingerprint.kt | 12 +++---- .../HideLoadMoreButtonFingerprint.kt | 15 ++------- ...ntSwitcherAccessibilityLabelFingerprint.kt | 14 +++------ .../CreatePlayerOverviewFingerprint.kt | 15 ++------- .../bytecode/patch/HidePlayerOverlayPatch.kt | 9 ++---- .../CreateShortsButtonsFingerprint.kt | 20 +++++------- .../ReelConstructorFingerprint.kt | 18 ++++------- .../fingerprints/TimeCounterFingerprint.kt | 31 ++++++++++--------- .../hide/time/patch/HideTimestampPatch.kt | 7 +++-- .../FullscreenViewAdderParentFingerprint.kt | 4 +-- .../EngagementPanelControllerFingerprint.kt | 3 -- .../DislikesOldLayoutTextViewFingerprint.kt | 12 ++----- .../fingerprints/ShortsTextViewFingerprint.kt | 3 ++ .../SetWordmarkHeaderFingerprint.kt | 7 +++-- .../CreateDarkThemeSeekbarFingerprint.kt | 6 ++-- .../SetSeekbarClickedColorFingerprint.kt | 5 ++- .../patch/SeekbarColorBytecodePatch.kt | 6 ++-- .../fingerprints/AppendTimeFingerprint.kt | 2 +- ...niPlayerDimensionsCalculatorFingerprint.kt | 23 -------------- ...erDimensionsCalculatorParentFingerprint.kt | 23 ++++++++++++++ ...PlayerResponseModelSizeCheckFingerprint.kt | 2 +- .../patch/TabletMiniPlayerPatch.kt | 5 +-- .../fingerprints/LithoThemeFingerprint.kt | 10 ++++-- .../fingerprints/OnBackPressedFingerprint.kt | 4 +++ .../RecyclerViewScrollingFingerprint.kt | 5 +++ ...cyclerViewTopScrollingParentFingerprint.kt | 7 +++-- .../StandalonePlayerActivityFingerprint.kt | 5 +++ .../ComponentContextParserFingerprint.kt | 2 +- .../fingerprints/LithoFilterFingerprint.kt | 8 +++-- .../MinimizedPlaybackManagerFingerprint.kt | 3 -- .../MinimizedPlaybackSettingsFingerprint.kt | 8 ++--- ...imizedPlaybackSettingsParentFingerprint.kt | 14 +++++++++ .../patch/MinimizedPlaybackPatch.kt | 6 +++- .../patch/PlayerControlsBytecodePatch.kt | 15 ++------- .../BottomControlsInflateFingerprint.kt | 20 ++++++------ .../PlayerControlsVisibilityFingerprint.kt | 6 ++-- .../patch/BottomControlsResourcePatch.kt | 10 ++++-- .../LicenseActivityFingerprint.kt | 5 +++ .../fingerprints/SetThemeFingerprint.kt | 19 +++++------- .../OnPlaybackSpeedItemClickFingerprint.kt | 5 +++ .../QualityMenuViewInflateFingerprint.kt | 20 +++++------- .../SpeedArrayGeneratorFingerprint.kt | 9 +++--- .../videoid/fingerprint/VideoIdFingerprint.kt | 2 -- .../app/revanced/util/patch/BytecodeUtils.kt | 16 ---------- .../util/patch/LiteralValueFingerprint.kt | 23 ++++++++++++++ 71 files changed, 367 insertions(+), 381 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/LiteralOpcodesFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorParentFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsParentFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/util/patch/BytecodeUtils.kt create mode 100644 src/main/kotlin/app/revanced/util/patch/LiteralValueFingerprint.kt diff --git a/src/main/kotlin/app/revanced/extensions/Extensions.kt b/src/main/kotlin/app/revanced/extensions/Extensions.kt index df0f5205d..e90fbdcfe 100644 --- a/src/main/kotlin/app/revanced/extensions/Extensions.kt +++ b/src/main/kotlin/app/revanced/extensions/Extensions.kt @@ -57,17 +57,28 @@ internal fun MutableMethod.injectHideViewCall( "invoke-static { v$viewRegister }, $classDescriptor->$targetMethod(Landroid/view/View;)V" ) -internal fun MutableMethod.findIndexForIdResource(resourceName: String): Int { +internal fun Method.findIndexForIdResource(resourceName: String): Int { fun getIdResourceId(resourceName: String) = ResourceMappingPatch.resourceMappings.single { it.type == "id" && it.name == resourceName }.id - val resourceId = getIdResourceId(resourceName) - return implementation!!.instructions.indexOfFirst { - if (it.opcode != Opcode.CONST) return@indexOfFirst false + return indexOfFirstConstantInstructionValue(getIdResourceId(resourceName)) +} - val literal = (it as WideLiteralInstruction).wideLiteral +/** + * @return the first constant instruction with the value, or -1 if not found. + */ +fun Method.indexOfFirstConstantInstructionValue(constantValue: Long): Int { + return implementation?.let { + it.instructions.indexOfFirst { instruction -> + instruction.opcode == Opcode.CONST && (instruction as WideLiteralInstruction).wideLiteral == constantValue + } + } ?: -1 +} - return@indexOfFirst resourceId == literal - } -} \ No newline at end of file +/** + * @return if the method contains a constant with the given value. + */ +fun Method.containsConstantInstructionValue(constantValue: Long): Boolean { + return indexOfFirstConstantInstructionValue(constantValue) >= 0 +} diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CheckCertificateFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CheckCertificateFingerprint.kt index f0a261588..3c68e6a37 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CheckCertificateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CheckCertificateFingerprint.kt @@ -1,10 +1,9 @@ package app.revanced.patches.music.misc.androidauto.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.music.misc.androidauto.patch.BypassCertificateChecksPatch - object CheckCertificateFingerprint : MethodFingerprint( - "Z", - strings = listOf("No match") // Unique in combination with boolean return type + returnType = "Z", + parameters = listOf("Ljava/lang/String;"), + strings = listOf("X509", "Failed to get public key.", "Failed to get certificate.") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/WatchWhileActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/WatchWhileActivityFingerprint.kt index eefe790f0..9aec2409a 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/WatchWhileActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/WatchWhileActivityFingerprint.kt @@ -1,10 +1,13 @@ package app.revanced.patches.shared.fingerprints - +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags object WatchWhileActivityFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + parameters = listOf(), customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("WatchWhileActivity;") && methodDef.name == "" + methodDef.definingClass.endsWith("WatchWhileActivity;") } ) diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt index 3301d2b34..c58581081 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt @@ -1,11 +1,14 @@ package app.revanced.patches.shared.misc.fix.verticalscroll.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object CanScrollVerticallyFingerprint : MethodFingerprint( - "Z", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "Z", parameters = emptyList(), opcodes = listOf( Opcode.MOVE_RESULT, diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt index 8b60e9fd9..c4a134f8d 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt @@ -53,6 +53,7 @@ class SettingsPatch : BytecodePatch( } - 6 + // fixme: instead use Method.indexOfFirstConstantInstructionValue() val copyrightPolicyIndex = instructions.indexOfFirst { (it as? WideLiteralInstruction)?.wideLiteral == copyrightPolicyLabelId } + 2 diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/fingerprints/GetPremiumViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/fingerprints/GetPremiumViewFingerprint.kt index 18af00c43..0f32e3e6a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/fingerprints/GetPremiumViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/fingerprints/GetPremiumViewFingerprint.kt @@ -1,9 +1,14 @@ package app.revanced.patches.youtube.ad.getpremium.bytecode.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object GetPremiumViewFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL, + returnType = "V", + parameters = listOf("I", "I"), opcodes = listOf( Opcode.ADD_INT_2ADDR, Opcode.ADD_INT_2ADDR, diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AccessibilityPlayerProgressTimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AccessibilityPlayerProgressTimeFingerprint.kt index d6d0653af..8b2f5243f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AccessibilityPlayerProgressTimeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AccessibilityPlayerProgressTimeFingerprint.kt @@ -1,23 +1,12 @@ package app.revanced.patches.youtube.interaction.seekbar.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.interaction.seekbar.patch.EnableSeekbarTappingResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction - -object AccessibilityPlayerProgressTimeFingerprint : MethodFingerprint( +object AccessibilityPlayerProgressTimeFingerprint : LiteralValueFingerprint( returnType = "L", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - if (instruction.opcode != Opcode.CONST) return@any false - - val wideLiteral = (instruction as WideLiteralInstruction).wideLiteral - - EnableSeekbarTappingResourcePatch.accessibilityPlayerProgressTime == wideLiteral - } ?: false - } + literal = EnableSeekbarTappingResourcePatch.accessibilityPlayerProgressTime ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/SwipeControlsHostActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/SwipeControlsHostActivityFingerprint.kt index 368ba1fdd..ad6de5cc3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/SwipeControlsHostActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/SwipeControlsHostActivityFingerprint.kt @@ -1,10 +1,13 @@ package app.revanced.patches.youtube.interaction.swipecontrols.fingerprints - +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags object SwipeControlsHostActivityFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + parameters = listOf(), customFingerprint = { methodDef, _ -> - methodDef.definingClass == "Lapp/revanced/integrations/swipecontrols/SwipeControlsHostActivity;" && methodDef.name == "" + methodDef.definingClass == "Lapp/revanced/integrations/swipecontrols/SwipeControlsHostActivity;" } ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/StartVideoInformerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/StartVideoInformerFingerprint.kt index e65c2b74f..1b1cd1088 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/StartVideoInformerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/StartVideoInformerFingerprint.kt @@ -1,13 +1,10 @@ package app.revanced.patches.youtube.layout.autocaptions.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode - -@FuzzyPatternScanMethod(3) object StartVideoInformerFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L", "L", "L", "L"), listOf( Opcode.INVOKE_STATIC, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleButtonControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleButtonControllerFingerprint.kt index d42965f73..48d98f4f3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleButtonControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleButtonControllerFingerprint.kt @@ -6,7 +6,10 @@ import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object SubtitleButtonControllerFingerprint : MethodFingerprint( - "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), listOf( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("Lcom/google/android/libraries/youtube/player/subtitles/model/SubtitleTrack;"), + opcodes = listOf( Opcode.IGET_OBJECT, Opcode.IF_NEZ, Opcode.RETURN_VOID, @@ -16,5 +19,8 @@ object SubtitleButtonControllerFingerprint : MethodFingerprint( Opcode.CONST, Opcode.INVOKE_VIRTUAL, Opcode.IGET_OBJECT, - ) + ), + customFingerprint = { methodDef, _ -> + methodDef.definingClass.endsWith("SubtitleButtonController;") + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleTrackFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleTrackFingerprint.kt index a011e60c2..66ac4f617 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleTrackFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleTrackFingerprint.kt @@ -14,5 +14,8 @@ object SubtitleTrackFingerprint : MethodFingerprint( Opcode.MOVE_RESULT, Opcode.RETURN, ), - strings = listOf("DISABLE_CAPTIONS_OPTION") + strings = listOf("DISABLE_CAPTIONS_OPTION"), + customFingerprint = { methodDef, _ -> + methodDef.definingClass.endsWith("SubtitleTrack;") + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt index 788c3b3d6..007d97e5e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.youtube.layout.buttons.autoplay.patch +import app.revanced.extensions.findIndexForIdResource import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -23,7 +24,6 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import org.jf.dexlib2.iface.instruction.Instruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction import org.jf.dexlib2.iface.reference.MethodReference @Patch @@ -48,15 +48,8 @@ class HideAutoplayButtonPatch : BytecodePatch( LayoutConstructorFingerprint.result?.mutableMethod?.apply { val layoutGenMethodInstructions = implementation!!.instructions - // resolve the offsets such as ... - val autoNavPreviewStubId = ResourceMappingPatch.resourceMappings.single { - it.name == "autonav_preview_stub" - }.id - - // where to insert the branch instructions and ... - val insertIndex = layoutGenMethodInstructions.indexOfFirst { - (it as? WideLiteralInstruction)?.wideLiteral == autoNavPreviewStubId - } + // resolve the offsets of where to insert the branch instructions and ... + val insertIndex = findIndexForIdResource("autonav_preview_stub") // where to branch away val branchIndex = diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/fingerprints/InitializeButtonsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/fingerprints/InitializeButtonsFingerprint.kt index 33d384042..1b2241153 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/fingerprints/InitializeButtonsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/fingerprints/InitializeButtonsFingerprint.kt @@ -1,15 +1,13 @@ package app.revanced.patches.youtube.layout.buttons.navigation.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.extensions.or import app.revanced.patches.youtube.layout.buttons.navigation.patch.ResolvePivotBarFingerprintsPatch -import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction +import app.revanced.util.patch.LiteralValueFingerprint +import org.jf.dexlib2.AccessFlags -object InitializeButtonsFingerprint : MethodFingerprint( - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { - it.opcode == Opcode.CONST && (it as WideLiteralInstruction).wideLiteral == - ResolvePivotBarFingerprintsPatch.imageOnlyTabResourceId - } == true - } +object InitializeButtonsFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "V", + parameters = listOf(), + literal = ResolvePivotBarFingerprintsPatch.imageOnlyTabResourceId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/fingerprints/PlayerControlsVisibilityModelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/fingerprints/PlayerControlsVisibilityModelFingerprint.kt index 37f90e60c..bf9d48e44 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/fingerprints/PlayerControlsVisibilityModelFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/fingerprints/PlayerControlsVisibilityModelFingerprint.kt @@ -5,5 +5,5 @@ import org.jf.dexlib2.Opcode object PlayerControlsVisibilityModelFingerprint : MethodFingerprint( opcodes = listOf(Opcode.INVOKE_DIRECT_RANGE), - strings = listOf("hasNext", "hasPrevious", "Missing required properties:") + strings = listOf("Missing required properties:", "hasNext", "hasPrevious") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/fingerprints/AlbumCardsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/fingerprints/AlbumCardsFingerprint.kt index 9382220c2..6d8cad5c3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/fingerprints/AlbumCardsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/fingerprints/AlbumCardsFingerprint.kt @@ -1,11 +1,13 @@ package app.revanced.patches.youtube.layout.hide.albumcards.bytecode.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.extensions.or import app.revanced.patches.youtube.layout.hide.albumcards.resource.patch.AlbumCardsResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object AlbumCardsFingerprint : MethodFingerprint( +object AlbumCardsFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, opcodes = listOf( Opcode.MOVE_RESULT_OBJECT, Opcode.CONST, @@ -14,10 +16,5 @@ object AlbumCardsFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST, ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == AlbumCardsResourcePatch.albumCardId - } == true - } + literal = AlbumCardsResourcePatch.albumCardId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/fingerprints/BreakingNewsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/fingerprints/BreakingNewsFingerprint.kt index eb54fbdb6..16ae7019d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/fingerprints/BreakingNewsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/fingerprints/BreakingNewsFingerprint.kt @@ -1,11 +1,13 @@ package app.revanced.patches.youtube.layout.hide.breakingnews.bytecode.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.extensions.or import app.revanced.patches.youtube.layout.hide.breakingnews.resource.patch.BreakingNewsResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object BreakingNewsFingerprint : MethodFingerprint( +object BreakingNewsFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, opcodes = listOf( Opcode.CONST, Opcode.CONST_4, @@ -14,10 +16,5 @@ object BreakingNewsFingerprint : MethodFingerprint( Opcode.CHECK_CAST, Opcode.IPUT_OBJECT, ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == BreakingNewsResourcePatch.horizontalCardListId - } == true - } + literal = BreakingNewsResourcePatch.horizontalCardListId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/fingerprints/CrowdfundingBoxFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/fingerprints/CrowdfundingBoxFingerprint.kt index 1ed367227..30dc121c3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/fingerprints/CrowdfundingBoxFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/fingerprints/CrowdfundingBoxFingerprint.kt @@ -1,20 +1,17 @@ package app.revanced.patches.youtube.layout.hide.crowdfundingbox.bytecode.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.extensions.or import app.revanced.patches.youtube.layout.hide.crowdfundingbox.resource.patch.CrowdfundingBoxResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object CrowdfundingBoxFingerprint : MethodFingerprint( +object CrowdfundingBoxFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, opcodes = listOf( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT, Opcode.IPUT_OBJECT, ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == CrowdfundingBoxResourcePatch.crowdfundingBoxId - } == true - } + literal = CrowdfundingBoxResourcePatch.crowdfundingBoxId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutCircleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutCircleFingerprint.kt index 55521394a..5469dc111 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutCircleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutCircleFingerprint.kt @@ -1,11 +1,11 @@ package app.revanced.patches.youtube.layout.hide.endscreencards.bytecode.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.hide.endscreencards.resource.patch.HideEndscreenCardsResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object LayoutCircleFingerprint : MethodFingerprint( +object LayoutCircleFingerprint : LiteralValueFingerprint( + returnType = "Landroid/view/View;", opcodes = listOf( Opcode.CONST, Opcode.CONST_4, @@ -13,10 +13,5 @@ object LayoutCircleFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST, ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == HideEndscreenCardsResourcePatch.layoutCircle - } == true - } + literal = HideEndscreenCardsResourcePatch.layoutCircle ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutIconFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutIconFingerprint.kt index 603bebdd3..90350f4c0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutIconFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutIconFingerprint.kt @@ -1,11 +1,11 @@ package app.revanced.patches.youtube.layout.hide.endscreencards.bytecode.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.hide.endscreencards.resource.patch.HideEndscreenCardsResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object LayoutIconFingerprint : MethodFingerprint( +object LayoutIconFingerprint : LiteralValueFingerprint( + returnType = "Landroid/view/View;", opcodes = listOf( Opcode.CONST_4, Opcode.CONST, @@ -13,10 +13,5 @@ object LayoutIconFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST, ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == HideEndscreenCardsResourcePatch.layoutIcon - } == true - } + literal = HideEndscreenCardsResourcePatch.layoutIcon ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutVideoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutVideoFingerprint.kt index 01307ad6c..22c9b07b9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutVideoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/fingerprints/LayoutVideoFingerprint.kt @@ -1,11 +1,11 @@ package app.revanced.patches.youtube.layout.hide.endscreencards.bytecode.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.hide.endscreencards.resource.patch.HideEndscreenCardsResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object LayoutVideoFingerprint : MethodFingerprint( +object LayoutVideoFingerprint : LiteralValueFingerprint( + returnType = "Landroid/view/View;", opcodes = listOf( Opcode.CONST, Opcode.CONST_4, @@ -13,10 +13,5 @@ object LayoutVideoFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST, ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == HideEndscreenCardsResourcePatch.layoutVideo - } == true - } + literal = HideEndscreenCardsResourcePatch.layoutVideo ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/FilterBarHeightFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/FilterBarHeightFingerprint.kt index 6178c4c89..7307754d0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/FilterBarHeightFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/FilterBarHeightFingerprint.kt @@ -1,14 +1,19 @@ package app.revanced.patches.youtube.layout.hide.filterbar.fingerprints -import app.revanced.patches.youtube.layout.hide.filterbar.patch.HideFilterBarResourcePatch.Companion.filterBarHeightId +import app.revanced.patcher.extensions.or +import app.revanced.patches.youtube.layout.hide.filterbar.patch.HideFilterBarResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -object FilterBarHeightFingerprint : LiteralOpcodesFingerprint( +object FilterBarHeightFingerprint : LiteralValueFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, opcodes = listOf( Opcode.CONST, Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT, Opcode.IPUT ), - filterBarHeightId + literal = HideFilterBarResourcePatch.filterBarHeightId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/LiteralOpcodesFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/LiteralOpcodesFingerprint.kt deleted file mode 100644 index 3189e17ec..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/LiteralOpcodesFingerprint.kt +++ /dev/null @@ -1,19 +0,0 @@ -package app.revanced.patches.youtube.layout.hide.filterbar.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction - - -abstract class LiteralOpcodesFingerprint(opcodes: List, literal: Long) : MethodFingerprint( - opcodes = opcodes, - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - if (instruction.opcode != Opcode.CONST) return@any false - - val wideLiteral = (instruction as WideLiteralInstruction).wideLiteral - - literal == wideLiteral - } ?: false - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/RelatedChipCloudFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/RelatedChipCloudFingerprint.kt index be0ef5cee..a5d47dbd3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/RelatedChipCloudFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/RelatedChipCloudFingerprint.kt @@ -1,13 +1,18 @@ package app.revanced.patches.youtube.layout.hide.filterbar.fingerprints -import app.revanced.patches.youtube.layout.hide.filterbar.patch.HideFilterBarResourcePatch.Companion.relatedChipCloudMarginId +import app.revanced.patcher.extensions.or +import app.revanced.patches.youtube.layout.hide.filterbar.patch.HideFilterBarResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -object RelatedChipCloudFingerprint : LiteralOpcodesFingerprint( +object RelatedChipCloudFingerprint : LiteralValueFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, opcodes = listOf( Opcode.CONST, Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT ), - relatedChipCloudMarginId + literal = HideFilterBarResourcePatch.relatedChipCloudMarginId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/SearchResultsChipBarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/SearchResultsChipBarFingerprint.kt index 82deee685..9dc8f9359 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/SearchResultsChipBarFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/fingerprints/SearchResultsChipBarFingerprint.kt @@ -1,9 +1,14 @@ package app.revanced.patches.youtube.layout.hide.filterbar.fingerprints -import app.revanced.patches.youtube.layout.hide.filterbar.patch.HideFilterBarResourcePatch.Companion.barContainerHeightId +import app.revanced.patcher.extensions.or +import app.revanced.patches.youtube.layout.hide.filterbar.patch.HideFilterBarResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -object SearchResultsChipBarFingerprint : LiteralOpcodesFingerprint( +object SearchResultsChipBarFingerprint : LiteralValueFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, opcodes = listOf( Opcode.CONST, Opcode.INVOKE_VIRTUAL, @@ -11,5 +16,5 @@ object SearchResultsChipBarFingerprint : LiteralOpcodesFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT ), - barContainerHeightId + literal = HideFilterBarResourcePatch.barContainerHeightId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/fingerprints/ShowFloatingMicrophoneButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/fingerprints/ShowFloatingMicrophoneButtonFingerprint.kt index 276cfbe4b..b471d6473 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/fingerprints/ShowFloatingMicrophoneButtonFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/fingerprints/ShowFloatingMicrophoneButtonFingerprint.kt @@ -1,19 +1,19 @@ package app.revanced.patches.youtube.layout.hide.floatingmicrophone.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.extensions.or +import app.revanced.util.patch.LiteralValueFingerprint import app.revanced.patches.youtube.layout.hide.floatingmicrophone.patch.HideFloatingMicrophoneButtonResourcePatch +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object ShowFloatingMicrophoneButtonFingerprint : MethodFingerprint( +object ShowFloatingMicrophoneButtonFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "V", + parameters = listOf(), opcodes = listOf( Opcode.IGET_BOOLEAN, Opcode.IF_EQZ, Opcode.RETURN_VOID ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { - (it as? WideLiteralInstruction)?.wideLiteral == HideFloatingMicrophoneButtonResourcePatch.fabButtonId - } == true - } + literal = HideFloatingMicrophoneButtonResourcePatch.fabButtonId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/fingerprints/InfocardsIncognitoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/fingerprints/InfocardsIncognitoFingerprint.kt index 1c5d3d54c..d59f8bff2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/fingerprints/InfocardsIncognitoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/fingerprints/InfocardsIncognitoFingerprint.kt @@ -5,7 +5,8 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags object InfocardsIncognitoFingerprint : MethodFingerprint( - "Ljava/lang/Boolean;", - AccessFlags.PUBLIC or AccessFlags.FINAL, + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "Ljava/lang/Boolean;", + parameters = listOf("L", "J"), strings = listOf("vibrator") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/fingerprints/InfocardsMethodCallFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/fingerprints/InfocardsMethodCallFingerprint.kt index 08f9ed020..48bef700a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/fingerprints/InfocardsMethodCallFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/fingerprints/InfocardsMethodCallFingerprint.kt @@ -1,19 +1,15 @@ package app.revanced.patches.youtube.layout.hide.infocards.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.util.patch.LiteralValueFingerprint import app.revanced.patches.youtube.layout.hide.infocards.resource.patch.HideInfocardsResourcePatch import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object InfocardsMethodCallFingerprint : MethodFingerprint( +object InfocardsMethodCallFingerprint : LiteralValueFingerprint( opcodes = listOf( Opcode.INVOKE_VIRTUAL, Opcode.IGET_OBJECT, Opcode.INVOKE_INTERFACE, ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - (instruction as? WideLiteralInstruction)?.wideLiteral == HideInfocardsResourcePatch.drawerResourceId - } == true - } + strings = listOf("Missing ControlsOverlayPresenter for InfoCards to work."), + literal = HideInfocardsResourcePatch.drawerResourceId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/fingerprints/HideLoadMoreButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/fingerprints/HideLoadMoreButtonFingerprint.kt index 2669411e2..8a01d2224 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/fingerprints/HideLoadMoreButtonFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/fingerprints/HideLoadMoreButtonFingerprint.kt @@ -1,13 +1,12 @@ package app.revanced.patches.youtube.layout.hide.loadmorebutton.bytecode.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.util.patch.LiteralValueFingerprint import app.revanced.patches.youtube.layout.hide.loadmorebutton.resource.patch.HideLoadMoreButtonResourcePatch import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object HideLoadMoreButtonFingerprint : MethodFingerprint( +object HideLoadMoreButtonFingerprint : LiteralValueFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, parameters = listOf("L", "L", "L", "L"), @@ -17,13 +16,5 @@ object HideLoadMoreButtonFingerprint : MethodFingerprint( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { - if (it.opcode != Opcode.CONST) return@any false - - val literal = (it as WideLiteralInstruction).wideLiteral - - literal == HideLoadMoreButtonResourcePatch.expandButtonDownId - } ?: false - } + literal = HideLoadMoreButtonResourcePatch.expandButtonDownId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt index 4597c4da4..372c21c5e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt @@ -1,11 +1,12 @@ package app.revanced.patches.youtube.layout.hide.personalinformation.bytecode.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.util.patch.LiteralValueFingerprint import app.revanced.patches.youtube.layout.hide.personalinformation.resource.patch.HideEmailAddressResourcePatch import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object AccountSwitcherAccessibilityLabelFingerprint : MethodFingerprint( +object AccountSwitcherAccessibilityLabelFingerprint : LiteralValueFingerprint( + returnType = "V", + parameters = listOf("L", "Ljava/lang/Object;"), opcodes = listOf( Opcode.INVOKE_VIRTUAL, Opcode.IGET_OBJECT, @@ -15,10 +16,5 @@ object AccountSwitcherAccessibilityLabelFingerprint : MethodFingerprint( Opcode.APUT_OBJECT, Opcode.CONST, ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == HideEmailAddressResourcePatch.accountSwitcherAccessibilityLabelId - } == true - } + literal = HideEmailAddressResourcePatch.accountSwitcherAccessibilityLabelId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/fingerprints/CreatePlayerOverviewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/fingerprints/CreatePlayerOverviewFingerprint.kt index f235b62ec..c22588a28 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/fingerprints/CreatePlayerOverviewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/fingerprints/CreatePlayerOverviewFingerprint.kt @@ -1,13 +1,12 @@ package app.revanced.patches.youtube.layout.hide.player.overlay.bytecode.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.util.patch.LiteralValueFingerprint import app.revanced.patches.youtube.layout.hide.player.overlay.resource.patch.HidePlayerOverlayResourcePatch import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object CreatePlayerOverviewFingerprint : MethodFingerprint( +object CreatePlayerOverviewFingerprint : LiteralValueFingerprint( returnType = "V", accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, opcodes = listOf( @@ -16,13 +15,5 @@ object CreatePlayerOverviewFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { - if (it.opcode != Opcode.CONST) return@any false - - val literal = (it as WideLiteralInstruction).wideLiteral - - literal == HidePlayerOverlayResourcePatch.scrimOverlayId - } ?: false - } + literal = HidePlayerOverlayResourcePatch.scrimOverlayId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt index a0170c0eb..ab2310342 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.youtube.layout.hide.player.overlay.bytecode.patch +import app.revanced.extensions.indexOfFirstConstantInstructionValue import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -16,7 +17,6 @@ import app.revanced.patches.youtube.layout.hide.player.overlay.annotations.HideP import app.revanced.patches.youtube.layout.hide.player.overlay.bytecode.fingerprints.CreatePlayerOverviewFingerprint import app.revanced.patches.youtube.layout.hide.player.overlay.resource.patch.HidePlayerOverlayResourcePatch import org.jf.dexlib2.iface.instruction.OneRegisterInstruction -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction @Patch @Name("hide-player-overlay") @@ -28,11 +28,8 @@ class HidePlayerOverlayPatch : BytecodePatch(listOf(CreatePlayerOverviewFingerpr override fun execute(context: BytecodeContext): PatchResult { CreatePlayerOverviewFingerprint.result?.let { result -> result.mutableMethod.apply { - val viewRegisterIndex = implementation!!.instructions.indexOfFirst { - val literal = (it as? WideLiteralInstruction)?.wideLiteral - - literal == HidePlayerOverlayResourcePatch.scrimOverlayId - } + 3 + val viewRegisterIndex = + indexOfFirstConstantInstructionValue(HidePlayerOverlayResourcePatch.scrimOverlayId) + 3 val viewRegister = getInstruction(viewRegisterIndex).registerA val insertIndex = viewRegisterIndex + 1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/fingerprints/CreateShortsButtonsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/fingerprints/CreateShortsButtonsFingerprint.kt index 2f99a2f0b..282737f7d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/fingerprints/CreateShortsButtonsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/fingerprints/CreateShortsButtonsFingerprint.kt @@ -1,19 +1,13 @@ package app.revanced.patches.youtube.layout.hide.shorts.bytecode.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.extensions.or +import app.revanced.util.patch.LiteralValueFingerprint import app.revanced.patches.youtube.layout.hide.shorts.resource.patch.HideShortsComponentsResourcePatch -import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction +import org.jf.dexlib2.AccessFlags -object CreateShortsButtonsFingerprint : MethodFingerprint( +object CreateShortsButtonsFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, + returnType = "V", parameters = listOf("Z", "Z", "L"), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { - if (it.opcode != Opcode.CONST) return@any false - - val literal = (it as WideLiteralInstruction).wideLiteral - - literal == HideShortsComponentsResourcePatch.reelPlayerRightLargeIconSize - } ?: false - } + literal = HideShortsComponentsResourcePatch.reelPlayerRightLargeIconSize ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/fingerprints/ReelConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/fingerprints/ReelConstructorFingerprint.kt index 2d6836b2f..467fa3c19 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/fingerprints/ReelConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/fingerprints/ReelConstructorFingerprint.kt @@ -1,19 +1,13 @@ package app.revanced.patches.youtube.layout.hide.shorts.bytecode.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.extensions.or +import app.revanced.util.patch.LiteralValueFingerprint import app.revanced.patches.youtube.layout.hide.shorts.resource.patch.HideShortsComponentsResourcePatch +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object ReelConstructorFingerprint : MethodFingerprint( +object ReelConstructorFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, opcodes = listOf(Opcode.INVOKE_VIRTUAL), - customFingerprint = { method, _ -> - method.implementation?.instructions?.any { - if (it.opcode != Opcode.CONST) return@any false - - val literal = (it as WideLiteralInstruction).wideLiteral - - literal == HideShortsComponentsResourcePatch.reelMultipleItemShelfId - } ?: false - } + literal = HideShortsComponentsResourcePatch.reelMultipleItemShelfId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/fingerprints/TimeCounterFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/fingerprints/TimeCounterFingerprint.kt index d230e5420..2f43eb0aa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/fingerprints/TimeCounterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/fingerprints/TimeCounterFingerprint.kt @@ -1,25 +1,28 @@ package app.revanced.patches.youtube.layout.hide.time.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode - -@FuzzyPatternScanMethod(3) object TimeCounterFingerprint : MethodFingerprint( - "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), listOf( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf(), + returnType = "V", + opcodes = listOf( + Opcode.SUB_LONG_2ADDR, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, Opcode.IGET_OBJECT, Opcode.IGET_WIDE, - Opcode.CONST_WIDE_16, - Opcode.CMP_LONG, - Opcode.IF_LEZ, - Opcode.IGET_OBJECT, - Opcode.IF_EQZ, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT, - Opcode.IF_EQZ, - Opcode.GOTO, - ) + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.INVOKE_INTERFACE, + Opcode.RETURN_VOID, + ), + customFingerprint = { _, classDef -> + // On older devices this fingerprint resolves very slowly. + // Speed this up by checking for the number of methods. + classDef.methods.count() == 14 + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt index bb7270d55..8206e9363 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.youtube.layout.hide.time.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -38,7 +39,8 @@ class HideTimestampPatch : BytecodePatch( ) ) - TimeCounterFingerprint.result!!.mutableMethod.addInstructionsWithLabels( + TimeCounterFingerprint.result?.apply { + mutableMethod.addInstructionsWithLabels( 0, """ invoke-static { }, Lapp/revanced/integrations/patches/HideTimestampPatch;->hideTimestamp()Z @@ -48,7 +50,8 @@ class HideTimestampPatch : BytecodePatch( :hide_time nop """ - ) + ) + } ?: return TimeCounterFingerprint.toErrorResult() return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/fingerprints/FullscreenViewAdderParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/fingerprints/FullscreenViewAdderParentFingerprint.kt index 601e62b83..9a1bb4219 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/fingerprints/FullscreenViewAdderParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/fingerprints/FullscreenViewAdderParentFingerprint.kt @@ -1,11 +1,11 @@ package app.revanced.patches.youtube.layout.panels.fullscreen.remove.fingerprints - import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode object FullscreenViewAdderParentFingerprint : MethodFingerprint( - parameters = listOf("L", "L"), + returnType = "V", + parameters = listOf("Landroid/content/Context;", "Landroid/view/View;"), opcodes = listOf( Opcode.GOTO, Opcode.IGET_BOOLEAN, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/fingerprints/EngagementPanelControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/fingerprints/EngagementPanelControllerFingerprint.kt index a45ae6093..a2c94e6f4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/fingerprints/EngagementPanelControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/fingerprints/EngagementPanelControllerFingerprint.kt @@ -1,12 +1,9 @@ package app.revanced.patches.youtube.layout.panels.popup.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags - -@FuzzyPatternScanMethod(3) object EngagementPanelControllerFingerprint : MethodFingerprint( returnType = "L", accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/DislikesOldLayoutTextViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/DislikesOldLayoutTextViewFingerprint.kt index 7fe768162..3ac14b345 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/DislikesOldLayoutTextViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/DislikesOldLayoutTextViewFingerprint.kt @@ -1,13 +1,12 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.util.patch.LiteralValueFingerprint import app.revanced.patches.youtube.layout.returnyoutubedislike.resource.patch.ReturnYouTubeDislikeResourcePatch import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object DislikesOldLayoutTextViewFingerprint : MethodFingerprint( +object DislikesOldLayoutTextViewFingerprint : LiteralValueFingerprint( returnType = "V", parameters = listOf("L"), accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, @@ -19,10 +18,5 @@ object DislikesOldLayoutTextViewFingerprint : MethodFingerprint( Opcode.IF_NEZ, // textview register Opcode.GOTO, ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == ReturnYouTubeDislikeResourcePatch.oldUIDislikeId - } == true - } + literal = ReturnYouTubeDislikeResourcePatch.oldUIDislikeId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/ShortsTextViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/ShortsTextViewFingerprint.kt index 9d5c2ec2a..1c78732d5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/ShortsTextViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/ShortsTextViewFingerprint.kt @@ -1,9 +1,12 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object ShortsTextViewFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL, returnType = "V", parameters = listOf("L", "L"), opcodes = listOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/fingerprints/SetWordmarkHeaderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/fingerprints/SetWordmarkHeaderFingerprint.kt index f0a823398..836b1aa86 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/fingerprints/SetWordmarkHeaderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/fingerprints/SetWordmarkHeaderFingerprint.kt @@ -6,7 +6,9 @@ import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object SetWordmarkHeaderFingerprint : MethodFingerprint( - "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "V", + parameters = listOf("Landroid/widget/ImageView;"), opcodes = listOf( Opcode.IGET_OBJECT, Opcode.INVOKE_STATIC, @@ -17,6 +19,5 @@ object SetWordmarkHeaderFingerprint : MethodFingerprint( Opcode.IGET_OBJECT, Opcode.CONST, Opcode.INVOKE_STATIC, - ), - customFingerprint = { methodDef, _ -> methodDef.parameterTypes.first() == "Landroid/widget/ImageView;" } + ) ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/fingerprints/CreateDarkThemeSeekbarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/fingerprints/CreateDarkThemeSeekbarFingerprint.kt index 89aec9b6f..9c8b32ffe 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/fingerprints/CreateDarkThemeSeekbarFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/fingerprints/CreateDarkThemeSeekbarFingerprint.kt @@ -1,15 +1,15 @@ package app.revanced.patches.youtube.layout.seekbar.bytecode.fingerprints +import app.revanced.extensions.containsConstantInstructionValue import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.seekbar.resource.SeekbarColorResourcePatch -import app.revanced.util.patch.indexOfFirstConstantInstruction import org.jf.dexlib2.AccessFlags object CreateDarkThemeSeekbarFingerprint : MethodFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, customFingerprint = { method, _ -> - method.indexOfFirstConstantInstruction(SeekbarColorResourcePatch.inlineTimeBarColorizedBarPlayedColorDarkId) != -1 - && method.indexOfFirstConstantInstruction(SeekbarColorResourcePatch.inlineTimeBarPlayedNotHighlightedColorId) != -1 + method.containsConstantInstructionValue(SeekbarColorResourcePatch.inlineTimeBarColorizedBarPlayedColorDarkId) + && method.containsConstantInstructionValue(SeekbarColorResourcePatch.inlineTimeBarPlayedNotHighlightedColorId) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/fingerprints/SetSeekbarClickedColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/fingerprints/SetSeekbarClickedColorFingerprint.kt index abae290d7..1ebccca75 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/fingerprints/SetSeekbarClickedColorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/fingerprints/SetSeekbarClickedColorFingerprint.kt @@ -5,5 +5,8 @@ import org.jf.dexlib2.Opcode object SetSeekbarClickedColorFingerprint : MethodFingerprint( opcodes = listOf(Opcode.CONST_HIGH16), - strings = listOf("YOUTUBE", "PREROLL", "POSTROLL") + strings = listOf("YOUTUBE", "PREROLL", "POSTROLL"), + customFingerprint = { methodDef, _ -> + methodDef.definingClass.endsWith("ControlsOverlayStyle;") + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt index e57079a14..ad5773576 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.youtube.layout.seekbar.bytecode.patch +import app.revanced.extensions.indexOfFirstConstantInstructionValue import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version @@ -19,7 +20,6 @@ import app.revanced.patches.youtube.layout.seekbar.resource.SeekbarColorResource import app.revanced.patches.youtube.layout.theme.bytecode.patch.LithoColorHookPatch import app.revanced.patches.youtube.layout.theme.bytecode.patch.LithoColorHookPatch.Companion.lithoColorOverrideHook import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch -import app.revanced.util.patch.indexOfFirstConstantInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction @@ -32,7 +32,7 @@ class SeekbarColorBytecodePatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { CreateDarkThemeSeekbarFingerprint.result?.mutableMethod?.apply { - var registerIndex = indexOfFirstConstantInstruction(SeekbarColorResourcePatch.inlineTimeBarColorizedBarPlayedColorDarkId) + 2 + var registerIndex = indexOfFirstConstantInstructionValue(SeekbarColorResourcePatch.inlineTimeBarColorizedBarPlayedColorDarkId) + 2 var colorRegister = (getInstruction(registerIndex) as OneRegisterInstruction).registerA addInstructions( registerIndex + 1, @@ -42,7 +42,7 @@ class SeekbarColorBytecodePatch : BytecodePatch( """ ) - registerIndex = indexOfFirstConstantInstruction(SeekbarColorResourcePatch.inlineTimeBarPlayedNotHighlightedColorId) + 2 + registerIndex = indexOfFirstConstantInstructionValue(SeekbarColorResourcePatch.inlineTimeBarPlayedNotHighlightedColorId) + 2 colorRegister = (getInstruction(registerIndex) as OneRegisterInstruction).registerA addInstructions( registerIndex + 1, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/AppendTimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/AppendTimeFingerprint.kt index 2c6d4720c..950c74602 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/AppendTimeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/AppendTimeFingerprint.kt @@ -8,7 +8,7 @@ import org.jf.dexlib2.Opcode object AppendTimeFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.FINAL, - listOf("L", "L", "L"), + listOf("Ljava/lang/CharSequence;", "Ljava/lang/CharSequence;", "Ljava/lang/CharSequence;"), listOf( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt deleted file mode 100644 index 247655248..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt +++ /dev/null @@ -1,23 +0,0 @@ -package app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.Opcode - - -@FuzzyPatternScanMethod(2) -object MiniPlayerDimensionsCalculatorFingerprint : MethodFingerprint( - "V", - AccessFlags.PUBLIC or AccessFlags.FINAL, - listOf("L"), - listOf( - Opcode.INVOKE_DIRECT, - Opcode.MOVE_RESULT, - Opcode.IF_NEZ, - Opcode.FLOAT_TO_DOUBLE, - Opcode.CONST_WIDE_HIGH16, - Opcode.CMPL_DOUBLE, - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorParentFingerprint.kt new file mode 100644 index 000000000..735c55462 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorParentFingerprint.kt @@ -0,0 +1,23 @@ +package app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +object MiniPlayerDimensionsCalculatorParentFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "V", + parameters = listOf("F"), + opcodes = listOf( + Opcode.CONST_HIGH16, + Opcode.ADD_FLOAT_2ADDR, + Opcode.MUL_FLOAT, + Opcode.CONST_4, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT, + Opcode.FLOAT_TO_INT, + Opcode.INVOKE_INTERFACE, + Opcode.RETURN_VOID, + ) +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt index e4777c4c1..45cede93b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt @@ -8,7 +8,7 @@ import org.jf.dexlib2.Opcode object MiniPlayerResponseModelSizeCheckFingerprint : MethodFingerprint( "L", AccessFlags.PUBLIC or AccessFlags.FINAL, - listOf("L", "L"), + listOf("Ljava/lang/Object;", "Ljava/lang/Object;"), listOf( Opcode.RETURN_OBJECT, Opcode.CHECK_CAST, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt index 0fdc1bccb..70c06eeb9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt @@ -32,7 +32,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Version("0.0.1") class TabletMiniPlayerPatch : BytecodePatch( listOf( - MiniPlayerDimensionsCalculatorFingerprint, + MiniPlayerDimensionsCalculatorParentFingerprint, MiniPlayerResponseModelSizeCheckFingerprint, MiniPlayerOverrideParentFingerprint ) @@ -48,7 +48,8 @@ class TabletMiniPlayerPatch : BytecodePatch( ) // First resolve the fingerprints via the parent fingerprint. - val miniPlayerClass = MiniPlayerDimensionsCalculatorFingerprint.result!!.classDef + MiniPlayerDimensionsCalculatorParentFingerprint.result ?: return MiniPlayerDimensionsCalculatorParentFingerprint.toErrorResult() + val miniPlayerClass = MiniPlayerDimensionsCalculatorParentFingerprint.result!!.classDef /* * No context parameter method. diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/fingerprints/LithoThemeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/fingerprints/LithoThemeFingerprint.kt index ffb29604f..70d9f9ea6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/fingerprints/LithoThemeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/fingerprints/LithoThemeFingerprint.kt @@ -6,7 +6,10 @@ import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object LithoThemeFingerprint : MethodFingerprint( - "V", AccessFlags.PROTECTED or AccessFlags.FINAL, listOf("L"), listOf( + returnType = "V", + accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL, + parameters = listOf("Landroid/graphics/Rect;"), + opcodes = listOf( Opcode.APUT, Opcode.NEW_INSTANCE, Opcode.INVOKE_DIRECT, @@ -22,5 +25,8 @@ object LithoThemeFingerprint : MethodFingerprint( Opcode.IGET_OBJECT, Opcode.INVOKE_VIRTUAL, Opcode.RETURN_VOID - ) + ), + customFingerprint = { methodDef, _ -> + methodDef.name == "onBoundsChange" + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/OnBackPressedFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/OnBackPressedFingerprint.kt index 06f039393..52fee3beb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/OnBackPressedFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/OnBackPressedFingerprint.kt @@ -1,9 +1,13 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object OnBackPressedFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "V", opcodes = listOf( Opcode.RETURN_VOID ), diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/RecyclerViewScrollingFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/RecyclerViewScrollingFingerprint.kt index 7307d9abc..73c5faeeb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/RecyclerViewScrollingFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/RecyclerViewScrollingFingerprint.kt @@ -1,9 +1,14 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object RecyclerViewScrollingFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, + returnType = "V", + parameters = listOf(), opcodes = listOf( Opcode.IGET_OBJECT, Opcode.IGET_OBJECT, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/RecyclerViewTopScrollingParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/RecyclerViewTopScrollingParentFingerprint.kt index 0d4425b90..b891aa4ae 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/RecyclerViewTopScrollingParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/fingerprints/RecyclerViewTopScrollingParentFingerprint.kt @@ -1,9 +1,13 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object RecyclerViewTopScrollingParentFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + parameters = listOf("L", "L", "Landroid/view/ViewGroup;", "Landroid/view/ViewGroup;"), opcodes = listOf( Opcode.INVOKE_DIRECT, Opcode.IPUT_OBJECT, @@ -14,7 +18,4 @@ object RecyclerViewTopScrollingParentFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.NEW_INSTANCE ), - customFingerprint = { methodDef, _ -> - methodDef.name == "" - } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt index 799b80ee5..9d2eb4c07 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt @@ -1,6 +1,8 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint +import org.jf.dexlib2.AccessFlags /** * Old API activity to embed YouTube into 3rd party Android apps. @@ -10,6 +12,9 @@ import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch. * https://developers.google.com/youtube/android/player */ object StandalonePlayerActivityFingerprint : IntegrationsFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "V", + parameters = listOf("L"), customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lcom/google/android/youtube/api/StandalonePlayerActivity;" && methodDef.name == "onCreate" diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ComponentContextParserFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ComponentContextParserFingerprint.kt index 498f7ca25..b0fad80b9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ComponentContextParserFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ComponentContextParserFingerprint.kt @@ -9,5 +9,5 @@ object ComponentContextParserFingerprint : MethodFingerprint( Opcode.IPUT_OBJECT, Opcode.NEW_INSTANCE ), - strings = listOf("Component was not found %s because it was removed due to duplicate converter bindings") + strings = listOf("Component was not found %s because it was removed due to duplicate converter bindings.") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/LithoFilterFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/LithoFilterFingerprint.kt index 0d3760725..9839efc31 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/LithoFilterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/LithoFilterFingerprint.kt @@ -1,11 +1,13 @@ package app.revanced.patches.youtube.misc.litho.filter.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags object LithoFilterFingerprint : MethodFingerprint( - customFingerprint = custom@{ method, classDef -> - if (method.name != "") return@custom false - + accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC or AccessFlags.CONSTRUCTOR, + returnType = "V", + customFingerprint = { _, classDef -> classDef.type.endsWith("LithoFilterPatch;") } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt index 015736b73..dbb7e1e45 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt @@ -1,13 +1,10 @@ package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode - -@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. object MinimizedPlaybackManagerFingerprint : MethodFingerprint( "Z", AccessFlags.PUBLIC or AccessFlags.STATIC, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt index af3840d08..ca676e7a3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt @@ -1,16 +1,14 @@ package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode - -@FuzzyPatternScanMethod(2) object MinimizedPlaybackSettingsFingerprint : MethodFingerprint( - "L", - AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "L", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf(), opcodes = listOf( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsParentFingerprint.kt new file mode 100644 index 000000000..59754a7fd --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsParentFingerprint.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags + +/** + * Class fingerprint for [MinimizedPlaybackSettingsFingerprint] + */ +object MinimizedPlaybackSettingsParentFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + parameters = listOf("Landroid/content/Context;", "Landroid/support/v4/media/session/MediaSessionCompat"), + strings = listOf("sessionToken must not be null") +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt index 3848df841..c22654389 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -8,6 +8,7 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.toMethodWalker import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -21,6 +22,7 @@ import app.revanced.patches.youtube.misc.minimizedplayback.annotations.Minimized import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.KidsMinimizedPlaybackPolicyControllerFingerprint import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackSettingsFingerprint +import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackSettingsParentFingerprint import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import org.jf.dexlib2.iface.instruction.ReferenceInstruction @@ -35,7 +37,7 @@ import org.jf.dexlib2.iface.reference.MethodReference class MinimizedPlaybackPatch : BytecodePatch( listOf( MinimizedPlaybackManagerFingerprint, - MinimizedPlaybackSettingsFingerprint, + MinimizedPlaybackSettingsParentFingerprint, KidsMinimizedPlaybackPolicyControllerFingerprint ) ) { @@ -60,6 +62,8 @@ class MinimizedPlaybackPatch : BytecodePatch( } ?: return MinimizedPlaybackManagerFingerprint.toErrorResult() // Enable minimized playback option in YouTube settings + MinimizedPlaybackSettingsParentFingerprint.result ?: return MinimizedPlaybackSettingsParentFingerprint.toErrorResult() + MinimizedPlaybackSettingsFingerprint.resolve(context, MinimizedPlaybackSettingsParentFingerprint.result!!.classDef) MinimizedPlaybackSettingsFingerprint.result?.apply { val booleanCalls = method.implementation!!.instructions.withIndex() .filter { ((it.value as? ReferenceInstruction)?.reference as? MethodReference)?.returnType == "Z" } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt index 7de6849bf..48b3fb2d0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt @@ -5,42 +5,33 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch import app.revanced.patches.youtube.misc.playercontrols.annotation.PlayerControlsCompatibility import app.revanced.patches.youtube.misc.playercontrols.fingerprints.BottomControlsInflateFingerprint import app.revanced.patches.youtube.misc.playercontrols.fingerprints.PlayerControlsVisibilityFingerprint +import app.revanced.patches.youtube.misc.playercontrols.resource.patch.BottomControlsResourcePatch import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Name("player-controls-bytecode-patch") -@DependsOn([ResourceMappingPatch::class]) +@DependsOn([BottomControlsResourcePatch::class]) @Description("Manages the code for the player controls of the YouTube player.") @PlayerControlsCompatibility @Version("0.0.1") class PlayerControlsBytecodePatch : BytecodePatch( - listOf(PlayerControlsVisibilityFingerprint) + listOf(PlayerControlsVisibilityFingerprint, BottomControlsInflateFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { showPlayerControlsFingerprintResult = PlayerControlsVisibilityFingerprint.result!! - - bottomUiContainerResourceId = ResourceMappingPatch - .resourceMappings - .single { it.type == "id" && it.name == "bottom_ui_container_stub" }.id - - // TODO: another solution is required, this is hacky - listOf(BottomControlsInflateFingerprint).resolve(context, context.classes) inflateFingerprintResult = BottomControlsInflateFingerprint.result!! return PatchResultSuccess() } internal companion object { - var bottomUiContainerResourceId: Long = 0 lateinit var showPlayerControlsFingerprintResult: MethodFingerprintResult diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt index 902f88943..63864aa56 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt @@ -1,21 +1,19 @@ package app.revanced.patches.youtube.misc.playercontrols.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch +import app.revanced.patcher.extensions.or +import app.revanced.util.patch.LiteralValueFingerprint +import app.revanced.patches.youtube.misc.playercontrols.resource.patch.BottomControlsResourcePatch +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object BottomControlsInflateFingerprint : MethodFingerprint( +object BottomControlsInflateFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.SYNTHETIC, + returnType = "L", + parameters = listOf(), opcodes = listOf( Opcode.CHECK_CAST, Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == PlayerControlsBytecodePatch.bottomUiContainerResourceId - } == true - } + literal = BottomControlsResourcePatch.bottomUiContainerResourceId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt index 0bf59e705..db64aaaa4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt @@ -1,10 +1,12 @@ package app.revanced.patches.youtube.misc.playercontrols.fingerprints - +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags object PlayerControlsVisibilityFingerprint : MethodFingerprint( - "V", + accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, + returnType = "V", parameters = listOf("Z", "Z"), customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("YouTubeControlsOverlay;") diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/resource/patch/BottomControlsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/resource/patch/BottomControlsResourcePatch.kt index 8ef75872d..20d3841db 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/resource/patch/BottomControlsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/resource/patch/BottomControlsResourcePatch.kt @@ -8,22 +8,30 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch import app.revanced.patches.youtube.misc.playercontrols.annotation.PlayerControlsCompatibility import java.io.Closeable @Name("bottom-controls-resource-patch") @Description("Manages the resources for the bottom controls of the YouTube player.") @PlayerControlsCompatibility +@DependsOn([ResourceMappingPatch::class]) @Version("0.0.1") class BottomControlsResourcePatch : ResourcePatch, Closeable { override fun execute(context: ResourceContext): PatchResult { resourceContext = context targetXmlEditor = context.xmlEditor[TARGET_RESOURCE] + bottomUiContainerResourceId = ResourceMappingPatch.resourceMappings + .single { it.type == "id" && it.name == "bottom_ui_container_stub" }.id + return PatchResultSuccess() } companion object { + internal var bottomUiContainerResourceId : Long = -1 + internal const val TARGET_RESOURCE_NAME = "youtube_controls_bottom_ui_container.xml" private const val TARGET_RESOURCE = "res/layout/$TARGET_RESOURCE_NAME" @@ -33,8 +41,6 @@ class BottomControlsResourcePatch : ResourcePatch, Closeable { // The element to which to add the new elements to private var lastLeftOf = "fullscreen_button" - - /** * Add new controls to the bottom of the YouTube player. * @param hostYouTubeControlsBottomUiResourceName The hosting resource name containing the elements. diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/LicenseActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/LicenseActivityFingerprint.kt index 42a9f0afa..05dfba24f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/LicenseActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/LicenseActivityFingerprint.kt @@ -1,8 +1,13 @@ package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags object LicenseActivityFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "V", + parameters = listOf("L"), customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("LicenseActivity;") && methodDef.name == "onCreate" } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/SetThemeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/SetThemeFingerprint.kt index 468e8e244..77e548568 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/SetThemeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/SetThemeFingerprint.kt @@ -1,20 +1,15 @@ package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.extensions.or +import app.revanced.util.patch.LiteralValueFingerprint import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsResourcePatch +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object SetThemeFingerprint : MethodFingerprint( +object SetThemeFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, returnType = "L", + parameters = listOf(), opcodes = listOf(Opcode.RETURN_OBJECT), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { instruction -> - if (instruction.opcode != Opcode.CONST) return@any false - - val wideLiteral = (instruction as WideLiteralInstruction).wideLiteral - - SettingsResourcePatch.appearanceStringId == wideLiteral - } ?: false - } + literal = SettingsResourcePatch.appearanceStringId ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/information/fingerprints/OnPlaybackSpeedItemClickFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/information/fingerprints/OnPlaybackSpeedItemClickFingerprint.kt index edb712070..81de6a392 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/information/fingerprints/OnPlaybackSpeedItemClickFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/information/fingerprints/OnPlaybackSpeedItemClickFingerprint.kt @@ -1,9 +1,14 @@ package app.revanced.patches.youtube.video.information.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object OnPlaybackSpeedItemClickFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "V", + parameters = listOf("L", "L", "I", "J"), customFingerprint = { methodDef, _ -> methodDef.name == "onItemClick" }, opcodes = listOf( Opcode.MOVE_RESULT_OBJECT, diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt index bce667560..e671f4c4e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt @@ -1,11 +1,15 @@ package app.revanced.patches.youtube.video.oldqualitylayout.fingerprints -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.extensions.or +import app.revanced.util.patch.LiteralValueFingerprint import app.revanced.patches.youtube.video.oldqualitylayout.patch.OldQualityLayoutResourcePatch +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -object QualityMenuViewInflateFingerprint : MethodFingerprint( +object QualityMenuViewInflateFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L", "L", "L"), + returnType = "L", opcodes = listOf( Opcode.INVOKE_SUPER, Opcode.CONST, @@ -22,13 +26,5 @@ object QualityMenuViewInflateFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST ), - customFingerprint = { methodDef, _ -> - methodDef.implementation?.instructions?.any { - if (it.opcode != Opcode.CONST) return@any false - - val literal = (it as WideLiteralInstruction).wideLiteral - - literal == OldQualityLayoutResourcePatch.videoQualityBottomSheetListFragmentTitle - } ?: false - } + literal = OldQualityLayoutResourcePatch.videoQualityBottomSheetListFragmentTitle ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/SpeedArrayGeneratorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/SpeedArrayGeneratorFingerprint.kt index 4d624dab2..ba9982988 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/SpeedArrayGeneratorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/SpeedArrayGeneratorFingerprint.kt @@ -1,19 +1,18 @@ package app.revanced.patches.youtube.video.speed.custom.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@FuzzyPatternScanMethod(2) object SpeedArrayGeneratorFingerprint : MethodFingerprint( - "[L", - AccessFlags.PUBLIC or AccessFlags.STATIC, + returnType = "[L", + accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, + parameters = listOf("Lcom/google/android/libraries/youtube/innertube/model/player/PlayerResponseModel;"), opcodes = listOf( Opcode.IF_NEZ, Opcode.SGET_OBJECT, - Opcode.GOTO, + Opcode.GOTO_16, Opcode.INVOKE_INTERFACE, Opcode.MOVE_RESULT_OBJECT, Opcode.IGET_OBJECT, diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/fingerprint/VideoIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/fingerprint/VideoIdFingerprint.kt index d9c51ab7c..3f4a0e237 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/fingerprint/VideoIdFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/fingerprint/VideoIdFingerprint.kt @@ -1,12 +1,10 @@ package app.revanced.patches.youtube.video.videoid.fingerprint import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@FuzzyPatternScanMethod(2) object VideoIdFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, diff --git a/src/main/kotlin/app/revanced/util/patch/BytecodeUtils.kt b/src/main/kotlin/app/revanced/util/patch/BytecodeUtils.kt deleted file mode 100644 index d62857323..000000000 --- a/src/main/kotlin/app/revanced/util/patch/BytecodeUtils.kt +++ /dev/null @@ -1,16 +0,0 @@ -package app.revanced.util.patch - -import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.Method -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction - -/** - * @return the first constant instruction with the resource id, or -1 if not found. - */ -fun Method.indexOfFirstConstantInstruction(constantValue: Long): Int { - return implementation?.let { - it.instructions.indexOfFirst { instruction -> - instruction.opcode == Opcode.CONST && (instruction as WideLiteralInstruction).wideLiteral == constantValue - } - } ?: -1 -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/util/patch/LiteralValueFingerprint.kt b/src/main/kotlin/app/revanced/util/patch/LiteralValueFingerprint.kt new file mode 100644 index 000000000..ec977e062 --- /dev/null +++ b/src/main/kotlin/app/revanced/util/patch/LiteralValueFingerprint.kt @@ -0,0 +1,23 @@ +package app.revanced.util.patch + +import app.revanced.extensions.containsConstantInstructionValue +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +abstract class LiteralValueFingerprint( + returnType: String? = null, + accessFlags: Int? = null, + parameters: Iterable? = null, + opcodes: Iterable? = null, + strings: Iterable? = null, + literal: Long +) : MethodFingerprint( + returnType = returnType, + accessFlags = accessFlags, + parameters = parameters, + opcodes = opcodes, + strings = strings, + customFingerprint = { methodDef, _ -> + methodDef.containsConstantInstructionValue(literal) + } +) \ No newline at end of file