mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-30 17:42:52 +01:00
feat(trakt): add unlock-pro
patch (#2210)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
633703ddea
commit
1e8dcae6f5
@ -0,0 +1,8 @@
|
||||
package app.revanced.patches.trakt.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility([Package("tv.trakt.trakt")])
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
internal annotation class UnlockProCompatibility
|
@ -0,0 +1,11 @@
|
||||
package app.revanced.patches.trakt.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object IsVIPEPFingerprint : MethodFingerprint(
|
||||
customFingerprint = custom@{ methodDef, _ ->
|
||||
if (!methodDef.definingClass.endsWith("RealmUserSettings;")) return@custom false
|
||||
|
||||
methodDef.name == "isVIPEP"
|
||||
}
|
||||
)
|
@ -0,0 +1,11 @@
|
||||
package app.revanced.patches.trakt.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object IsVIPFingerprint : MethodFingerprint(
|
||||
customFingerprint = custom@{ methodDef, _ ->
|
||||
if (!methodDef.definingClass.endsWith("RealmUserSettings;")) return@custom false
|
||||
|
||||
methodDef.name == "isVIP"
|
||||
}
|
||||
)
|
@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.trakt.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object RealmUserSettingsFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass.endsWith("RealmUserSettings;")
|
||||
}
|
||||
)
|
@ -0,0 +1,52 @@
|
||||
package app.revanced.patches.trakt.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
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.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
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.trakt.annotations.UnlockProCompatibility
|
||||
import app.revanced.patches.trakt.fingerprints.IsVIPEPFingerprint
|
||||
import app.revanced.patches.trakt.fingerprints.IsVIPFingerprint
|
||||
import app.revanced.patches.trakt.fingerprints.RealmUserSettingsFingerprint
|
||||
|
||||
@Patch
|
||||
@Name("unlock-pro")
|
||||
@Description("Unlocks pro features.")
|
||||
@UnlockProCompatibility
|
||||
@Version("0.0.1")
|
||||
class UnlockProPatch : BytecodePatch(
|
||||
listOf(RealmUserSettingsFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
RealmUserSettingsFingerprint.result?.classDef?.let { realUserSettingsClass ->
|
||||
arrayOf(IsVIPFingerprint, IsVIPEPFingerprint).onEach { fingerprint ->
|
||||
// Resolve both fingerprints on the same class.
|
||||
if (!fingerprint.resolve(context, realUserSettingsClass))
|
||||
throw fingerprint.toErrorResult()
|
||||
}.forEach { fingerprint ->
|
||||
// Return true for both VIP check methods.
|
||||
fingerprint.result?.mutableMethod?.addInstructions(0, RETURN_TRUE_INSTRUCTIONS)
|
||||
?: return fingerprint.toErrorResult()
|
||||
}
|
||||
} ?: return RealmUserSettingsFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val RETURN_TRUE_INSTRUCTIONS =
|
||||
"""
|
||||
const/4 v0, 0x1
|
||||
invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
|
||||
move-result-object v1
|
||||
return-object v1
|
||||
"""
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user