From 64663983b84de1f28636205f61bf0a24c83968d1 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 22 Feb 2025 08:20:19 +0200 Subject: [PATCH] fix(TikTok): Resolve startup app crash --- .../tiktok/misc/extension/ExtensionPatch.kt | 2 +- .../patches/tiktok/misc/extension/Hooks.kt | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/extension/ExtensionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/extension/ExtensionPatch.kt index 5101f3d52..81d253055 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/extension/ExtensionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/extension/ExtensionPatch.kt @@ -2,4 +2,4 @@ package app.revanced.patches.tiktok.misc.extension import app.revanced.patches.shared.misc.extension.sharedExtensionPatch -val sharedExtensionPatch = sharedExtensionPatch("tiktok", initHook, jatoInitHook) +val sharedExtensionPatch = sharedExtensionPatch("tiktok", initHook, jatoInitHook, storeRegionInitHook) diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/extension/Hooks.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/extension/Hooks.kt index 75382f92c..db1912677 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/extension/Hooks.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/extension/Hooks.kt @@ -3,9 +3,7 @@ package app.revanced.patches.tiktok.misc.extension import app.revanced.patches.shared.misc.extension.extensionHook import com.android.tools.smali.dexlib2.AccessFlags -internal val initHook = extensionHook( - insertIndexResolver = { 0 } -) { +internal val initHook = extensionHook { custom { method, classDef -> classDef.type == "Lcom/ss/android/ugc/aweme/main/MainActivity;" && method.name == "onCreate" @@ -16,14 +14,24 @@ internal val initHook = extensionHook( * In some cases the extension code can be called before * the app main activity onCreate is called. * - * This class is called from startup code titled "BPEA RunnableGuardLancet" + * This class is called from startup code titled "BPEA RunnableGuardLancet". */ internal val jatoInitHook = extensionHook( - insertIndexResolver = { 0 }, contextRegisterResolver = { "p1" } ) { + parameters("Landroid/content/Context;") custom { method, classDef -> classDef.type == "Lcom/ss/android/ugc/aweme/legoImp/task/JatoInitTask;" && method.name == "run" } } + +internal val storeRegionInitHook = extensionHook( + contextRegisterResolver = { "p1" } +) { + parameters("Landroid/content/Context;") + custom { method, classDef -> + classDef.type == "Lcom/ss/android/ugc/aweme/legoImp/task/StoreRegionInitTask;" && + method.name == "run" + } +}