diff --git a/src/main/kotlin/app/revanced/patches/music/actionbar/component/ActionBarComponentPatch.kt b/src/main/kotlin/app/revanced/patches/music/actionbar/component/ActionBarComponentPatch.kt index 476a50aa9..c80c5b906 100644 --- a/src/main/kotlin/app/revanced/patches/music/actionbar/component/ActionBarComponentPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/actionbar/component/ActionBarComponentPatch.kt @@ -2,14 +2,12 @@ package app.revanced.patches.music.actionbar.component import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.music.actionbar.component.fingerprints.ActionBarComponentFingerprint import app.revanced.patches.music.actionbar.component.fingerprints.LikeDislikeContainerFingerprint -import app.revanced.patches.music.actionbar.component.fingerprints.LikeDislikeContainerVisibilityFingerprint import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.music.utils.integrations.Constants.ACTIONBAR_CLASS_DESCRIPTOR import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch @@ -120,29 +118,8 @@ object ActionBarComponentPatch : BaseBytecodePatch( } } - LikeDislikeContainerFingerprint.resultOrThrow().let { parentResult -> - // Resolves fingerprints - LikeDislikeContainerVisibilityFingerprint.resolve(context, parentResult.classDef) - - /** - * Added in YouTube Music v6.35.xx~ - */ - LikeDislikeContainerVisibilityFingerprint.result?.let { - it.mutableMethod.apply { - val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1 - val targetRegister = - getInstruction(targetIndex).registerA - - addInstructions( - targetIndex + 1, """ - invoke-static {v$targetRegister}, $ACTIONBAR_CLASS_DESCRIPTOR->hideLikeDislikeButton(Z)Z - move-result v$targetRegister - """ - ) - } - } // Don't throw exception - - parentResult.mutableMethod.apply { + LikeDislikeContainerFingerprint.resultOrThrow().let { + it.mutableMethod.apply { val insertIndex = getWideLiteralInstructionIndex(LikeDislikeContainer) + 2 val insertRegister = getInstruction(insertIndex).registerA diff --git a/src/main/kotlin/app/revanced/patches/music/actionbar/component/fingerprints/LikeDislikeContainerVisibilityFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/actionbar/component/fingerprints/LikeDislikeContainerVisibilityFingerprint.kt deleted file mode 100644 index 7ba8a0a79..000000000 --- a/src/main/kotlin/app/revanced/patches/music/actionbar/component/fingerprints/LikeDislikeContainerVisibilityFingerprint.kt +++ /dev/null @@ -1,33 +0,0 @@ -package app.revanced.patches.music.actionbar.component.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 -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction - -object LikeDislikeContainerVisibilityFingerprint : MethodFingerprint( - returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("L"), - opcodes = listOf( - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT - ), - customFingerprint = custom@{ methodDef, _ -> - if (methodDef.implementation == null) - return@custom false - - for (instruction in methodDef.implementation!!.instructions) { - if (instruction.opcode != Opcode.INVOKE_VIRTUAL) - continue - - val referenceInstruction = instruction as ReferenceInstruction - if (referenceInstruction.reference.toString() != "Landroid/view/View;->setVisibility(I)V") - continue - - return@custom true - } - return@custom false - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/opus/BaseOpusCodecsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/opus/BaseOpusCodecsPatch.kt index 10293947e..82bdc20d0 100644 --- a/src/main/kotlin/app/revanced/patches/shared/opus/BaseOpusCodecsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/opus/BaseOpusCodecsPatch.kt @@ -13,6 +13,8 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.reference.Reference +@Deprecated("This patch is generally not required for the latest versions of YouTube and YouTube Music." + + "For YouTube Music, if user spoofs the app version to v4.27.53, mp4a codec is still used, this is the patch for some of these users.") abstract class BaseOpusCodecsPatch( private val descriptor: String ) : BytecodePatch( @@ -21,28 +23,29 @@ abstract class BaseOpusCodecsPatch( CodecSelectorFingerprint ) ) { - private lateinit var targetReference: Reference + private lateinit var opusCodecReference: Reference override fun execute(context: BytecodeContext) { CodecReferenceFingerprint.resultOrThrow().let { it.mutableMethod.apply { val targetIndex = getTargetIndexWithReference("Ljava/util/Set;") - targetReference = getInstruction(targetIndex).reference + opusCodecReference = getInstruction(targetIndex).reference } } CodecSelectorFingerprint.resultOrThrow().let { it.mutableMethod.apply { + val freeRegister = implementation!!.registerCount - parameters.size - 2 val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetRegister = getInstruction(targetIndex).registerA addInstructionsWithLabels( targetIndex + 1, """ invoke-static {}, $descriptor - move-result v7 - if-eqz v7, :mp4a - invoke-static {}, $targetReference + move-result v$freeRegister + if-eqz v$freeRegister, :mp4a + invoke-static {}, $opusCodecReference move-result-object v$targetRegister """, ExternalLabel("mp4a", getInstruction(targetIndex + 1)) ) diff --git a/src/main/kotlin/app/revanced/patches/shared/opus/fingerprints/CodecSelectorFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/opus/fingerprints/CodecSelectorFingerprint.kt index 926383250..a306385d8 100644 --- a/src/main/kotlin/app/revanced/patches/shared/opus/fingerprints/CodecSelectorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/opus/fingerprints/CodecSelectorFingerprint.kt @@ -14,5 +14,5 @@ internal object CodecSelectorFingerprint : MethodFingerprint( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT_OBJECT ), - strings = listOf("eac3_supported") + strings = listOf("Audio track id %s not in audio streams") )