From a9aeb325de1160262c4db9b4b60c6c5e39730620 Mon Sep 17 00:00:00 2001 From: Sayanth <13906889+SayanthD@users.noreply.github.com> Date: Fri, 20 Mar 2026 00:53:38 +0530 Subject: [PATCH 01/12] fix(YouTube - Spoof video streams): Set `ANDROID_REEL` client as default (#6878) --- .../java/app/revanced/extension/youtube/settings/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java index d69ed54e2d..cfe0f927d3 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java @@ -391,7 +391,7 @@ public class Settings extends YouTubeAndMusicSettings { public static final BooleanSetting EXTERNAL_BROWSER = new BooleanSetting("revanced_external_browser", TRUE, true); public static final BooleanSetting SPOOF_DEVICE_DIMENSIONS = new BooleanSetting("revanced_spoof_device_dimensions", FALSE, true, "revanced_spoof_device_dimensions_user_dialog_message"); - public static final EnumSetting SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.ANDROID_VR_1_43_32, true, parent(SPOOF_VIDEO_STREAMS)); + public static final EnumSetting SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.ANDROID_REEL, true, parent(SPOOF_VIDEO_STREAMS)); public static final BooleanSetting SPOOF_VIDEO_STREAMS_AV1 = new BooleanSetting("revanced_spoof_video_streams_av1", FALSE, true, "revanced_spoof_video_streams_av1_user_dialog_message", new SpoofClientAv1Availability()); From b1ae92cdddaa2c31e7d36b172a94105a3da4910a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 19 Mar 2026 19:26:26 +0000 Subject: [PATCH 02/12] chore: Release v6.1.1-dev.1 [skip ci] ## [6.1.1-dev.1](https://github.com/ReVanced/revanced-patches/compare/v6.1.0...v6.1.1-dev.1) (2026-03-19) ### Bug Fixes * **YouTube - Spoof video streams:** Set `ANDROID_REEL` client as default ([#6878](https://github.com/ReVanced/revanced-patches/issues/6878)) ([a9aeb32](https://github.com/ReVanced/revanced-patches/commit/a9aeb325de1160262c4db9b4b60c6c5e39730620)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfebce7e69..6ea2c0d35e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [6.1.1-dev.1](https://github.com/ReVanced/revanced-patches/compare/v6.1.0...v6.1.1-dev.1) (2026-03-19) + + +### Bug Fixes + +* **YouTube - Spoof video streams:** Set `ANDROID_REEL` client as default ([#6878](https://github.com/ReVanced/revanced-patches/issues/6878)) ([a9aeb32](https://github.com/ReVanced/revanced-patches/commit/a9aeb325de1160262c4db9b4b60c6c5e39730620)) + # [6.1.0](https://github.com/ReVanced/revanced-patches/compare/v6.0.1...v6.1.0) (2026-03-18) diff --git a/gradle.properties b/gradle.properties index d65f6857e0..abde35e11e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,4 +4,4 @@ org.gradle.parallel = true android.useAndroidX = true android.uniquePackageNames = false kotlin.code.style = official -version = 6.1.0 +version = 6.1.1-dev.1 From 8f54a7c5a08086a8641161b14e134d5909501186 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 19 Mar 2026 20:46:42 +0100 Subject: [PATCH 03/12] docs: Fix where to find a full list of patches --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a7a9db8855..0693f1048a 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Some of the features the patches provide are: export activities, etc. * ✨ **And much more!** -For a complete list of all available patches, visit [revanced.app/patches](https://revanced.app/patches). +For a complete list of all available patches, see [this](https://github.com/ReVanced/revanced-documentation/blob/main/docs/revanced-resources/questions.md#5-which-patches-are-available). ## 🚀 How to get started From bfa94c9463da999319007e6ec7cbf176acb9189e Mon Sep 17 00:00:00 2001 From: Dawid Krajcarz <80264606+drobotk@users.noreply.github.com> Date: Fri, 20 Mar 2026 20:08:54 +0100 Subject: [PATCH 04/12] refactor: Deprecate `Instruction.getReference` in favor of patcher extensions (#6854) --- .../patches/all/misc/adb/HideAdbStatusPatch.kt | 5 ++--- .../all/misc/build/BaseSpoofBuildInfoPatch.kt | 5 ++--- .../location/hide/HideMockLocationPatch.kt | 5 ++--- .../patches/all/misc/play/DisablePlayIntegrity.kt | 5 ++--- .../patches/all/misc/play/SpoofPlayAgeSignals.kt | 6 ++---- .../screenshot/PreventScreenshotDetectionPatch.kt | 5 ++--- .../patches/cricbuzz/ads/DisableAdsPatch.kt | 5 ++--- .../patches/crunchyroll/ads/HideAdsPatch.kt | 5 ++--- .../misc/extension/hooks/StartActivityInitHook.kt | 7 ++----- .../patches/googlephotos/misc/extension/Hooks.kt | 7 ++----- .../misc/features/SpoofFeaturesPatch.kt | 5 ++--- .../googlephotos/misc/gms/GmsCoreSupportPatch.kt | 4 ---- .../instagram/feed/LimitFeedToFollowedProfiles.kt | 6 ++---- .../hide/navigation/HideNavigationButtons.kt | 5 ++--- .../music/layout/branding/CustomBrandingPatch.kt | 5 ++--- .../miniplayercolor/ChangeMiniplayerColor.kt | 4 ++-- .../openinghours/misc/fix/crash/FixCrashPatch.kt | 5 ++--- .../piccomafr/tracking/DisableTrackingPatch.kt | 5 ++--- .../patches/primevideo/ads/SkipAdsPatch.kt | 5 ++--- .../primevideo/video/speed/PlaybackSpeedPatch.kt | 5 ++--- .../splittunneling/UnlockSplitTunneling.kt | 5 ++--- .../patches/reddit/ad/general/HideAdsPatch.kt | 5 ++--- .../baconreader/fix/redgifs/FixRedgifsApiPatch.kt | 5 ++--- .../boostforreddit/api/SpoofClientPatch.kt | 5 ++--- .../redditisfun/api/SpoofClientPatch.kt | 5 ++--- .../fix/redgifs/FixRedgifsApiPatch.kt | 5 ++--- .../restrictions/device/BypassDeviceChecksPatch.kt | 5 ++--- .../layout/branding/BaseCustomBrandingPatch.kt | 12 ++++++------ .../shared/misc/spoof/SpoofVideoStreamsPatch.kt | 13 ++++++------- .../shared/misc/spoof/UserAgentClientSpoofPatch.kt | 9 ++++----- .../shared/misc/string/ReplaceStringPatch.kt | 5 ++--- .../offlinesync/EnableOfflineSyncPatch.kt | 4 +--- .../spotify/layout/theme/CustomThemePatch.kt | 7 +++---- .../patches/spotify/misc/extension/Hooks.kt | 5 ++--- .../misc/lyrics/ChangeLyricsProviderPatch.kt | 10 ++++------ .../patches/spotify/misc/lyrics/Fingerprints.kt | 7 +------ .../AddGiveGroupKudosButtonToGroupActivityPatch.kt | 5 ++--- .../strava/media/download/AddMediaDownloadPatch.kt | 9 ++++----- .../tiktok/interaction/downloads/DownloadsPatch.kt | 4 +--- .../tiktok/interaction/speed/PlaybackSpeedPatch.kt | 6 ++---- .../tiktok/misc/share/SanitizeShareUrlsPatch.kt | 6 +++--- .../interaction/seekbar/EnableSlideToSeekPatch.kt | 4 +--- .../interaction/seekbar/EnableTapToSeekPatch.kt | 6 ++---- .../buttons/navigation/NavigationBarPatch.kt | 4 +--- .../overlay/HidePlayerOverlayButtonsPatch.kt | 5 ++--- .../DisableFullscreenAmbientModePatch.kt | 5 ++--- .../hide/general/HideLayoutComponentsPatch.kt | 6 ++---- .../youtube/layout/miniplayer/MiniplayerPatch.kt | 8 ++++---- .../youtube/layout/seekbar/SeekbarColorPatch.kt | 5 ++--- .../layout/shortsautoplay/ShortsAutoplayPatch.kt | 12 +++++------- .../shortsplayer/OpenShortsInRegularPlayerPatch.kt | 6 ++---- .../layout/sponsorblock/SponsorBlockPatch.kt | 7 ++++--- .../DisableResumingShortsOnStartupPatch.kt | 7 +++---- .../youtube/layout/toolbar/ToolbarHookPatch.kt | 7 +++---- .../backgroundplayback/BackgroundPlaybackPatch.kt | 4 ++-- .../misc/engagement/EngagementPanelHookPatch.kt | 2 -- .../backtoexitgesture/FixBackToExitGesturePatch.kt | 5 ++--- .../youtube/misc/fix/playbackspeed/Fingerprints.kt | 6 ++---- .../misc/imageurlhook/CronetImageUrlHook.kt | 4 ++-- .../misc/navigation/NavigationBarHookPatch.kt | 14 +++++--------- .../video/codecs/DisableVideoCodecsPatch.kt | 5 ++--- .../video/information/VideoInformationPatch.kt | 10 ++++------ .../main/kotlin/app/revanced/util/BytecodeUtils.kt | 12 ++++++------ .../app/revanced/util/FreeRegisterProvider.kt | 3 ++- 64 files changed, 153 insertions(+), 235 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/adb/HideAdbStatusPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/adb/HideAdbStatusPatch.kt index 71f6777857..4c903f0789 100644 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/adb/HideAdbStatusPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/all/misc/adb/HideAdbStatusPatch.kt @@ -1,12 +1,11 @@ package app.revanced.patches.all.misc.adb +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference import com.android.tools.smali.dexlib2.util.MethodUtil @@ -44,7 +43,7 @@ val hideADBStatusPatch = bytecodePatch( filterMap = filterMap@{ classDef, method, instruction, instructionIndex -> val reference = instruction .takeIf { it.opcode == Opcode.INVOKE_STATIC } - ?.getReference() + ?.methodReference ?.takeIf { reference -> getIntMethodReferences.any { MethodUtil.methodSignaturesMatch(it, reference) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/build/BaseSpoofBuildInfoPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/build/BaseSpoofBuildInfoPatch.kt index 567df9f7e0..ee3e0d2c31 100644 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/build/BaseSpoofBuildInfoPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/all/misc/build/BaseSpoofBuildInfoPatch.kt @@ -1,12 +1,11 @@ package app.revanced.patches.all.misc.build +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference private const val BUILD_CLASS_DESCRIPTOR = "Landroid/os/Build;" @@ -75,7 +74,7 @@ fun baseSpoofBuildInfoPatch(buildInfoSupplier: () -> BuildInfo) = bytecodePatch dependsOn( transformInstructionsPatch( filterMap = filterMap@{ _, _, instruction, instructionIndex -> - val reference = instruction.getReference() ?: return@filterMap null + val reference = instruction.fieldReference ?: return@filterMap null if (reference.definingClass != BUILD_CLASS_DESCRIPTOR) return@filterMap null return@filterMap replacements[reference.name]?.let { instructionIndex to it } diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/location/hide/HideMockLocationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/location/hide/HideMockLocationPatch.kt index 8c69bfad07..9b5afef4a2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/location/hide/HideMockLocationPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/location/hide/HideMockLocationPatch.kt @@ -1,13 +1,12 @@ package app.revanced.patches.all.misc.connectivity.location.hide +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.transformation.IMethodCall import app.revanced.patches.all.misc.transformation.fromMethodReference import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Suppress("unused") val hideMockLocationPatch = bytecodePatch( @@ -18,7 +17,7 @@ val hideMockLocationPatch = bytecodePatch( dependsOn( transformInstructionsPatch( filterMap = filter@{ _, _, instruction, instructionIndex -> - val reference = instruction.getReference() ?: return@filter null + val reference = instruction.methodReference ?: return@filter null if (fromMethodReference(reference) == null) return@filter null instruction to instructionIndex diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/play/DisablePlayIntegrity.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/play/DisablePlayIntegrity.kt index dd5dad79e4..186eec96b6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/play/DisablePlayIntegrity.kt +++ b/patches/src/main/kotlin/app/revanced/patches/all/misc/play/DisablePlayIntegrity.kt @@ -1,11 +1,10 @@ package app.revanced.patches.all.misc.play +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference import com.android.tools.smali.dexlib2.util.MethodUtil @@ -30,7 +29,7 @@ val disablePlayIntegrityPatch = bytecodePatch( transformInstructionsPatch( filterMap = filterMap@{ classDef, method, instruction, instructionIndex -> val reference = instruction - .getReference() + .methodReference ?.takeIf { MethodUtil.methodSignaturesMatch(CONTEXT_BIND_SERVICE_METHOD_REFERENCE, it) } diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/play/SpoofPlayAgeSignals.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/play/SpoofPlayAgeSignals.kt index ccb41b81b4..d11e3cf84b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/play/SpoofPlayAgeSignals.kt +++ b/patches/src/main/kotlin/app/revanced/patches/all/misc/play/SpoofPlayAgeSignals.kt @@ -2,14 +2,12 @@ package app.revanced.patches.all.misc.play import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.removeInstructions import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.intOption -import app.revanced.patcher.patch.option import app.revanced.util.forEachInstructionAsSequence -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference @@ -46,7 +44,7 @@ val spoofPlayAgeSignalsPatch = bytecodePatch( if (classDef.type.startsWith("Lcom/google/android/play/agesignals/")) return@forEachInstructionAsSequence null // Keep method calls only. - val reference = instruction.getReference() + val reference = instruction.methodReference ?: return@forEachInstructionAsSequence null val match = MethodCall.entries.firstOrNull { diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/screenshot/PreventScreenshotDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/screenshot/PreventScreenshotDetectionPatch.kt index 93092b5f3e..f0c3aa92b4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/screenshot/PreventScreenshotDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/all/misc/screenshot/PreventScreenshotDetectionPatch.kt @@ -1,11 +1,10 @@ package app.revanced.patches.all.misc.screenshot +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference import com.android.tools.smali.dexlib2.util.MethodUtil @@ -39,7 +38,7 @@ val preventScreenshotDetectionPatch = bytecodePatch( filterMap = { _, _, instruction, instructionIndex -> if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return@transformInstructionsPatch null - val reference = instruction.getReference() ?: return@transformInstructionsPatch null + val reference = instruction.methodReference ?: return@transformInstructionsPatch null instructionIndex.takeIf { MethodUtil.methodSignaturesMatch(reference, registerScreenCaptureCallbackMethodReference) || diff --git a/patches/src/main/kotlin/app/revanced/patches/cricbuzz/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/cricbuzz/ads/DisableAdsPatch.kt index 6dde6e7257..322794cc68 100644 --- a/patches/src/main/kotlin/app/revanced/patches/cricbuzz/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/cricbuzz/ads/DisableAdsPatch.kt @@ -1,15 +1,14 @@ package app.revanced.patches.cricbuzz.ads import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.cricbuzz.misc.extension.sharedExtensionPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.returnEarly import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/cricbuzz/ads/HideAdsPatch;" @@ -27,7 +26,7 @@ val hideAdsPatch = bytecodePatch("Hide ads") { cb11ConstructorMethod.addInstruction(0, "const/4 p7, 0x0") getBottomBarMethod.apply { val getIndex = indexOfFirstInstructionOrThrow { - opcode == Opcode.IGET_OBJECT && getReference()?.name == "bottomBar" + opcode == Opcode.IGET_OBJECT && fieldReference?.name == "bottomBar" } val getRegister = getInstruction(getIndex).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/crunchyroll/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/crunchyroll/ads/HideAdsPatch.kt index 3a697c3b75..290da66397 100644 --- a/patches/src/main/kotlin/app/revanced/patches/crunchyroll/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/crunchyroll/ads/HideAdsPatch.kt @@ -1,16 +1,15 @@ package app.revanced.patches.crunchyroll.ads import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.instructions import app.revanced.patcher.patch.bytecodePatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstruction import app.revanced.util.removeFlags import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference @Suppress("unused") val hideAdsPatch = bytecodePatch("Hide ads") { @@ -22,7 +21,7 @@ val hideAdsPatch = bytecodePatch("Hide ads") { val stringIndex = videoUrlReadyToStringMethodMatch[-1] val fieldIndex = it.indexOfFirstInstruction(stringIndex, Opcode.IGET_BOOLEAN) - it.getInstruction(fieldIndex).getReference()!! + it.getInstruction(fieldIndex).fieldReference!! } // Remove final access flag on field. diff --git a/patches/src/main/kotlin/app/revanced/patches/googlenews/misc/extension/hooks/StartActivityInitHook.kt b/patches/src/main/kotlin/app/revanced/patches/googlenews/misc/extension/hooks/StartActivityInitHook.kt index 3096647525..e7793ec9ec 100644 --- a/patches/src/main/kotlin/app/revanced/patches/googlenews/misc/extension/hooks/StartActivityInitHook.kt +++ b/patches/src/main/kotlin/app/revanced/patches/googlenews/misc/extension/hooks/StartActivityInitHook.kt @@ -2,23 +2,20 @@ package app.revanced.patches.googlenews.misc.extension.hooks import app.revanced.patcher.definingClass import app.revanced.patcher.extensions.instructions -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.name import app.revanced.patcher.opcodes import app.revanced.patches.shared.misc.extension.extensionHook -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private var getApplicationContextIndex = -1 internal val startActivityInitHook = extensionHook( getInsertIndex = { getApplicationContextIndex = indexOfFirstInstructionOrThrow { - getReference()?.name == "getApplicationContext" + methodReference?.name == "getApplicationContext" } getApplicationContextIndex + 2 // Below the move-result-object instruction. diff --git a/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/extension/Hooks.kt b/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/extension/Hooks.kt index 8ed9937cff..08b805b4df 100644 --- a/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/extension/Hooks.kt +++ b/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/extension/Hooks.kt @@ -2,23 +2,20 @@ package app.revanced.patches.googlephotos.misc.extension import app.revanced.patcher.definingClass import app.revanced.patcher.extensions.instructions -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.name import app.revanced.patcher.opcodes import app.revanced.patches.shared.misc.extension.extensionHook -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private var getApplicationContextIndex = -1 internal val homeActivityInitHook = extensionHook( getInsertIndex = { getApplicationContextIndex = indexOfFirstInstructionOrThrow { - getReference()?.name == "getApplicationContext" + methodReference?.name == "getApplicationContext" } getApplicationContextIndex + 2 // Below the move-result-object instruction. diff --git a/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/features/SpoofFeaturesPatch.kt b/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/features/SpoofFeaturesPatch.kt index 71046d14eb..4ea5eca910 100644 --- a/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/features/SpoofFeaturesPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/features/SpoofFeaturesPatch.kt @@ -2,12 +2,11 @@ package app.revanced.patches.googlephotos.misc.features import app.revanced.patcher.extensions.instructions import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.stringReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.stringsOption -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.StringReference @Suppress("unused") val spoofFeaturesPatch = bytecodePatch( @@ -62,7 +61,7 @@ val spoofFeaturesPatch = bytecodePatch( initializeFeaturesEnumMethod.apply { instructions.filter { it.opcode == Opcode.CONST_STRING }.forEach { - val feature = it.getReference()!!.string + val feature = it.stringReference!!.string val spoofedFeature = when (feature) { in featuresToEnable -> "android.hardware.wifi" diff --git a/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch.kt b/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch.kt index 65ae7572c4..7537158302 100644 --- a/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch.kt @@ -7,10 +7,6 @@ import app.revanced.patches.googlephotos.misc.extension.extensionPatch import app.revanced.patches.googlephotos.misc.gms.Constants.PHOTOS_PACKAGE_NAME import app.revanced.patches.googlephotos.misc.gms.Constants.REVANCED_PHOTOS_PACKAGE_NAME import app.revanced.patches.shared.misc.gms.gmsCoreSupportPatch -import app.revanced.util.getReference -import app.revanced.util.indexOfFirstInstructionOrThrow -import com.android.tools.smali.dexlib2.iface.reference.MethodReference -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow @Suppress("unused") diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/feed/LimitFeedToFollowedProfiles.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/feed/LimitFeedToFollowedProfiles.kt index c998611255..5f927822b0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/feed/LimitFeedToFollowedProfiles.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/feed/LimitFeedToFollowedProfiles.kt @@ -9,10 +9,8 @@ import app.revanced.patcher.immutableClassDef import app.revanced.patcher.name import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/instagram/feed/LimitFeedToFollowedProfiles;" @@ -40,7 +38,7 @@ val limitFeedToFollowedProfilesPatch = bytecodePatch( reference?.type == "Ljava/util/Map;" && reference.definingClass == mainFeedRequestClassMethod.classDef.type }.let { instructionIndex -> - getInstruction(instructionIndex).getReference()!!.name + getInstruction(instructionIndex).fieldReference!!.name } } @@ -49,7 +47,7 @@ val limitFeedToFollowedProfilesPatch = bytecodePatch( }.apply { // Finds the instruction where the map is being initialized in the constructor val getHeaderIndex = indexOfFirstInstructionOrThrow { - getReference().let { + fieldReference.let { it?.name == mainFeedRequestHeaderFieldName } } diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt index ef4070c62a..fdf9cae6f8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt @@ -1,5 +1,6 @@ package app.revanced.patches.instagram.hide.navigation +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.firstMethodDeclaratively import app.revanced.patcher.immutableClassDef @@ -9,12 +10,10 @@ import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch import app.revanced.util.addInstructionsAtControlFlowLabel import app.revanced.util.findFreeRegister -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference import java.util.logging.Logger private const val EXTENSION_CLASS_DESCRIPTOR = @@ -82,7 +81,7 @@ val hideNavigationButtonsPatch = bytecodePatch( opcode == Opcode.IPUT_OBJECT && (this as TwoRegisterInstruction).registerA == 2 // p2 register. }.let { - method.getInstruction(it).getReference()!!.name + method.getInstruction(it).fieldReference!!.name } } diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/branding/CustomBrandingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/branding/CustomBrandingPatch.kt index ff6b5326a5..fdb15699cb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/branding/CustomBrandingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/branding/CustomBrandingPatch.kt @@ -2,6 +2,7 @@ package app.revanced.patches.music.layout.branding import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.typeReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.music.misc.extension.sharedExtensionPatch import app.revanced.patches.music.misc.gms.Constants.MUSIC_MAIN_ACTIVITY_NAME @@ -12,12 +13,10 @@ import app.revanced.patches.shared.layout.branding.EXTENSION_CLASS_DESCRIPTOR import app.revanced.patches.shared.layout.branding.baseCustomBrandingPatch import app.revanced.patches.shared.misc.mapping.ResourceType import app.revanced.patches.shared.misc.mapping.resourceMappingPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstLiteralInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.TypeReference private val disableSplashAnimationPatch = bytecodePatch { @@ -37,7 +36,7 @@ private val disableSplashAnimationPatch = bytecodePatch { ) val checkCastIndex = indexOfFirstInstructionOrThrow(literalIndex) { opcode == Opcode.CHECK_CAST && - getReference()?.type == "Lcom/airbnb/lottie/LottieAnimationView;" + typeReference?.type == "Lcom/airbnb/lottie/LottieAnimationView;" } val register = getInstruction(checkCastIndex).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/miniplayercolor/ChangeMiniplayerColor.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/miniplayercolor/ChangeMiniplayerColor.kt index d8f78efe2f..3699860112 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/miniplayercolor/ChangeMiniplayerColor.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/miniplayercolor/ChangeMiniplayerColor.kt @@ -4,6 +4,7 @@ package app.revanced.patches.music.layout.miniplayercolor import app.revanced.patcher.accessFlags import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.firstMethodDeclaratively import app.revanced.patcher.parameterTypes import app.revanced.patcher.patch.bytecodePatch @@ -20,7 +21,6 @@ import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.reference.FieldReference -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/music/patches/ChangeMiniplayerColorPatch;" @@ -72,7 +72,7 @@ val changeMiniplayerColorPatch = bytecodePatch( val colorGreyIndex = miniPlayerConstructorMethodMatch.immutableMethod.indexOfFirstInstructionReversedOrThrow { - getReference()?.name == "getColor" + methodReference?.name == "getColor" } val iPutIndex = miniPlayerConstructorMethodMatch.immutableMethod.indexOfFirstInstructionOrThrow( diff --git a/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt b/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt index d2242b172c..888d364892 100644 --- a/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt @@ -1,15 +1,14 @@ package app.revanced.patches.openinghours.misc.fix.crash import app.revanced.patcher.extensions.instructions +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.newLabel import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21t import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.Instruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Suppress("unused") val fixCrashPatch = bytecodePatch( @@ -78,7 +77,7 @@ val fixCrashPatch = bytecodePatch( } private fun isInvokeInstruction(instruction: Instruction, className: String, methodName: String): Boolean { - val methodRef = instruction.getReference() ?: return false + val methodRef = instruction.methodReference ?: return false return methodRef.definingClass == className && methodRef.name == methodName } diff --git a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt index d37280e454..38a32991f6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt @@ -3,11 +3,10 @@ package app.revanced.patches.piccomafr.tracking import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.instructions import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.stringReference import app.revanced.patcher.patch.bytecodePatch -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.StringReference @Suppress("unused") val disableTrackingPatch = bytecodePatch( @@ -48,7 +47,7 @@ val disableTrackingPatch = bytecodePatch( firebaseInstallMethod.instructions.filter { it.opcode == Opcode.CONST_STRING }.filter { - it.getReference()?.string == "firebaseinstallations.googleapis.com" + it.stringReference?.string == "firebaseinstallations.googleapis.com" }.forEach { instruction -> instruction as OneRegisterInstruction diff --git a/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/SkipAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/SkipAdsPatch.kt index a78fcf1269..e9ed08b8c7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/SkipAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/SkipAdsPatch.kt @@ -2,14 +2,13 @@ package app.revanced.patches.primevideo.ads import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.primevideo.misc.extension.sharedExtensionPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Suppress("unused") val skipAdsPatch = bytecodePatch( @@ -32,7 +31,7 @@ val skipAdsPatch = bytecodePatch( // move-result-object { playerRegister } val getPlayerIndex = indexOfFirstInstructionOrThrow { opcode == Opcode.INVOKE_VIRTUAL && - getReference()?.name == "getPrimaryPlayer" + methodReference?.name == "getPrimaryPlayer" } val playerRegister = getInstruction(getPlayerIndex + 1).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/PlaybackSpeedPatch.kt b/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/PlaybackSpeedPatch.kt index cce68b6c13..7797be1f66 100644 --- a/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/PlaybackSpeedPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/PlaybackSpeedPatch.kt @@ -1,14 +1,13 @@ package app.revanced.patches.primevideo.video.speed import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.primevideo.misc.extension.sharedExtensionPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/primevideo/videoplayer/PlaybackSpeedPatch;" @@ -30,7 +29,7 @@ val playbackSpeedPatch = bytecodePatch( playbackUserControlsInitializeMethod.apply { val getIndex = indexOfFirstInstructionOrThrow { opcode == Opcode.IPUT_OBJECT && - getReference()?.name == "mUserControls" + fieldReference?.name == "mUserControls" } val getRegister = getInstruction(getIndex).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/protonvpn/splittunneling/UnlockSplitTunneling.kt b/patches/src/main/kotlin/app/revanced/patches/protonvpn/splittunneling/UnlockSplitTunneling.kt index 79bc78ec1a..59aa93e76c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/protonvpn/splittunneling/UnlockSplitTunneling.kt +++ b/patches/src/main/kotlin/app/revanced/patches/protonvpn/splittunneling/UnlockSplitTunneling.kt @@ -1,13 +1,12 @@ package app.revanced.patches.protonvpn.splittunneling import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Suppress("unused") val unlockSplitTunnelingPatch = bytecodePatch("Unlock split tunneling") { @@ -22,7 +21,7 @@ val unlockSplitTunnelingPatch = bytecodePatch("Unlock split tunneling") { initializeSplitTunnelingSettingsUIMethod.apply { val initSettingsIndex = indexOfFirstInstructionOrThrow { - getReference()?.name == "getSplitTunneling" + methodReference?.name == "getSplitTunneling" } removeInstruction(initSettingsIndex - 1) } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt index 8cf4a3aa67..4269a5284d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt @@ -1,17 +1,16 @@ package app.revanced.patches.reddit.ad.general import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.reddit.ad.comments.hideCommentAdsPatch import app.revanced.patches.reddit.misc.extension.sharedExtensionPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c import com.android.tools.smali.dexlib2.iface.reference.FieldReference -import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Suppress("unused") val hideAdsPatch = bytecodePatch("Hide ads") { @@ -57,7 +56,7 @@ val hideAdsPatch = bytecodePatch("Hide ads") { // By removing the appending instruction no ad posts gets appended to the feed. val index = newAdPostMethod.indexOfFirstInstruction { - val reference = getReference() ?: return@indexOfFirstInstruction false + val reference = methodReference ?: return@indexOfFirstInstruction false reference.name == "add" && reference.definingClass == "Ljava/util/ArrayList;" } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt index 3d3e6e3ed6..709cf7d24b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt @@ -1,17 +1,16 @@ package app.revanced.patches.reddit.customclients.baconreader.fix.redgifs import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.removeInstructions import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.extensions.typeReference import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD import app.revanced.patches.reddit.customclients.baconreader.misc.extension.sharedExtensionPatch import app.revanced.patches.reddit.customclients.fixRedgifsApiPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/baconreader/FixRedgifsApiPatch;" @@ -34,7 +33,7 @@ val fixRedgifsApi = fixRedgifsApiPatch( getOkHttpClientMethod.removeInstructions(originalInterceptorInstallIndex, 5) val index = getOkHttpClientMethod.indexOfFirstInstructionOrThrow { - val reference = getReference() + val reference = methodReference reference?.name == "build" && reference.definingClass == $$"Lokhttp3/OkHttpClient$Builder;" } val register = getOkHttpClientMethod.getInstruction(index).registerC diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt index b99df9d8e2..d5fac16131 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt @@ -2,13 +2,12 @@ package app.revanced.patches.reddit.customclients.boostforreddit.api import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.stringReference import app.revanced.patches.reddit.customclients.spoofClientPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.returnEarly import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.StringReference @Suppress("unused") val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") { clientIdOption -> @@ -30,7 +29,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" val userAgentTemplateIndex = buildUserAgentMethod.indexOfFirstInstructionOrThrow { - opcode == Opcode.CONST_STRING && getReference()?.string == "%s:%s:%s (by /u/%s)" + opcode == Opcode.CONST_STRING && stringReference?.string == "%s:%s:%s (by /u/%s)" } val register = buildUserAgentMethod.getInstruction(userAgentTemplateIndex).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt index 95bd1ccd5d..536e363178 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt @@ -3,12 +3,11 @@ package app.revanced.patches.reddit.customclients.redditisfun.api import app.revanced.patcher.CompositeMatch import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.stringReference import app.revanced.patches.reddit.customclients.spoofClientPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.returnEarly import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.StringReference @Suppress("unused") val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { clientIdOption -> @@ -64,7 +63,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { cl // Replace old.reddit.com with www.reddit.com to fix this. buildAuthorizationStringMethodMatch.method.apply { val index = indexOfFirstInstructionOrThrow { - getReference()?.contains("old.reddit.com") == true + stringReference?.contains("old.reddit.com") == true } val targetRegister = getInstruction(index).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt index e4ae3a322e..c5e64b6929 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt @@ -2,14 +2,13 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.redgifs import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD import app.revanced.patches.reddit.customclients.fixRedgifsApiPatch import app.revanced.patches.reddit.customclients.sync.syncforreddit.extension.sharedExtensionPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/syncforreddit/FixRedgifsApiPatch;" @@ -27,7 +26,7 @@ val fixRedgifsApi = fixRedgifsApiPatch( // region Patch Redgifs OkHttp3 client. val index = createOkHttpClientMethod.indexOfFirstInstructionOrThrow { - val reference = getReference() + val reference = methodReference reference?.name == "build" && reference.definingClass == $$"Lokhttp3/OkHttpClient$Builder;" } val register = createOkHttpClientMethod.getInstruction(index).registerC diff --git a/patches/src/main/kotlin/app/revanced/patches/samsung/radio/restrictions/device/BypassDeviceChecksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/samsung/radio/restrictions/device/BypassDeviceChecksPatch.kt index f3b2e9f080..cabec25adc 100644 --- a/patches/src/main/kotlin/app/revanced/patches/samsung/radio/restrictions/device/BypassDeviceChecksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/samsung/radio/restrictions/device/BypassDeviceChecksPatch.kt @@ -2,12 +2,11 @@ package app.revanced.patches.samsung.radio.restrictions.device import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.removeInstructions +import app.revanced.patcher.extensions.stringReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.util.findFreeRegister -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.reference.StringReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/samsung/radio/restrictions/device/BypassDeviceChecksPatch;" @@ -25,7 +24,7 @@ val bypassDeviceChecksPatch = bytecodePatch( // Find the first string that start with "SM-", that's the list of incompatible devices. val firstStringIndex = checkDeviceMethod.indexOfFirstInstructionOrThrow { opcode == Opcode.CONST_STRING && - getReference()?.string?.startsWith("SM-") == true + stringReference?.string?.startsWith("SM-") == true } // Find the following filled-new-array (or filled-new-array/range) instruction. diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/layout/branding/BaseCustomBrandingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/layout/branding/BaseCustomBrandingPatch.kt index 9a583e2c7a..0c4a27d759 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/layout/branding/BaseCustomBrandingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/layout/branding/BaseCustomBrandingPatch.kt @@ -2,7 +2,9 @@ package app.revanced.patches.shared.layout.branding import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.typeReference import app.revanced.patcher.patch.* import app.revanced.patches.all.misc.packagename.setOrGetFallbackPackageName import app.revanced.patches.all.misc.resources.addResources @@ -14,8 +16,6 @@ import app.revanced.util.* import app.revanced.util.Utils.trimIndentMultiline import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference -import com.android.tools.smali.dexlib2.iface.reference.TypeReference import org.w3c.dom.Element import org.w3c.dom.NodeList import java.io.File @@ -125,22 +125,22 @@ internal fun baseCustomBrandingPatch( val getBuilderIndex = if (isYouTubeMusic) { // YT Music the field is not a plain object type. indexOfFirstInstructionOrThrow { - getReference()?.type == $$"Landroid/app/Notification$Builder;" + fieldReference?.type == $$"Landroid/app/Notification$Builder;" } } else { // Find the field name of the notification builder. Field is an Object type. val builderCastIndex = indexOfFirstInstructionOrThrow { - val reference = getReference() + val reference = typeReference opcode == Opcode.CHECK_CAST && reference?.type == $$"Landroid/app/Notification$Builder;" } indexOfFirstInstructionReversedOrThrow(builderCastIndex) { - getReference()?.type == "Ljava/lang/Object;" + fieldReference?.type == "Ljava/lang/Object;" } } val builderFieldName = getInstruction(getBuilderIndex) - .getReference() + .fieldReference findInstructionIndicesReversedOrThrow( Opcode.RETURN_VOID, diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/SpoofVideoStreamsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/SpoofVideoStreamsPatch.kt index 1c918b8104..c7d39f73de 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/SpoofVideoStreamsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/SpoofVideoStreamsPatch.kt @@ -20,7 +20,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter @@ -123,7 +122,7 @@ internal fun spoofVideoStreamsPatch( val resultMethodType = createStreamingDataMethodMatch.classDef.type val videoDetailsIndex = createStreamingDataMethodMatch[-1] val videoDetailsRegister = getInstruction(videoDetailsIndex).registerA - val videoDetailsClass = getInstruction(videoDetailsIndex).getReference()!!.type + val videoDetailsClass = getInstruction(videoDetailsIndex).fieldReference!!.type addInstruction( videoDetailsIndex + 1, @@ -135,15 +134,15 @@ internal fun spoofVideoStreamsPatch( val setStreamingDataIndex = createStreamingDataMethodMatch[0] val playerProtoClass = getInstruction(setStreamingDataIndex + 1) - .getReference()!!.definingClass + .fieldReference!!.definingClass - val setStreamingDataField = getInstruction(setStreamingDataIndex).getReference() + val setStreamingDataField = getInstruction(setStreamingDataIndex).fieldReference val getStreamingDataField = getInstruction( indexOfFirstInstructionOrThrow { - opcode == Opcode.IGET_OBJECT && getReference()?.definingClass == playerProtoClass + opcode == Opcode.IGET_OBJECT && fieldReference?.definingClass == playerProtoClass }, - ).getReference() + ).fieldReference // Use a helper method to avoid the need of picking out multiple free registers from the hooked code. createStreamingDataMethodMatch.classDef.methods.add( @@ -275,7 +274,7 @@ internal fun spoofVideoStreamsPatch( val mediaFetchEnumClass = definingClass val sabrFieldIndex = indexOfFirstInstructionOrThrow(disabledBySABRStreamingUrlString) { opcode == Opcode.SPUT_OBJECT && - getReference()?.type == mediaFetchEnumClass + fieldReference?.type == mediaFetchEnumClass } Pair( diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/UserAgentClientSpoofPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/UserAgentClientSpoofPatch.kt index e512578bd8..d41c58dd61 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/UserAgentClientSpoofPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/UserAgentClientSpoofPatch.kt @@ -1,16 +1,15 @@ package app.revanced.patches.shared.misc.spoof import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.stringReference import app.revanced.patches.all.misc.transformation.IMethodCall import app.revanced.patches.all.misc.transformation.filterMapInstruction35c import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference -import com.android.tools.smali.dexlib2.iface.reference.StringReference private const val USER_AGENT_STRING_BUILDER_APPEND_METHOD_REFERENCE = "Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;" @@ -37,7 +36,7 @@ fun userAgentClientSpoofPatch(originalPackageName: String) = transformInstructio // IndexOutOfBoundsException is technically possible here, // but no such occurrences are present in the app. - val referee = getInstruction(instructionIndex + 2).getReference()?.toString() + val referee = getInstruction(instructionIndex + 2).methodReference?.toString() // Only replace string builder usage. if (referee != USER_AGENT_STRING_BUILDER_APPEND_METHOD_REFERENCE) { @@ -48,7 +47,7 @@ fun userAgentClientSpoofPatch(originalPackageName: String) = transformInstructio // Changing these package names will result in playback limitations, // particularly Android VR background audio only playback. val resourceOrGmsStringInstructionIndex = indexOfFirstInstruction { - val reference = getReference() + val reference = stringReference opcode == Opcode.CONST_STRING && (reference?.string == "android.resource://" || reference?.string == "gcore_") } diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/string/ReplaceStringPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/string/ReplaceStringPatch.kt index a6ba7a12e9..afb6566349 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/string/ReplaceStringPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/string/ReplaceStringPatch.kt @@ -1,12 +1,11 @@ package app.revanced.patches.shared.misc.string import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.stringReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.ReferenceType import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.StringReference import kotlin.text.contains fun replaceStringPatch( @@ -20,7 +19,7 @@ fun replaceStringPatch( filterMap = filterMap@{ _, _, instruction, instructionIndex -> if (instruction.opcode.referenceType != ReferenceType.STRING) return@filterMap null - val stringReference = instruction.getReference()!!.string + val stringReference = instruction.stringReference!!.string if (from !in stringReference) return@filterMap null Triple(instructionIndex, instruction as OneRegisterInstruction, stringReference) diff --git a/patches/src/main/kotlin/app/revanced/patches/soundcloud/offlinesync/EnableOfflineSyncPatch.kt b/patches/src/main/kotlin/app/revanced/patches/soundcloud/offlinesync/EnableOfflineSyncPatch.kt index 7fd1114419..f3ed6ac6d3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/soundcloud/offlinesync/EnableOfflineSyncPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/soundcloud/offlinesync/EnableOfflineSyncPatch.kt @@ -3,10 +3,8 @@ package app.revanced.patches.soundcloud.offlinesync import app.revanced.patcher.extensions.* import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.soundcloud.shared.featureConstructorMethod -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference @Suppress("unused") val enableOfflineSyncPatch = bytecodePatch("Enable offline sync") { @@ -40,7 +38,7 @@ val enableOfflineSyncPatch = bytecodePatch("Enable offline sync") { val getEndpointsEnumFieldInstruction = getInstruction(getEndpointsEnumFieldIndex) val targetRegister = getEndpointsEnumFieldInstruction.registerA - val endpointsType = getEndpointsEnumFieldInstruction.getReference()!!.type + val endpointsType = getEndpointsEnumFieldInstruction.fieldReference!!.type replaceInstruction( getEndpointsEnumFieldIndex, diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt index 6b859d3e05..c08907e4a4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt @@ -2,16 +2,15 @@ package app.revanced.patches.spotify.layout.theme import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.immutableClassDef import app.revanced.patcher.patch.booleanOption import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.resourcePatch import app.revanced.patcher.patch.stringOption import app.revanced.patches.spotify.misc.extension.sharedExtensionPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import org.w3c.dom.Element private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/spotify/layout/theme/CustomThemePatch;" @@ -39,7 +38,7 @@ private val customThemeBytecodePatch = bytecodePatch { // including the solid color of it. parseLottieJsonMethod.apply { val invokeParseColorIndex = indexOfFirstInstructionOrThrow { - val reference = getReference() + val reference = methodReference reference?.definingClass == "Landroid/graphics/Color;" && reference.name == "parseColor" } @@ -60,7 +59,7 @@ private val customThemeBytecodePatch = bytecodePatch { // Lottie animated color parser. parseAnimatedColorMethod.apply { val invokeArgbIndex = indexOfFirstInstructionOrThrow { - val reference = getReference() + val reference = methodReference reference?.definingClass == "Landroid/graphics/Color;" && reference.name == "argb" } diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/extension/Hooks.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/extension/Hooks.kt index 60726251d5..7da96936b0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/extension/Hooks.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/extension/Hooks.kt @@ -1,15 +1,14 @@ package app.revanced.patches.spotify.misc.extension +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.string import app.revanced.patcher.instructions import app.revanced.patcher.invoke import app.revanced.patches.shared.misc.extension.activityOnCreateExtensionHook import app.revanced.patches.shared.misc.extension.extensionHook -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference internal val mainActivityOnCreateHook = activityOnCreateExtensionHook( "Lcom/spotify/music/SpotifyMainActivity;" @@ -25,7 +24,7 @@ internal val loadOrbitLibraryHook = extensionHook( }, getContextRegister = { contextReferenceIndex = indexOfFirstInstruction { - getReference()?.type == "Landroid/content/Context;" + fieldReference?.type == "Landroid/content/Context;" } val contextRegister = getInstruction(contextReferenceIndex).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/ChangeLyricsProviderPatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/ChangeLyricsProviderPatch.kt index 020399c703..a3638464c8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/ChangeLyricsProviderPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/ChangeLyricsProviderPatch.kt @@ -4,6 +4,7 @@ import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod import app.revanced.patcher.classDef import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.firstMethodDeclaratively import app.revanced.patcher.instructions @@ -12,13 +13,10 @@ import app.revanced.patcher.parameterTypes import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.stringOption import app.revanced.patcher.returnType -import app.revanced.util.getReference -import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstInstructionReversedOrThrow import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference import java.net.InetAddress import java.net.URI @@ -70,10 +68,10 @@ val changeLyricsProviderPatch = bytecodePatch( val patchedHttpClientBuilderMethod = with(httpClientBuilderMethod) { val invokeBuildUrlIndex = indexOfFirstInstructionOrThrow { - getReference()?.returnType == "Lokhttp3/HttpUrl;" + methodReference?.returnType == "Lokhttp3/HttpUrl;" } val setUrlBuilderHostIndex = indexOfFirstInstructionReversedOrThrow(invokeBuildUrlIndex) { - val reference = getReference() + val reference = methodReference reference?.definingClass == "Lokhttp3/HttpUrl${"$"}Builder;" && reference.parameterTypes.firstOrNull() == "Ljava/lang/String;" } @@ -103,7 +101,7 @@ val changeLyricsProviderPatch = bytecodePatch( getLyricsHttpClientMethod.apply { val getLyricsHttpClientIndex = indexOfFirstInstructionOrThrow { - getReference() == httpClientBuilderMethod + methodReference == httpClientBuilderMethod } val getLyricsHttpClientInstruction = getInstruction(getLyricsHttpClientIndex) diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/Fingerprints.kt index ee60ea884f..a681ebdbaa 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/Fingerprints.kt @@ -1,12 +1,7 @@ package app.revanced.patches.spotify.misc.lyrics import app.revanced.patcher.gettingFirstImmutableMethod -import app.revanced.patcher.gettingFirstImmutableMethodDeclaratively -import app.revanced.patcher.parameterTypes import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType -import app.revanced.util.getReference -import app.revanced.util.indexOfFirstInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference + internal val BytecodePatchContext.httpClientBuilderMethod by gettingFirstImmutableMethod("client == null", "scheduler == null") diff --git a/patches/src/main/kotlin/app/revanced/patches/strava/groupkudos/AddGiveGroupKudosButtonToGroupActivityPatch.kt b/patches/src/main/kotlin/app/revanced/patches/strava/groupkudos/AddGiveGroupKudosButtonToGroupActivityPatch.kt index 9d4756f455..b789e47da7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/strava/groupkudos/AddGiveGroupKudosButtonToGroupActivityPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/strava/groupkudos/AddGiveGroupKudosButtonToGroupActivityPatch.kt @@ -4,12 +4,12 @@ import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Compan import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.instructions +import app.revanced.patcher.extensions.typeReference import app.revanced.patcher.immutableClassDef import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.resourcePatch import app.revanced.util.childElementsSequence import app.revanced.util.findElementByAttributeValueOrThrow -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.AccessFlags.* import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation @@ -18,7 +18,6 @@ import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction31i import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction -import com.android.tools.smali.dexlib2.iface.reference.TypeReference import com.android.tools.smali.dexlib2.immutable.ImmutableClassDef import com.android.tools.smali.dexlib2.immutable.ImmutableField import com.android.tools.smali.dexlib2.immutable.ImmutableMethod @@ -115,7 +114,7 @@ val addGiveGroupKudosButtonToGroupActivityPatch = bytecodePatch( val checkCastButtonInstruction = getInstruction(constLeaveIdInstruction.location.index + 3) - val buttonClassName = checkCastButtonInstruction.getReference()!!.type + val buttonClassName = checkCastButtonInstruction.typeReference!!.type addInstructions( constLeaveIdInstruction.location.index, diff --git a/patches/src/main/kotlin/app/revanced/patches/strava/media/download/AddMediaDownloadPatch.kt b/patches/src/main/kotlin/app/revanced/patches/strava/media/download/AddMediaDownloadPatch.kt index a3905c139a..e295a45e6e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/strava/media/download/AddMediaDownloadPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/strava/media/download/AddMediaDownloadPatch.kt @@ -4,19 +4,18 @@ import app.revanced.patcher.extensions.ExternalLabel import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.instructions +import app.revanced.patcher.extensions.typeReference import app.revanced.patcher.firstImmutableClassDef import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.shared.misc.mapping.ResourceType import app.revanced.patches.shared.misc.mapping.resourceMappingPatch import app.revanced.patches.strava.misc.extension.sharedExtensionPatch -import app.revanced.util.getReference import app.revanced.util.writeRegister import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction22c -import com.android.tools.smali.dexlib2.iface.reference.FieldReference -import com.android.tools.smali.dexlib2.iface.reference.TypeReference private const val ACTION_CLASS_DESCRIPTOR = "Lcom/strava/bottomsheet/Action;" private const val MEDIA_CLASS_DESCRIPTOR = "Lcom/strava/photos/data/Media;" @@ -45,7 +44,7 @@ val addMediaDownloadPatch = bytecodePatch( } val actionRegistrarRegister = getInstruction(setTrueIndex).registerB val actionRegister = instructions.first { instruction -> - instruction.getReference()?.type == ACTION_CLASS_DESCRIPTOR + instruction.typeReference?.type == ACTION_CLASS_DESCRIPTOR }.writeRegister!! fun addMenuItem(actionId: String, string: String, color: String, drawable: String) = addInstructions( @@ -74,7 +73,7 @@ val addMediaDownloadPatch = bytecodePatch( // Move media to last parameter of `Action` constructor. val getMediaInstruction = instructions.first { instruction -> - instruction.getReference()?.type == MEDIA_CLASS_DESCRIPTOR + instruction.fieldReference?.type == MEDIA_CLASS_DESCRIPTOR } addInstruction( getMediaInstruction.location.index + 1, diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt index 3150c6a190..75b3a4d906 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt @@ -6,11 +6,9 @@ import app.revanced.patches.tiktok.misc.extension.sharedExtensionPatch import app.revanced.patches.tiktok.misc.settings.settingsPatch import app.revanced.patches.tiktok.misc.settings.settingsStatusLoadMethod import app.revanced.util.findInstructionIndicesReversedOrThrow -import app.revanced.util.getReference import app.revanced.util.returnEarly import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/tiktok/download/DownloadsPatch;" @@ -50,7 +48,7 @@ val downloadsPatch = bytecodePatch( // Change the download path patch. downloadUriMethod.apply { findInstructionIndicesReversedOrThrow { - getReference().let { + fieldReference.let { it?.definingClass == "Landroid/os/Environment;" && it.name.startsWith("DIRECTORY_") } }.forEach { fieldIndex -> diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt index 9ad16de080..738eab47ec 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt @@ -4,15 +4,13 @@ import app.revanced.patcher.classDef import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction -import app.revanced.patcher.firstClassDef +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.tiktok.shared.getEnterFromMethod import app.revanced.patches.tiktok.shared.onRenderFirstFrameMethod -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.returnEarly import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction11x -import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Suppress("unused") val playbackSpeedPatch = bytecodePatch( @@ -28,7 +26,7 @@ val playbackSpeedPatch = bytecodePatch( apply { getSpeedMethod.apply { val injectIndex = - indexOfFirstInstructionOrThrow { getReference()?.returnType == "F" } + 2 + indexOfFirstInstructionOrThrow { methodReference?.returnType == "F" } + 2 val register = getInstruction(injectIndex - 1).registerA addInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt index da6e6aaacc..c81fbc61ad 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt @@ -2,10 +2,10 @@ package app.revanced.patches.tiktok.misc.share import app.revanced.patcher.extensions.addInstructionsWithLabels import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.tiktok.misc.extension.sharedExtensionPatch import app.revanced.util.findFreeRegister -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @@ -30,7 +30,7 @@ val sanitizeSharingLinksPatch = bytecodePatch( apply { urlShorteningMethod.apply { val invokeIndex = indexOfFirstInstructionOrThrow { - val reference = getReference() + val reference = methodReference reference?.name == "LIZ" && reference.definingClass.startsWith("LX/") } @@ -43,7 +43,7 @@ val sanitizeSharingLinksPatch = bytecodePatch( .reference.toString() val observableFactoryIndex = indexOfFirstInstructionOrThrow { - val ref = getReference() + val ref = methodReference ref?.name == "LJ" && ref.definingClass.startsWith("LX/") } val observableFactoryRef = getInstruction(observableFactoryIndex) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt index 208151e344..560de817b4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt @@ -14,10 +14,8 @@ import app.revanced.patches.youtube.misc.playservice.versionCheckPatch import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch import app.revanced.util.findInstructionIndicesReversed -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/SlideToSeekPatch;" @@ -45,7 +43,7 @@ val enableSlideToSeekPatch = bytecodePatch( val checkIndex = slideToSeekMethodMatch[0] val checkReference = slideToSeekMethodMatch.method.getInstruction(checkIndex) - .getReference()!! + .methodReference!! val extensionMethodDescriptor = "$EXTENSION_CLASS_DESCRIPTOR->isSlideToSeekDisabled(Z)Z" diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableTapToSeekPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableTapToSeekPatch.kt index 610d923c26..d96878c680 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableTapToSeekPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableTapToSeekPatch.kt @@ -3,6 +3,7 @@ package app.revanced.patches.youtube.interaction.seekbar import app.revanced.patcher.extensions.ExternalLabel import app.revanced.patcher.extensions.addInstructionsWithLabels import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch @@ -12,8 +13,6 @@ import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch import app.revanced.util.findFreeRegister import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/TapToSeekPatch;" @@ -35,8 +34,7 @@ val enableTapToSeekPatch = bytecodePatch( // Find the required methods to tap the seekbar. val tapToSeekMethods = onTouchEventHandlerMethodMatch.let { - fun getReference(index: Int) = it.method.getInstruction(index) - .reference as MethodReference + fun getReference(index: Int) = it.method.getInstruction(index).methodReference!! listOf( getReference(it[0]), diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationBarPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationBarPatch.kt index 64df88bb37..3121a666f6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationBarPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationBarPatch.kt @@ -26,13 +26,11 @@ import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch import app.revanced.util.addInstructionsAtControlFlowLabel import app.revanced.util.findInstructionIndicesReversedOrThrow -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.insertLiteralOverride import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import kotlin.collections.plusAssign private const val EXTENSION_CLASS_DESCRIPTOR = @@ -235,7 +233,7 @@ val navigationBarPatch = bytecodePatch( // Fix missing left padding when using wide searchbar. wideSearchbarLayoutMethod.apply { findInstructionIndicesReversedOrThrow { - val reference = getReference() + val reference = methodReference reference?.definingClass == "Landroid/view/LayoutInflater;" && reference.name == "inflate" }.forEach { inflateIndex -> val register = diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt index 2af8a1177a..8768e09781 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt @@ -17,12 +17,11 @@ import app.revanced.util.* import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/HidePlayerOverlayButtonsPatch;" -@Suppress("ObjectPropertyName") +@Suppress("unused") val hidePlayerOverlayButtonsPatch = bytecodePatch( name = "Hide player overlay buttons", description = "Adds options to hide the player Cast, Autoplay, Captions, Previous & Next buttons, and the player " + @@ -121,7 +120,7 @@ val hidePlayerOverlayButtonsPatch = bytecodePatch( // Add a conditional branch around the code that inflates and adds the auto-repeat button. val gotoIndex = indexOfFirstInstructionOrThrow(constIndex) { - val parameterTypes = getReference()?.parameterTypes + val parameterTypes = methodReference?.parameterTypes opcode == Opcode.INVOKE_VIRTUAL && parameterTypes?.size == 2 && parameterTypes.first() == "Landroid/view/ViewStub;" diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt index 00cf27fe76..bb9aaa39d1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt @@ -2,6 +2,7 @@ package app.revanced.patches.youtube.layout.hide.fullscreenambientmode import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch @@ -9,10 +10,8 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionReversedOrThrow import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/DisableFullscreenAmbientModePatch;" @@ -51,7 +50,7 @@ val disableFullscreenAmbientModePatch = bytecodePatch( setFullScreenBackgroundColorMethod.apply { val insertIndex = indexOfFirstInstructionReversedOrThrow { - getReference()?.name == "setBackgroundColor" + methodReference?.name == "setBackgroundColor" } val register = getInstruction(insertIndex).registerD diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt index ea7fd4c919..9c8b2f15fb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt @@ -21,7 +21,6 @@ import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch import app.revanced.util.findFreeRegister import app.revanced.util.findInstructionIndicesReversedOrThrow -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionReversedOrThrow import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode @@ -31,7 +30,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter @@ -489,7 +487,7 @@ val hideLayoutComponentsPatch = hideLayoutComponentsPatch( yoodlesImageViewMethod.apply { findInstructionIndicesReversedOrThrow { - getReference()?.name == "setImageDrawable" + methodReference?.name == "setImageDrawable" }.forEach { insertIndex -> val drawableRegister = getInstruction(insertIndex).registerD val imageViewRegister = getInstruction(insertIndex).registerC @@ -512,7 +510,7 @@ val hideLayoutComponentsPatch = hideLayoutComponentsPatch( // Find the instruction where the text dimension is retrieved. val applyDimensionIndex = indexOfFirstInstructionReversedOrThrow { - val reference = getReference() + val reference = methodReference opcode == Opcode.INVOKE_STATIC && reference?.definingClass == "Landroid/util/TypedValue;" && reference.returnType == "F" && diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt index 0ef561d714..1b6cc63117 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt @@ -7,7 +7,9 @@ import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Compan import app.revanced.patcher.classDef import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.immutableClassDef import app.revanced.patcher.patch.bytecodePatch @@ -29,8 +31,6 @@ import com.android.tools.smali.dexlib2.iface.ClassDef import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter @@ -269,7 +269,7 @@ val miniplayerPatch = bytecodePatch( it.apply { if (AccessFlags.CONSTRUCTOR.isSet(accessFlags)) { val iPutIndex = indexOfFirstInstructionOrThrow { - this.opcode == Opcode.IPUT && this.getReference()?.type == "I" + this.opcode == Opcode.IPUT && this.fieldReference?.type == "I" } insertModernMiniplayerTypeOverride(iPutIndex) @@ -394,7 +394,7 @@ val miniplayerPatch = bytecodePatch( if (is_20_31_or_greater) { miniplayerSetIconsMethod.apply { findInstructionIndicesReversedOrThrow { - val reference = getReference() + val reference = methodReference opcode == Opcode.INVOKE_INTERFACE && reference?.returnType == "Z" && reference.parameterTypes.isEmpty() }.forEach { index -> diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt index 801fc83880..6709ae898d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt @@ -5,6 +5,7 @@ import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Compan import app.revanced.patcher.* import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.shared.layout.theme.lithoColorHookPatch @@ -18,14 +19,12 @@ import app.revanced.patches.youtube.misc.playservice.is_21_02_or_greater import app.revanced.patches.youtube.misc.playservice.versionCheckPatch import app.revanced.patches.youtube.shared.mainActivityOnCreateMethod import app.revanced.util.findInstructionIndicesReversedOrThrow -import app.revanced.util.getReference import app.revanced.util.insertLiteralOverride import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter @@ -158,7 +157,7 @@ val seekbarColorPatch = bytecodePatch( val setAnimationIntMethodName = lottieAnimationViewSetAnimationIntMethod.name findInstructionIndicesReversedOrThrow { - val reference = getReference() + val reference = methodReference reference?.definingClass == LOTTIE_ANIMATION_VIEW_CLASS_TYPE && reference.name == setAnimationIntMethodName }.forEach { index -> diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt index 63fa21a216..caf2e6f0e2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt @@ -5,6 +5,7 @@ import app.revanced.patcher.classDef import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.immutableClassDef @@ -20,22 +21,19 @@ import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch import app.revanced.patches.youtube.shared.mainActivityOnCreateMethod import app.revanced.util.findInstructionIndicesReversedOrThrow -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/ShortsAutoplayPatch;" -@Suppress("ObjectPropertyName") +@Suppress("unused") val shortsAutoplayPatch = bytecodePatch( name = "Shorts autoplay", description = "Adds options to automatically play the next Short.", @@ -99,7 +97,7 @@ val shortsAutoplayPatch = bytecodePatch( reelPlaybackRepeatMethod.apply { // The behavior enums are looked up from an ordinal value to an enum type. findInstructionIndicesReversedOrThrow { - val reference = getReference() + val reference = methodReference reference?.definingClass == reelEnumClass && reference.parameterTypes.firstOrNull() == "I" && reference.returnType == reelEnumClass @@ -129,12 +127,12 @@ val shortsAutoplayPatch = bytecodePatch( // Find the first call modified by extension code above. val extensionReturnResultIndex = indexOfFirstInstructionOrThrow { opcode == Opcode.INVOKE_STATIC && - getReference()?.definingClass == EXTENSION_CLASS_DESCRIPTOR + methodReference?.definingClass == EXTENSION_CLASS_DESCRIPTOR } + 1 val enumRegister = getInstruction(extensionReturnResultIndex).registerA val getReelSequenceControllerIndex = indexOfFirstInstructionOrThrow { - val reference = getReference() + val reference = fieldReference opcode == Opcode.IGET_OBJECT && reference?.definingClass == definingClass && reference.type == reelSequenceControllerMethodReference.definingClass diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt index 518902cab2..ed706d3311 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt @@ -24,13 +24,11 @@ import app.revanced.patches.youtube.shared.mainActivityOnCreateMethod import app.revanced.patches.youtube.video.information.playbackStartDescriptorToStringMethodMatch import app.revanced.util.addInstructionsAtControlFlowLabel import app.revanced.util.findInstructionIndicesReversedOrThrow -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstInstructionReversedOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch;" @@ -149,14 +147,14 @@ val openShortsInRegularPlayerPatch = bytecodePatch( // Method call for Activity.finish() val finishIndexFirst = indexOfFirstInstructionOrThrow { - val reference = getReference() + val reference = methodReference reference?.name == "finish" } // Second Activity.finish() call. Has been present since 19.x but started // to interfere with back to exit fullscreen around 20.47. val finishIndexSecond = indexOfFirstInstruction(finishIndexFirst + 1) { - val reference = getReference() + val reference = methodReference reference?.name == "finish" } val getBooleanFieldIndex = indexOfFirstInstructionReversedOrThrow(finishIndexSecond) { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt index 41c049d821..a59fda9908 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt @@ -2,7 +2,9 @@ package app.revanced.patches.youtube.layout.sponsorblock import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.immutableClassDef import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.resourcePatch @@ -33,7 +35,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.reference.FieldReference -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private val sponsorBlockResourcePatch = resourcePatch { dependsOn( @@ -157,7 +158,7 @@ val sponsorBlockPatch = bytecodePatch( val rectangleIndex = indexOfFirstInstructionReversedOrThrow( it[0], ) { - getReference()?.type == "Landroid/graphics/Rect;" + fieldReference?.type == "Landroid/graphics/Rect;" } rectangleFieldName = getInstruction(rectangleIndex).reference as FieldReference @@ -182,7 +183,7 @@ val sponsorBlockPatch = bytecodePatch( // Find the drawCircle call and draw the segment before it. val drawCircleIndex = indexOfFirstInstructionReversedOrThrow { - getReference()?.name == "drawCircle" + methodReference?.name == "drawCircle" } val drawCircleInstruction = getInstruction(drawCircleIndex) val canvasInstanceRegister = drawCircleInstruction.registerC diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt index c727aa8267..c7887afad1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt @@ -2,6 +2,7 @@ package app.revanced.patches.youtube.layout.startupshortsreset import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch @@ -14,11 +15,9 @@ import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch import app.revanced.util.addInstructionsAtControlFlowLabel import app.revanced.util.findFreeRegister -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/DisableResumingStartupShortsPlayerPatch;" @@ -78,8 +77,8 @@ val disableResumingShortsOnStartupPatch = bytecodePatch( userWasInShortsLegacyMethod.apply { val listenableInstructionIndex = indexOfFirstInstructionOrThrow { opcode == Opcode.INVOKE_INTERFACE && - getReference()?.definingClass == "Lcom/google/common/util/concurrent/ListenableFuture;" && - getReference()?.name == "isDone" + methodReference?.definingClass == "Lcom/google/common/util/concurrent/ListenableFuture;" && + methodReference?.name == "isDone" } val freeRegister = findFreeRegister(listenableInstructionIndex) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/toolbar/ToolbarHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/toolbar/ToolbarHookPatch.kt index b01a440873..1c266dde71 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/toolbar/ToolbarHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/toolbar/ToolbarHookPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.toolbar import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.shared.misc.mapping.resourceMappingPatch import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.shared.getToolBarButtonMethodMatch import app.revanced.util.findFreeRegister -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstInstructionReversedOrThrow @@ -17,7 +17,6 @@ import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/ToolbarPatch;" @@ -33,14 +32,14 @@ val toolbarHookPatch = bytecodePatch { fun indexOfGetDrawableInstruction(method: Method) = method.indexOfFirstInstruction { opcode == Opcode.INVOKE_VIRTUAL && - getReference()?.toString() == "Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;" + methodReference?.toString() == "Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;" } getToolBarButtonMethodMatch().method.apply { val getDrawableIndex = indexOfGetDrawableInstruction(this) val enumOrdinalIndex = indexOfFirstInstructionReversedOrThrow(getDrawableIndex) { opcode == Opcode.INVOKE_INTERFACE && - getReference()?.returnType == "I" + methodReference?.returnType == "I" } val replaceReference = getInstruction(enumOrdinalIndex).reference val replaceRegister = getInstruction(enumOrdinalIndex).registerC diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt index 6f4944eaa4..a9c3489a25 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt @@ -2,6 +2,7 @@ package app.revanced.patches.youtube.misc.backgroundplayback import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.instructions +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch @@ -20,7 +21,6 @@ import app.revanced.patches.youtube.video.information.videoInformationPatch import app.revanced.util.* import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference internal var prefBackgroundAndOfflineCategoryId = -1L private set @@ -86,7 +86,7 @@ val removeBackgroundPlaybackRestrictionsPatch = bytecodePatch( // Enable background playback option in YouTube settings backgroundPlaybackSettingsMethod.apply { val booleanCalls = instructions.withIndex().filter { - it.value.getReference()?.returnType == "Z" + it.value.methodReference?.returnType == "Z" } val settingsBooleanIndex = booleanCalls.elementAt(1).index diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/engagement/EngagementPanelHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/engagement/EngagementPanelHookPatch.kt index dc274c3b64..b0f49d64db 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/engagement/EngagementPanelHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/engagement/EngagementPanelHookPatch.kt @@ -9,9 +9,7 @@ import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.shared.getEngagementPanelControllerMethodMatch -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference import kotlin.properties.Delegates private const val EXTENSION_CLASS_DESCRIPTOR = diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt index a8615c1d50..75b6cea642 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt @@ -1,13 +1,12 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.youtube.shared.mainActivityOnBackPressedMethod import app.revanced.util.addInstructionsAtControlFlowLabel -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/FixBackToExitGesturePatch;" @@ -26,7 +25,7 @@ internal val fixBackToExitGesturePatch = bytecodePatch( with(scrollPositionMethodMatch) { navigate(immutableMethod).to(scrollPositionMethodMatch[0] + 1).stop().apply { val index = indexOfFirstInstructionOrThrow { - opcode == Opcode.INVOKE_VIRTUAL && getReference()?.definingClass == + opcode == Opcode.INVOKE_VIRTUAL && methodReference?.definingClass == "Landroid/support/v7/widget/RecyclerView;" } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playbackspeed/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playbackspeed/Fingerprints.kt index 728ad0fef0..860617bd6f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playbackspeed/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playbackspeed/Fingerprints.kt @@ -2,18 +2,16 @@ package app.revanced.patches.youtube.misc.fix.playbackspeed import app.revanced.patcher.accessFlags import app.revanced.patcher.custom -import app.revanced.patcher.gettingFirstImmutableMethodDeclaratively +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.gettingFirstMethodDeclaratively import app.revanced.patcher.opcodes import app.revanced.patcher.parameterTypes import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.returnType -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionReversed import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.Method -import com.android.tools.smali.dexlib2.iface.reference.FieldReference /** * This method is usually used to set the initial speed (1.0x) when playback starts from the feed. @@ -40,5 +38,5 @@ internal val BytecodePatchContext.playbackSpeedInFeedsMethod by gettingFirstMeth internal fun indexOfGetPlaybackSpeedInstruction(method: Method) = method.indexOfFirstInstructionReversed { opcode == Opcode.IGET && - getReference()?.type == "F" + fieldReference?.type == "F" } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt index f1d569e459..9144593e02 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt @@ -5,11 +5,11 @@ import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Compan import app.revanced.patcher.classDef import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.instructions import app.revanced.patcher.immutableClassDef import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation @@ -40,7 +40,7 @@ val cronetImageURLHookPatch = bytecodePatch( // The URL is required for the failure callback hook, but the URL field is obfuscated. // Add a helper get method that returns the URL field. val urlFieldInstruction = requestMethod.instructions.first { - val reference = it.getReference() + val reference = it.fieldReference it.opcode == Opcode.IPUT_OBJECT && reference?.type == "Ljava/lang/String;" } as ReferenceInstruction diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt index 705539bd40..290439908b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt @@ -7,6 +7,7 @@ import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.instructions +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.reference import app.revanced.patcher.immutableClassDef import app.revanced.patcher.patch.PatchException @@ -20,19 +21,14 @@ import app.revanced.patches.youtube.shared.mainActivityOnBackPressedMethod import app.revanced.util.ResourceGroup import app.revanced.util.copyResources import app.revanced.util.findFreeRegister -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.Instruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction31i -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.util.MethodUtil -import java.util.logging.Logger internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/shared/NavigationBar;" @@ -84,14 +80,14 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig val navigationEnumClassName = navigationEnumMethod.classDef.type addHook(NavigationHook.SET_LAST_APP_NAVIGATION_ENUM) { opcode == Opcode.INVOKE_STATIC && - getReference()?.definingClass == navigationEnumClassName + methodReference?.definingClass == navigationEnumClassName } // Hook the creation of navigation tab views. val drawableTabMethod = pivotBarButtonsCreateDrawableViewMethod addHook(NavigationHook.NAVIGATION_TAB_LOADED) predicate@{ MethodUtil.methodSignaturesMatch( - getReference() ?: return@predicate false, + methodReference ?: return@predicate false, drawableTabMethod, ) } @@ -99,7 +95,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig if (is_20_21_or_greater && !is_20_28_or_greater) { addHook(NavigationHook.NAVIGATION_TAB_LOADED) predicate@{ MethodUtil.methodSignaturesMatch( - getReference() ?: return@predicate false, + methodReference ?: return@predicate false, pivotBarButtonsCreateResourceIntViewMethod, ) } @@ -107,7 +103,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig addHook(NavigationHook.NAVIGATION_IMAGE_RESOURCE_TAB_LOADED) predicate@{ MethodUtil.methodSignaturesMatch( - getReference() ?: return@predicate false, + methodReference ?: return@predicate false, pivotBarButtonsCreateResourceStyledViewMethod, ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/codecs/DisableVideoCodecsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/codecs/DisableVideoCodecsPatch.kt index 7e3360dde0..691426ed92 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/codecs/DisableVideoCodecsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/codecs/DisableVideoCodecsPatch.kt @@ -1,6 +1,7 @@ package app.revanced.patches.youtube.video.codecs import app.revanced.patcher.extensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources @@ -10,9 +11,7 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch -import app.revanced.util.getReference import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/DisableVideoCodecsPatch;" @@ -35,7 +34,7 @@ val disableVideoCodecsPatch = bytecodePatch( return@filterMap null } - val reference = instruction.getReference() + val reference = instruction.methodReference if (reference?.definingClass == "Landroid/view/Display\$HdrCapabilities;" && reference.name == "getSupportedHdrTypes") { return@filterMap instruction to instructionIndex } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt index 26117af4df..ab86563445 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt @@ -23,7 +23,6 @@ import app.revanced.patches.youtube.video.videoid.hookVideoId import app.revanced.patches.youtube.video.videoid.videoIdPatch import app.revanced.util.addInstructionsAtControlFlowLabel import app.revanced.util.addStaticFieldToExtension -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.patcher.patch.PatchException import com.android.tools.smali.dexlib2.AccessFlags @@ -105,7 +104,7 @@ val videoInformationPatch = bytecodePatch( // Find the location of the first invoke-direct call // and extract the register storing the 'this' object reference. val initThisIndex = playerInitMethod.indexOfFirstInstructionOrThrow { - opcode == Opcode.INVOKE_DIRECT && getReference()?.name == "" + opcode == Opcode.INVOKE_DIRECT && methodReference?.name == "" } playerInitInsertRegister = playerInitMethod.getInstruction(initThisIndex).registerC @@ -123,7 +122,7 @@ val videoInformationPatch = bytecodePatch( mdxInitMethod = classDef.methods.first { MethodUtil.isConstructor(it) } val initThisIndex = mdxInitMethod.indexOfFirstInstructionOrThrow { - opcode == Opcode.INVOKE_DIRECT && getReference()?.name == "" + opcode == Opcode.INVOKE_DIRECT && methodReference?.name == "" } mdxInitInsertRegister = mdxInitMethod.getInstruction(initThisIndex).registerC @@ -201,7 +200,7 @@ val videoInformationPatch = bytecodePatch( setPlaybackSpeedMethodReference = getInstruction( indexOfFirstInstructionOrThrow(speedSelectionValueInstructionIndex) { - val reference = getReference() + val reference = methodReference reference?.parameterTypes?.size == 1 && reference.parameterTypes.first() == "F" } ).reference as MethodReference @@ -231,7 +230,7 @@ val videoInformationPatch = bytecodePatch( setPlaybackSpeedClassFieldReference = getInstruction( indexOfFirstInstructionOrThrow(speedSelectionValueInstructionIndex) { - getReference()?.type?.startsWith("L") == true + fieldReference?.type?.startsWith("L") == true } ).reference as FieldReference @@ -398,7 +397,6 @@ val videoInformationPatch = bytecodePatch( // Detect video quality changes and override the current quality. videoQualitySetterMethod.immutableClassDef.getSetVideoQualityMethod().let { - it // This instruction refers to the field with the type that contains the setQuality method. val onItemClickListenerClassReference = it.getInstruction(0).reference diff --git a/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt b/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt index 5694608dfe..775189b74a 100644 --- a/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt +++ b/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt @@ -21,9 +21,7 @@ import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.MethodParameter import com.android.tools.smali.dexlib2.iface.instruction.* import com.android.tools.smali.dexlib2.iface.reference.FieldReference -import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.iface.reference.Reference -import com.android.tools.smali.dexlib2.iface.reference.StringReference import com.android.tools.smali.dexlib2.iface.value.* import com.android.tools.smali.dexlib2.immutable.ImmutableField import com.android.tools.smali.dexlib2.immutable.ImmutableMethod @@ -40,7 +38,7 @@ import kotlin.collections.remove */ private fun Method.findInstructionIndexFromToString(fieldName: String): Int { val stringIndex = indexOfFirstInstruction { - val reference = getReference() + val reference = stringReference reference?.string?.contains(fieldName) == true } if (stringIndex < 0) { @@ -50,7 +48,7 @@ private fun Method.findInstructionIndexFromToString(fieldName: String): Int { // Find use of the string with a StringBuilder. val stringUsageIndex = indexOfFirstInstruction(stringIndex) { - val reference = getReference() + val reference = methodReference reference?.definingClass == "Ljava/lang/StringBuilder;" && (this as? FiveRegisterInstruction)?.registerD == stringRegister } @@ -60,7 +58,7 @@ private fun Method.findInstructionIndexFromToString(fieldName: String): Int { // Find the next usage of StringBuilder, which should be the desired field. val fieldUsageIndex = indexOfFirstInstruction(stringUsageIndex + 1) { - val reference = getReference() + val reference = methodReference reference?.definingClass == "Ljava/lang/StringBuilder;" && reference.name == "append" } if (fieldUsageIndex < 0) { @@ -104,7 +102,7 @@ internal fun Method.findMethodFromToString(fieldName: String): MutableMethod { */ internal fun Method.findFieldFromToString(fieldName: String): FieldReference { val methodUsageIndex = findInstructionIndexFromToString(fieldName) - return getInstruction(methodUsageIndex).getReference()!! + return getInstruction(methodUsageIndex).fieldReference!! } /** @@ -380,6 +378,8 @@ fun BytecodePatchContext.traverseClassHierarchy(targetClass: MutableClassDef, ca * if the [Instruction] is not a [ReferenceInstruction] or the [Reference] is not of type [T]. * @see ReferenceInstruction */ +@Deprecated("Instead use `methodReference`, `fieldReference`, `typeReference` or `stringReference`") +@Suppress("unused") inline fun Instruction.getReference() = (this as? ReferenceInstruction)?.reference as? T /** diff --git a/patches/src/main/kotlin/app/revanced/util/FreeRegisterProvider.kt b/patches/src/main/kotlin/app/revanced/util/FreeRegisterProvider.kt index c309e05368..b2dc14bccb 100644 --- a/patches/src/main/kotlin/app/revanced/util/FreeRegisterProvider.kt +++ b/patches/src/main/kotlin/app/revanced/util/FreeRegisterProvider.kt @@ -2,6 +2,7 @@ package app.revanced.util import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.instructions +import app.revanced.patcher.extensions.reference import app.revanced.util.FreeRegisterProvider.Companion.conditionalBranchOpcodes import app.revanced.util.FreeRegisterProvider.Companion.logFreeRegisterSearch import app.revanced.util.FreeRegisterProvider.Companion.returnOpcodes @@ -345,7 +346,7 @@ private fun Method.findFreeRegistersInternal( // If it appears more than once, it's also read. if (occurrences <= 1) { if (logFreeRegisterSearch) println("Found free register at $i: $writeRegister " + - "opcode: " + instruction.opcode + " reference: " + (instruction.getReference())) + "opcode: " + instruction.opcode + " reference: " + (instruction.reference)) freeRegisters.add(writeRegister) // If the requested number of free registers is found and this is not a branch, // then no additional searching is needed. From f4b2545742e0501ab252c70654993a4e4414319e Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 20 Mar 2026 23:42:06 +0100 Subject: [PATCH 05/12] fix(Twitter): Correct extension path to fix crashes --- .../twitter/patches/hook/json/BaseJsonHook.kt | 0 .../twitter/patches/hook/json/JsonHook.kt | 0 .../patches/hook/json/JsonHookPatch.kt | 0 .../twitter/patches/hook/patch/Hook.kt | 0 .../patches/hook/patch/ads/HideAdsHook.kt | 0 .../patches/hook/patch/dummy/DummyHook.kt | 0 .../recommendation/RecommendedUsersHook.kt | 0 .../patches/hook/twifucker/TwiFucker.kt | 0 .../patches/hook/twifucker/TwiFuckerUtils.kt | 0 .../links/ChangeLinkSharingDomainPatch.java | 2 +- .../twitter/utils/json/JsonUtils.kt | 0 .../twitter/utils/stream/StreamUtils.kt | 0 .../links/OpenLinksWithAppChooserPatch.java | 22 ------------------- .../links/ChangeLinkSharingDomainPatch.kt | 2 +- 14 files changed, 2 insertions(+), 24 deletions(-) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/patches/hook/json/BaseJsonHook.kt (100%) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/patches/hook/json/JsonHook.kt (100%) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/patches/hook/json/JsonHookPatch.kt (100%) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/patches/hook/patch/Hook.kt (100%) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/patches/hook/patch/ads/HideAdsHook.kt (100%) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/patches/hook/patch/dummy/DummyHook.kt (100%) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/patches/hook/patch/recommendation/RecommendedUsersHook.kt (100%) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/patches/hook/twifucker/TwiFucker.kt (100%) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/patches/hook/twifucker/TwiFuckerUtils.kt (100%) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/patches/links/ChangeLinkSharingDomainPatch.java (94%) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/utils/json/JsonUtils.kt (100%) rename extensions/twitter/src/main/java/app/revanced/{ => extension}/twitter/utils/stream/StreamUtils.kt (100%) delete mode 100644 extensions/twitter/src/main/java/app/revanced/twitter/patches/links/OpenLinksWithAppChooserPatch.java diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/json/BaseJsonHook.kt b/extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/json/BaseJsonHook.kt similarity index 100% rename from extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/json/BaseJsonHook.kt rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/json/BaseJsonHook.kt diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/json/JsonHook.kt b/extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/json/JsonHook.kt similarity index 100% rename from extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/json/JsonHook.kt rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/json/JsonHook.kt diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/json/JsonHookPatch.kt b/extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/json/JsonHookPatch.kt similarity index 100% rename from extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/json/JsonHookPatch.kt rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/json/JsonHookPatch.kt diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/patch/Hook.kt b/extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/patch/Hook.kt similarity index 100% rename from extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/patch/Hook.kt rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/patch/Hook.kt diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/patch/ads/HideAdsHook.kt b/extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/patch/ads/HideAdsHook.kt similarity index 100% rename from extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/patch/ads/HideAdsHook.kt rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/patch/ads/HideAdsHook.kt diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/patch/dummy/DummyHook.kt b/extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/patch/dummy/DummyHook.kt similarity index 100% rename from extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/patch/dummy/DummyHook.kt rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/patch/dummy/DummyHook.kt diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/patch/recommendation/RecommendedUsersHook.kt b/extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/patch/recommendation/RecommendedUsersHook.kt similarity index 100% rename from extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/patch/recommendation/RecommendedUsersHook.kt rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/patch/recommendation/RecommendedUsersHook.kt diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/twifucker/TwiFucker.kt b/extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/twifucker/TwiFucker.kt similarity index 100% rename from extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/twifucker/TwiFucker.kt rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/twifucker/TwiFucker.kt diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/twifucker/TwiFuckerUtils.kt b/extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/twifucker/TwiFuckerUtils.kt similarity index 100% rename from extensions/twitter/src/main/java/app/revanced/twitter/patches/hook/twifucker/TwiFuckerUtils.kt rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/hook/twifucker/TwiFuckerUtils.kt diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/patches/links/ChangeLinkSharingDomainPatch.java b/extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/links/ChangeLinkSharingDomainPatch.java similarity index 94% rename from extensions/twitter/src/main/java/app/revanced/twitter/patches/links/ChangeLinkSharingDomainPatch.java rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/links/ChangeLinkSharingDomainPatch.java index 0be07403bc..3eb477e127 100644 --- a/extensions/twitter/src/main/java/app/revanced/twitter/patches/links/ChangeLinkSharingDomainPatch.java +++ b/extensions/twitter/src/main/java/app/revanced/extension/twitter/patches/links/ChangeLinkSharingDomainPatch.java @@ -1,4 +1,4 @@ -package app.revanced.twitter.patches.links; +package app.revanced.extension.twitter.patches.links; @SuppressWarnings("unused") public final class ChangeLinkSharingDomainPatch { diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/utils/json/JsonUtils.kt b/extensions/twitter/src/main/java/app/revanced/extension/twitter/utils/json/JsonUtils.kt similarity index 100% rename from extensions/twitter/src/main/java/app/revanced/twitter/utils/json/JsonUtils.kt rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/utils/json/JsonUtils.kt diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/utils/stream/StreamUtils.kt b/extensions/twitter/src/main/java/app/revanced/extension/twitter/utils/stream/StreamUtils.kt similarity index 100% rename from extensions/twitter/src/main/java/app/revanced/twitter/utils/stream/StreamUtils.kt rename to extensions/twitter/src/main/java/app/revanced/extension/twitter/utils/stream/StreamUtils.kt diff --git a/extensions/twitter/src/main/java/app/revanced/twitter/patches/links/OpenLinksWithAppChooserPatch.java b/extensions/twitter/src/main/java/app/revanced/twitter/patches/links/OpenLinksWithAppChooserPatch.java deleted file mode 100644 index bd0476d8b2..0000000000 --- a/extensions/twitter/src/main/java/app/revanced/twitter/patches/links/OpenLinksWithAppChooserPatch.java +++ /dev/null @@ -1,22 +0,0 @@ -package app.revanced.twitter.patches.links; - -import android.content.Context; -import android.content.Intent; - -import app.revanced.extension.shared.Logger; - -@SuppressWarnings("unused") -@Deprecated(forRemoval = true) -public final class OpenLinksWithAppChooserPatch { - - /** - * Injection point. - */ - public static void openWithChooser(final Context context, final Intent intent) { - Logger.printInfo(() -> "Opening intent with chooser: " + intent); - - intent.setAction("android.intent.action.VIEW"); - - context.startActivity(Intent.createChooser(intent, null)); - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt index 77660b0118..4f8b5d7e98 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt @@ -14,7 +14,7 @@ import java.net.InetAddress import java.net.UnknownHostException import java.util.logging.Logger -internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/twitter/patches/links/ChangeLinkSharingDomainPatch;" +internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/twitter/patches/links/ChangeLinkSharingDomainPatch;" internal val domainNameOption = stringOption( default = "fxtwitter.com", From cf22240c10af12e5db645478d4b231f0840b85f0 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 20 Mar 2026 22:46:32 +0000 Subject: [PATCH 06/12] chore: Release v6.1.1-dev.2 [skip ci] ## [6.1.1-dev.2](https://github.com/ReVanced/revanced-patches/compare/v6.1.1-dev.1...v6.1.1-dev.2) (2026-03-20) ### Bug Fixes * **Twitter:** Correct extension path to fix crashes ([f4b2545](https://github.com/ReVanced/revanced-patches/commit/f4b2545742e0501ab252c70654993a4e4414319e)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ea2c0d35e..3a82dc8cec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [6.1.1-dev.2](https://github.com/ReVanced/revanced-patches/compare/v6.1.1-dev.1...v6.1.1-dev.2) (2026-03-20) + + +### Bug Fixes + +* **Twitter:** Correct extension path to fix crashes ([f4b2545](https://github.com/ReVanced/revanced-patches/commit/f4b2545742e0501ab252c70654993a4e4414319e)) + ## [6.1.1-dev.1](https://github.com/ReVanced/revanced-patches/compare/v6.1.0...v6.1.1-dev.1) (2026-03-19) diff --git a/gradle.properties b/gradle.properties index abde35e11e..ad1d86a27c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,4 +4,4 @@ org.gradle.parallel = true android.useAndroidX = true android.uniquePackageNames = false kotlin.code.style = official -version = 6.1.1-dev.1 +version = 6.1.1-dev.2 From 6cbef5a48a83e4a74de578e7d20f7d71a8b1de8e Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 20 Mar 2026 23:55:21 +0100 Subject: [PATCH 07/12] fix(GmsCore support): Correct option name --- .../revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt index 0a356a1a7c..9bc4b2b8ea 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt @@ -65,10 +65,9 @@ fun gmsCoreSupportPatch( "using a GmsCore instead of Google Play Services.", ) { val gmsCoreVendorGroupIdOption = stringOption( - key = "gmsCoreVendorGroupId", + name = "GmsCore vendor group ID", default = "app.revanced", values = mapOf("ReVanced" to "app.revanced"), - title = "GmsCore vendor group ID", description = "The vendor's group ID for GmsCore.", required = true, ) { it!!.matches(Regex(PACKAGE_NAME_REGEX_PATTERN)) } From 292728a8baddbca87993590db4a8bab60b564432 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 20 Mar 2026 23:58:18 +0100 Subject: [PATCH 08/12] fix(GmsCore support): Correct package name for custom vendor group id --- .../main/java/app/revanced/extension/shared/GmsCoreSupport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/shared/library/src/main/java/app/revanced/extension/shared/GmsCoreSupport.java b/extensions/shared/library/src/main/java/app/revanced/extension/shared/GmsCoreSupport.java index fb7e68963a..bafdc04163 100644 --- a/extensions/shared/library/src/main/java/app/revanced/extension/shared/GmsCoreSupport.java +++ b/extensions/shared/library/src/main/java/app/revanced/extension/shared/GmsCoreSupport.java @@ -105,7 +105,7 @@ public class GmsCoreSupport { return null; } }), - UNKNOWN(getGmsCoreVendorGroupId(), getGmsCoreVendorGroupId() + "android.gms", () -> null); + UNKNOWN(getGmsCoreVendorGroupId(), getGmsCoreVendorGroupId() + ".android.gms", () -> null); private static final String DONT_KILL_MY_APP_URL = "https://dontkillmyapp.com/"; From 49ee19ac7dbb870306359df896909ec5b9aeca1d Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 20 Mar 2026 23:06:21 +0000 Subject: [PATCH 09/12] chore: Release v6.1.1-dev.3 [skip ci] ## [6.1.1-dev.3](https://github.com/ReVanced/revanced-patches/compare/v6.1.1-dev.2...v6.1.1-dev.3) (2026-03-20) ### Bug Fixes * **GmsCore support:** Correct option name ([6cbef5a](https://github.com/ReVanced/revanced-patches/commit/6cbef5a48a83e4a74de578e7d20f7d71a8b1de8e)) * **GmsCore support:** Correct package name for custom vendor group id ([292728a](https://github.com/ReVanced/revanced-patches/commit/292728a8baddbca87993590db4a8bab60b564432)) --- CHANGELOG.md | 8 ++++++++ gradle.properties | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a82dc8cec..dddb0982c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [6.1.1-dev.3](https://github.com/ReVanced/revanced-patches/compare/v6.1.1-dev.2...v6.1.1-dev.3) (2026-03-20) + + +### Bug Fixes + +* **GmsCore support:** Correct option name ([6cbef5a](https://github.com/ReVanced/revanced-patches/commit/6cbef5a48a83e4a74de578e7d20f7d71a8b1de8e)) +* **GmsCore support:** Correct package name for custom vendor group id ([292728a](https://github.com/ReVanced/revanced-patches/commit/292728a8baddbca87993590db4a8bab60b564432)) + ## [6.1.1-dev.2](https://github.com/ReVanced/revanced-patches/compare/v6.1.1-dev.1...v6.1.1-dev.2) (2026-03-20) diff --git a/gradle.properties b/gradle.properties index ad1d86a27c..4c893f83f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,4 +4,4 @@ org.gradle.parallel = true android.useAndroidX = true android.uniquePackageNames = false kotlin.code.style = official -version = 6.1.1-dev.2 +version = 6.1.1-dev.3 From 4a36d1ab569201316ee3b83be9f5ab9539c3336d Mon Sep 17 00:00:00 2001 From: Sayanth <13906889+SayanthD@users.noreply.github.com> Date: Mon, 23 Mar 2026 02:30:07 +0530 Subject: [PATCH 10/12] fix(Instagram - Disable signature check): Set correct return type (#6918) --- .../patches/instagram/misc/signature/SignatureCheckPatch.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/signature/SignatureCheckPatch.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/signature/SignatureCheckPatch.kt index 3ee3f82380..972a6f6028 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/signature/SignatureCheckPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/signature/SignatureCheckPatch.kt @@ -14,6 +14,6 @@ val disableSignatureCheckPatch = bytecodePatch( compatibleWith("com.instagram.android") apply { - isValidSignatureMethodMethod.immutableClassDef.getIsValidSignatureClassMethod().returnEarly(true) + isValidSignatureMethodMethod.immutableClassDef.getIsValidSignatureClassMethod().returnEarly() } } From 77098b2c057e53f375bca8dffd369e801fdaed52 Mon Sep 17 00:00:00 2001 From: Dawid Krajcarz <80264606+drobotk@users.noreply.github.com> Date: Sun, 22 Mar 2026 22:00:42 +0100 Subject: [PATCH 11/12] fix(YouTube - Announcements): Parse announcement correctly by using `Instant` instead of `LocalDateTime` for `archived_at` (#6889) --- .../patches/announcements/AnnouncementsPatch.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/announcements/AnnouncementsPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/announcements/AnnouncementsPatch.java index 8e24d65ec5..466c87dbf0 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/announcements/AnnouncementsPatch.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/announcements/AnnouncementsPatch.java @@ -20,7 +20,7 @@ import org.json.JSONObject; import java.io.IOException; import java.net.HttpURLConnection; -import java.time.LocalDateTime; +import java.time.Instant; import app.revanced.extension.shared.Logger; import app.revanced.extension.shared.Utils; @@ -116,7 +116,7 @@ public final class AnnouncementsPatch { int id = Settings.ANNOUNCEMENT_LAST_ID.defaultValue; String title; String message; - LocalDateTime archivedAt = LocalDateTime.MAX; + Instant archivedAt = Instant.MAX; Level level = Level.INFO; try { final var announcements = new JSONArray(jsonString); @@ -140,20 +140,20 @@ public final class AnnouncementsPatch { title = announcement.getString("title"); message = announcement.getString("content"); if (!announcement.isNull("archived_at")) { - archivedAt = LocalDateTime.parse(announcement.getString("archived_at")); + archivedAt = Instant.parse(announcement.getString("archived_at")); } if (!announcement.isNull("level")) { level = Level.fromInt(announcement.getInt("level")); } } catch (Throwable ex) { - Logger.printException(() -> "Failed to parse announcement. Fall-backing to raw string", ex); + Logger.printException(() -> "Failed to parse announcement. Falling back to raw string", ex); title = "Announcement"; message = jsonString; } // If the announcement is archived, do not show it. - if (archivedAt.isBefore(LocalDateTime.now())) { + if (archivedAt.isBefore(Instant.now())) { Settings.ANNOUNCEMENT_LAST_ID.save(id); return; } From 42409ece7df480ac6d6266dac66414960870d931 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sun, 22 Mar 2026 21:04:00 +0000 Subject: [PATCH 12/12] chore: Release v6.1.1-dev.4 [skip ci] ## [6.1.1-dev.4](https://github.com/ReVanced/revanced-patches/compare/v6.1.1-dev.3...v6.1.1-dev.4) (2026-03-22) ### Bug Fixes * **Instagram - Disable signature check:** Set correct return type ([#6918](https://github.com/ReVanced/revanced-patches/issues/6918)) ([4a36d1a](https://github.com/ReVanced/revanced-patches/commit/4a36d1ab569201316ee3b83be9f5ab9539c3336d)) * **YouTube - Announcements:** Parse announcement correctly by using `Instant` instead of `LocalDateTime` for `archived_at` ([#6889](https://github.com/ReVanced/revanced-patches/issues/6889)) ([77098b2](https://github.com/ReVanced/revanced-patches/commit/77098b2c057e53f375bca8dffd369e801fdaed52)) --- CHANGELOG.md | 8 ++++++++ gradle.properties | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dddb0982c2..062786bdb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [6.1.1-dev.4](https://github.com/ReVanced/revanced-patches/compare/v6.1.1-dev.3...v6.1.1-dev.4) (2026-03-22) + + +### Bug Fixes + +* **Instagram - Disable signature check:** Set correct return type ([#6918](https://github.com/ReVanced/revanced-patches/issues/6918)) ([4a36d1a](https://github.com/ReVanced/revanced-patches/commit/4a36d1ab569201316ee3b83be9f5ab9539c3336d)) +* **YouTube - Announcements:** Parse announcement correctly by using `Instant` instead of `LocalDateTime` for `archived_at` ([#6889](https://github.com/ReVanced/revanced-patches/issues/6889)) ([77098b2](https://github.com/ReVanced/revanced-patches/commit/77098b2c057e53f375bca8dffd369e801fdaed52)) + ## [6.1.1-dev.3](https://github.com/ReVanced/revanced-patches/compare/v6.1.1-dev.2...v6.1.1-dev.3) (2026-03-20) diff --git a/gradle.properties b/gradle.properties index 4c893f83f4..0ef9f06173 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,4 +4,4 @@ org.gradle.parallel = true android.useAndroidX = true android.uniquePackageNames = false kotlin.code.style = official -version = 6.1.1-dev.3 +version = 6.1.1-dev.4