generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Strava): Add
Subscription features
patch (#2872)
Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
.../kotlin/app/revanced/patches/strava/subscription/fingerprints/GetSubscribedFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
) |
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |