mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 21:30:19 +02:00
fix(YouTube Music/Hide taste builder): apply fingerprints compatible with the wider version
This commit is contained in:
parent
152319da76
commit
66f452173a
@ -1,18 +1,25 @@
|
||||
package app.revanced.patches.music.misc.tastebuilder
|
||||
|
||||
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.getInstruction
|
||||
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.misc.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint
|
||||
import app.revanced.patches.music.misc.tastebuilder.fingerprints.TasteBuilderSyntheticFingerprint
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicTastebuilderShelf
|
||||
import app.revanced.util.exception
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch(
|
||||
name = "Hide taste builder",
|
||||
description = "Hides the \"Tell us which artists you like\" card from the homepage.",
|
||||
dependencies = [SharedResourceIdPatch::class],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.apps.youtube.music",
|
||||
@ -36,19 +43,38 @@ object TasteBuilderPatch : BytecodePatch(
|
||||
setOf(TasteBuilderConstructorFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
TasteBuilderConstructorFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 8
|
||||
val register = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
TasteBuilderConstructorFingerprint.result?.let { parentResult ->
|
||||
TasteBuilderSyntheticFingerprint.resolve(context, parentResult.classDef)
|
||||
|
||||
parentResult.mutableMethod.apply {
|
||||
val freeRegister = implementation!!.registerCount - parameters.size - 2
|
||||
val constIndex = getWideLiteralInstructionIndex(MusicTastebuilderShelf)
|
||||
val targetIndex = implementation!!.instructions.let {
|
||||
constIndex + it.subList(constIndex, it.size - 1).indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.MOVE_RESULT_OBJECT
|
||||
}
|
||||
}
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
const/16 v1, 0x8
|
||||
invoke-virtual {v$register, v1}, Landroid/view/View;->setVisibility(I)V
|
||||
targetIndex + 1, """
|
||||
const/16 v$freeRegister, 0x8
|
||||
invoke-virtual {v$targetRegister, v$freeRegister}, Landroid/view/View;->setVisibility(I)V
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw TasteBuilderConstructorFingerprint.exception
|
||||
|
||||
TasteBuilderSyntheticFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"const/4 v$insertRegister, 0x0"
|
||||
)
|
||||
}
|
||||
} ?: throw TasteBuilderSyntheticFingerprint.exception
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +1,12 @@
|
||||
package app.revanced.patches.music.misc.tastebuilder.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patcher.fingerprint.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicTastebuilderShelf
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
|
||||
object TasteBuilderConstructorFingerprint : MethodFingerprint(
|
||||
object TasteBuilderConstructorFingerprint : LiteralValueFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
parameters = listOf("L", "L", "L"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CONST,
|
||||
Opcode.CONST_4,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.CONST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.CONST
|
||||
)
|
||||
literalSupplier = { MusicTastebuilderShelf }
|
||||
)
|
@ -0,0 +1,16 @@
|
||||
package app.revanced.patches.music.misc.tastebuilder.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
|
||||
|
||||
object TasteBuilderSyntheticFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.SYNTHETIC,
|
||||
parameters = listOf("L", "Ljava/lang/Object;"),
|
||||
opcodes = listOf(
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.IGET_OBJECT
|
||||
)
|
||||
)
|
@ -32,6 +32,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var MiniPlayerMdxPlaying: Long = -1
|
||||
var MusicMenuLikeButtons: Long = -1
|
||||
var MusicNotifierShelf: Long = -1
|
||||
var MusicTastebuilderShelf: Long = -1
|
||||
var NamesInactiveAccountThumbnailSize: Long = -1
|
||||
var OfflineSettingsMenuItem: Long = -1
|
||||
var PlayerCastMediaRouteButton: Long = -1
|
||||
@ -67,6 +68,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
MiniPlayerMdxPlaying = find(STRING, "mini_player_mdx_playing")
|
||||
MusicMenuLikeButtons = find(LAYOUT, "music_menu_like_buttons")
|
||||
MusicNotifierShelf = find(LAYOUT, "music_notifier_shelf")
|
||||
MusicTastebuilderShelf = find(LAYOUT, "music_tastebuilder_shelf")
|
||||
NamesInactiveAccountThumbnailSize = find(DIMEN, "names_inactive_account_thumbnail_size")
|
||||
OfflineSettingsMenuItem = find(ID, "offline_settings_menu_item")
|
||||
PlayerCastMediaRouteButton = find(LAYOUT, "player_cast_media_route_button")
|
||||
|
Loading…
x
Reference in New Issue
Block a user