mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-04 16:44:29 +02:00
fix(YouTube Music/Disable dislike redirection): not working at notification controls or widgets
This commit is contained in:
parent
49507936e9
commit
df01c0bf8c
@ -6,13 +6,24 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
import app.revanced.patches.music.general.redirection.fingerprints.DislikeButtonOnClickListenerFingerprint
|
import app.revanced.patches.music.general.redirection.fingerprints.DislikeButtonOnClickListenerFingerprint
|
||||||
|
import app.revanced.patches.music.utils.fingerprints.PendingIntentReceiverFingerprint
|
||||||
import app.revanced.patches.music.utils.integrations.Constants.GENERAL
|
import app.revanced.patches.music.utils.integrations.Constants.GENERAL
|
||||||
import app.revanced.patches.music.utils.settings.CategoryType
|
import app.revanced.patches.music.utils.settings.CategoryType
|
||||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||||
import app.revanced.util.exception
|
import app.revanced.util.exception
|
||||||
|
import app.revanced.util.getStringInstructionIndex
|
||||||
|
import app.revanced.util.getTargetIndexReversed
|
||||||
|
import app.revanced.util.getTargetIndexWithReference
|
||||||
|
import app.revanced.util.getWalkerMethod
|
||||||
|
import app.revanced.util.indexOfFirstInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
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.MethodReference
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.Reference
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Disable dislike redirection",
|
name = "Disable dislike redirection",
|
||||||
@ -38,23 +49,45 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
)
|
)
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object DislikeRedirectionPatch : BytecodePatch(
|
object DislikeRedirectionPatch : BytecodePatch(
|
||||||
setOf(DislikeButtonOnClickListenerFingerprint)
|
setOf(
|
||||||
|
DislikeButtonOnClickListenerFingerprint,
|
||||||
|
PendingIntentReceiverFingerprint
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
|
private lateinit var onClickReference: Reference
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
|
PendingIntentReceiverFingerprint.result?.let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val startIndex = getStringInstructionIndex("YTM Dislike")
|
||||||
|
val onClickRelayIndex = getTargetIndexReversed(startIndex, Opcode.INVOKE_VIRTUAL)
|
||||||
|
val onClickRelayMethod = getWalkerMethod(context, onClickRelayIndex)
|
||||||
|
|
||||||
|
onClickRelayMethod.apply {
|
||||||
|
val onClickMethodIndex = getTargetIndexReversed(Opcode.INVOKE_DIRECT)
|
||||||
|
val onClickMethod = getWalkerMethod(context, onClickMethodIndex)
|
||||||
|
|
||||||
|
onClickMethod.apply {
|
||||||
|
val onClickIndex = indexOfFirstInstruction {
|
||||||
|
val reference = ((this as? ReferenceInstruction)?.reference as? MethodReference)
|
||||||
|
|
||||||
|
opcode == Opcode.INVOKE_INTERFACE
|
||||||
|
&& reference?.returnType == "V"
|
||||||
|
&& reference.parameterTypes.size == 1
|
||||||
|
}
|
||||||
|
onClickReference = getInstruction<ReferenceInstruction>(onClickIndex).reference
|
||||||
|
|
||||||
|
injectCall(onClickIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: throw PendingIntentReceiverFingerprint.exception
|
||||||
|
|
||||||
DislikeButtonOnClickListenerFingerprint.result?.let {
|
DislikeButtonOnClickListenerFingerprint.result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
val onClickIndex = getTargetIndexWithReference(onClickReference.toString())
|
||||||
val jumpIndex = it.scanResult.patternScanResult!!.endIndex + 1
|
injectCall(onClickIndex)
|
||||||
val freeRegister = getInstruction<OneRegisterInstruction>(startIndex).registerA
|
|
||||||
|
|
||||||
addInstructionsWithLabels(
|
|
||||||
startIndex + 1, """
|
|
||||||
invoke-static {}, $GENERAL->disableDislikeRedirection()Z
|
|
||||||
move-result v$freeRegister
|
|
||||||
if-nez v$freeRegister, :disable
|
|
||||||
""", ExternalLabel("disable", getInstruction(jumpIndex))
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} ?: throw DislikeButtonOnClickListenerFingerprint.exception
|
} ?: throw DislikeButtonOnClickListenerFingerprint.exception
|
||||||
|
|
||||||
@ -65,4 +98,17 @@ object DislikeRedirectionPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun MutableMethod.injectCall(onClickIndex: Int) {
|
||||||
|
val targetIndex = getTargetIndexReversed(onClickIndex, Opcode.IF_EQZ)
|
||||||
|
val insertRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||||
|
|
||||||
|
addInstructionsWithLabels(
|
||||||
|
targetIndex + 1, """
|
||||||
|
invoke-static {}, $GENERAL->disableDislikeRedirection()Z
|
||||||
|
move-result v$insertRegister
|
||||||
|
if-nez v$insertRegister, :disable
|
||||||
|
""", ExternalLabel("disable", getInstruction(onClickIndex + 1))
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,14 @@
|
|||||||
package app.revanced.patches.music.general.redirection.fingerprints
|
package app.revanced.patches.music.general.redirection.fingerprints
|
||||||
|
|
||||||
import app.revanced.util.containsWideLiteralInstructionIndex
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import app.revanced.util.containsWideLiteralInstructionIndex
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
|
|
||||||
internal object DislikeButtonOnClickListenerFingerprint : MethodFingerprint(
|
internal object DislikeButtonOnClickListenerFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf("Landroid/view/View;"),
|
parameters = listOf("Landroid/view/View;"),
|
||||||
opcodes = listOf(
|
|
||||||
Opcode.IF_EQZ,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.SGET_OBJECT,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.INVOKE_INTERFACE
|
|
||||||
),
|
|
||||||
customFingerprint = handler@{ methodDef, _ ->
|
customFingerprint = handler@{ methodDef, _ ->
|
||||||
if (!methodDef.containsWideLiteralInstructionIndex(53465))
|
if (!methodDef.containsWideLiteralInstructionIndex(53465))
|
||||||
return@handler false
|
return@handler false
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.patches.music.utils.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
|
||||||
|
object PendingIntentReceiverFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
strings = listOf("YTM Dislike", "YTM Next", "YTM Previous"),
|
||||||
|
customFingerprint = { methodDef, _ ->
|
||||||
|
methodDef.definingClass.endsWith("/PendingIntentReceiver;")
|
||||||
|
}
|
||||||
|
)
|
@ -257,6 +257,11 @@ fun MutableMethod.getTargetIndexWithReferenceReversed(startIndex: Int, reference
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun MutableMethod.getWalkerMethod(context: BytecodeContext, index: Int) =
|
||||||
|
context.toMethodWalker(this)
|
||||||
|
.nextMethod(index, true)
|
||||||
|
.getMethod() as MutableMethod
|
||||||
|
|
||||||
fun BytecodeContext.updatePatchStatus(
|
fun BytecodeContext.updatePatchStatus(
|
||||||
className: String,
|
className: String,
|
||||||
methodName: String
|
methodName: String
|
||||||
|
Loading…
x
Reference in New Issue
Block a user