From 387eb29e7ed45169c89a03513af64104d0082f28 Mon Sep 17 00:00:00 2001 From: xehpuk Date: Fri, 25 Aug 2023 03:16:12 +0200 Subject: [PATCH] feat(Strava): Add `Subscription features` patch (#2872) Co-authored-by: oSumAtrIX --- .../fingerprints/GetSubscribedFingerprint.kt | 11 +++++++++ .../patch/UnlockSubscriptionPatch.kt | 23 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/strava/subscription/fingerprints/GetSubscribedFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/strava/subscription/fingerprints/GetSubscribedFingerprint.kt b/src/main/kotlin/app/revanced/patches/strava/subscription/fingerprints/GetSubscribedFingerprint.kt new file mode 100644 index 0000000000..a0f6ff393b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/strava/subscription/fingerprints/GetSubscribedFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.strava.subscription.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.Opcode + +object GetSubscribedFingerprint : MethodFingerprint( + opcodes = listOf(Opcode.IGET_BOOLEAN), + customFingerprint = { methodDef, classDef -> + classDef.type.endsWith("SubscriptionDetailResponse;") && methodDef.name == "getSubscribed" + } +) diff --git a/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt b/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt new file mode 100644 index 0000000000..42a462e348 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt @@ -0,0 +1,23 @@ +package app.revanced.patches.strava.subscription.patch + +import app.revanced.extensions.exception +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Package +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.strava.subscription.fingerprints.GetSubscribedFingerprint + +@Patch +@Name("Unlock subscription features") +@Description("Unlocks \"Matched Runs\" and \"Segment Efforts\".") +@Compatibility([Package("com.strava", ["320.12"])]) +class UnlockSubscriptionPatch : BytecodePatch(listOf(GetSubscribedFingerprint)) { + override fun execute(context: BytecodeContext) = GetSubscribedFingerprint.result?.let { result -> + val isSubscribedIndex = result.scanResult.patternScanResult!!.startIndex + result.mutableMethod.replaceInstruction(isSubscribedIndex, "const/4 v0, 0x1") + } ?: throw GetSubscribedFingerprint.exception +} \ No newline at end of file