From 7d76e2e43c69b2b75f40a15a9147d041c77cbcd9 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 7 Feb 2024 16:16:33 +0100 Subject: [PATCH] fix(Infinity for Reddit - Unlock subscription): Do not crash by patching billing client --- .../subscription/UnlockSubscriptionPatch.kt | 10 +++++----- .../fingerprints/BillingClientOnServiceConnected.kt | 7 +++++++ .../SubscriptionActivityOnCreateFingerprint.kt | 13 ------------- 3 files changed, 12 insertions(+), 18 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/fingerprints/BillingClientOnServiceConnected.kt delete mode 100644 src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/fingerprints/SubscriptionActivityOnCreateFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt index a60360202..a80adb154 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt @@ -5,22 +5,22 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.reddit.customclients.infinityforreddit.api.SpoofClientPatch +import app.revanced.patches.reddit.customclients.infinityforreddit.subscription.fingerprints.BillingClientOnServiceConnected import app.revanced.patches.reddit.customclients.infinityforreddit.subscription.fingerprints.StartSubscriptionActivityFingerprint -import app.revanced.patches.reddit.customclients.infinityforreddit.subscription.fingerprints.SubscriptionActivityOnCreateFingerprint import app.revanced.util.returnEarly @Patch( name = "Unlock subscription", description = "Unlocks the subscription feature but requires a custom client ID.", compatiblePackages = [ - CompatiblePackage("ml.docilealligator.infinityforreddit") + CompatiblePackage("ml.docilealligator.infinityforreddit"), ], - dependencies = [SpoofClientPatch::class] + dependencies = [SpoofClientPatch::class], ) @Suppress("unused") object UnlockSubscriptionPatch : BytecodePatch( - setOf(StartSubscriptionActivityFingerprint, SubscriptionActivityOnCreateFingerprint) + setOf(StartSubscriptionActivityFingerprint, BillingClientOnServiceConnected), ) { override fun execute(context: BytecodeContext) = - listOf(StartSubscriptionActivityFingerprint, SubscriptionActivityOnCreateFingerprint).returnEarly() + listOf(StartSubscriptionActivityFingerprint, BillingClientOnServiceConnected).returnEarly() } diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/fingerprints/BillingClientOnServiceConnected.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/fingerprints/BillingClientOnServiceConnected.kt new file mode 100644 index 000000000..fce786c85 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/fingerprints/BillingClientOnServiceConnected.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.reddit.customclients.infinityforreddit.subscription.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object BillingClientOnServiceConnected : MethodFingerprint( + strings = listOf("Billing service connected"), +) diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/fingerprints/SubscriptionActivityOnCreateFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/fingerprints/SubscriptionActivityOnCreateFingerprint.kt deleted file mode 100644 index dd5f1710d..000000000 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/fingerprints/SubscriptionActivityOnCreateFingerprint.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.revanced.patches.reddit.customclients.infinityforreddit.subscription.fingerprints - -import app.revanced.patcher.fingerprint.MethodFingerprint -import com.android.tools.smali.dexlib2.AccessFlags - -internal object SubscriptionActivityOnCreateFingerprint : MethodFingerprint( - returnType = "V", - accessFlags = AccessFlags.PUBLIC.value, - parameters = listOf("Landroid/os/Bundle;"), - customFingerprint = { method, classDef -> - method.name == "onCreate" && classDef.type.endsWith("SubscriptionActivity;") - } -)