Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Strava): Add Subscription features patch #2872

Merged
merged 7 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"
}
)
Original file line number Diff line number Diff line change
@@ -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
}