From dd45ddde80d894cde85763a2cfe1fa6cd56838b6 Mon Sep 17 00:00:00 2001 From: naijun0403 Date: Tue, 20 May 2025 23:22:31 +0900 Subject: [PATCH] feat(kakaotalk): enhance version info patch to include build timestamp --- .../kakaotalk/versioninfo/VersionInfoPatch.kt | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/versioninfo/VersionInfoPatch.kt b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/versioninfo/VersionInfoPatch.kt index eb08dae8f..5cfc80f4d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/versioninfo/VersionInfoPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/versioninfo/VersionInfoPatch.kt @@ -10,6 +10,7 @@ import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c import com.android.tools.smali.dexlib2.iface.reference.StringReference import com.android.tools.smali.dexlib2.immutable.reference.ImmutableStringReference +import java.time.format.DateTimeFormatter @Suppress("unused") val versionInfoPatch = bytecodePatch( @@ -19,8 +20,8 @@ val versionInfoPatch = bytecodePatch( compatibleWith("com.kakao.talk"("25.4.2")) execute { - val runPatch: (Fingerprint) -> Unit = { - val versionInfo = it.method.instructions + val runPatch: (Fingerprint, Boolean) -> Unit = { fp, inDetail -> + val versionInfo = fp.method.instructions .filterIsInstance() .first { inst -> inst.opcode == Opcode.CONST_STRING @@ -28,20 +29,29 @@ val versionInfoPatch = bytecodePatch( val versionString = (versionInfo.reference as StringReference).string - it.method + fp.method .replaceInstruction( versionInfo.location.index, BuilderInstruction21c( Opcode.CONST_STRING, versionInfo.registerA, ImmutableStringReference( - "$versionString (ReVanced)" + if (inDetail) { + val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") + "$versionString (ReVanced)\nBuild at: ${ + formatter.format( + java.time.LocalDateTime.now() + ) + }" + } else { + "$versionString (ReVanced)" + } ) ) ) } - runPatch(versionInfoFingerprint) - runPatch(versionInfoPreviewFingerprint) + runPatch(versionInfoFingerprint, true) + runPatch(versionInfoPreviewFingerprint, false) } } \ No newline at end of file