Skip to content

Commit

Permalink
fix hide get premium
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Mar 27, 2024
1 parent 2c4c8e4 commit a2aa7e9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,43 @@ package app.revanced.patches.music.layout.premium
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumFingerprint
import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumParentFingerprint
import app.revanced.util.exception
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction

@Patch(
name = "Hide get premium",
description = "Removes all \"Get Premium\" evidences from the avatar menu.",
name = "Hide 'Get Music Premium' label",
description = "Hides the red \"Get Music Premium\" label from the account menu.",
compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")],
)
@Suppress("unused")
object HideGetPremiumPatch : BytecodePatch(
setOf(HideGetPremiumParentFingerprint),
setOf(HideGetPremiumFingerprint),
) {
override fun execute(context: BytecodeContext) {
HideGetPremiumParentFingerprint.result?.let {
HideGetPremiumFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 1
val register = getInstruction<TwoRegisterInstruction>(insertIndex - 1).registerA
val insertIndex = it.scanResult.patternScanResult!!.endIndex

addInstruction(insertIndex, "const/4 v$register, 0x0")
}
} ?: throw HideGetPremiumParentFingerprint.exception
val setVisibilityInstruction = getInstruction<FiveRegisterInstruction>(insertIndex)
val getPremiumViewRegister = setVisibilityInstruction.registerC
val visibilityRegister = setVisibilityInstruction.registerD

val parentResult = HideGetPremiumParentFingerprint.result!!
HideGetPremiumFingerprint.resolve(context, parentResult.classDef)
replaceInstruction(
insertIndex,
"const/16 v$visibilityRegister, 0x8",
)

val startIndex = parentResult.scanResult.patternScanResult!!.startIndex
HideGetPremiumFingerprint.result!!.mutableMethod.addInstruction(
startIndex,
"""
const/16 v0, 0x8
""",
)
addInstruction(
insertIndex + 1,
"invoke-virtual {v$getPremiumViewRegister, v$visibilityRegister}, " +
"Landroid/view/View;->setVisibility(I)V",
)
}
} ?: throw HideGetPremiumFingerprint.exception
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ internal object HideGetPremiumFingerprint : MethodFingerprint(
listOf(
Opcode.IF_NEZ,
Opcode.CONST_16,
Opcode.GOTO,
Opcode.NOP,
Opcode.INVOKE_VIRTUAL,
),
listOf("FEmusic_history", "FEmusic_offline"),
)

This file was deleted.

0 comments on commit a2aa7e9

Please sign in to comment.