-
public final class XposedHelpersHelpers that simplify hooking and calling methods/constructors, getting and settings fields, ...
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classXposedHelpers.ClassNotFoundErrorThrown when a class loader is unable to find a class. Unlike ClassNotFoundException,callers are not forced to explicitly catch this. If uncaught, the error will be passed to thenext caller in the stack.
public final classXposedHelpers.InvocationTargetErrorThis class provides a wrapper for an exception thrown by a method invocation.
-
Method Summary
Modifier and Type Method Description static Class<out Object>findClass(String className, ClassLoader classLoader)Look up a class with the specified class loader. static Class<out Object>findClassIfExists(String className, ClassLoader classLoader)Look up and return a class if it exists. static FieldfindField(Class<out Object> clazz, String fieldName)Look up a field in a class and set it to accessible. static FieldfindFieldIfExists(Class<out Object> clazz, String fieldName)Look up and return a field if it exists. static FieldfindFirstFieldByExactType(Class<out Object> clazz, Class<out Object> type)Returns the first field of the given type in a class.Might be useful for Proguard'ed classes to identify fields with unique types. static XC_MethodHook.UnhookfindAndHookMethod(Class<out Object> clazz, String methodName, Array<Object> parameterTypesAndCallback)Look up a method and hook it. static XC_MethodHook.UnhookfindAndHookMethod(String className, ClassLoader classLoader, String methodName, Array<Object> parameterTypesAndCallback)Look up a method and hook it. static MethodfindMethodExact(Class<out Object> clazz, String methodName, Array<Object> parameterTypes)Look up a method in a class and set it to accessible. static MethodfindMethodExactIfExists(Class<out Object> clazz, String methodName, Array<Object> parameterTypes)Look up and return a method if it exists. static MethodfindMethodExact(String className, ClassLoader classLoader, String methodName, Array<Object> parameterTypes)Look up a method in a class and set it to accessible.The method must be declared or overridden in the given class. static MethodfindMethodExactIfExists(String className, ClassLoader classLoader, String methodName, Array<Object> parameterTypes)Look up and return a method if it exists. static MethodfindMethodExact(Class<out Object> clazz, String methodName, Array<Class<out Object>> parameterTypes)Look up a method in a class and set it to accessible. static Array<Method>findMethodsByExactParameters(Class<out Object> clazz, Class<out Object> returnType, Array<Class<out Object>> parameterTypes)Returns an array of all methods declared/overridden in a class with the specified parameter types. static MethodfindMethodBestMatch(Class<out Object> clazz, String methodName, Array<Class<out Object>> parameterTypes)Look up a method in a class and set it to accessible. static MethodfindMethodBestMatch(Class<out Object> clazz, String methodName, Array<Object> args)Look up a method in a class and set it to accessible. static MethodfindMethodBestMatch(Class<out Object> clazz, String methodName, Array<Class<out Object>> parameterTypes, Array<Object> args)Look up a method in a class and set it to accessible. static Array<Class<out Object>>getParameterTypes(Array<Object> args)Returns an array with the classes of the given objects. static Array<Class<out Object>>getClassesAsArray(Array<Class<out Object>> clazzes)Returns an array of the given classes. static Constructor<out Object>findConstructorExact(Class<out Object> clazz, Array<Object> parameterTypes)Look up a constructor of a class and set it to accessible. static Constructor<out Object>findConstructorExactIfExists(Class<out Object> clazz, Array<Object> parameterTypes)Look up and return a constructor if it exists. static Constructor<out Object>findConstructorExact(String className, ClassLoader classLoader, Array<Object> parameterTypes)Look up a constructor of a class and set it to accessible. static Constructor<out Object>findConstructorExactIfExists(String className, ClassLoader classLoader, Array<Object> parameterTypes)Look up and return a constructor if it exists. static Constructor<out Object>findConstructorExact(Class<out Object> clazz, Array<Class<out Object>> parameterTypes)Look up a constructor of a class and set it to accessible. static XC_MethodHook.UnhookfindAndHookConstructor(Class<out Object> clazz, Array<Object> parameterTypesAndCallback)Look up a constructor and hook it. static XC_MethodHook.UnhookfindAndHookConstructor(String className, ClassLoader classLoader, Array<Object> parameterTypesAndCallback)Look up a constructor and hook it. static Constructor<out Object>findConstructorBestMatch(Class<out Object> clazz, Array<Class<out Object>> parameterTypes)Look up a constructor in a class and set it to accessible. static Constructor<out Object>findConstructorBestMatch(Class<out Object> clazz, Array<Object> args)Look up a constructor in a class and set it to accessible. static Constructor<out Object>findConstructorBestMatch(Class<out Object> clazz, Array<Class<out Object>> parameterTypes, Array<Object> args)Look up a constructor in a class and set it to accessible. static intgetFirstParameterIndexByType(Member method, Class<out Object> type)Returns the index of the first parameter declared with the given type. static intgetParameterIndexByType(Member method, Class<out Object> type)Returns the index of the parameter declared with the given type, ensuring that there is exactly one such parameter. static voidsetObjectField(Object obj, String fieldName, Object value)Sets the value of an object field in the given object instance. static voidsetBooleanField(Object obj, String fieldName, boolean value)Sets the value of a {@code boolean}field in the given object instance.static voidsetByteField(Object obj, String fieldName, byte value)Sets the value of a {@code byte}field in the given object instance.static voidsetCharField(Object obj, String fieldName, char value)Sets the value of a {@code char}field in the given object instance.static voidsetDoubleField(Object obj, String fieldName, double value)Sets the value of a {@code double}field in the given object instance.static voidsetFloatField(Object obj, String fieldName, float value)Sets the value of a {@code float}field in the given object instance.static voidsetIntField(Object obj, String fieldName, int value)Sets the value of an {@code int}field in the given object instance.static voidsetLongField(Object obj, String fieldName, long value)Sets the value of a {@code long}field in the given object instance.static voidsetShortField(Object obj, String fieldName, short value)Sets the value of a {@code short}field in the given object instance.static ObjectgetObjectField(Object obj, String fieldName)Returns the value of an object field in the given object instance. static ObjectgetSurroundingThis(Object obj)For inner classes, returns the surrounding instance, i.e. static booleangetBooleanField(Object obj, String fieldName)Returns the value of a {@code boolean}field in the given object instance.static bytegetByteField(Object obj, String fieldName)Returns the value of a {@code byte}field in the given object instance.static chargetCharField(Object obj, String fieldName)Returns the value of a {@code char}field in the given object instance.static doublegetDoubleField(Object obj, String fieldName)Returns the value of a {@code double}field in the given object instance.static floatgetFloatField(Object obj, String fieldName)Returns the value of a {@code float}field in the given object instance.static intgetIntField(Object obj, String fieldName)Returns the value of an {@code int}field in the given object instance.static longgetLongField(Object obj, String fieldName)Returns the value of a {@code long}field in the given object instance.static shortgetShortField(Object obj, String fieldName)Returns the value of a {@code short}field in the given object instance.static voidsetStaticObjectField(Class<out Object> clazz, String fieldName, Object value)Sets the value of a static object field in the given class. static voidsetStaticBooleanField(Class<out Object> clazz, String fieldName, boolean value)Sets the value of a static {@code boolean}field in the given class.static voidsetStaticByteField(Class<out Object> clazz, String fieldName, byte value)Sets the value of a static {@code byte}field in the given class.static voidsetStaticCharField(Class<out Object> clazz, String fieldName, char value)Sets the value of a static {@code char}field in the given class.static voidsetStaticDoubleField(Class<out Object> clazz, String fieldName, double value)Sets the value of a static {@code double}field in the given class.static voidsetStaticFloatField(Class<out Object> clazz, String fieldName, float value)Sets the value of a static {@code float}field in the given class.static voidsetStaticIntField(Class<out Object> clazz, String fieldName, int value)Sets the value of a static {@code int}field in the given class.static voidsetStaticLongField(Class<out Object> clazz, String fieldName, long value)Sets the value of a static {@code long}field in the given class.static voidsetStaticShortField(Class<out Object> clazz, String fieldName, short value)Sets the value of a static {@code short}field in the given class.static ObjectgetStaticObjectField(Class<out Object> clazz, String fieldName)Returns the value of a static object field in the given class. static booleangetStaticBooleanField(Class<out Object> clazz, String fieldName)Returns the value of a static {@code boolean}field in the given class.static bytegetStaticByteField(Class<out Object> clazz, String fieldName)Sets the value of a static {@code byte}field in the given class.static chargetStaticCharField(Class<out Object> clazz, String fieldName)Sets the value of a static {@code char}field in the given class.static doublegetStaticDoubleField(Class<out Object> clazz, String fieldName)Sets the value of a static {@code double}field in the given class.static floatgetStaticFloatField(Class<out Object> clazz, String fieldName)Sets the value of a static {@code float}field in the given class.static intgetStaticIntField(Class<out Object> clazz, String fieldName)Sets the value of a static {@code int}field in the given class.static longgetStaticLongField(Class<out Object> clazz, String fieldName)Sets the value of a static {@code long}field in the given class.static shortgetStaticShortField(Class<out Object> clazz, String fieldName)Sets the value of a static {@code short}field in the given class.static ObjectcallMethod(Object obj, String methodName, Array<Object> args)Calls an instance or static method of the given object. static ObjectcallMethod(Object obj, String methodName, Array<Class<out Object>> parameterTypes, Array<Object> args)Calls an instance or static method of the given object. static ObjectcallStaticMethod(Class<out Object> clazz, String methodName, Array<Object> args)Calls a static method of the given class. static ObjectcallStaticMethod(Class<out Object> clazz, String methodName, Array<Class<out Object>> parameterTypes, Array<Object> args)Calls a static method of the given class. static ObjectnewInstance(Class<out Object> clazz, Array<Object> args)Creates a new instance of the given class. static ObjectnewInstance(Class<out Object> clazz, Array<Class<out Object>> parameterTypes, Array<Object> args)Creates a new instance of the given class. static ObjectsetAdditionalInstanceField(Object obj, String key, Object value)Attaches any value to an object instance. static ObjectgetAdditionalInstanceField(Object obj, String key)Returns a value which was stored with setAdditionalInstanceField. static ObjectremoveAdditionalInstanceField(Object obj, String key)Removes and returns a value which was stored with setAdditionalInstanceField. static ObjectsetAdditionalStaticField(Object obj, String key, Object value)Like setAdditionalInstanceField, but the value is stored for the class of {@code obj}.static ObjectgetAdditionalStaticField(Object obj, String key)Like getAdditionalInstanceField, but the value is returned for the class of {@code obj}.static ObjectremoveAdditionalStaticField(Object obj, String key)Like removeAdditionalInstanceField, but the value is removed and returned for the class of {@code obj}.static ObjectsetAdditionalStaticField(Class<out Object> clazz, String key, Object value)Like setAdditionalInstanceField, but the value is stored for {@code clazz}.static ObjectgetAdditionalStaticField(Class<out Object> clazz, String key)Like setAdditionalInstanceField, but the value is returned for {@code clazz}.static ObjectremoveAdditionalStaticField(Class<out Object> clazz, String key)Like setAdditionalInstanceField, but the value is removed and returned for {@code clazz}.static Array<byte>assetAsByteArray(Resources res, String path)Loads an asset from a resource object and returns the content as {@code byte}array.static StringgetMD5Sum(String file)Returns the lowercase hex string representation of a file's MD5 hash sum. static intincrementMethodDepth(String method)Increments the depth counter for the given method. static intdecrementMethodDepth(String method)Decrements the depth counter for the given method. static intgetMethodDepth(String method)Returns the current depth counter for the given method. -
-
Method Detail
-
findClass
static Class<out Object> findClass(String className, ClassLoader classLoader)
Look up a class with the specified class loader.
There are various allowed syntaxes for the class name, but it's recommended to use one ofthese:
{@code java.lang.String}{@code java.lang.String[]}(array){@code android.app.ActivityThread.ResourcesKey}{@code android.app.ActivityThread$ResourcesKey}
- Parameters:
className- The class name in one of the formats mentioned above.classLoader- The class loader, or{@code null}for the boot class loader.
-
findClassIfExists
static Class<out Object> findClassIfExists(String className, ClassLoader classLoader)
Look up and return a class if it exists.Like findClass, but doesn't throw an exception if the class doesn't exist.
- Parameters:
className- The class name.classLoader- The class loader, or{@code null}for the boot class loader.
-
findField
static Field findField(Class<out Object> clazz, String fieldName)
Look up a field in a class and set it to accessible.
- Parameters:
clazz- The class which either declares or inherits the field.fieldName- The field name.
-
findFieldIfExists
static Field findFieldIfExists(Class<out Object> clazz, String fieldName)
Look up and return a field if it exists.Like findField, but doesn't throw an exception if the field doesn't exist.
- Parameters:
clazz- The class which either declares or inherits the field.fieldName- The field name.
-
findFirstFieldByExactType
static Field findFirstFieldByExactType(Class<out Object> clazz, Class<out Object> type)
Returns the first field of the given type in a class.Might be useful for Proguard'ed classes to identify fields with unique types.
- Parameters:
clazz- The class which either declares or inherits the field.type- The type of the field.
-
findAndHookMethod
static XC_MethodHook.Unhook findAndHookMethod(Class<out Object> clazz, String methodName, Array<Object> parameterTypesAndCallback)
Look up a method and hook it. See findAndHookMethod for details.
-
findAndHookMethod
static XC_MethodHook.Unhook findAndHookMethod(String className, ClassLoader classLoader, String methodName, Array<Object> parameterTypesAndCallback)
Look up a method and hook it. The last argument must be the callback for the hook.
This combines calls to findMethodExact and hookMethod.
The method must be declared or overridden in the given class, inheritedmethods are not considered! That's because each method implementation exists only once inthe memory, and when classes inherit it, they just get another reference to the implementation.Hooking a method therefore applies to all classes inheriting the same implementation. Youhave to expect that the hook applies to subclasses (unless they override the method), but youshouldn't have to worry about hooks applying to superclasses, hence this "limitation".There could be undesired or even dangerous hooks otherwise, e.g. if you hook
{@code SomeClass.equals()}and that class doesn't override the{@code equals()}on some ROMs,making you hook{@code Object.equals()}instead.There are two ways to specify the parameter types. If you already have a reference to the Class, use that. For Android framework classes, you can often use something like
{@code String.class}. If you don't have the class reference, you can simply use thefull class name as a string, e.g.{@code java.lang.String}or{@code com.example.MyClass}.It will be passed to findClass with the same class loader that is used for the targetmethod, see its documentation for the allowed notations.Primitive types, such as
{@code int}, can be specified using{@code int.class}(recommended)or{@code Integer.TYPE}. Note that{@code Integer.class}doesn't refer to{@code int}but to{@code Integer}, which is a normal class (boxed primitive). Therefore it must not be used whenthe method expects an{@code int}parameter - it has to be used for{@code Integer}parametersthough, so check the method signature in detail.As last argument to this method (after the list of target method parameters), you needto specify the callback that should be executed when the method is invoked. It's usuallyan anonymous subclass of XC_MethodHook or XC_MethodReplacement.
Example
// In order to hook this method ... package com.example; public class SomeClass { public int doSomething(String s, int i, MyClass m) { ... } } // ... you can use this call: findAndHookMethod("com.example.SomeClass", lpparam.classLoader, String.class, int.class, "com.example.MyClass", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { String oldText = (String) param.args[0]; Log.d("MyModule", oldText); param.args[0] = "test"; param.args[1] = 42; // auto-boxing is working here setBooleanField(param.args[2], "great", true); // This would not work (as MyClass can't be resolved at compile time): // MyClass myClass = (MyClass) param.args[2]; // myClass.great = true; } });- Parameters:
className- The name of the class which implements the method.classLoader- The class loader for resolving the target and parameter classes.methodName- The target method name.parameterTypesAndCallback- The parameter types of the target method, plus the callback.
-
findMethodExact
static Method findMethodExact(Class<out Object> clazz, String methodName, Array<Object> parameterTypes)
Look up a method in a class and set it to accessible.See findMethodExact for details.
-
findMethodExactIfExists
static Method findMethodExactIfExists(Class<out Object> clazz, String methodName, Array<Object> parameterTypes)
Look up and return a method if it exists.See findMethodExactIfExists for details.
-
findMethodExact
static Method findMethodExact(String className, ClassLoader classLoader, String methodName, Array<Object> parameterTypes)
Look up a method in a class and set it to accessible.The method must be declared or overridden in the given class.
See findAndHookMethod for details aboutthe method and parameter type resolution.
- Parameters:
className- The name of the class which implements the method.classLoader- The class loader for resolving the target and parameter classes.methodName- The target method name.parameterTypes- The parameter types of the target method.
-
findMethodExactIfExists
static Method findMethodExactIfExists(String className, ClassLoader classLoader, String methodName, Array<Object> parameterTypes)
Look up and return a method if it exists.Like findMethodExact, but doesn't throw anexception if the method doesn't exist.
- Parameters:
className- The name of the class which implements the method.classLoader- The class loader for resolving the target and parameter classes.methodName- The target method name.parameterTypes- The parameter types of the target method.
-
findMethodExact
static Method findMethodExact(Class<out Object> clazz, String methodName, Array<Class<out Object>> parameterTypes)
Look up a method in a class and set it to accessible.See findMethodExact for details.
This variant requires that you already have reference to all the parameter types.
-
findMethodsByExactParameters
static Array<Method> findMethodsByExactParameters(Class<out Object> clazz, Class<out Object> returnType, Array<Class<out Object>> parameterTypes)
Returns an array of all methods declared/overridden in a class with the specified parameter types.
The return type is optional, it will not be compared if it is
{@code null}.Use{@code void.class}if you want to search for methods returning nothing.- Parameters:
clazz- The class to look in.returnType- The return type, or{@code null}(see above).parameterTypes- The parameter types.
-
findMethodBestMatch
static Method findMethodBestMatch(Class<out Object> clazz, String methodName, Array<Class<out Object>> parameterTypes)
Look up a method in a class and set it to accessible.
This does'nt only look for exact matches, but for the best match. All considered candidatesmust be compatible with the given parameter types, i.e. the parameters must be assignableto the method's formal parameters. Inherited methods are considered here.
- Parameters:
clazz- The class which declares, inherits or overrides the method.methodName- The method name.parameterTypes- The types of the method's parameters.
-
findMethodBestMatch
static Method findMethodBestMatch(Class<out Object> clazz, String methodName, Array<Object> args)
Look up a method in a class and set it to accessible.
See findMethodBestMatch for details. This variantdetermines the parameter types from the classes of the given objects.
-
findMethodBestMatch
static Method findMethodBestMatch(Class<out Object> clazz, String methodName, Array<Class<out Object>> parameterTypes, Array<Object> args)
Look up a method in a class and set it to accessible.
See findMethodBestMatch for details. This variantdetermines the parameter types from the classes of the given objects. For any item that is
{@code null}, the type is taken from{@code parameterTypes}instead.
-
getParameterTypes
static Array<Class<out Object>> getParameterTypes(Array<Object> args)
Returns an array with the classes of the given objects.
-
getClassesAsArray
static Array<Class<out Object>> getClassesAsArray(Array<Class<out Object>> clazzes)
Returns an array of the given classes.
-
findConstructorExact
static Constructor<out Object> findConstructorExact(Class<out Object> clazz, Array<Object> parameterTypes)
Look up a constructor of a class and set it to accessible.See findMethodExact for details.
-
findConstructorExactIfExists
static Constructor<out Object> findConstructorExactIfExists(Class<out Object> clazz, Array<Object> parameterTypes)
Look up and return a constructor if it exists.See findMethodExactIfExists for details.
-
findConstructorExact
static Constructor<out Object> findConstructorExact(String className, ClassLoader classLoader, Array<Object> parameterTypes)
Look up a constructor of a class and set it to accessible.See findMethodExact for details.
-
findConstructorExactIfExists
static Constructor<out Object> findConstructorExactIfExists(String className, ClassLoader classLoader, Array<Object> parameterTypes)
Look up and return a constructor if it exists.See findMethodExactIfExists for details.
-
findConstructorExact
static Constructor<out Object> findConstructorExact(Class<out Object> clazz, Array<Class<out Object>> parameterTypes)
Look up a constructor of a class and set it to accessible.See findMethodExact for details.
-
findAndHookConstructor
static XC_MethodHook.Unhook findAndHookConstructor(Class<out Object> clazz, Array<Object> parameterTypesAndCallback)
Look up a constructor and hook it. See findAndHookMethod for details.
-
findAndHookConstructor
static XC_MethodHook.Unhook findAndHookConstructor(String className, ClassLoader classLoader, Array<Object> parameterTypesAndCallback)
Look up a constructor and hook it. See findAndHookMethod for details.
-
findConstructorBestMatch
static Constructor<out Object> findConstructorBestMatch(Class<out Object> clazz, Array<Class<out Object>> parameterTypes)
Look up a constructor in a class and set it to accessible.
See findMethodBestMatch for details.
-
findConstructorBestMatch
static Constructor<out Object> findConstructorBestMatch(Class<out Object> clazz, Array<Object> args)
Look up a constructor in a class and set it to accessible.
See findMethodBestMatch for details. This variantdetermines the parameter types from the classes of the given objects.
-
findConstructorBestMatch
static Constructor<out Object> findConstructorBestMatch(Class<out Object> clazz, Array<Class<out Object>> parameterTypes, Array<Object> args)
Look up a constructor in a class and set it to accessible.
See findMethodBestMatch for details. This variantdetermines the parameter types from the classes of the given objects. For any item that is
{@code null}, the type is taken from{@code parameterTypes}instead.
-
getFirstParameterIndexByType
static int getFirstParameterIndexByType(Member method, Class<out Object> type)
Returns the index of the first parameter declared with the given type.
-
getParameterIndexByType
static int getParameterIndexByType(Member method, Class<out Object> type)
Returns the index of the parameter declared with the given type, ensuring that there is exactly one such parameter.
-
setObjectField
static void setObjectField(Object obj, String fieldName, Object value)
Sets the value of an object field in the given object instance. A class reference is not sufficient! See also findField.
-
setBooleanField
static void setBooleanField(Object obj, String fieldName, boolean value)
Sets the value of a
{@code boolean}field in the given object instance. A class reference is not sufficient! See also findField.
-
setByteField
static void setByteField(Object obj, String fieldName, byte value)
Sets the value of a
{@code byte}field in the given object instance. A class reference is not sufficient! See also findField.
-
setCharField
static void setCharField(Object obj, String fieldName, char value)
Sets the value of a
{@code char}field in the given object instance. A class reference is not sufficient! See also findField.
-
setDoubleField
static void setDoubleField(Object obj, String fieldName, double value)
Sets the value of a
{@code double}field in the given object instance. A class reference is not sufficient! See also findField.
-
setFloatField
static void setFloatField(Object obj, String fieldName, float value)
Sets the value of a
{@code float}field in the given object instance. A class reference is not sufficient! See also findField.
-
setIntField
static void setIntField(Object obj, String fieldName, int value)
Sets the value of an
{@code int}field in the given object instance. A class reference is not sufficient! See also findField.
-
setLongField
static void setLongField(Object obj, String fieldName, long value)
Sets the value of a
{@code long}field in the given object instance. A class reference is not sufficient! See also findField.
-
setShortField
static void setShortField(Object obj, String fieldName, short value)
Sets the value of a
{@code short}field in the given object instance. A class reference is not sufficient! See also findField.
-
getObjectField
static Object getObjectField(Object obj, String fieldName)
Returns the value of an object field in the given object instance. A class reference is not sufficient! See also findField.
-
getSurroundingThis
static Object getSurroundingThis(Object obj)
For inner classes, returns the surrounding instance, i.e. the
{@code this}reference of the surrounding class.
-
getBooleanField
static boolean getBooleanField(Object obj, String fieldName)
Returns the value of a
{@code boolean}field in the given object instance. A class reference is not sufficient! See also findField.
-
getByteField
static byte getByteField(Object obj, String fieldName)
Returns the value of a
{@code byte}field in the given object instance. A class reference is not sufficient! See also findField.
-
getCharField
static char getCharField(Object obj, String fieldName)
Returns the value of a
{@code char}field in the given object instance. A class reference is not sufficient! See also findField.
-
getDoubleField
static double getDoubleField(Object obj, String fieldName)
Returns the value of a
{@code double}field in the given object instance. A class reference is not sufficient! See also findField.
-
getFloatField
static float getFloatField(Object obj, String fieldName)
Returns the value of a
{@code float}field in the given object instance. A class reference is not sufficient! See also findField.
-
getIntField
static int getIntField(Object obj, String fieldName)
Returns the value of an
{@code int}field in the given object instance. A class reference is not sufficient! See also findField.
-
getLongField
static long getLongField(Object obj, String fieldName)
Returns the value of a
{@code long}field in the given object instance. A class reference is not sufficient! See also findField.
-
getShortField
static short getShortField(Object obj, String fieldName)
Returns the value of a
{@code short}field in the given object instance. A class reference is not sufficient! See also findField.
-
setStaticObjectField
static void setStaticObjectField(Class<out Object> clazz, String fieldName, Object value)
Sets the value of a static object field in the given class. See also findField.
-
setStaticBooleanField
static void setStaticBooleanField(Class<out Object> clazz, String fieldName, boolean value)
Sets the value of a static
{@code boolean}field in the given class. See also findField.
-
setStaticByteField
static void setStaticByteField(Class<out Object> clazz, String fieldName, byte value)
Sets the value of a static
{@code byte}field in the given class. See also findField.
-
setStaticCharField
static void setStaticCharField(Class<out Object> clazz, String fieldName, char value)
Sets the value of a static
{@code char}field in the given class. See also findField.
-
setStaticDoubleField
static void setStaticDoubleField(Class<out Object> clazz, String fieldName, double value)
Sets the value of a static
{@code double}field in the given class. See also findField.
-
setStaticFloatField
static void setStaticFloatField(Class<out Object> clazz, String fieldName, float value)
Sets the value of a static
{@code float}field in the given class. See also findField.
-
setStaticIntField
static void setStaticIntField(Class<out Object> clazz, String fieldName, int value)
Sets the value of a static
{@code int}field in the given class. See also findField.
-
setStaticLongField
static void setStaticLongField(Class<out Object> clazz, String fieldName, long value)
Sets the value of a static
{@code long}field in the given class. See also findField.
-
setStaticShortField
static void setStaticShortField(Class<out Object> clazz, String fieldName, short value)
Sets the value of a static
{@code short}field in the given class. See also findField.
-
getStaticObjectField
static Object getStaticObjectField(Class<out Object> clazz, String fieldName)
Returns the value of a static object field in the given class. See also findField.
-
getStaticBooleanField
static boolean getStaticBooleanField(Class<out Object> clazz, String fieldName)
Returns the value of a static
{@code boolean}field in the given class. See also findField.
-
getStaticByteField
static byte getStaticByteField(Class<out Object> clazz, String fieldName)
Sets the value of a static
{@code byte}field in the given class. See also findField.
-
getStaticCharField
static char getStaticCharField(Class<out Object> clazz, String fieldName)
Sets the value of a static
{@code char}field in the given class. See also findField.
-
getStaticDoubleField
static double getStaticDoubleField(Class<out Object> clazz, String fieldName)
Sets the value of a static
{@code double}field in the given class. See also findField.
-
getStaticFloatField
static float getStaticFloatField(Class<out Object> clazz, String fieldName)
Sets the value of a static
{@code float}field in the given class. See also findField.
-
getStaticIntField
static int getStaticIntField(Class<out Object> clazz, String fieldName)
Sets the value of a static
{@code int}field in the given class. See also findField.
-
getStaticLongField
static long getStaticLongField(Class<out Object> clazz, String fieldName)
Sets the value of a static
{@code long}field in the given class. See also findField.
-
getStaticShortField
static short getStaticShortField(Class<out Object> clazz, String fieldName)
Sets the value of a static
{@code short}field in the given class. See also findField.
-
callMethod
static Object callMethod(Object obj, String methodName, Array<Object> args)
Calls an instance or static method of the given object.The method is resolved using findMethodBestMatch.
- Parameters:
obj- The object instance.methodName- The method name.args- The arguments for the method call.
-
callMethod
static Object callMethod(Object obj, String methodName, Array<Class<out Object>> parameterTypes, Array<Object> args)
Calls an instance or static method of the given object.See callMethod.
This variant allows you to specify parameter types, which can help in case there are multiplemethods with the same name, especially if you call it with
{@code null}parameters.
-
callStaticMethod
static Object callStaticMethod(Class<out Object> clazz, String methodName, Array<Object> args)
Calls a static method of the given class.The method is resolved using findMethodBestMatch.
- Parameters:
clazz- The class reference.methodName- The method name.args- The arguments for the method call.
-
callStaticMethod
static Object callStaticMethod(Class<out Object> clazz, String methodName, Array<Class<out Object>> parameterTypes, Array<Object> args)
Calls a static method of the given class.See callStaticMethod.
This variant allows you to specify parameter types, which can help in case there are multiplemethods with the same name, especially if you call it with
{@code null}parameters.
-
newInstance
static Object newInstance(Class<out Object> clazz, Array<Object> args)
Creates a new instance of the given class.The constructor is resolved using findConstructorBestMatch.
- Parameters:
clazz- The class reference.args- The arguments for the constructor call.
-
newInstance
static Object newInstance(Class<out Object> clazz, Array<Class<out Object>> parameterTypes, Array<Object> args)
Creates a new instance of the given class.See newInstance.
This variant allows you to specify parameter types, which can help in case there are multipleconstructors with the same name, especially if you call it with
{@code null}parameters.
-
setAdditionalInstanceField
static Object setAdditionalInstanceField(Object obj, String key, Object value)
Attaches any value to an object instance. This simulates adding an instance field.The value can be retrieved again with getAdditionalInstanceField.
- Parameters:
obj- The object instance for which the value should be stored.key- The key in the value map for this object instance.value- The value to store.
-
getAdditionalInstanceField
static Object getAdditionalInstanceField(Object obj, String key)
Returns a value which was stored with setAdditionalInstanceField.
- Parameters:
obj- The object instance for which the value has been stored.key- The key in the value map for this object instance.
-
removeAdditionalInstanceField
static Object removeAdditionalInstanceField(Object obj, String key)
Removes and returns a value which was stored with setAdditionalInstanceField.
- Parameters:
obj- The object instance for which the value has been stored.key- The key in the value map for this object instance.
-
setAdditionalStaticField
static Object setAdditionalStaticField(Object obj, String key, Object value)
Like setAdditionalInstanceField, but the value is stored for the class of
{@code obj}.
-
getAdditionalStaticField
static Object getAdditionalStaticField(Object obj, String key)
Like getAdditionalInstanceField, but the value is returned for the class of
{@code obj}.
-
removeAdditionalStaticField
static Object removeAdditionalStaticField(Object obj, String key)
Like removeAdditionalInstanceField, but the value is removed and returned for the class of
{@code obj}.
-
setAdditionalStaticField
static Object setAdditionalStaticField(Class<out Object> clazz, String key, Object value)
Like setAdditionalInstanceField, but the value is stored for
{@code clazz}.
-
getAdditionalStaticField
static Object getAdditionalStaticField(Class<out Object> clazz, String key)
Like setAdditionalInstanceField, but the value is returned for
{@code clazz}.
-
removeAdditionalStaticField
static Object removeAdditionalStaticField(Class<out Object> clazz, String key)
Like setAdditionalInstanceField, but the value is removed and returned for
{@code clazz}.
-
assetAsByteArray
static Array<byte> assetAsByteArray(Resources res, String path)
Loads an asset from a resource object and returns the content as
{@code byte}array.- Parameters:
res- The resources from which the asset should be loaded.path- The path to the asset, as in open.
-
getMD5Sum
static String getMD5Sum(String file)
Returns the lowercase hex string representation of a file's MD5 hash sum.
-
incrementMethodDepth
static int incrementMethodDepth(String method)
Increments the depth counter for the given method.
The intention of the method depth counter is to keep track of the call depth for recursivemethods, e.g. to override parameters only for the outer call. The Xposed framework uses thisto load drawable replacements only once per call, even when multiple getDrawable variants call each other.
- Parameters:
method- The method name.
-
decrementMethodDepth
static int decrementMethodDepth(String method)
Decrements the depth counter for the given method.See incrementMethodDepth for details.
- Parameters:
method- The method name.
-
getMethodDepth
static int getMethodDepth(String method)
Returns the current depth counter for the given method.See incrementMethodDepth for details.
- Parameters:
method- The method name.
-
-
-
-