fix(Tiktok - Remember clear display): Use correct name

This commit is contained in:
oSumAtrIX 2023-12-21 15:32:18 +01:00
parent c9efa27d4a
commit d7e44cb887
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
4 changed files with 29 additions and 28 deletions

View File

@ -818,8 +818,8 @@ public final class app/revanced/patches/tiktok/feedfilter/FeedFilterPatch : app/
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
} }
public final class app/revanced/patches/tiktok/interaction/clearmode/RememberClearModePatch : app/revanced/patcher/patch/BytecodePatch { public final class app/revanced/patches/tiktok/interaction/cleardisplay/RememberClearDisplayPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/tiktok/interaction/clearmode/RememberClearModePatch; public static final field INSTANCE Lapp/revanced/patches/tiktok/interaction/cleardisplay/RememberClearDisplayPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
} }

View File

@ -1,4 +1,4 @@
package app.revanced.patches.tiktok.interaction.clearmode package app.revanced.patches.tiktok.interaction.cleardisplay
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.addInstructions
@ -8,31 +8,31 @@ 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.patcher.util.smali.ExternalLabel
import app.revanced.patches.tiktok.interaction.clearmode.fingerprints.OnClearModeEventFingerprint import app.revanced.patches.tiktok.interaction.cleardisplay.fingerprints.OnClearDisplayEventFingerprint
import app.revanced.patches.tiktok.interaction.clearmode.fingerprints.OnRenderFirstFrameFingerprint import app.revanced.patches.tiktok.interaction.cleardisplay.fingerprints.OnRenderFirstFrameFingerprint
import app.revanced.util.exception import app.revanced.util.exception
import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstruction
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c
@Patch( @Patch(
name = "Remember clear mode", name = "Remember clear display",
description = "Remembers the clear mode configurations in between videos.", description = "Remembers the clear display configurations in between videos.",
compatiblePackages = [ compatiblePackages = [
CompatiblePackage("com.ss.android.ugc.trill", ["32.5.3"]), CompatiblePackage("com.ss.android.ugc.trill", ["32.5.3"]),
CompatiblePackage("com.zhiliaoapp.musically", ["32.5.3"]) CompatiblePackage("com.zhiliaoapp.musically", ["32.5.3"])
] ]
) )
@Suppress("unused") @Suppress("unused")
object RememberClearModePatch : BytecodePatch( object RememberClearDisplayPatch : BytecodePatch(
setOf( setOf(
OnClearModeEventFingerprint, OnClearDisplayEventFingerprint,
OnRenderFirstFrameFingerprint OnRenderFirstFrameFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
OnClearModeEventFingerprint.result?.mutableMethod?.let { OnClearDisplayEventFingerprint.result?.mutableMethod?.let {
// region Hook the "Clear mode" configuration save event to remember the state of clear mode. // region Hook the "Clear display" configuration save event to remember the state of clear display.
val isEnabledIndex = it.indexOfFirstInstruction { opcode == Opcode.IGET_BOOLEAN } + 1 val isEnabledIndex = it.indexOfFirstInstruction { opcode == Opcode.IGET_BOOLEAN } + 1
val isEnabledRegister = it.getInstruction<Instruction22c>(isEnabledIndex - 1).registerA val isEnabledRegister = it.getInstruction<Instruction22c>(isEnabledIndex - 1).registerA
@ -40,40 +40,40 @@ object RememberClearModePatch : BytecodePatch(
it.addInstructions( it.addInstructions(
isEnabledIndex, isEnabledIndex,
"invoke-static { v$isEnabledRegister }, " + "invoke-static { v$isEnabledRegister }, " +
"Lapp/revanced/tiktok/clearmode/RememberClearModePatch;->rememberClearModeState(Z)V" "Lapp/revanced/tiktok/cleardisplay/RememberClearDisplayPatch;->rememberClearDisplayState(Z)V"
) )
// endregion // endregion
// region Override the "Clear mode" configuration load event to load the state of clear mode. // region Override the "Clear display" configuration load event to load the state of clear display.
val clearModeEventClass = it.parameters[0].type val clearDisplayEventClass = it.parameters[0].type
OnRenderFirstFrameFingerprint.result?.mutableMethod?.apply { OnRenderFirstFrameFingerprint.result?.mutableMethod?.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
0, 0,
""" """
# Create a new clearModeEvent and post it to the EventBus (https://github.com/greenrobot/EventBus) # Create a new clearDisplayEvent and post it to the EventBus (https://github.com/greenrobot/EventBus)
# The state of clear mode. # The state of clear display.
invoke-static { }, Lapp/revanced/tiktok/clearmode/RememberClearModePatch;->getClearModeState()Z invoke-static { }, Lapp/revanced/tiktok/cleardisplay/RememberClearDisplayPatch;->getClearDisplayState()Z
move-result v3 move-result v3
if-eqz v3, :clear_mode_disabled if-eqz v3, :clear_display_disabled
# Clear mode type such as 0 = LONG_PRESS, 1 = SCREEN_RECORD etc. # Clear display type such as 0 = LONG_PRESS, 1 = SCREEN_RECORD etc.
const/4 v1, 0x0 const/4 v1, 0x0
# Name of the clear mode type which is equivalent to the clear mode type. # Name of the clear display type which is equivalent to the clear display type.
const-string v2, "long_press" const-string v2, "long_press"
new-instance v0, $clearModeEventClass new-instance v0, $clearDisplayEventClass
invoke-direct { v0, v1, v2, v3 }, $clearModeEventClass-><init>(ILjava/lang/String;Z)V invoke-direct { v0, v1, v2, v3 }, $clearDisplayEventClass-><init>(ILjava/lang/String;Z)V
invoke-virtual { v0 }, $clearModeEventClass->post()Lcom/ss/android/ugc/governance/eventbus/IEvent; invoke-virtual { v0 }, $clearDisplayEventClass->post()Lcom/ss/android/ugc/governance/eventbus/IEvent;
""", """,
ExternalLabel("clear_mode_disabled", getInstruction(0)) ExternalLabel("clear_display_disabled", getInstruction(0))
) )
} ?: throw OnRenderFirstFrameFingerprint.exception } ?: throw OnRenderFirstFrameFingerprint.exception
// endregion // endregion
} ?: throw OnClearModeEventFingerprint.exception } ?: throw OnClearDisplayEventFingerprint.exception
} }
} }

View File

@ -1,9 +1,10 @@
package app.revanced.patches.tiktok.interaction.clearmode.fingerprints package app.revanced.patches.tiktok.interaction.cleardisplay.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.fingerprint.MethodFingerprint
internal object OnClearModeEventFingerprint : MethodFingerprint( internal object OnClearDisplayEventFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ -> customFingerprint = { methodDef, _ ->
// Internally the feature is called "Clear mode".
methodDef.definingClass.endsWith("/ClearModePanelComponent;") && methodDef.name == "onClearModeEvent" methodDef.definingClass.endsWith("/ClearModePanelComponent;") && methodDef.name == "onClearModeEvent"
} }
) )

View File

@ -1,4 +1,4 @@
package app.revanced.patches.tiktok.interaction.clearmode.fingerprints package app.revanced.patches.tiktok.interaction.cleardisplay.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.fingerprint.MethodFingerprint