From a2aa7e92e05262cda7bdc39a367f7d16fb5600d0 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 27 Mar 2024 15:33:52 +0100 Subject: [PATCH] fix hide get premium --- .../layout/premium/HideGetPremiumPatch.kt | 41 ++++++++++--------- .../fingerprints/HideGetPremiumFingerprint.kt | 3 +- .../HideGetPremiumParentFingerprint.kt | 19 --------- 3 files changed, 22 insertions(+), 41 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumParentFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt index fb338274de..4be4470dc9 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt @@ -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(insertIndex - 1).registerA + val insertIndex = it.scanResult.patternScanResult!!.endIndex - addInstruction(insertIndex, "const/4 v$register, 0x0") - } - } ?: throw HideGetPremiumParentFingerprint.exception + val setVisibilityInstruction = getInstruction(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 } } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt index d126285425..e97251de52 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt @@ -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"), ) diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumParentFingerprint.kt deleted file mode 100644 index 3463fcfcd3..0000000000 --- a/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumParentFingerprint.kt +++ /dev/null @@ -1,19 +0,0 @@ -package app.revanced.patches.music.layout.premium.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.MethodFingerprint -import com.android.tools.smali.dexlib2.AccessFlags -import com.android.tools.smali.dexlib2.Opcode - -internal 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"), -)