-
Notifications
You must be signed in to change notification settings - Fork 74
Description
We are working on this API with @canyie and @tiann.
Description
We are proposing an API that allows Xposed modules to communicate with the Xposed framework. For modules to this API, they have to implementation-ly depend on us.
We will provide an aidl interface for modules to RPC framework's methods. Modules can get an implementation of such an aidl interface by calling a static method. Let say its name is IXpoedService getService(), where we will grab the binder from the framework.
Framework Implementation
Root Framework
Two options to get the binder for root frameworks:
- Most modules will hook themselves to get the hook status. So for the root framework, putting the binder to a static field of modules' classloader is a stable way. And
getServicecan directly return the binder. - Or, we can hook
getServiceto return the binder.
Non-root framework
To get the binder from another app, the only way is to use ContentProvider. Thus, for non-root frameworks to provide such an API, they have to register a content provider with a certain authority: say io.github.xposed-service. Then we can get the content provider can use call to binder from the framework.
HOWEVER, using a content provider requires context, which is not available before binding the application. For non-root frameworks, I supposed they are loading framework after Application is created.
To sum up, the getService should look like:
IXPosedService getService() {
if (sService != null) return sService; // For the first option of root framework, it should always be the case.
sService = getFromContentProvider(); // For non-root framework, get it from content provider.
return sService;
}API Implementation
A brief aidl API is proposed as:
parcelable Application {
String packageName;
int userId;
}
interface IXposedService {
const String FEATURE_X = "xposed.feature.x"; // some constants
int getXposedApi(); // 89 for example
String getFrameworkName(); // LSPosed for example
String getFrameworkVersionName(); // v1 for example
int getFrameworkVersionCode(); // 233 for example
List<String> getSupportedFeatures(); // ["x"] for example. Should match predefined constants
bool isFeatureSupported(String); // pass predefined constants to it
XRemoteSharedPreference getRemoteSharedPreference(String name); // An alternative to XSharedPreference
List<Application> getScope(); // Scopes of the modules. ["android", "com.android.systemui"] for example.
// How about returning PackageInfo instead?
bool setScope(List<Application>); // Set scopes to provided package names. Futher user confirm is required.
// return false only if framework fails to pop confirm windows.
// Should a callback provided?
// For modules targeting API 30+, it's hard for them to query all packages from all users.
// Maybe we can provide an interface to help them?
// Other interface suggestions are welcome.
}