Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
zainarbani committed Oct 5, 2024
1 parent 6bb0723 commit 6465d05
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import app.revanced.patches.youtube.layout.hide.general.fingerprints.HideShowMor
import app.revanced.patches.youtube.layout.hide.general.fingerprints.ParseElementFromBufferFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.PlayerOverlayFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.ShowWatermarkFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.TestFingerprint
import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch
import app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
Expand Down Expand Up @@ -53,7 +54,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
)
@Suppress("unused")
object HideLayoutComponentsPatch : BytecodePatch(
setOf(ParseElementFromBufferFingerprint, PlayerOverlayFingerprint, HideShowMoreButtonFingerprint),
setOf(ParseElementFromBufferFingerprint, PlayerOverlayFingerprint, HideShowMoreButtonFingerprint, TestFingerprint),
) {
private const val LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/youtube/patches/components/LayoutComponentsFilter;"
Expand Down Expand Up @@ -210,5 +211,24 @@ object HideLayoutComponentsPatch : BytecodePatch(
}

// endregion

TestFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val igetIndex = it.scanResult.patternScanResult!!.endIndex
val igetRegister = getInstruction<TwoRegisterInstruction>(igetIndex).registerA
val freeRegister = getInstruction<TwoRegisterInstruction>(igetIndex + 1).registerA

val insertIndex = igetIndex + 1
addInstructions(
insertIndex,
"""
invoke-static { v$igetRegister }, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;
move-result-object v$freeRegister
invoke-static { v$freeRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->testMethod(Ljava/lang/String;)V
""",
)
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package app.revanced.patches.youtube.layout.hide.general.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode

internal object TestFingerprint : MethodFingerprint(
returnType = "L",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = emptyList(),
opcodes = listOf(
Opcode.NEW_INSTANCE,
Opcode.IGET,
Opcode.IGET,
Opcode.IGET_OBJECT, // Surface type.
),
strings = listOf(" lithoInitRange")
)

0 comments on commit 6465d05

Please sign in to comment.