Add xposed utils

This commit is contained in:
LoveSy 2023-01-02 16:50:16 +08:00 committed by LoveSy
parent bfd049637f
commit 439537fd89
4 changed files with 39 additions and 4 deletions

View File

@ -85,6 +85,12 @@ public class XposedContextWrapper extends ContextWrapper implements XposedInterf
return getBaseContext().deoptimize(constructor); return getBaseContext().deoptimize(constructor);
} }
@Nullable
@Override
public XposedUtils getUtils() {
return getBaseContext().getUtils();
}
@Override @Override
final public void log(@NonNull String message) { final public void log(@NonNull String message) {
getBaseContext().log(message); getBaseContext().log(message);

View File

@ -5,6 +5,7 @@ import androidx.annotation.Nullable;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ConcurrentModificationException;
public interface XposedInterface { public interface XposedInterface {
interface BeforeHookCallback<T> { interface BeforeHookCallback<T> {
@ -24,7 +25,7 @@ public interface XposedInterface {
@Nullable @Nullable
Object invokeOrigin(@Nullable Object thisObject, Object[] args); Object invokeOrigin(@Nullable Object thisObject, Object[] args);
<U> void setExtra(String key, @Nullable U value); <U> void setExtra(@NonNull String key, @Nullable U value) throws ConcurrentModificationException;
} }
interface AfterHookCallback<T> { interface AfterHookCallback<T> {
@ -53,7 +54,7 @@ public interface XposedInterface {
Object invokeOrigin(@Nullable Object thisObject, Object[] args); Object invokeOrigin(@Nullable Object thisObject, Object[] args);
@Nullable @Nullable
<U> U getExtra(String key); <U> U getExtra(@NonNull String key);
} }
interface PriorityMethodHooker { interface PriorityMethodHooker {
@ -109,6 +110,8 @@ public interface XposedInterface {
<T> boolean deoptimize(@Nullable Constructor<T> constructor); <T> boolean deoptimize(@Nullable Constructor<T> constructor);
@Nullable XposedUtils getUtils();
void log(@NonNull String message); void log(@NonNull String message);
void log(@NonNull String message, @NonNull Throwable throwable); void log(@NonNull String message, @NonNull Throwable throwable);

View File

@ -0,0 +1,18 @@
package io.github.libxposed;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public interface XposedUtils {
@NonNull
<T> Class<T> classByName(@NonNull String className, @Nullable ClassLoader classLoader) throws ClassNotFoundException;
@Nullable
<T> Class<T> classOrNullByName(@NonNull String className, @Nullable ClassLoader classLoader);
@NonNull
<T> Class<T> classByBinaryName(@NonNull String binaryClassName, @Nullable ClassLoader classLoader) throws ClassNotFoundException;
@Nullable
<T> Class<T> classOrNullByBinaryName(@NonNull String binaryClassName, @Nullable ClassLoader classLoader);
}

View File

@ -53,6 +53,7 @@ import de.robv.android.xposed.XposedInit;
import io.github.libxposed.XposedContext; import io.github.libxposed.XposedContext;
import io.github.libxposed.XposedModule; import io.github.libxposed.XposedModule;
import io.github.libxposed.XposedModuleInterface; import io.github.libxposed.XposedModuleInterface;
import io.github.libxposed.XposedUtils;
public class LSPosedContext extends XposedContext { public class LSPosedContext extends XposedContext {
@ -787,13 +788,20 @@ public class LSPosedContext extends XposedContext {
return false; return false;
} }
// TODO
@Nullable
@Override @Override
public void log(@NonNull String message) { public XposedUtils getUtils() {
return null;
}
@Override
public synchronized void log(@NonNull String message) {
Log.i(TAG, mPackageName + ": " + message); Log.i(TAG, mPackageName + ": " + message);
} }
@Override @Override
public void log(@NonNull String message, @NonNull Throwable throwable) { public synchronized void log(@NonNull String message, @NonNull Throwable throwable) {
Log.e(TAG, mPackageName + ": " + message, throwable); Log.e(TAG, mPackageName + ": " + message, throwable);
} }
} }