Skip to content

Commit

Permalink
refactor: general refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Aug 25, 2023
1 parent 0b25540 commit 1110274
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +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.PatchException
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) {
val result = GetSubscribedFingerprint.result
?: throw PatchException("Fingerprint not found")
val patternScanResult = result.scanResult.patternScanResult
?: throw PatchException("Fingerprint pattern not found")

result.mutableMethod.replaceInstruction(patternScanResult.startIndex, "const/4 v0, 0x1")
}
}
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
}

0 comments on commit 1110274

Please sign in to comment.