From b43d867925efbaef9ab012683060982031436e5f Mon Sep 17 00:00:00 2001 From: xehpuk Date: Fri, 25 Aug 2023 00:09:22 +0200 Subject: [PATCH 1/7] feat(strava): add `Subscription features` patch --- .../fingerprints/SubscriptionFingerprint.kt | 12 +++++++ .../patches/strava/patch/SubscriptionPatch.kt | 33 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/strava/fingerprints/SubscriptionFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/strava/patch/SubscriptionPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/strava/fingerprints/SubscriptionFingerprint.kt b/src/main/kotlin/app/revanced/patches/strava/fingerprints/SubscriptionFingerprint.kt new file mode 100644 index 0000000000..ba60891516 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/strava/fingerprints/SubscriptionFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.strava.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object SubscriptionFingerprint : MethodFingerprint( + returnType = "Z", + 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/patch/SubscriptionPatch.kt b/src/main/kotlin/app/revanced/patches/strava/patch/SubscriptionPatch.kt new file mode 100644 index 0000000000..75fcee443c --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/strava/patch/SubscriptionPatch.kt @@ -0,0 +1,33 @@ +package app.revanced.patches.strava.patch + +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.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.strava.fingerprints.SubscriptionFingerprint + +@Patch +@Name("Subscription features") +@Description("Enables Matched Runs and Segment Efforts.") +@Compatibility([Package("com.strava", ["320.12"])]) +class SubscriptionPatch : BytecodePatch( + listOf(SubscriptionFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + val result = SubscriptionFingerprint.result + ?: return PatchResultError("Fingerprint not found") + val patternScanResult = result.scanResult.patternScanResult + ?: return PatchResultError("Fingerprint pattern not found") + + result.mutableMethod.replaceInstruction(patternScanResult.startIndex, "const/4 v0, 0x1") + + return PatchResultSuccess() + } +} From efff1d287aab56da583d991a1b978095904819ac Mon Sep 17 00:00:00 2001 From: xehpuk Date: Fri, 25 Aug 2023 00:44:06 +0200 Subject: [PATCH 2/7] chore(strava/subscription-features): rename patch --- .../patch/{SubscriptionPatch.kt => UnlockSubscriptionPatch.kt} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/kotlin/app/revanced/patches/strava/patch/{SubscriptionPatch.kt => UnlockSubscriptionPatch.kt} (96%) diff --git a/src/main/kotlin/app/revanced/patches/strava/patch/SubscriptionPatch.kt b/src/main/kotlin/app/revanced/patches/strava/patch/UnlockSubscriptionPatch.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/strava/patch/SubscriptionPatch.kt rename to src/main/kotlin/app/revanced/patches/strava/patch/UnlockSubscriptionPatch.kt index 75fcee443c..7636234885 100644 --- a/src/main/kotlin/app/revanced/patches/strava/patch/SubscriptionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/strava/patch/UnlockSubscriptionPatch.kt @@ -17,7 +17,7 @@ import app.revanced.patches.strava.fingerprints.SubscriptionFingerprint @Name("Subscription features") @Description("Enables Matched Runs and Segment Efforts.") @Compatibility([Package("com.strava", ["320.12"])]) -class SubscriptionPatch : BytecodePatch( +class UnlockSubscriptionPatch : BytecodePatch( listOf(SubscriptionFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { From 7e8913b6e030e88b107d6e27d64a187d64619a48 Mon Sep 17 00:00:00 2001 From: xehpuk Date: Fri, 25 Aug 2023 00:45:54 +0200 Subject: [PATCH 3/7] chore(strava/subscription-features): rename fingerprint and remove return type --- ...bscriptionFingerprint.kt => GetSubscribedFingerprint.kt} | 3 +-- .../patches/strava/patch/UnlockSubscriptionPatch.kt | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) rename src/main/kotlin/app/revanced/patches/strava/fingerprints/{SubscriptionFingerprint.kt => GetSubscribedFingerprint.kt} (82%) diff --git a/src/main/kotlin/app/revanced/patches/strava/fingerprints/SubscriptionFingerprint.kt b/src/main/kotlin/app/revanced/patches/strava/fingerprints/GetSubscribedFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/strava/fingerprints/SubscriptionFingerprint.kt rename to src/main/kotlin/app/revanced/patches/strava/fingerprints/GetSubscribedFingerprint.kt index ba60891516..55db0e4ca2 100644 --- a/src/main/kotlin/app/revanced/patches/strava/fingerprints/SubscriptionFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/strava/fingerprints/GetSubscribedFingerprint.kt @@ -3,8 +3,7 @@ package app.revanced.patches.strava.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode -object SubscriptionFingerprint : MethodFingerprint( - returnType = "Z", +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/patch/UnlockSubscriptionPatch.kt b/src/main/kotlin/app/revanced/patches/strava/patch/UnlockSubscriptionPatch.kt index 7636234885..31d7369a27 100644 --- a/src/main/kotlin/app/revanced/patches/strava/patch/UnlockSubscriptionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/strava/patch/UnlockSubscriptionPatch.kt @@ -11,17 +11,17 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.strava.fingerprints.SubscriptionFingerprint +import app.revanced.patches.strava.fingerprints.GetSubscribedFingerprint @Patch @Name("Subscription features") @Description("Enables Matched Runs and Segment Efforts.") @Compatibility([Package("com.strava", ["320.12"])]) class UnlockSubscriptionPatch : BytecodePatch( - listOf(SubscriptionFingerprint) + listOf(GetSubscribedFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - val result = SubscriptionFingerprint.result + val result = GetSubscribedFingerprint.result ?: return PatchResultError("Fingerprint not found") val patternScanResult = result.scanResult.patternScanResult ?: return PatchResultError("Fingerprint pattern not found") From 83cc8a85e9d60166101d2f7c0d0178d928167b13 Mon Sep 17 00:00:00 2001 From: xehpuk Date: Fri, 25 Aug 2023 00:47:49 +0200 Subject: [PATCH 4/7] chore(strava/subscription-features): introduce `subscription` package --- .../fingerprints/GetSubscribedFingerprint.kt | 2 +- .../{ => subscription}/patch/UnlockSubscriptionPatch.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/main/kotlin/app/revanced/patches/strava/{ => subscription}/fingerprints/GetSubscribedFingerprint.kt (85%) rename src/main/kotlin/app/revanced/patches/strava/{ => subscription}/patch/UnlockSubscriptionPatch.kt (90%) diff --git a/src/main/kotlin/app/revanced/patches/strava/fingerprints/GetSubscribedFingerprint.kt b/src/main/kotlin/app/revanced/patches/strava/subscription/fingerprints/GetSubscribedFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/strava/fingerprints/GetSubscribedFingerprint.kt rename to src/main/kotlin/app/revanced/patches/strava/subscription/fingerprints/GetSubscribedFingerprint.kt index 55db0e4ca2..f0163cb3ed 100644 --- a/src/main/kotlin/app/revanced/patches/strava/fingerprints/GetSubscribedFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/strava/subscription/fingerprints/GetSubscribedFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.strava.fingerprints +package app.revanced.patches.strava.subscription.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/strava/patch/UnlockSubscriptionPatch.kt b/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/strava/patch/UnlockSubscriptionPatch.kt rename to src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt index 31d7369a27..fc8cf8ee81 100644 --- a/src/main/kotlin/app/revanced/patches/strava/patch/UnlockSubscriptionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.strava.patch +package app.revanced.patches.strava.subscription.patch import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Description @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.strava.fingerprints.GetSubscribedFingerprint +import app.revanced.patches.strava.subscription.fingerprints.GetSubscribedFingerprint @Patch @Name("Subscription features") From 7319bafc6bcae345355b085b4b70f1eeb0b4cc26 Mon Sep 17 00:00:00 2001 From: xehpuk Date: Fri, 25 Aug 2023 00:57:13 +0200 Subject: [PATCH 5/7] build: update dependencies --- .../fingerprints/GetSubscribedFingerprint.kt | 2 +- .../subscription/patch/UnlockSubscriptionPatch.kt | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) 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 index f0163cb3ed..a0f6ff393b 100644 --- a/src/main/kotlin/app/revanced/patches/strava/subscription/fingerprints/GetSubscribedFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/strava/subscription/fingerprints/GetSubscribedFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.strava.subscription.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.Opcode +import com.android.tools.smali.dexlib2.Opcode object GetSubscribedFingerprint : MethodFingerprint( opcodes = listOf(Opcode.IGET_BOOLEAN), 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 index fc8cf8ee81..d5f5a85bad 100644 --- a/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt @@ -7,9 +7,7 @@ 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.PatchResult -import app.revanced.patcher.patch.PatchResultError -import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.strava.subscription.fingerprints.GetSubscribedFingerprint @@ -20,14 +18,12 @@ import app.revanced.patches.strava.subscription.fingerprints.GetSubscribedFinger class UnlockSubscriptionPatch : BytecodePatch( listOf(GetSubscribedFingerprint) ) { - override fun execute(context: BytecodeContext): PatchResult { + override fun execute(context: BytecodeContext) { val result = GetSubscribedFingerprint.result - ?: return PatchResultError("Fingerprint not found") + ?: throw PatchException("Fingerprint not found") val patternScanResult = result.scanResult.patternScanResult - ?: return PatchResultError("Fingerprint pattern not found") + ?: throw PatchException("Fingerprint pattern not found") result.mutableMethod.replaceInstruction(patternScanResult.startIndex, "const/4 v0, 0x1") - - return PatchResultSuccess() } } From 0b25540a3d2d9f04d9de8e8eb7abfe66f816766f Mon Sep 17 00:00:00 2001 From: xehpuk Date: Fri, 25 Aug 2023 00:59:01 +0200 Subject: [PATCH 6/7] chore(strava/subscription-features): change name and description --- .../strava/subscription/patch/UnlockSubscriptionPatch.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index d5f5a85bad..aaff43832d 100644 --- a/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt @@ -12,8 +12,8 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.strava.subscription.fingerprints.GetSubscribedFingerprint @Patch -@Name("Subscription features") -@Description("Enables Matched Runs and Segment Efforts.") +@Name("Unlock subscription features") +@Description("Unlocks \"Matched Runs\" and \"Segment Efforts\".") @Compatibility([Package("com.strava", ["320.12"])]) class UnlockSubscriptionPatch : BytecodePatch( listOf(GetSubscribedFingerprint) From 1110274a62b7f37939dd85f80e394510d60ca864 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 25 Aug 2023 03:15:27 +0200 Subject: [PATCH 7/7] refactor: general refactoring --- .../patch/UnlockSubscriptionPatch.kt | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) 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 index aaff43832d..42a462e348 100644 --- a/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt @@ -1,5 +1,6 @@ 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 @@ -7,7 +8,6 @@ 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 @@ -15,15 +15,9 @@ import app.revanced.patches.strava.subscription.fingerprints.GetSubscribedFinger @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 +} \ No newline at end of file