API documents for XposedInterface
This commit is contained in:
parent
ffbce13602
commit
5d308c14c5
|
|
@ -1,5 +1,6 @@
|
||||||
package io.github.libxposed.api;
|
package io.github.libxposed.api;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
|
@ -485,105 +486,116 @@ public interface XposedInterface {
|
||||||
<T> MethodUnhooker<Hooker<Constructor<T>>, Constructor<T>> hook(@NonNull Constructor<T> origin, int priority, @NonNull Hooker<Constructor<T>> hooker);
|
<T> MethodUnhooker<Hooker<Constructor<T>>, Constructor<T>> hook(@NonNull Constructor<T> origin, int priority, @NonNull Hooker<Constructor<T>> hooker);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deoptimize boolean.
|
* Deoptimizes a method in case hooked callee is not called because of inline.
|
||||||
*
|
*
|
||||||
* @param method the method
|
* <p>By deoptimizing the method, the method will back all callee without inlining.
|
||||||
* @return the boolean
|
* For example, when a short hooked method B is invoked by method A, the callback to B is not invoked
|
||||||
|
* after hooking, which may mean A has inlined B inside its method body. To force A to call the hooked B,
|
||||||
|
* you can deoptimize A and then your hook can take effect.</p>
|
||||||
|
*
|
||||||
|
* <p>Generally, you need to find all the callers of your hooked callee and that can be hardly achieve
|
||||||
|
* (but you can still search all callers by using {@link DexParser}). Use this method if you are sure
|
||||||
|
* the deoptimized callers are all you need. Otherwise, it would be better to change the hook point or
|
||||||
|
* to deoptimize the whole app manually (by simply reinstalling the app without uninstall).</p>
|
||||||
|
*
|
||||||
|
* @param method The method to deoptimize
|
||||||
|
* @return Indicate whether the deoptimizing succeed or not
|
||||||
*/
|
*/
|
||||||
boolean deoptimize(@NonNull Method method);
|
boolean deoptimize(@NonNull Method method);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deoptimize boolean.
|
* Deoptimizes a constructor in case hooked callee is not called because of inline.
|
||||||
*
|
*
|
||||||
* @param <T> the type parameter
|
* @param <T> The type of the constructor
|
||||||
* @param constructor the constructor
|
* @param constructor The constructor to deoptimize
|
||||||
* @return the boolean
|
* @return Indicate whether the deoptimizing succeed or not
|
||||||
|
* @see #deoptimize(Method)
|
||||||
*/
|
*/
|
||||||
<T> boolean deoptimize(@NonNull Constructor<T> constructor);
|
<T> boolean deoptimize(@NonNull Constructor<T> constructor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke origin object.
|
* Basically the same as {@link Method#invoke(Object, Object...)}, but calls the original method
|
||||||
|
* as it was before the interception by Xposed.
|
||||||
*
|
*
|
||||||
* @param method the method
|
* @param method The method to be called
|
||||||
* @param thisObject the this object
|
* @param thisObject For non-static calls, the {@code this} pointer, otherwise {@code null}
|
||||||
* @param args the args
|
* @param args The arguments used for the method call
|
||||||
* @return the object
|
* @return The result returned from the invoked method
|
||||||
* @throws InvocationTargetException the invocation target exception
|
* @see Method#invoke(Object, Object...)
|
||||||
* @throws IllegalArgumentException the illegal argument exception
|
|
||||||
* @throws IllegalAccessException the illegal access exception
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
Object invokeOrigin(@NonNull Method method, @Nullable Object thisObject, Object... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException;
|
Object invokeOrigin(@NonNull Method method, @Nullable Object thisObject, Object... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke special object.
|
* Invokes a special (non-virtual) method on a given object instance, similar to the functionality of
|
||||||
|
* {@code CallNonVirtual<type>Method} in JNI, which invokes an instance (nonstatic) method on a Java
|
||||||
|
* object. This method is useful when you need to call a specific method on an object, bypassing any
|
||||||
|
* overridden methods in subclasses and directly invoking the method defined in the specified class.
|
||||||
*
|
*
|
||||||
* @param method the method
|
* <p>This method is useful when you need to call {@code super.xxx()} in a hooked constructor.</p>
|
||||||
* @param thisObject the this object
|
*
|
||||||
* @param args the args
|
* @param method The method to be called
|
||||||
* @return the object
|
* @param thisObject For non-static calls, the {@code this} pointer, otherwise {@code null}
|
||||||
* @throws InvocationTargetException the invocation target exception
|
* @param args The arguments used for the method call
|
||||||
* @throws IllegalArgumentException the illegal argument exception
|
* @return The result returned from the invoked method
|
||||||
* @throws IllegalAccessException the illegal access exception
|
* @see Method#invoke(Object, Object...)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
Object invokeSpecial(@NonNull Method method, @NonNull Object thisObject, Object... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException;
|
Object invokeSpecial(@NonNull Method method, @NonNull Object thisObject, Object... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* new origin object.
|
* Basically the same as {@link Constructor#newInstance(Object...)}, but calls the original constructor
|
||||||
|
* as it was before the interception by Xposed.
|
||||||
*
|
*
|
||||||
* @param <T> the type parameter
|
* @param <T> The type of the constructor
|
||||||
* @param constructor the constructor
|
* @param constructor The constructor to create and initialize a new instance
|
||||||
* @param args the args
|
* @param args The arguments used for the construction
|
||||||
* @return the object
|
* @return The instance created and initialized by the constructor
|
||||||
* @throws InvocationTargetException the invocation target exception
|
* @see Constructor#newInstance(Object...)
|
||||||
* @throws IllegalArgumentException the illegal argument exception
|
|
||||||
* @throws IllegalAccessException the illegal access exception
|
|
||||||
* @throws InstantiationException the instantiation exception
|
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> T newInstanceOrigin(@NonNull Constructor<T> constructor, Object... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException, InstantiationException;
|
<T> T newInstanceOrigin(@NonNull Constructor<T> constructor, Object... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException, InstantiationException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New instance special u.
|
* Creates a new instance of the given subclass, but initialize it with a parent constructor. This could
|
||||||
|
* leave the object in an invalid state, where the subclass constructor are not called and the fields
|
||||||
|
* of the subclass are not initialized.
|
||||||
*
|
*
|
||||||
* @param <T> the type parameter
|
* <p>This method is useful when you need to initialize some fields in the subclass by yourself.</p>
|
||||||
* @param <U> the type parameter
|
*
|
||||||
* @param constructor the constructor
|
* @param <T> The type of the parent constructor
|
||||||
* @param subClass the sub class
|
* @param <U> The type of the subclass
|
||||||
* @param args the args
|
* @param constructor The parent constructor to initialize a new instance
|
||||||
* @return the u
|
* @param subClass The subclass to create a new instance
|
||||||
* @throws InvocationTargetException the invocation target exception
|
* @param args The arguments used for the construction
|
||||||
* @throws IllegalArgumentException the illegal argument exception
|
* @return The instance of subclass initialized by the constructor
|
||||||
* @throws IllegalAccessException the illegal access exception
|
* @see Constructor#newInstance(Object...)
|
||||||
* @throws InstantiationException the instantiation exception
|
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T, U> U newInstanceSpecial(@NonNull Constructor<T> constructor, @NonNull Class<U> subClass, Object... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException, InstantiationException;
|
<T, U> U newInstanceSpecial(@NonNull Constructor<T> constructor, @NonNull Class<U> subClass, Object... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException, InstantiationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log.
|
* Writes a message to the Xposed log.
|
||||||
*
|
*
|
||||||
* @param message the message
|
* @param message The log message
|
||||||
*/
|
*/
|
||||||
void log(@NonNull String message);
|
void log(@NonNull String message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log.
|
* Writes a message with a stack trace to the Xposed log.
|
||||||
*
|
*
|
||||||
* @param message the message
|
* @param message The log message
|
||||||
* @param throwable the throwable
|
* @param throwable The Throwable object for the stack trace
|
||||||
*/
|
*/
|
||||||
void log(@NonNull String message, @NonNull Throwable throwable);
|
void log(@NonNull String message, @NonNull Throwable throwable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse dex dex parser.
|
* Parse a dex file in memory.
|
||||||
*
|
*
|
||||||
* @param dexData the dex data
|
* @param dexData The content of the dex file
|
||||||
* @param includeAnnotations the include annotations
|
* @param includeAnnotations Whether to include annotations
|
||||||
* @return the dex parser
|
* @return The {@link DexParser} of the dex file
|
||||||
* @throws IOException the io exception
|
* @throws IOException if the dex file is invalid
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
DexParser parseDex(@NonNull ByteBuffer dexData, boolean includeAnnotations) throws IOException;
|
DexParser parseDex(@NonNull ByteBuffer dexData, boolean includeAnnotations) throws IOException;
|
||||||
|
|
@ -592,48 +604,38 @@ public interface XposedInterface {
|
||||||
// Methods the same with Context
|
// Methods the same with Context
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets shared preferences.
|
* Gets remote preferences stored in Xposed framework. Note that those are read-only in hooked apps.
|
||||||
*
|
*
|
||||||
* @param name the name
|
* @see Context#getSharedPreferences(String, int)
|
||||||
* @param mode the mode
|
|
||||||
* @return the shared preferences
|
|
||||||
*/
|
*/
|
||||||
SharedPreferences getSharedPreferences(String name, int mode);
|
SharedPreferences getSharedPreferences(String name, int mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open file input file input stream.
|
* Open a remote file stored in Xposed framework.
|
||||||
*
|
*
|
||||||
* @param name the name
|
* @see Context#openFileInput(String)
|
||||||
* @return the file input stream
|
|
||||||
* @throws FileNotFoundException the file not found exception
|
|
||||||
*/
|
*/
|
||||||
FileInputStream openFileInput(String name) throws FileNotFoundException;
|
FileInputStream openFileInput(String name) throws FileNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File list string [ ].
|
* List all remote files stored in Xposed framework. Note that you can only access files created by
|
||||||
|
* your own module app with XposedService.
|
||||||
*
|
*
|
||||||
* @return the string [ ]
|
* @see Context#fileList()
|
||||||
*/
|
*/
|
||||||
String[] fileList();
|
String[] fileList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets resources.
|
* Gets resources of the module.
|
||||||
*
|
*
|
||||||
* @return the resources
|
* @see Context#getResources()
|
||||||
*/
|
*/
|
||||||
Resources getResources();
|
Resources getResources();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets class loader.
|
* Gets the application info of the module.
|
||||||
*
|
*
|
||||||
* @return the class loader
|
* @see Context#getApplicationInfo()
|
||||||
*/
|
|
||||||
ClassLoader getClassLoader();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets application info.
|
|
||||||
*
|
|
||||||
* @return the application info
|
|
||||||
*/
|
*/
|
||||||
ApplicationInfo getApplicationInfo();
|
ApplicationInfo getApplicationInfo();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue