mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 05:10:20 +02:00
fix(YouTube Music - Disable dislike redirection): Patch not working in 8.02.53
https://github.com/inotia00/ReVanced_Extended/issues/2695
This commit is contained in:
parent
3283cf3e98
commit
9ec17d4328
@ -9,6 +9,8 @@ import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKA
|
|||||||
import app.revanced.patches.music.utils.extension.Constants.GENERAL_CLASS_DESCRIPTOR
|
import app.revanced.patches.music.utils.extension.Constants.GENERAL_CLASS_DESCRIPTOR
|
||||||
import app.revanced.patches.music.utils.patch.PatchList.DISABLE_DISLIKE_REDIRECTION
|
import app.revanced.patches.music.utils.patch.PatchList.DISABLE_DISLIKE_REDIRECTION
|
||||||
import app.revanced.patches.music.utils.pendingIntentReceiverFingerprint
|
import app.revanced.patches.music.utils.pendingIntentReceiverFingerprint
|
||||||
|
import app.revanced.patches.music.utils.playservice.is_7_29_or_greater
|
||||||
|
import app.revanced.patches.music.utils.playservice.versionCheckPatch
|
||||||
import app.revanced.patches.music.utils.settings.CategoryType
|
import app.revanced.patches.music.utils.settings.CategoryType
|
||||||
import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus
|
import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus
|
||||||
import app.revanced.patches.music.utils.settings.addSwitchPreference
|
import app.revanced.patches.music.utils.settings.addSwitchPreference
|
||||||
@ -23,7 +25,8 @@ 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.instruction.ReferenceInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.Reference
|
|
||||||
|
var onClickReference = ""
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
val dislikeRedirectionPatch = bytecodePatch(
|
val dislikeRedirectionPatch = bytecodePatch(
|
||||||
@ -32,11 +35,12 @@ val dislikeRedirectionPatch = bytecodePatch(
|
|||||||
) {
|
) {
|
||||||
compatibleWith(COMPATIBLE_PACKAGE)
|
compatibleWith(COMPATIBLE_PACKAGE)
|
||||||
|
|
||||||
dependsOn(settingsPatch)
|
dependsOn(
|
||||||
|
settingsPatch,
|
||||||
|
versionCheckPatch,
|
||||||
|
)
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
lateinit var onClickReference: Reference
|
|
||||||
|
|
||||||
pendingIntentReceiverFingerprint.methodOrThrow().apply {
|
pendingIntentReceiverFingerprint.methodOrThrow().apply {
|
||||||
val startIndex = indexOfFirstStringInstructionOrThrow("YTM Dislike")
|
val startIndex = indexOfFirstStringInstructionOrThrow("YTM Dislike")
|
||||||
val onClickRelayIndex =
|
val onClickRelayIndex =
|
||||||
@ -63,18 +67,21 @@ val dislikeRedirectionPatch = bytecodePatch(
|
|||||||
reference.parameterTypes.size == 1
|
reference.parameterTypes.size == 1
|
||||||
}
|
}
|
||||||
onClickReference =
|
onClickReference =
|
||||||
getInstruction<ReferenceInstruction>(onClickIndex).reference
|
getInstruction<ReferenceInstruction>(onClickIndex).reference.toString()
|
||||||
|
|
||||||
disableDislikeRedirection(onClickIndex)
|
disableDislikeRedirection(onClickIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dislikeButtonOnClickListenerFingerprint.methodOrThrow().apply {
|
if (is_7_29_or_greater) {
|
||||||
val onClickIndex = indexOfFirstInstructionOrThrow {
|
dislikeButtonOnClickListenerAlternativeFingerprint
|
||||||
getReference<MethodReference>()?.toString() == onClickReference.toString()
|
.methodOrThrow()
|
||||||
}
|
.disableDislikeRedirection()
|
||||||
disableDislikeRedirection(onClickIndex)
|
} else {
|
||||||
|
dislikeButtonOnClickListenerFingerprint
|
||||||
|
.methodOrThrow()
|
||||||
|
.disableDislikeRedirection()
|
||||||
}
|
}
|
||||||
|
|
||||||
addSwitchPreference(
|
addSwitchPreference(
|
||||||
@ -88,7 +95,15 @@ val dislikeRedirectionPatch = bytecodePatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun MutableMethod.disableDislikeRedirection(onClickIndex: Int) {
|
private fun MutableMethod.disableDislikeRedirection(startIndex: Int = 0) {
|
||||||
|
val onClickIndex =
|
||||||
|
if (startIndex == 0) {
|
||||||
|
indexOfFirstInstructionOrThrow {
|
||||||
|
getReference<MethodReference>()?.toString() == onClickReference
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
startIndex
|
||||||
|
}
|
||||||
val targetIndex = indexOfFirstInstructionReversedOrThrow(onClickIndex, Opcode.IF_EQZ)
|
val targetIndex = indexOfFirstInstructionReversedOrThrow(onClickIndex, Opcode.IF_EQZ)
|
||||||
val insertRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
val insertRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import app.revanced.util.containsLiteralInstruction
|
|||||||
import app.revanced.util.fingerprint.legacyFingerprint
|
import app.revanced.util.fingerprint.legacyFingerprint
|
||||||
import app.revanced.util.or
|
import app.revanced.util.or
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||||
|
|
||||||
internal val dislikeButtonOnClickListenerFingerprint = legacyFingerprint(
|
internal val dislikeButtonOnClickListenerFingerprint = legacyFingerprint(
|
||||||
name = "dislikeButtonOnClickListenerFingerprint",
|
name = "dislikeButtonOnClickListenerFingerprint",
|
||||||
@ -18,3 +20,31 @@ internal val dislikeButtonOnClickListenerFingerprint = legacyFingerprint(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* YouTube Music 7.27.52 ~
|
||||||
|
* TODO: Make this fingerprint more concise
|
||||||
|
*/
|
||||||
|
internal val dislikeButtonOnClickListenerAlternativeFingerprint = legacyFingerprint(
|
||||||
|
name = "dislikeButtonOnClickListenerAlternativeFingerprint",
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
parameters = listOf("L", "Ljava/util/Map;"),
|
||||||
|
customFingerprint = custom@{ method, classDef ->
|
||||||
|
if (classDef.fields.count() != 7) {
|
||||||
|
return@custom false
|
||||||
|
}
|
||||||
|
if (classDef.methods.count() != 5) {
|
||||||
|
return@custom false
|
||||||
|
}
|
||||||
|
val implementation = method.implementation
|
||||||
|
?: return@custom false
|
||||||
|
val instructions = implementation.instructions
|
||||||
|
val instructionCount = instructions.count()
|
||||||
|
if (instructionCount < 50) {
|
||||||
|
return@custom false
|
||||||
|
}
|
||||||
|
|
||||||
|
((instructions.elementAt(0) as? ReferenceInstruction)?.reference as? FieldReference)?.name == "likeEndpoint"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ var is_7_23_or_greater = false
|
|||||||
private set
|
private set
|
||||||
var is_7_25_or_greater = false
|
var is_7_25_or_greater = false
|
||||||
private set
|
private set
|
||||||
|
var is_7_27_or_greater = false
|
||||||
|
private set
|
||||||
|
var is_7_29_or_greater = false
|
||||||
|
private set
|
||||||
|
|
||||||
val versionCheckPatch = resourcePatch(
|
val versionCheckPatch = resourcePatch(
|
||||||
description = "versionCheckPatch",
|
description = "versionCheckPatch",
|
||||||
@ -53,5 +57,7 @@ val versionCheckPatch = resourcePatch(
|
|||||||
is_7_20_or_greater = 243899000 <= playStoreServicesVersion
|
is_7_20_or_greater = 243899000 <= playStoreServicesVersion
|
||||||
is_7_23_or_greater = 244199000 <= playStoreServicesVersion
|
is_7_23_or_greater = 244199000 <= playStoreServicesVersion
|
||||||
is_7_25_or_greater = 244399000 <= playStoreServicesVersion
|
is_7_25_or_greater = 244399000 <= playStoreServicesVersion
|
||||||
|
is_7_27_or_greater = 244515000 <= playStoreServicesVersion
|
||||||
|
is_7_29_or_greater = 244799000 <= playStoreServicesVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user