From d8561414601801a4bb306aec6febfa81ed231ae8 Mon Sep 17 00:00:00 2001 From: d4rkk3y Date: Wed, 20 Dec 2023 04:28:05 +0700 Subject: [PATCH] refactor: rename `clear mode` to `clear display` --- .../RememberClearDisplayPatch.kt} | 36 +++++++++---------- .../OnClearModeEventFingerprint.kt | 2 +- .../OnRenderFirstFrameFingerprint.kt | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) rename src/main/kotlin/app/revanced/patches/tiktok/interaction/{clearmode/RememberClearModePatch.kt => cleardisplay/RememberClearDisplayPatch.kt} (61%) rename src/main/kotlin/app/revanced/patches/tiktok/interaction/{clearmode => cleardisplay}/fingerprints/OnClearModeEventFingerprint.kt (79%) rename src/main/kotlin/app/revanced/patches/tiktok/interaction/{clearmode => cleardisplay}/fingerprints/OnRenderFirstFrameFingerprint.kt (79%) diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/clearmode/RememberClearModePatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/RememberClearDisplayPatch.kt similarity index 61% rename from src/main/kotlin/app/revanced/patches/tiktok/interaction/clearmode/RememberClearModePatch.kt rename to src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/RememberClearDisplayPatch.kt index 3b9bfed5aa..0ab605bfd6 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/clearmode/RememberClearModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/RememberClearDisplayPatch.kt @@ -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.extensions.InstructionExtensions.addInstructions @@ -8,8 +8,8 @@ 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.tiktok.interaction.clearmode.fingerprints.OnClearModeEventFingerprint -import app.revanced.patches.tiktok.interaction.clearmode.fingerprints.OnRenderFirstFrameFingerprint +import app.revanced.patches.tiktok.interaction.cleardisplay.fingerprints.OnClearModeEventFingerprint +import app.revanced.patches.tiktok.interaction.cleardisplay.fingerprints.OnRenderFirstFrameFingerprint import app.revanced.util.exception import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.Opcode @@ -24,7 +24,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c ] ) @Suppress("unused") -object RememberClearModePatch : BytecodePatch( +object RememberClearDisplayPatch : BytecodePatch( setOf( OnClearModeEventFingerprint, OnRenderFirstFrameFingerprint @@ -32,7 +32,7 @@ object RememberClearModePatch : BytecodePatch( ) { override fun execute(context: BytecodeContext) { OnClearModeEventFingerprint.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 isEnabledRegister = it.getInstruction(isEnabledIndex - 1).registerA @@ -40,36 +40,36 @@ object RememberClearModePatch : BytecodePatch( it.addInstructions( isEnabledIndex, "invoke-static { v$isEnabledRegister }, " + - "Lapp/revanced/tiktok/clearmode/RememberClearModePatch;->rememberClearModeState(Z)V" + "Lapp/revanced/tiktok/clearmode/RememberClearModePatch;->rememberClearDisplayState(Z)V" ) // 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 { addInstructionsWithLabels( 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. - invoke-static { }, Lapp/revanced/tiktok/clearmode/RememberClearModePatch;->getClearModeState()Z + # The state of clear display. + invoke-static { }, Lapp/revanced/tiktok/clearmode/RememberClearModePatch;->getClearDisplayState()Z 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 - # 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" - new-instance v0, $clearModeEventClass - invoke-direct { v0, v1, v2, v3 }, $clearModeEventClass->(ILjava/lang/String;Z)V - invoke-virtual { v0 }, $clearModeEventClass->post()Lcom/ss/android/ugc/governance/eventbus/IEvent; + new-instance v0, $clearDisplayEventClass + invoke-direct { v0, v1, v2, v3 }, $clearDisplayEventClass->(ILjava/lang/String;Z)V + 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 diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/clearmode/fingerprints/OnClearModeEventFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/fingerprints/OnClearModeEventFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/tiktok/interaction/clearmode/fingerprints/OnClearModeEventFingerprint.kt rename to src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/fingerprints/OnClearModeEventFingerprint.kt index f1ade3128b..405da882b6 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/clearmode/fingerprints/OnClearModeEventFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/fingerprints/OnClearModeEventFingerprint.kt @@ -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 diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/clearmode/fingerprints/OnRenderFirstFrameFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/fingerprints/OnRenderFirstFrameFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/tiktok/interaction/clearmode/fingerprints/OnRenderFirstFrameFingerprint.kt rename to src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/fingerprints/OnRenderFirstFrameFingerprint.kt index e239229150..d9e5a15ed0 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/clearmode/fingerprints/OnRenderFirstFrameFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/fingerprints/OnRenderFirstFrameFingerprint.kt @@ -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