refactor(YouTube Music - Hide category bar): Fix possible crash when patching certain app targets
This commit is contained in:
+5
-3
@@ -3,6 +3,7 @@ package app.revanced.patches.music.layout.compactheader
|
|||||||
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.util.findFreeRegister
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@@ -17,13 +18,14 @@ val hideCategoryBar = bytecodePatch(
|
|||||||
constructCategoryBarFingerprint.method.apply {
|
constructCategoryBarFingerprint.method.apply {
|
||||||
val insertIndex = constructCategoryBarFingerprint.patternMatch!!.startIndex
|
val insertIndex = constructCategoryBarFingerprint.patternMatch!!.startIndex
|
||||||
val register = getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA
|
val register = getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA
|
||||||
|
val freeRegister = findFreeRegister(insertIndex, register)
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
insertIndex,
|
insertIndex,
|
||||||
"""
|
"""
|
||||||
const/16 v2, 0x8
|
const/16 v$freeRegister, 0x8
|
||||||
invoke-virtual {v$register, v2}, Landroid/view/View;->setVisibility(I)V
|
invoke-virtual { v$register, v$freeRegister }, Landroid/view/View;->setVisibility(I)V
|
||||||
""",
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user