Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
feat: add debugging logs during initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mkx173 committed Aug 6, 2024
1 parent 8014c20 commit b72a758
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/src/main/java/gm/tieba/tabswitch/XposedInit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class XposedInit : XposedContext(), IXposedHookZygoteInit, IXposedHookLoadPackag
"com.baidu.tieba.tblauncher.MainTabActivity", lpparam.classLoader
) == null)) return

XposedBridge.log("Loading TiebaTS, version ${BuildConfig.VERSION_CODE}")

sClassLoader = lpparam.classLoader
sAssetManager = XModuleResources.createInstance(sPath, null).assets
mAppComponentFactory = sClassLoader.loadClass("com.baidu.nps.hook.component.NPSComponentFactory")
Expand Down Expand Up @@ -119,12 +121,14 @@ class XposedInit : XposedContext(), IXposedHookZygoteInit, IXposedHookLoadPackag
Preferences.init(getContext())
AcRules.init(getContext())
DeobfuscationHelper.sCurrentTbVersion = getTbVersion(getContext())
XposedBridge.log("TB client detected, version ${DeobfuscationHelper.sCurrentTbVersion}")

// Workaround to address an issue with LSPatch (unable to open personal homepage)
// com.baidu.tieba.flutter.base.view.FlutterPageActivity must be instantiated by com.baidu.nps.hook.component.NPSComponentFactory
// However, LSPatch incorrectly sets appComponentFactory to null, causing android.app.Instrumentation.getFactory to fall back to AppComponentFactory.DEFAULT
// (see https://github.com/LSPosed/LSPatch/blob/bbe8d93fb9230f7b04babaf1c4a11642110f55a6/patch-loader/src/main/java/org/lsposed/lspatch/loader/LSPApplication.java#L173)
if (getContext().applicationInfo.appComponentFactory == null) {
XposedBridge.log("Applying LSPatch workaround")
hookAfterMethod(
Instrumentation::class.java,
"getFactory", String::class.java
Expand Down Expand Up @@ -175,6 +179,9 @@ class XposedInit : XposedContext(), IXposedHookZygoteInit, IXposedHookLoadPackag
}
}

val enabledKeys = getAll().filter { (_, value) -> value is Boolean && value == true }.keys
XposedBridge.log("Enabled hooks: ${enabledKeys.joinToString(", ")}")

val matchersList = matchers.flatMap { it.matchers() }.toMutableList()

// Remove matchers that does not satisfy version requirement
Expand Down Expand Up @@ -209,7 +216,7 @@ class XposedInit : XposedContext(), IXposedHookZygoteInit, IXposedHookLoadPackag
).apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) })
}
}
XposedBridge.log("Deobfuscation")
XposedBridge.log("Tb version changed. Performing deobfuscation")

DeobfuscationHooker(matchersList).hook()
return@hookAfterMethod
Expand Down

0 comments on commit b72a758

Please sign in to comment.