From 96f4ed6fe1354b51b8e9ce974ae436975f6a634e Mon Sep 17 00:00:00 2001 From: Jonathan <63370021+FineFindus@users.noreply.github.com> Date: Sat, 26 Nov 2022 15:43:04 +0100 Subject: [PATCH] feat(myexpenses): `unlock-pro` patch (#1120) --- .../pro/annotations/UnlockProCompatibility.kt | 9 +++++ .../pro/fingerprints/IsEnabledFingerprint.kt | 8 ++++ .../misc/pro/patch/UnlockProPatch.kt | 38 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/annotations/UnlockProCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/fingerprints/IsEnabledFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/patch/UnlockProPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/annotations/UnlockProCompatibility.kt b/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/annotations/UnlockProCompatibility.kt new file mode 100644 index 000000000..e4d8a13e2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/annotations/UnlockProCompatibility.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.myexpenses.misc.pro.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility([Package("org.totschnig.myexpenses")]) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class UnlockProCompatibility diff --git a/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/fingerprints/IsEnabledFingerprint.kt b/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/fingerprints/IsEnabledFingerprint.kt new file mode 100644 index 000000000..caebe9e50 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/fingerprints/IsEnabledFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.myexpenses.misc.pro.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object IsEnabledFingerprint : MethodFingerprint( + "Z", + strings = listOf("feature", "feature.licenceStatus") +) diff --git a/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/patch/UnlockProPatch.kt new file mode 100644 index 000000000..ebf34e63e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/patch/UnlockProPatch.kt @@ -0,0 +1,38 @@ +package app.revanced.patches.myexpenses.misc.pro.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.myexpenses.misc.pro.annotations.UnlockProCompatibility +import app.revanced.patches.myexpenses.misc.pro.fingerprints.IsEnabledFingerprint + +@Patch +@Name("unlock-pro") +@Description("Unlocks all professional features.") +@UnlockProCompatibility +@Version("0.0.1") +class UnlockProPatch : BytecodePatch( + listOf( + IsEnabledFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + val method = IsEnabledFingerprint.result!!.mutableMethod + method.addInstructions( + 0, + """ + const/4 v0, 0x1 + return v0 + """ + ) + + return PatchResultSuccess() + } +}