mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-03 16:14:28 +02:00
feat(music/hide-cast-button): patch now hides the cast banner inside the player
This commit is contained in:
parent
5dc592ac0d
commit
dc02ee4933
@ -1,11 +0,0 @@
|
||||
package app.revanced.patches.music.general.castbutton.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object HideCastButtonFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("I")
|
||||
)
|
@ -4,7 +4,7 @@ import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object HideCastButtonParentFingerprint : MethodFingerprint(
|
||||
object MediaRouteButtonFingerprint : MethodFingerprint(
|
||||
returnType = "Z",
|
||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
|
||||
strings = listOf("MediaRouteButton")
|
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.music.general.castbutton.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.PlayerOverlayChip
|
||||
import app.revanced.util.bytecode.isWideLiteralExists
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object PlayerOverlayChipFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(PlayerOverlayChip) }
|
||||
)
|
@ -4,41 +4,72 @@ import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.music.general.castbutton.fingerprints.HideCastButtonFingerprint
|
||||
import app.revanced.patches.music.general.castbutton.fingerprints.HideCastButtonParentFingerprint
|
||||
import app.revanced.patches.music.general.castbutton.fingerprints.MediaRouteButtonFingerprint
|
||||
import app.revanced.patches.music.general.castbutton.fingerprints.PlayerOverlayChipFingerprint
|
||||
import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
||||
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.PlayerOverlayChip
|
||||
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.bytecode.getWideLiteralIndex
|
||||
import app.revanced.util.enum.CategoryType
|
||||
import app.revanced.util.integrations.Constants.MUSIC_GENERAL
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("Hide cast button")
|
||||
@Description("Hides the cast button.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
)
|
||||
@MusicCompatibility
|
||||
class HideCastButtonPatch : BytecodePatch(
|
||||
listOf(HideCastButtonParentFingerprint)
|
||||
listOf(
|
||||
MediaRouteButtonFingerprint,
|
||||
PlayerOverlayChipFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
HideCastButtonParentFingerprint.result?.let { parentResult ->
|
||||
HideCastButtonFingerprint.also {
|
||||
it.resolve(
|
||||
context,
|
||||
parentResult.classDef
|
||||
/**
|
||||
* Hide cast button
|
||||
*/
|
||||
MediaRouteButtonFingerprint.result?.let {
|
||||
val setVisibilityMethod = it.mutableClass.methods.find { method -> method.name == "setVisibility" }
|
||||
|
||||
setVisibilityMethod?.apply {
|
||||
addInstructions(
|
||||
0, """
|
||||
invoke-static {p1}, $MUSIC_GENERAL->hideCastButton(I)I
|
||||
move-result p1
|
||||
"""
|
||||
)
|
||||
}.result?.mutableMethod?.addInstructions(
|
||||
0, """
|
||||
invoke-static {p1}, $MUSIC_GENERAL->hideCastButton(I)I
|
||||
move-result p1
|
||||
"""
|
||||
) ?: throw HideCastButtonFingerprint.exception
|
||||
} ?: throw HideCastButtonParentFingerprint.exception
|
||||
} ?: throw PatchException("Failed to find setVisibility method")
|
||||
} ?: throw MediaRouteButtonFingerprint.exception
|
||||
|
||||
/**
|
||||
* Hide floating cast banner
|
||||
*/
|
||||
PlayerOverlayChipFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getWideLiteralIndex(PlayerOverlayChip) + 2
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $MUSIC_GENERAL->hideCastButton(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
SettingsPatch.addMusicPreference(
|
||||
CategoryType.GENERAL,
|
||||
|
@ -28,6 +28,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var MenuEntry: Long = -1
|
||||
var MusicMenuLikeButtons: Long = -1
|
||||
var NamesInactiveAccountThumbnailSize: Long = -1
|
||||
var PlayerOverlayChip: Long = -1
|
||||
var PrivacyTosFooter: Long = -1
|
||||
var QualityAuto: Long = -1
|
||||
var Text1: Long = -1
|
||||
@ -54,6 +55,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
MenuEntry = find(LAYOUT, "menu_entry")
|
||||
MusicMenuLikeButtons = find(LAYOUT, "music_menu_like_buttons")
|
||||
NamesInactiveAccountThumbnailSize = find(DIMEN, "names_inactive_account_thumbnail_size")
|
||||
PlayerOverlayChip = find(ID, "player_overlay_chip")
|
||||
PrivacyTosFooter = find(ID, "privacy_tos_footer")
|
||||
QualityAuto = find(STRING, "quality_auto")
|
||||
Text1 = find(ID, "text1")
|
||||
|
Loading…
x
Reference in New Issue
Block a user