feat: hide-get-premium
patch (#195)
* feat: `hide-get-premium` patch * fix: improve `hide-get-premium` fingerprints
This commit is contained in:
parent
ac53f835b6
commit
639aab411e
|
@ -0,0 +1,14 @@
|
|||
package app.revanced.patches.music.layout.premium.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility(
|
||||
[Package(
|
||||
"com.google.android.apps.youtube.music", arrayOf("5.14.53")
|
||||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class HideGetPremiumCompatibility
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package app.revanced.patches.music.layout.premium.fingerprints
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
||||
import app.revanced.patches.music.layout.premium.annotations.HideGetPremiumCompatibility
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Name("hide-get-premium-fingerprint")
|
||||
@MatchingMethod(
|
||||
"Lktn;", "k"
|
||||
)
|
||||
@HideGetPremiumCompatibility
|
||||
@Version("0.0.1")
|
||||
object HideGetPremiumFingerprint : MethodFingerprint(
|
||||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), listOf(
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.CONST_16,
|
||||
Opcode.GOTO,
|
||||
Opcode.NOP,
|
||||
Opcode.INVOKE_VIRTUAL
|
||||
)
|
||||
)
|
|
@ -0,0 +1,29 @@
|
|||
package app.revanced.patches.music.layout.premium.fingerprints
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
||||
import app.revanced.patches.music.layout.premium.annotations.HideGetPremiumCompatibility
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Name("hide-get-premium-parent-fingerprint")
|
||||
@MatchingMethod(
|
||||
"Lktn;", "k"
|
||||
)
|
||||
@HideGetPremiumCompatibility
|
||||
@Version("0.0.1")
|
||||
object HideGetPremiumParentFingerprint : MethodFingerprint(
|
||||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), listOf(
|
||||
Opcode.IGET_BOOLEAN,
|
||||
Opcode.CONST_4,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_STATIC
|
||||
),
|
||||
listOf("FEmusic_history"),
|
||||
)
|
|
@ -0,0 +1,49 @@
|
|||
package app.revanced.patches.music.layout.premium.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.impl.BytecodeData
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.replaceInstruction
|
||||
import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.patch.impl.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.music.layout.premium.annotations.HideGetPremiumCompatibility
|
||||
import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumFingerprint
|
||||
import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumParentFingerprint
|
||||
|
||||
@Patch
|
||||
@Name("hide-get-premium")
|
||||
@Description("Removes all \"Get Premium\" evidences from the avatar menu.")
|
||||
@HideGetPremiumCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideGetPremiumPatch : BytecodePatch(
|
||||
listOf(
|
||||
HideGetPremiumParentFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(data: BytecodeData): PatchResult {
|
||||
val parentResult = HideGetPremiumParentFingerprint.result!!
|
||||
HideGetPremiumFingerprint.resolve(data, parentResult.classDef)
|
||||
|
||||
val parentMethod = parentResult.mutableMethod
|
||||
parentMethod.replaceInstruction(
|
||||
parentResult.patternScanResult!!.startIndex, """
|
||||
const/4 v1, 0x0
|
||||
"""
|
||||
)
|
||||
|
||||
val result = HideGetPremiumFingerprint.result!!
|
||||
val method = result.mutableMethod
|
||||
method.addInstructions(
|
||||
result.patternScanResult!!.startIndex, """
|
||||
const/16 v0, 0x8
|
||||
"""
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue