public final class XposedBridge
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.ClassLoader |
BOOTCLASSLOADER |
Constructor and Description |
---|
XposedBridge() |
Modifier and Type | Method and Description |
---|---|
static void |
deoptimizeMethod(java.lang.reflect.Member deoptimizedMethod)
Deoptimize a method to avoid callee being inlined.
|
static int |
getXposedVersion()
Returns the currently installed version of the Xposed framework.
|
static java.util.Set<XC_MethodHook.Unhook> |
hookAllConstructors(java.lang.Class<?> hookClass,
XC_MethodHook callback)
Hook all constructors of the specified class.
|
static java.util.Set<XC_MethodHook.Unhook> |
hookAllMethods(java.lang.Class<?> hookClass,
java.lang.String methodName,
XC_MethodHook callback)
Hooks all methods with a certain name that were declared in the specified class.
|
static void |
hookInitPackageResources(XC_InitPackageResources callback)
Adds a callback to be executed when the resources for an app are initialized.
|
static void |
hookLoadPackage(XC_LoadPackage callback)
Adds a callback to be executed when an app ("Android package") is loaded.
|
static XC_MethodHook.Unhook |
hookMethod(java.lang.reflect.Member hookMethod,
XC_MethodHook callback)
Hook any method (or constructor) with the specified callback.
|
static java.lang.Object |
invokeOriginalMethod(java.lang.reflect.Member method,
java.lang.Object thisObject,
java.lang.Object[] args)
Basically the same as
Method.invoke(java.lang.Object, java.lang.Object...) , but calls the original method
as it was before the interception by Xposed. |
static void |
log(java.lang.String text)
Writes a message to the Xposed modules log.
|
static void |
log(java.lang.Throwable t)
Logs a stack trace to the Xposed modules log.
|
static void |
unhookMethod(java.lang.reflect.Member hookMethod,
XC_MethodHook callback)
Deprecated.
Use
XC_MethodHook.Unhook.unhook() instead. An instance of the Unhook
class is returned when you hook the method. |
public static int getXposedVersion()
public static void log(java.lang.String text)
DON'T FLOOD THE LOG!!! This is only meant for error logging. If you want to write information/debug messages, use logcat.
text
- The log message.public static void log(java.lang.Throwable t)
DON'T FLOOD THE LOG!!! This is only meant for error logging. If you want to write information/debug messages, use logcat.
t
- The Throwable object for the stack trace.public static void deoptimizeMethod(java.lang.reflect.Member deoptimizedMethod)
deoptimizedMethod
- The method to deoptmize. Generally it should be a caller of a method
that is inlined.public static XC_MethodHook.Unhook hookMethod(java.lang.reflect.Member hookMethod, XC_MethodHook callback)
hookMethod
- The method to be hooked.callback
- The callback to be executed when the hooked method is called.XposedHelpers.findAndHookMethod(String, ClassLoader, String, Object...)
,
XposedHelpers.findAndHookMethod(Class, String, Object...)
,
XposedHelpers.findAndHookConstructor(String, ClassLoader, Object...)
,
XposedHelpers.findAndHookConstructor(Class, Object...)
@Deprecated public static void unhookMethod(java.lang.reflect.Member hookMethod, XC_MethodHook callback)
XC_MethodHook.Unhook.unhook()
instead. An instance of the Unhook
class is returned when you hook the method.hookMethod
- The method for which the callback should be removed.callback
- The reference to the callback as specified in hookMethod(java.lang.reflect.Member, de.robv.android.xposed.XC_MethodHook)
.public static java.util.Set<XC_MethodHook.Unhook> hookAllMethods(java.lang.Class<?> hookClass, java.lang.String methodName, XC_MethodHook callback)
hookAllConstructors(java.lang.Class<?>, de.robv.android.xposed.XC_MethodHook)
instead.hookClass
- The class to check for declared methods.methodName
- The name of the method(s) to hook.callback
- The callback to be executed when the hooked methods are called.public static java.util.Set<XC_MethodHook.Unhook> hookAllConstructors(java.lang.Class<?> hookClass, XC_MethodHook callback)
hookClass
- The class to check for constructors.callback
- The callback to be executed when the hooked constructors are called.public static void hookLoadPackage(XC_LoadPackage callback)
You probably don't need to call this. Simply implement IXposedHookLoadPackage
in your module class and Xposed will take care of registering it as a callback.
callback
- The callback to be executed.public static void hookInitPackageResources(XC_InitPackageResources callback)
You probably don't need to call this. Simply implement IXposedHookInitPackageResources
in your module class and Xposed will take care of registering it as a callback.
callback
- The callback to be executed.public static java.lang.Object invokeOriginalMethod(java.lang.reflect.Member method, java.lang.Object thisObject, java.lang.Object[] args) throws java.lang.Throwable
Method.invoke(java.lang.Object, java.lang.Object...)
, but calls the original method
as it was before the interception by Xposed. Also, access permissions are not checked.
There are very few cases where this method is needed. A common mistake is
to replace a method and then invoke the original one based on dynamic conditions. This
creates overhead and skips further hooks by other modules. Instead, just hook (don't replace)
the method and call param.setResult(null)
in XC_MethodHook.beforeHookedMethod(de.robv.android.xposed.XC_MethodHook.MethodHookParam<?>)
if the original method should be skipped.
method
- The method to be called.thisObject
- For non-static calls, the "this" pointer, otherwise null
.args
- Arguments for the method call as Object[] array.java.lang.NullPointerException
- if receiver == null
for a non-static methodjava.lang.IllegalAccessException
- if this method is not accessible (see AccessibleObject
)java.lang.IllegalArgumentException
- if the number of arguments doesn't match the number of parameters, the receiver
is incompatible with the declaring class, or an argument could not be unboxed
or converted by a widening conversion to the corresponding parameter typejava.lang.reflect.InvocationTargetException
- if an exception was thrown by the invoked methodjava.lang.Throwable