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
|
package app.revanced.patches.music.misc.tastebuilder
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
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.addInstructions
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
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.patches.music.misc.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint
|
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 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(
|
@Patch(
|
||||||
name = "Hide taste builder",
|
name = "Hide taste builder",
|
||||||
description = "Hides the \"Tell us which artists you like\" card from the homepage.",
|
description = "Hides the \"Tell us which artists you like\" card from the homepage.",
|
||||||
|
dependencies = [SharedResourceIdPatch::class],
|
||||||
compatiblePackages = [
|
compatiblePackages = [
|
||||||
CompatiblePackage(
|
CompatiblePackage(
|
||||||
"com.google.android.apps.youtube.music",
|
"com.google.android.apps.youtube.music",
|
||||||
@ -36,19 +43,38 @@ object TasteBuilderPatch : BytecodePatch(
|
|||||||
setOf(TasteBuilderConstructorFingerprint)
|
setOf(TasteBuilderConstructorFingerprint)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
TasteBuilderConstructorFingerprint.result?.let {
|
TasteBuilderConstructorFingerprint.result?.let { parentResult ->
|
||||||
it.mutableMethod.apply {
|
TasteBuilderSyntheticFingerprint.resolve(context, parentResult.classDef)
|
||||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 8
|
|
||||||
val register = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
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(
|
addInstructions(
|
||||||
insertIndex, """
|
targetIndex + 1, """
|
||||||
const/16 v1, 0x8
|
const/16 v$freeRegister, 0x8
|
||||||
invoke-virtual {v$register, v1}, Landroid/view/View;->setVisibility(I)V
|
invoke-virtual {v$targetRegister, v$freeRegister}, Landroid/view/View;->setVisibility(I)V
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} ?: throw TasteBuilderConstructorFingerprint.exception
|
} ?: 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
|
package app.revanced.patches.music.misc.tastebuilder.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicTastebuilderShelf
|
||||||
import app.revanced.patcher.fingerprint.annotation.FuzzyPatternScanMethod
|
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
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 : LiteralValueFingerprint(
|
||||||
object TasteBuilderConstructorFingerprint : MethodFingerprint(
|
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
parameters = listOf("L", "L", "L"),
|
literalSupplier = { MusicTastebuilderShelf }
|
||||||
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
|
|
||||||
)
|
|
||||||
)
|
)
|
@ -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 MiniPlayerMdxPlaying: Long = -1
|
||||||
var MusicMenuLikeButtons: Long = -1
|
var MusicMenuLikeButtons: Long = -1
|
||||||
var MusicNotifierShelf: Long = -1
|
var MusicNotifierShelf: Long = -1
|
||||||
|
var MusicTastebuilderShelf: Long = -1
|
||||||
var NamesInactiveAccountThumbnailSize: Long = -1
|
var NamesInactiveAccountThumbnailSize: Long = -1
|
||||||
var OfflineSettingsMenuItem: Long = -1
|
var OfflineSettingsMenuItem: Long = -1
|
||||||
var PlayerCastMediaRouteButton: Long = -1
|
var PlayerCastMediaRouteButton: Long = -1
|
||||||
@ -67,6 +68,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
MiniPlayerMdxPlaying = find(STRING, "mini_player_mdx_playing")
|
MiniPlayerMdxPlaying = find(STRING, "mini_player_mdx_playing")
|
||||||
MusicMenuLikeButtons = find(LAYOUT, "music_menu_like_buttons")
|
MusicMenuLikeButtons = find(LAYOUT, "music_menu_like_buttons")
|
||||||
MusicNotifierShelf = find(LAYOUT, "music_notifier_shelf")
|
MusicNotifierShelf = find(LAYOUT, "music_notifier_shelf")
|
||||||
|
MusicTastebuilderShelf = find(LAYOUT, "music_tastebuilder_shelf")
|
||||||
NamesInactiveAccountThumbnailSize = find(DIMEN, "names_inactive_account_thumbnail_size")
|
NamesInactiveAccountThumbnailSize = find(DIMEN, "names_inactive_account_thumbnail_size")
|
||||||
OfflineSettingsMenuItem = find(ID, "offline_settings_menu_item")
|
OfflineSettingsMenuItem = find(ID, "offline_settings_menu_item")
|
||||||
PlayerCastMediaRouteButton = find(LAYOUT, "player_cast_media_route_button")
|
PlayerCastMediaRouteButton = find(LAYOUT, "player_cast_media_route_button")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user