Skip to content

Commit

Permalink
feat(sleepasandroid): unlock-premium patch (#1172)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
aliveoutside and oSumAtrIX committed Dec 1, 2022
1 parent a43d149 commit 40ef51c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package app.revanced.patches.sleepasandroid.annotations

import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package

@Compatibility([Package("com.urbandroid.sleep")])
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class UnlockPremiumCompatibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package app.revanced.patches.sleepasandroid.fingerprints

import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

object IsTrialFingerprint : MethodFingerprint(
"Z",
customFingerprint = { it.name == "isTrial" }
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package app.revanced.patches.sleepasandroid.patch

import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
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.sleepasandroid.annotations.UnlockPremiumCompatibility
import app.revanced.patches.sleepasandroid.fingerprints.IsTrialFingerprint

@Patch
@Name("unlock-premium")
@Description("Unlocks all premium features.")
@UnlockPremiumCompatibility
class UnlockPremiumPatch : BytecodePatch(
listOf(
IsTrialFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
val method = IsTrialFingerprint.result!!.mutableMethod

method.addInstructions(
0,
"""
const/4 v0, 0x0
return v0
"""
)

return PatchResultSuccess()
}
}

0 comments on commit 40ef51c

Please sign in to comment.