Add getFrameworkPrivilege and featuredMethod

This commit is contained in:
Nullptr 2023-01-07 00:16:23 +08:00 committed by LoveSy
parent ad463ac1e0
commit 516f9e35db
7 changed files with 61 additions and 0 deletions

View File

@ -761,6 +761,20 @@ public class LSPosedContext extends XposedContext {
return BuildConfig.VERSION_CODE; return BuildConfig.VERSION_CODE;
} }
@Override
public int getFrameworkPrivilege() {
try {
return service.getFrameworkPrivilege();
} catch (RemoteException ignored) {
return -1;
}
}
@Override
public Object featuredMethod(String name, Object... args) {
throw new UnsupportedOperationException();
}
private <T, U extends Executable> MethodUnhooker<T, U> doHook(U hookMethod, int priority, T callback) { private <T, U extends Executable> MethodUnhooker<T, U> doHook(U hookMethod, int priority, T callback) {
if (Modifier.isAbstract(hookMethod.getModifiers())) { if (Modifier.isAbstract(hookMethod.getModifiers())) {
throw new IllegalArgumentException("Cannot hook abstract methods: " + hookMethod); throw new IllegalArgumentException("Cannot hook abstract methods: " + hookMethod);

View File

@ -13,6 +13,8 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import io.github.libxposed.service.IXposedService;
public class LSPInjectedModuleService extends ILSPInjectedModuleService.Stub { public class LSPInjectedModuleService extends ILSPInjectedModuleService.Stub {
private final Module loadedModule; private final Module loadedModule;
@ -22,6 +24,11 @@ public class LSPInjectedModuleService extends ILSPInjectedModuleService.Stub {
loadedModule = module; loadedModule = module;
} }
@Override
public int getFrameworkPrivilege() {
return IXposedService.FRAMEWORK_PRIVILEGE_ROOT;
}
@Override @Override
public Bundle requestRemotePreferences(String group, IRemotePreferenceCallback callback) { public Bundle requestRemotePreferences(String group, IRemotePreferenceCallback callback) {
var bundle = new Bundle(); var bundle = new Bundle();

View File

@ -137,6 +137,17 @@ public class LSPModuleService extends IXposedService.Stub {
return BuildConfig.VERSION_CODE; return BuildConfig.VERSION_CODE;
} }
@Override
public int getFrameworkPrivilege() throws RemoteException {
ensureModule();
return IXposedService.FRAMEWORK_PRIVILEGE_ROOT;
}
@Override
public Bundle featuredMethod(String name, Bundle args) {
throw new UnsupportedOperationException();
}
@Override @Override
public List<String> getScope() throws RemoteException { public List<String> getScope() throws RemoteException {
ensureModule(); ensureModule();

View File

@ -49,6 +49,16 @@ public class XposedContextWrapper extends ContextWrapper implements XposedInterf
return getBaseContext().getFrameworkVersionCode(); return getBaseContext().getFrameworkVersionCode();
} }
@Override
final public int getFrameworkPrivilege() {
return getBaseContext().getFrameworkPrivilege();
}
@Override
final public Object featuredMethod(String name, Object... args) {
return getBaseContext().featuredMethod(name, args);
}
@Override @Override
final public MethodUnhooker<BeforeHooker<Method>, Method> hookBefore(@NonNull Method origin, @NonNull BeforeHooker<Method> hooker) { final public MethodUnhooker<BeforeHooker<Method>, Method> hookBefore(@NonNull Method origin, @NonNull BeforeHooker<Method> hooker) {
return getBaseContext().hookBefore(origin, hooker); return getBaseContext().hookBefore(origin, hooker);

View File

@ -15,6 +15,11 @@ import io.github.libxposed.utils.DexParser;
public interface XposedInterface { public interface XposedInterface {
int API = 100; int API = 100;
int FRAMEWORK_PRIVILEGE_ROOT = 0;
int FRAMEWORK_PRIVILEGE_CONTAINER = 1;
int FRAMEWORK_PRIVILEGE_APP = 2;
int FRAMEWORK_PRIVILEGE_EMBEDDED = 3;
interface BeforeHookCallback<T> { interface BeforeHookCallback<T> {
@NonNull @NonNull
T getOrigin(); T getOrigin();
@ -104,6 +109,10 @@ public interface XposedInterface {
long getFrameworkVersionCode(); long getFrameworkVersionCode();
int getFrameworkPrivilege();
Object featuredMethod(String name, Object... args);
@Nullable @Nullable
MethodUnhooker<BeforeHooker<Method>, Method> hookBefore(@NonNull Method origin, @NonNull BeforeHooker<Method> hooker); MethodUnhooker<BeforeHooker<Method>, Method> hookBefore(@NonNull Method origin, @NonNull BeforeHooker<Method> hooker);

View File

@ -3,6 +3,12 @@ import io.github.libxposed.service.IXposedScopeCallback;
interface IXposedService { interface IXposedService {
const int API = 100; const int API = 100;
const int FRAMEWORK_PRIVILEGE_ROOT = 0;
const int FRAMEWORK_PRIVILEGE_CONTAINER = 1;
const int FRAMEWORK_PRIVILEGE_APP = 2;
const int FRAMEWORK_PRIVILEGE_EMBEDDED = 3;
const String AUTHORITY_SUFFIX = ".XposedService"; const String AUTHORITY_SUFFIX = ".XposedService";
const String SEND_BINDER = "SendBinder"; const String SEND_BINDER = "SendBinder";
@ -11,6 +17,8 @@ interface IXposedService {
String getFrameworkName() = 2; String getFrameworkName() = 2;
String getFrameworkVersion() = 3; String getFrameworkVersion() = 3;
long getFrameworkVersionCode() = 4; long getFrameworkVersionCode() = 4;
int getFrameworkPrivilege() = 5;
Bundle featuredMethod(String name, in Bundle args) = 6;
// scope utilities // scope utilities
List<String> getScope() = 10; List<String> getScope() = 10;

View File

@ -3,6 +3,8 @@ package org.lsposed.lspd.service;
import org.lsposed.lspd.service.IRemotePreferenceCallback; import org.lsposed.lspd.service.IRemotePreferenceCallback;
interface ILSPInjectedModuleService { interface ILSPInjectedModuleService {
int getFrameworkPrivilege();
Bundle requestRemotePreferences(String group, IRemotePreferenceCallback callback); Bundle requestRemotePreferences(String group, IRemotePreferenceCallback callback);
ParcelFileDescriptor openRemoteFile(String path); ParcelFileDescriptor openRemoteFile(String path);