程序包 io.github.libxposed.api
This package provides the public API for developing Xposed modules using the modern Xposed framework. It replaces the legacy XposedBridge API with a redesigned, type-safe interface.
Getting Started
Module entry classes should extend XposedModule. The
framework calls attachFramework() automatically; modules should not perform initialization work before
onModuleLoaded() is called.
Entry Registration
Java entry classes are listed in META-INF/xposed/java_init.list (one fully-qualified
class name per line); native entries use META-INF/xposed/native_init.list. Place these
files under src/main/resources/META-INF/xposed/ and Gradle will package them into the
APK automatically.
Module Configuration
Module metadata is specified via standard Android resources (android:label for the
module name, android:description for the description) and
META-INF/xposed/module.prop (Java Properties format). Required
properties:
minApiVersion– minimum Xposed API version requiredtargetApiVersion– target Xposed API version
Optional properties:
staticScope(boolean) – whether the module scope is fixed and users should not apply the module on apps outside the scope listexceptionMode(string) [protective|passthrough] - Default to protective, seeXposedInterface.ExceptionMode
Scope
Module scope is defined by a list of package names in META-INF/xposed/scope.list.
The framework injects the module into all regular processes declared by those packages.
After injection, every loaded package in that process will trigger callbacks.
As a result, modules may receive callbacks beyond the originally scoped packages, so they
should always filter by process name and package name.
A special case applies to components declared with android:process="system" in a
android:sharedUserId="android.uid.system" package: they run in system server.
For packages whose components all run in system server, adding the package name itself to the
scope has no effect. Instead, system server is represented by the special virtual package name
system, which should be used explicitly.
Note that android package is still a valid scope target because some of its
components declare android:process=":ui" and therefore do not run in system server.
Modules scoped to android can still receive events for android package loading
even though android package has no code. By contrast, com.android.providers.settings
is not a valid scope target, modules should use the system scope and then wait
for the com.android.providers.settings package loading event.
Hook Model
The API uses an interceptor-chain model (similar to OkHttp interceptors). Modules
implement Hooker and its
intercept(Chain) method. Hooking is performed through a builder returned by
hook(Executable):
HookHandle handle = hook(method)
.setPriority(PRIORITY_DEFAULT)
.setExceptionMode(ExceptionMode.PROTECTIVE)
.intercept(chain -> {
// pre-processing
Object result = chain.proceed();
// post-processing
return result;
});
Invoker System
To call the original (or hooked) method bypassing access checks, obtain an
Invoker via
getInvoker(Method) or
getInvoker(Constructor). The invoker type controls what part of the hook chain is executed
(see Invoker.Type).
Module Lifecycle Callbacks
Override the following callbacks in XposedModule:
onModuleLoaded()– called once when the module is loaded into the target process.onPackageLoaded()– called when the default classloader is ready, beforeAppComponentFactoryinstantiation (API 29+).onPackageReady()– called after the app classloader is created.onSystemServerStarting()– called once when system server is starting. This callback replaces the first package load phase.
Error Handling
Framework-level errors are reported via subclasses of
XposedFrameworkError. In particular,
HookFailedError indicates a fatal hook failure that
should be reported to the framework maintainers instead of handled by the module.
- 另请参阅:
-
类说明Xposed interface for modules to operate on application processes.Interceptor chain for a method or constructor.Invoker for a constructor.Exception handling mode for hookers.Builder for configuring a hook.Hooker for a method or constructor.Handle for a hook.Invoker for a method or constructor.Type of the invoker, which determines the hook chain to be invokedInvokes the executable starting from the middle of the hook chain, skipping all hooks with priority higher than the given value.Invokes the original executable, skipping all hooks.Wrapper of
XposedInterfaceused by modules to shield framework implementation details.Super class which all Xposed module entry classes should extend.
Entry classes will be instantiated exactly once for each process.Interface for module initialization.Wraps information about the process in which the module is loaded.Wraps information about the package being loaded.Wraps information about the package whose classloader is ready.Wraps information about system server.