fix(YouTube - Hide layout components): Reduce false positives when hiding mix playlists

Implementation references taken from github.com/inotia00/revanced-integrations/commit/cfaf3d6356f316623ad32b10719b1b5ef0ba25b9
This commit is contained in:
oSumAtrIX 2023-11-12 16:23:57 +01:00
parent 68d10d4779
commit fb173e18af
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4

View file

@ -23,6 +23,7 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch.PreferenceScreen
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@Patch(
name = "Hide layout components",
@ -327,12 +328,15 @@ object HideLayoutComponentsPatch : BytecodePatch(
result.mutableMethod.apply {
val consumeByteBufferIndex = result.scanResult.patternScanResult!!.startIndex
val byteBufferRegister = getInstruction<FiveRegisterInstruction>(consumeByteBufferIndex).registerD
val conversionContextRegister =
getInstruction<TwoRegisterInstruction>(consumeByteBufferIndex - 2).registerA
val byteBufferRegister =
getInstruction<FiveRegisterInstruction>(consumeByteBufferIndex).registerD
addInstructionsWithLabels(
result.scanResult.patternScanResult!!.startIndex,
consumeByteBufferIndex,
"""
invoke-static {v$byteBufferRegister}, $FILTER_CLASS_DESCRIPTOR->filterMixPlaylists([B)Z
invoke-static {v$conversionContextRegister, v$byteBufferRegister}, $FILTER_CLASS_DESCRIPTOR->filterMixPlaylists(Ljava/lang/Object;[B)Z
move-result v0 # Conveniently same register happens to be free.
if-nez v0, :return_empty_component
""",