mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
fix(YouTube Music/Hide action bar label): patch breaks in v6.31.55+
This commit is contained in:
@ -1,11 +1,13 @@
|
|||||||
package app.revanced.patches.music.actionbar.label
|
package app.revanced.patches.music.actionbar.label
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||||
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.smali.ExternalLabel
|
||||||
import app.revanced.patches.music.actionbar.label.fingerprints.ActionBarLabelFingerprint
|
import app.revanced.patches.music.actionbar.label.fingerprints.ActionBarLabelFingerprint
|
||||||
import app.revanced.patches.music.utils.fingerprints.ActionsBarParentFingerprint
|
import app.revanced.patches.music.utils.fingerprints.ActionsBarParentFingerprint
|
||||||
import app.revanced.patches.music.utils.integrations.Constants.ACTIONBAR
|
import app.revanced.patches.music.utils.integrations.Constants.ACTIONBAR
|
||||||
@ -13,7 +15,9 @@ import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
|||||||
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 com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Hide action bar label",
|
name = "Hide action bar label",
|
||||||
@ -29,24 +33,36 @@ object ActionBarLabelPatch : BytecodePatch(
|
|||||||
setOf(ActionsBarParentFingerprint)
|
setOf(ActionsBarParentFingerprint)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
ActionsBarParentFingerprint.result?.let { parentResult ->
|
ActionsBarParentFingerprint.result?.classDef?.let { parentClassDef ->
|
||||||
ActionBarLabelFingerprint.also {
|
ActionBarLabelFingerprint.resolve(context, parentClassDef)
|
||||||
it.resolve(
|
ActionBarLabelFingerprint.result?.let {
|
||||||
context,
|
|
||||||
parentResult.classDef
|
|
||||||
)
|
|
||||||
}.result?.let {
|
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
val instructions = implementation!!.instructions
|
||||||
val targetRegister =
|
|
||||||
getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
|
||||||
|
|
||||||
addInstructions(
|
val noLabelIndex = instructions.indexOfFirst { instruction ->
|
||||||
targetIndex, """
|
val reference = (instruction as? ReferenceInstruction)?.reference.toString()
|
||||||
invoke-static {v$targetRegister}, $ACTIONBAR->hideActionBarLabel(Z)Z
|
instruction.opcode == Opcode.INVOKE_DIRECT
|
||||||
move-result v$targetRegister
|
&& reference.endsWith("<init>(Landroid/content/Context;)V")
|
||||||
"""
|
&& !reference.contains("Lcom/google/android/libraries/youtube/common/ui/YouTubeButton;")
|
||||||
|
} - 2
|
||||||
|
|
||||||
|
val replaceIndex = instructions.indexOfFirst { instruction ->
|
||||||
|
val reference = (instruction as? ReferenceInstruction)?.reference.toString()
|
||||||
|
instruction.opcode == Opcode.INVOKE_DIRECT
|
||||||
|
&& reference.endsWith("Lcom/google/android/libraries/youtube/common/ui/YouTubeButton;-><init>(Landroid/content/Context;)V")
|
||||||
|
} - 2
|
||||||
|
val replaceInstruction = getInstruction<TwoRegisterInstruction>(replaceIndex)
|
||||||
|
val replaceReference = getInstruction<ReferenceInstruction>(replaceIndex).reference
|
||||||
|
|
||||||
|
addInstructionsWithLabels(
|
||||||
|
replaceIndex + 1, """
|
||||||
|
invoke-static {}, $ACTIONBAR->hideActionBarLabel()Z
|
||||||
|
move-result v${replaceInstruction.registerA}
|
||||||
|
if-nez v${replaceInstruction.registerA}, :hidden
|
||||||
|
iget-object v${replaceInstruction.registerA}, v${replaceInstruction.registerB}, $replaceReference
|
||||||
|
""", ExternalLabel("hidden", getInstruction(noLabelIndex))
|
||||||
)
|
)
|
||||||
|
removeInstruction(replaceIndex)
|
||||||
}
|
}
|
||||||
} ?: throw ActionBarLabelFingerprint.exception
|
} ?: throw ActionBarLabelFingerprint.exception
|
||||||
} ?: throw ActionsBarParentFingerprint.exception
|
} ?: throw ActionsBarParentFingerprint.exception
|
||||||
|
@ -10,10 +10,9 @@ object ActionBarLabelFingerprint : MethodFingerprint(
|
|||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf("L", "L"),
|
parameters = listOf("L", "L"),
|
||||||
opcodes = listOf(
|
opcodes = listOf(
|
||||||
Opcode.INVOKE_INTERFACE,
|
Opcode.INVOKE_STATIC,
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
Opcode.CHECK_CAST,
|
Opcode.INVOKE_STATIC,
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.MOVE_RESULT,
|
Opcode.MOVE_RESULT,
|
||||||
Opcode.IF_EQZ,
|
Opcode.IF_EQZ,
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user