Generate java doc

This commit is contained in:
LoveSy 2023-01-10 21:23:30 +08:00
parent 45f3e9722a
commit 29ece95014
No known key found for this signature in database
6 changed files with 689 additions and 0 deletions

View File

@ -2,6 +2,9 @@ package io.github.libxposed;
import android.content.Context;
/**
* The type Xposed context.
*/
public abstract class XposedContext extends Context implements XposedInterface {
}

View File

@ -13,17 +13,35 @@ import java.nio.ByteBuffer;
import io.github.libxposed.utils.DexParser;
/**
* The type Xposed context wrapper.
*/
@SuppressWarnings("unused")
public class XposedContextWrapper extends ContextWrapper implements XposedInterface {
/**
* Instantiates a new Xposed context wrapper.
*
* @param base the base
*/
XposedContextWrapper(XposedContext base) {
super(base);
}
/**
* Instantiates a new Xposed context wrapper.
*
* @param base the base
*/
public XposedContextWrapper(XposedContextWrapper base) {
super(base);
}
/**
* Gets api version.
*
* @return the api version
*/
final public int getAPIVersion() {
return API;
}

View File

@ -12,152 +12,505 @@ import java.util.ConcurrentModificationException;
import io.github.libxposed.utils.DexParser;
/**
* The interface Xposed interface.
*/
@SuppressWarnings("unused")
public interface XposedInterface {
/**
* The constant API.
*/
int API = 100;
/**
* The constant FRAMEWORK_PRIVILEGE_ROOT.
*/
int FRAMEWORK_PRIVILEGE_ROOT = 0;
/**
* The constant FRAMEWORK_PRIVILEGE_CONTAINER.
*/
int FRAMEWORK_PRIVILEGE_CONTAINER = 1;
/**
* The constant FRAMEWORK_PRIVILEGE_APP.
*/
int FRAMEWORK_PRIVILEGE_APP = 2;
/**
* The constant FRAMEWORK_PRIVILEGE_EMBEDDED.
*/
int FRAMEWORK_PRIVILEGE_EMBEDDED = 3;
/**
* The interface Before hook callback.
*
* @param <T> the type parameter
*/
interface BeforeHookCallback<T> {
/**
* Gets origin.
*
* @return the origin
*/
@NonNull
T getOrigin();
/**
* Gets this.
*
* @return the this
*/
@Nullable
Object getThis();
/**
* Get args object [ ].
*
* @return the object [ ]
*/
@NonNull
Object[] getArgs();
/**
* Gets arg.
*
* @param <U> the type parameter
* @param index the index
* @return the arg
*/
@Nullable
<U> U getArg(int index);
/**
* Sets arg.
*
* @param <U> the type parameter
* @param index the index
* @param value the value
*/
<U> void setArg(int index, U value);
/**
* Return and skip.
*
* @param returnValue the return value
*/
void returnAndSkip(@Nullable Object returnValue);
/**
* Throw and skip.
*
* @param throwable the throwable
*/
void throwAndSkip(@Nullable Throwable throwable);
/**
* Invoke origin object.
*
* @param thisObject the this object
* @param args the args
* @return the object
* @throws InvocationTargetException the invocation target exception
* @throws IllegalAccessException the illegal access exception
*/
@Nullable
Object invokeOrigin(@Nullable Object thisObject, Object[] args) throws InvocationTargetException, IllegalAccessException;
/**
* Invoke origin object.
*
* @return the object
* @throws InvocationTargetException the invocation target exception
* @throws IllegalAccessException the illegal access exception
*/
@Nullable
Object invokeOrigin() throws InvocationTargetException, IllegalAccessException;
/**
* Sets extra.
*
* @param <U> the type parameter
* @param key the key
* @param value the value
* @throws ConcurrentModificationException the concurrent modification exception
*/
<U> void setExtra(@NonNull String key, @Nullable U value) throws ConcurrentModificationException;
}
/**
* The interface After hook callback.
*
* @param <T> the type parameter
*/
interface AfterHookCallback<T> {
/**
* Gets origin.
*
* @return the origin
*/
@NonNull
T getOrigin();
/**
* Gets this.
*
* @return the this
*/
@Nullable
Object getThis();
/**
* Get args object [ ].
*
* @return the object [ ]
*/
@NonNull
Object[] getArgs();
/**
* Gets result.
*
* @return the result
*/
@Nullable
Object getResult();
/**
* Gets throwable.
*
* @return the throwable
*/
@Nullable
Throwable getThrowable();
/**
* Is skipped boolean.
*
* @return the boolean
*/
boolean isSkipped();
/**
* Sets result.
*
* @param result the result
*/
void setResult(@Nullable Object result);
/**
* Sets throwable.
*
* @param throwable the throwable
*/
void setThrowable(@Nullable Throwable throwable);
/**
* Invoke origin object.
*
* @param thisObject the this object
* @param args the args
* @return the object
* @throws InvocationTargetException the invocation target exception
* @throws IllegalAccessException the illegal access exception
*/
@Nullable
Object invokeOrigin(@Nullable Object thisObject, Object[] args) throws InvocationTargetException, IllegalAccessException;
/**
* Invoke origin object.
*
* @return the object
* @throws InvocationTargetException the invocation target exception
* @throws IllegalAccessException the illegal access exception
*/
@Nullable
Object invokeOrigin() throws InvocationTargetException, IllegalAccessException;
/**
* Gets extra.
*
* @param <U> the type parameter
* @param key the key
* @return the extra
*/
@Nullable
<U> U getExtra(@NonNull String key);
}
/**
* The interface Before hooker.
*
* @param <T> the type parameter
*/
interface BeforeHooker<T> {
/**
* Before.
*
* @param callback the callback
*/
void before(@NonNull BeforeHookCallback<T> callback);
}
/**
* The interface After hooker.
*
* @param <T> the type parameter
*/
interface AfterHooker<T> {
/**
* After.
*
* @param callback the callback
*/
void after(@NonNull AfterHookCallback<T> callback);
}
/**
* The interface Hooker.
*
* @param <T> the type parameter
*/
interface Hooker<T> extends BeforeHooker<T>, AfterHooker<T> {
}
/**
* The interface Method unhooker.
*
* @param <T> the type parameter
* @param <U> the type parameter
*/
interface MethodUnhooker<T, U> {
/**
* Gets origin.
*
* @return the origin
*/
@NonNull
U getOrigin();
/**
* Gets hooker.
*
* @return the hooker
*/
@NonNull
T getHooker();
/**
* Unhook.
*/
void unhook();
}
/**
* Gets framework name.
*
* @return the framework name
*/
@NonNull
String getFrameworkName();
/**
* Gets framework version.
*
* @return the framework version
*/
@NonNull
String getFrameworkVersion();
/**
* Gets framework version code.
*
* @return the framework version code
*/
long getFrameworkVersionCode();
/**
* Gets framework privilege.
*
* @return the framework privilege
*/
int getFrameworkPrivilege();
/**
* Featured method object.
*
* @param name the name
* @param args the args
* @return the object
*/
Object featuredMethod(String name, Object... args);
/**
* Hook before method unhooker.
*
* @param origin the origin
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
MethodUnhooker<BeforeHooker<Method>, Method> hookBefore(@NonNull Method origin, @NonNull BeforeHooker<Method> hooker);
/**
* Hook after method unhooker.
*
* @param origin the origin
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
MethodUnhooker<AfterHooker<Method>, Method> hookAfter(@NonNull Method origin, @NonNull AfterHooker<Method> hooker);
/**
* Hook method unhooker.
*
* @param origin the origin
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
MethodUnhooker<Hooker<Method>, Method> hook(@NonNull Method origin, @NonNull Hooker<Method> hooker);
/**
* Hook before method unhooker.
*
* @param origin the origin
* @param priority the priority
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
MethodUnhooker<BeforeHooker<Method>, Method> hookBefore(@NonNull Method origin, int priority, @NonNull BeforeHooker<Method> hooker);
/**
* Hook after method unhooker.
*
* @param origin the origin
* @param priority the priority
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
MethodUnhooker<AfterHooker<Method>, Method> hookAfter(@NonNull Method origin, int priority, @NonNull AfterHooker<Method> hooker);
/**
* Hook method unhooker.
*
* @param origin the origin
* @param priority the priority
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
MethodUnhooker<Hooker<Method>, Method> hook(@NonNull Method origin, int priority, @NonNull Hooker<Method> hooker);
/**
* Hook before method unhooker.
*
* @param <T> the type parameter
* @param origin the origin
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
<T> MethodUnhooker<BeforeHooker<Constructor<T>>, Constructor<T>> hookBefore(@NonNull Constructor<T> origin, @NonNull BeforeHooker<Constructor<T>> hooker);
/**
* Hook after method unhooker.
*
* @param <T> the type parameter
* @param origin the origin
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
<T> MethodUnhooker<AfterHooker<Constructor<T>>, Constructor<T>> hookAfter(@NonNull Constructor<T> origin, @NonNull AfterHooker<Constructor<T>> hooker);
/**
* Hook method unhooker.
*
* @param <T> the type parameter
* @param origin the origin
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
<T> MethodUnhooker<Hooker<Constructor<T>>, Constructor<T>> hook(@NonNull Constructor<T> origin, @NonNull Hooker<Constructor<T>> hooker);
/**
* Hook before method unhooker.
*
* @param <T> the type parameter
* @param origin the origin
* @param priority the priority
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
<T> MethodUnhooker<BeforeHooker<Constructor<T>>, Constructor<T>> hookBefore(@NonNull Constructor<T> origin, int priority, @NonNull BeforeHooker<Constructor<T>> hooker);
/**
* Hook after method unhooker.
*
* @param <T> the type parameter
* @param origin the origin
* @param priority the priority
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
<T> MethodUnhooker<AfterHooker<Constructor<T>>, Constructor<T>> hookAfter(@NonNull Constructor<T> origin, int priority, @NonNull AfterHooker<Constructor<T>> hooker);
/**
* Hook method unhooker.
*
* @param <T> the type parameter
* @param origin the origin
* @param priority the priority
* @param hooker the hooker
* @return the method unhooker
*/
@Nullable
<T> MethodUnhooker<Hooker<Constructor<T>>, Constructor<T>> hook(@NonNull Constructor<T> origin, int priority, @NonNull Hooker<Constructor<T>> hooker);
/**
* Deoptimize boolean.
*
* @param method the method
* @return the boolean
*/
boolean deoptimize(@NonNull Method method);
/**
* Deoptimize boolean.
*
* @param <T> the type parameter
* @param constructor the constructor
* @return the boolean
*/
<T> boolean deoptimize(@NonNull Constructor<T> constructor);
/**
* Log.
*
* @param message the message
*/
void log(@NonNull String message);
/**
* Log.
*
* @param message the message
* @param throwable the throwable
*/
void log(@NonNull String message, @NonNull Throwable throwable);
/**
* Parse dex dex parser.
*
* @param dexData the dex data
* @param includeAnnotations the include annotations
* @return the dex parser
* @throws IOException the io exception
*/
@Nullable
DexParser parseDex(@NonNull ByteBuffer dexData, boolean includeAnnotations) throws IOException;
}

View File

@ -2,8 +2,17 @@ package io.github.libxposed;
import androidx.annotation.NonNull;
/**
* The type Xposed module.
*/
@SuppressWarnings("unused")
public abstract class XposedModule extends XposedContextWrapper implements XposedModuleInterface {
/**
* Instantiates a new Xposed module.
*
* @param base the base
* @param param the param
*/
public XposedModule(XposedContext base, @NonNull ModuleLoadedParam param) {
super(base);
}

View File

@ -6,39 +6,103 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* The interface Xposed module interface.
*/
@SuppressWarnings("unused")
public interface XposedModuleInterface {
/**
* The interface Module loaded param.
*/
interface ModuleLoadedParam {
/**
* Is system server boolean.
*
* @return the boolean
*/
boolean isSystemServer();
/**
* Gets process name.
*
* @return the process name
*/
@NonNull
String getProcessName();
/**
* Gets app data dir.
*
* @return the app data dir
*/
@NonNull
String getAppDataDir();
/**
* Gets extras.
*
* @return the extras
*/
@Nullable
Bundle getExtras();
}
/**
* The interface Package loaded param.
*/
interface PackageLoadedParam {
/**
* Gets package name.
*
* @return the package name
*/
@NonNull
String getPackageName();
/**
* Gets app info.
*
* @return the app info
*/
@NonNull
ApplicationInfo getAppInfo();
/**
* Gets class loader.
*
* @return the class loader
*/
@NonNull
ClassLoader getClassLoader();
/**
* Gets process name.
*
* @return the process name
*/
@NonNull
String getProcessName();
/**
* Is first application boolean.
*
* @return the boolean
*/
boolean isFirstApplication();
/**
* Gets extras.
*
* @return the extras
*/
@Nullable
Bundle getExtras();
}
/**
* On package loaded.
*
* @param param the param
*/
void onPackageLoaded(@NonNull PackageLoadedParam param);
}

View File

@ -5,130 +5,372 @@ import androidx.annotation.Nullable;
import java.io.Closeable;
/**
* The interface Dex parser.
*/
@SuppressWarnings("unused")
public interface DexParser extends Closeable {
/**
* The constant NO_INDEX.
*/
int NO_INDEX = 0xffffffff;
/**
* The interface Array.
*/
interface Array {
/**
* Get values value [ ].
*
* @return the value [ ]
*/
@NonNull
Value[] getValues();
}
/**
* The interface Annotation.
*/
interface Annotation {
/**
* Gets visibility.
*
* @return the visibility
*/
int getVisibility();
/**
* Gets type.
*
* @return the type
*/
@NonNull
TypeId getType();
/**
* Get elements element [ ].
*
* @return the element [ ]
*/
@NonNull
Element[] getElements();
}
/**
* The interface Value.
*/
interface Value {
/**
* Get value byte [ ].
*
* @return the byte [ ]
*/
@Nullable
byte[] getValue();
/**
* Gets value type.
*
* @return the value type
*/
int getValueType();
}
/**
* The interface Element.
*/
interface Element extends Value {
/**
* Gets name.
*
* @return the name
*/
@NonNull
StringId getName();
}
/**
* The interface Type id.
*/
interface TypeId {
/**
* Gets descriptor.
*
* @return the descriptor
*/
@NonNull
StringId getDescriptor();
}
/**
* The interface Id.
*/
interface Id {
/**
* Gets id.
*
* @return the id
*/
int getId();
}
/**
* The interface String id.
*/
interface StringId extends Id {
/**
* Gets string.
*
* @return the string
*/
@NonNull
String getString();
}
/**
* The interface Field id.
*/
interface FieldId extends Id {
/**
* Gets type.
*
* @return the type
*/
@NonNull
TypeId getType();
/**
* Gets declaring class.
*
* @return the declaring class
*/
@NonNull
TypeId getDeclaringClass();
/**
* Gets name.
*
* @return the name
*/
@NonNull
StringId getName();
}
/**
* The interface Method id.
*/
interface MethodId extends Id {
/**
* Gets declaring class.
*
* @return the declaring class
*/
@NonNull
TypeId getDeclaringClass();
/**
* Gets prototype.
*
* @return the prototype
*/
@NonNull
ProtoId getPrototype();
/**
* Gets name.
*
* @return the name
*/
@NonNull
StringId getName();
}
/**
* The interface Proto id.
*/
interface ProtoId extends Id {
/**
* Gets shorty.
*
* @return the shorty
*/
@NonNull
StringId getShorty();
/**
* Gets return type.
*
* @return the return type
*/
@NonNull
TypeId getReturnType();
/**
* Get parameters type id [ ].
*
* @return the type id [ ]
*/
@Nullable
TypeId[] getParameters();
}
/**
* Get string id string id [ ].
*
* @return the string id [ ]
*/
@NonNull
StringId[] getStringId();
/**
* Get type id type id [ ].
*
* @return the type id [ ]
*/
@NonNull
TypeId[] getTypeId();
/**
* Get field id field id [ ].
*
* @return the field id [ ]
*/
@NonNull
FieldId[] getFieldId();
/**
* Get method id method id [ ].
*
* @return the method id [ ]
*/
@NonNull
MethodId[] getMethodId();
/**
* Get proto id proto id [ ].
*
* @return the proto id [ ]
*/
@NonNull
ProtoId[] getProtoId();
/**
* Get annotations annotation [ ].
*
* @return the annotation [ ]
*/
@NonNull
Annotation[] getAnnotations();
/**
* Get arrays array [ ].
*
* @return the array [ ]
*/
@NonNull
Array[] getArrays();
/**
* The interface Early stop visitor.
*/
interface EarlyStopVisitor {
/**
* Stop boolean.
*
* @return the boolean
*/
boolean stop();
}
/**
* The interface Member visitor.
*/
interface MemberVisitor extends EarlyStopVisitor {
}
/**
* The interface Class visitor.
*/
interface ClassVisitor extends EarlyStopVisitor {
/**
* Visit member visitor.
*
* @param clazz the clazz
* @param accessFlags the access flags
* @param superClass the super class
* @param interfaces the interfaces
* @param sourceFile the source file
* @param staticFields the static fields
* @param staticFieldsAccessFlags the static fields access flags
* @param instanceFields the instance fields
* @param instanceFieldsAccessFlags the instance fields access flags
* @param directMethods the direct methods
* @param directMethodsAccessFlags the direct methods access flags
* @param virtualMethods the virtual methods
* @param virtualMethodsAccessFlags the virtual methods access flags
* @param annotations the annotations
* @return the member visitor
*/
@Nullable
MemberVisitor visit(int clazz, int accessFlags, int superClass, @NonNull int[] interfaces, int sourceFile, @NonNull int[] staticFields, @NonNull int[] staticFieldsAccessFlags, @NonNull int[] instanceFields, @NonNull int[] instanceFieldsAccessFlags, @NonNull int[] directMethods, @NonNull int[] directMethodsAccessFlags, @NonNull int[] virtualMethods, @NonNull int[] virtualMethodsAccessFlags, @NonNull int[] annotations);
}
/**
* The interface Field visitor.
*/
interface FieldVisitor extends MemberVisitor {
/**
* Visit.
*
* @param field the field
* @param accessFlags the access flags
* @param annotations the annotations
*/
void visit(int field, int accessFlags, @NonNull int[] annotations);
}
/**
* The interface Method visitor.
*/
interface MethodVisitor extends MemberVisitor {
/**
* Visit method body visitor.
*
* @param method the method
* @param accessFlags the access flags
* @param hasBody the has body
* @param annotations the annotations
* @param parameterAnnotations the parameter annotations
* @return the method body visitor
*/
@Nullable
MethodBodyVisitor visit(int method, int accessFlags, boolean hasBody, @NonNull int[] annotations, @NonNull int[] parameterAnnotations);
}
/**
* The interface Method body visitor.
*/
interface MethodBodyVisitor {
/**
* Visit.
*
* @param method the method
* @param accessFlags the access flags
* @param referredStrings the referred strings
* @param invokedMethods the invoked methods
* @param accessedFields the accessed fields
* @param assignedFields the assigned fields
* @param opcodes the opcodes
*/
void visit(int method, int accessFlags, @NonNull int[] referredStrings, @NonNull int[] invokedMethods, @NonNull int[] accessedFields, @NonNull int[] assignedFields, @NonNull byte[] opcodes);
}
/**
* Visit defined classes.
*
* @param visitor the visitor
* @throws IllegalStateException the illegal state exception
*/
void visitDefinedClasses(@NonNull ClassVisitor visitor) throws IllegalStateException;
}