From a92b7fb43c8b1b45577360cdc6d883fe2815c2f2 Mon Sep 17 00:00:00 2001 From: 1fexd <58902674+1fexd@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:41:45 +0200 Subject: [PATCH] feat(Amazon): Add `Always allow deep-linking` patch (#3000) --- api/revanced-patches.api | 6 ++++ .../deeplinking/DeepLinkingFingerprint.kt | 11 ++++++++ .../amazon/deeplinking/DeepLinkingPatch.kt | 28 +++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/amazon/deeplinking/DeepLinkingFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/amazon/deeplinking/DeepLinkingPatch.kt diff --git a/api/revanced-patches.api b/api/revanced-patches.api index e07e2e7a..e885e2eb 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -152,6 +152,12 @@ public final class app/revanced/patches/all/telephony/sim/spoof/SpoofSimCountryP public fun transform (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Lkotlin/Pair;)V } +public final class app/revanced/patches/amazon/deeplinking/DeepLinkingPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/amazon/deeplinking/DeepLinkingPatch; + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + public final class app/revanced/patches/backdrops/misc/pro/ProUnlockPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/backdrops/misc/pro/ProUnlockPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/amazon/deeplinking/DeepLinkingFingerprint.kt b/src/main/kotlin/app/revanced/patches/amazon/deeplinking/DeepLinkingFingerprint.kt new file mode 100644 index 00000000..8caa3ece --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/amazon/deeplinking/DeepLinkingFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.amazon.deeplinking + +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +internal object DeepLinkingFingerprint : MethodFingerprint( + "Z", + parameters = listOf("L"), + accessFlags = AccessFlags.PRIVATE.value, + strings = listOf("https://www.", "android.intent.action.VIEW") +) diff --git a/src/main/kotlin/app/revanced/patches/amazon/deeplinking/DeepLinkingPatch.kt b/src/main/kotlin/app/revanced/patches/amazon/deeplinking/DeepLinkingPatch.kt new file mode 100644 index 00000000..96cf4454 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/amazon/deeplinking/DeepLinkingPatch.kt @@ -0,0 +1,28 @@ +package app.revanced.patches.amazon.deeplinking + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.util.exception + +@Patch( + name = "Always allow deep-linking", + description = "Open Amazon links, even if the app is not set to handle Amazon links.", + compatiblePackages = [CompatiblePackage("com.amazon.mShop.android.shopping")] +) +@Suppress("unused") +object DeepLinkingPatch : BytecodePatch( + setOf(DeepLinkingFingerprint) +) { + override fun execute(context: BytecodeContext) { + DeepLinkingFingerprint.result?.mutableMethod?.addInstructions( + 0, + """ + const/4 v0, 0x1 + return v0 + """ + ) ?: throw DeepLinkingFingerprint.exception + } +}