mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +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
|
||||
|
||||
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.removeInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
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.utils.fingerprints.ActionsBarParentFingerprint
|
||||
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.SettingsPatch
|
||||
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(
|
||||
name = "Hide action bar label",
|
||||
@ -29,24 +33,36 @@ object ActionBarLabelPatch : BytecodePatch(
|
||||
setOf(ActionsBarParentFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
ActionsBarParentFingerprint.result?.let { parentResult ->
|
||||
ActionBarLabelFingerprint.also {
|
||||
it.resolve(
|
||||
context,
|
||||
parentResult.classDef
|
||||
)
|
||||
}.result?.let {
|
||||
ActionsBarParentFingerprint.result?.classDef?.let { parentClassDef ->
|
||||
ActionBarLabelFingerprint.resolve(context, parentClassDef)
|
||||
ActionBarLabelFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val targetRegister =
|
||||
getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
val instructions = implementation!!.instructions
|
||||
|
||||
addInstructions(
|
||||
targetIndex, """
|
||||
invoke-static {v$targetRegister}, $ACTIONBAR->hideActionBarLabel(Z)Z
|
||||
move-result v$targetRegister
|
||||
"""
|
||||
val noLabelIndex = instructions.indexOfFirst { instruction ->
|
||||
val reference = (instruction as? ReferenceInstruction)?.reference.toString()
|
||||
instruction.opcode == Opcode.INVOKE_DIRECT
|
||||
&& 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 ActionsBarParentFingerprint.exception
|
||||
|
@ -10,10 +10,9 @@ object ActionBarLabelFingerprint : MethodFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "L"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_EQZ,
|
||||
)
|
||||
|
Reference in New Issue
Block a user