Skip to content

Commit fcfc37e

Browse files
authored
Clarity modern modules loading process (#662)
Both legacy and modern modules are loaded in `XposedInit.java`. However, to facilitate context fetching and resource loading, modern modules are loaded after an activity thread is attached (`AppAttachHooker.kt`). We thus correct docs in comments, and add `VectorModuleManager` into `kModuleTags` to monitor modern module loading. Moreover, the private field of `VectorChain` is renamed to improve readability.
1 parent 1983e00 commit fcfc37e

4 files changed

Lines changed: 9 additions & 8 deletions

File tree

daemon/src/main/jni/logcat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ constexpr std::array<char, ANDROID_LOG_SILENT + 1> kLogChar = {
3434

3535
// Module tags are sorted for O(log N) binary search.
3636
// These always route to the 'modules' (Xposed) log stream.
37-
constexpr auto kModuleTags =
38-
std::array{"VectorContext"sv, "VectorLegacyBridge"sv, "XSharedPreferences"sv};
37+
constexpr auto kModuleTags = std::array{"VectorContext"sv, "VectorLegacyBridge"sv,
38+
"VectorModuleManager"sv, "XSharedPreferences"sv};
3939

4040
// These route to the 'verbose' stream only.
4141
constexpr auto kExactTags = std::array{"APatchD"sv, "Dobby"sv, "KernelSU"sv, "LSPlant"sv,

xposed/src/main/kotlin/org/matrix/vector/impl/di/VectorBootstrap.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fun interface OriginalInvoker {
2222
* methods at the appropriate lifecycle moments.
2323
*/
2424
interface LegacyFrameworkDelegate {
25-
/** Instructs the legacy bridge to load legacy modules. */
25+
/** Instructs the legacy bridge to load modern modules. */
2626
fun loadModules(activityThread: Any)
2727

2828
/** Dispatches a package load event to legacy XC_LoadPackage callbacks. */

xposed/src/main/kotlin/org/matrix/vector/impl/hookers/AppAttachHooker.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.matrix.vector.impl.di.VectorBootstrap
55

66
/**
77
* Intercepts the early ApplicationThread attachment phase. Triggers the legacy compatibility layer
8-
* to load modules into the process.
8+
* to load modern modules into the process.
99
*/
1010
object AppAttachHooker : XposedInterface.Hooker {
1111
override fun intercept(chain: XposedInterface.Chain): Any? {

xposed/src/main/kotlin/org/matrix/vector/impl/hooks/VectorChain.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class VectorChain(
2222
private val thisObj: Any?,
2323
private val args: Array<Any?>,
2424
private val hooks: Array<VectorHookRecord>,
25-
private val index: Int,
25+
private val hookIndex: Int,
2626
private val terminal: (thisObj: Any?, args: Array<Any?>) -> Any?,
2727
) : Chain {
2828

@@ -55,12 +55,13 @@ class VectorChain(
5555
proceedCalled = true
5656

5757
// Reached the end of the modern hooks; trigger the original executable (and legacy hooks)
58-
if (index >= hooks.size) {
58+
if (hookIndex >= hooks.size) {
5959
return executeDownstream { terminal(thisObject, currentArgs) }
6060
}
6161

62-
val record = hooks[index]
63-
val nextChain = VectorChain(executable, thisObject, currentArgs, hooks, index + 1, terminal)
62+
val record = hooks[hookIndex]
63+
val nextChain =
64+
VectorChain(executable, thisObject, currentArgs, hooks, hookIndex + 1, terminal)
6465

6566
return try {
6667
executeDownstream { record.hooker.intercept(nextChain) }

0 commit comments

Comments
 (0)