Change interface name and update docs
This commit is contained in:
parent
7e344e2c71
commit
cf5c8f18e5
|
|
@ -17,7 +17,7 @@ import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings({"resource", "unused"})
|
||||||
public final class XposedService {
|
public final class XposedService {
|
||||||
|
|
||||||
public final static class ServiceException extends RuntimeException {
|
public final static class ServiceException extends RuntimeException {
|
||||||
|
|
@ -29,11 +29,11 @@ public final class XposedService {
|
||||||
private final static Map<OnScopeEventListener, IXposedScopeCallback> scopeCallbacks = new WeakHashMap<>();
|
private final static Map<OnScopeEventListener, IXposedScopeCallback> scopeCallbacks = new WeakHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback interface for module scope request
|
* Callback interface for module scope request.
|
||||||
*/
|
*/
|
||||||
public interface OnScopeEventListener {
|
public interface OnScopeEventListener {
|
||||||
/**
|
/**
|
||||||
* Callback when the request notification / window prompted
|
* Callback when the request notification / window prompted.
|
||||||
*
|
*
|
||||||
* @param packageName Package name of requested app
|
* @param packageName Package name of requested app
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,7 +41,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback when the request is approved
|
* Callback when the request is approved.
|
||||||
*
|
*
|
||||||
* @param packageName Package name of requested app
|
* @param packageName Package name of requested app
|
||||||
*/
|
*/
|
||||||
|
|
@ -49,7 +49,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback when the request is denied
|
* Callback when the request is denied.
|
||||||
*
|
*
|
||||||
* @param packageName Package name of requested app
|
* @param packageName Package name of requested app
|
||||||
*/
|
*/
|
||||||
|
|
@ -57,7 +57,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback when the request is timeout or revoked
|
* Callback when the request is timeout or revoked.
|
||||||
*
|
*
|
||||||
* @param packageName Package name of requested app
|
* @param packageName Package name of requested app
|
||||||
*/
|
*/
|
||||||
|
|
@ -65,7 +65,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback when the request is failed
|
* Callback when the request is failed.
|
||||||
*
|
*
|
||||||
* @param packageName Package name of requested app
|
* @param packageName Package name of requested app
|
||||||
* @param message Error message
|
* @param message Error message
|
||||||
|
|
@ -105,27 +105,27 @@ public final class XposedService {
|
||||||
|
|
||||||
public enum Privilege {
|
public enum Privilege {
|
||||||
/**
|
/**
|
||||||
* Unknown privilege value
|
* Unknown privilege value.
|
||||||
*/
|
*/
|
||||||
FRAMEWORK_PRIVILEGE_UNKNOWN,
|
FRAMEWORK_PRIVILEGE_UNKNOWN,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The framework is running as root
|
* The framework is running as root.
|
||||||
*/
|
*/
|
||||||
FRAMEWORK_PRIVILEGE_ROOT,
|
FRAMEWORK_PRIVILEGE_ROOT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The framework is running in a container with a fake system_server
|
* The framework is running in a container with a fake system_server.
|
||||||
*/
|
*/
|
||||||
FRAMEWORK_PRIVILEGE_CONTAINER,
|
FRAMEWORK_PRIVILEGE_CONTAINER,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The framework is running as a different app, which may have at most shell permission
|
* The framework is running as a different app, which may have at most shell permission.
|
||||||
*/
|
*/
|
||||||
FRAMEWORK_PRIVILEGE_APP,
|
FRAMEWORK_PRIVILEGE_APP,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The framework is embedded in the hooked app, which means {@link #getRemotePreferences} and remote file streams will be null
|
* The framework is embedded in the hooked app, which means {@link #getRemotePreferences} and remote file streams will be null.
|
||||||
*/
|
*/
|
||||||
FRAMEWORK_PRIVILEGE_EMBEDDED
|
FRAMEWORK_PRIVILEGE_EMBEDDED
|
||||||
}
|
}
|
||||||
|
|
@ -144,7 +144,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Xposed API version of current implementation
|
* Get the Xposed API version of current implementation.
|
||||||
*
|
*
|
||||||
* @return API version
|
* @return API version
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
* @throws ServiceException If the service is dead or error occurred
|
||||||
|
|
@ -158,7 +158,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Xposed framework name of current implementation
|
* Get the Xposed framework name of current implementation.
|
||||||
*
|
*
|
||||||
* @return Framework name
|
* @return Framework name
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
* @throws ServiceException If the service is dead or error occurred
|
||||||
|
|
@ -173,7 +173,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Xposed framework version of current implementation
|
* Get the Xposed framework version of current implementation.
|
||||||
*
|
*
|
||||||
* @return Framework version
|
* @return Framework version
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
* @throws ServiceException If the service is dead or error occurred
|
||||||
|
|
@ -188,7 +188,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Xposed framework version code of current implementation
|
* Get the Xposed framework version code of current implementation.
|
||||||
*
|
*
|
||||||
* @return Framework version code
|
* @return Framework version code
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
* @throws ServiceException If the service is dead or error occurred
|
||||||
|
|
@ -202,7 +202,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Xposed framework privilege of current implementation
|
* Get the Xposed framework privilege of current implementation.
|
||||||
*
|
*
|
||||||
* @return Framework privilege
|
* @return Framework privilege
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
* @throws ServiceException If the service is dead or error occurred
|
||||||
|
|
@ -218,7 +218,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional methods provided by specific Xposed framework
|
* Additional methods provided by specific Xposed framework.
|
||||||
*
|
*
|
||||||
* @param name Featured method name
|
* @param name Featured method name
|
||||||
* @param args Featured method arguments
|
* @param args Featured method arguments
|
||||||
|
|
@ -230,7 +230,7 @@ public final class XposedService {
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Nullable
|
@Nullable
|
||||||
public Bundle featuredMethod(@NonNull String name, @Nullable Bundle args) throws UnsupportedOperationException {
|
public Bundle featuredMethod(@NonNull String name, @Nullable Bundle args) {
|
||||||
try {
|
try {
|
||||||
return mService.featuredMethod(name, args);
|
return mService.featuredMethod(name, args);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
|
@ -239,7 +239,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the application scope of current module
|
* Get the application scope of current module.
|
||||||
*
|
*
|
||||||
* @return Module scope
|
* @return Module scope
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
* @throws ServiceException If the service is dead or error occurred
|
||||||
|
|
@ -254,7 +254,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request to add a new app to the module scope
|
* Request to add a new app to the module scope.
|
||||||
*
|
*
|
||||||
* @param packageName Package name of the app to be added
|
* @param packageName Package name of the app to be added
|
||||||
* @param callback Callback to be invoked when the request is completed or error occurred
|
* @param callback Callback to be invoked when the request is completed or error occurred
|
||||||
|
|
@ -269,7 +269,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an app from the module scope
|
* Remove an app from the module scope.
|
||||||
*
|
*
|
||||||
* @param packageName Package name of the app to be added
|
* @param packageName Package name of the app to be added
|
||||||
* @return null if successful, or non-null with error message
|
* @return null if successful, or non-null with error message
|
||||||
|
|
@ -285,7 +285,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get remote preferences from Xposed framework
|
* Get remote preferences from Xposed framework.
|
||||||
*
|
*
|
||||||
* @param group Group name
|
* @param group Group name
|
||||||
* @return The preferences, null if the framework is embedded
|
* @return The preferences, null if the framework is embedded
|
||||||
|
|
@ -303,7 +303,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a group of remote preferences
|
* Delete a group of remote preferences.
|
||||||
*
|
*
|
||||||
* @param group Group name
|
* @param group Group name
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
* @throws ServiceException If the service is dead or error occurred
|
||||||
|
|
@ -324,7 +324,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open an InputStream to read a file from the module's shared data directory
|
* Open an InputStream to read a file from the module's shared data directory.
|
||||||
*
|
*
|
||||||
* @param name File name
|
* @param name File name
|
||||||
* @return The InputStream, null if the framework is embedded
|
* @return The InputStream, null if the framework is embedded
|
||||||
|
|
@ -342,7 +342,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open an OutputStream to write a file to the module's shared data directory
|
* Open an OutputStream to write a file to the module's shared data directory.
|
||||||
*
|
*
|
||||||
* @param name File name
|
* @param name File name
|
||||||
* @param mode Operating mode
|
* @param mode Operating mode
|
||||||
|
|
@ -361,7 +361,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a file in the module's shared data directory
|
* Delete a file in the module's shared data directory.
|
||||||
*
|
*
|
||||||
* @param name File name
|
* @param name File name
|
||||||
* @return true if successful, false if failed or the framework is embedded
|
* @return true if successful, false if failed or the framework is embedded
|
||||||
|
|
@ -376,7 +376,7 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all files in the module's shared data directory
|
* List all files in the module's shared data directory.
|
||||||
*
|
*
|
||||||
* @return The file list, null if the framework is embedded
|
* @return The file list, null if the framework is embedded
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
* @throws ServiceException If the service is dead or error occurred
|
||||||
|
|
|
||||||
|
|
@ -11,24 +11,27 @@ import java.util.Set;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class XposedServiceHelper {
|
public final class XposedServiceHelper {
|
||||||
|
|
||||||
public interface ServiceListener {
|
|
||||||
/**
|
/**
|
||||||
* Callback when the service is connected<br/>
|
* Callback interface for Xposed service.
|
||||||
* This method could be called multiple times if multiple Xposed frameworks exist
|
*/
|
||||||
|
public interface OnServiceListener {
|
||||||
|
/**
|
||||||
|
* Callback when the service is connected.<br/>
|
||||||
|
* This method could be called multiple times if multiple Xposed frameworks exist.
|
||||||
*
|
*
|
||||||
* @param service Service instance
|
* @param service Service instance
|
||||||
*/
|
*/
|
||||||
void onServiceBind(@NonNull XposedService service);
|
void onServiceBind(@NonNull XposedService service);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback when the service is dead
|
* Callback when the service is dead.
|
||||||
*/
|
*/
|
||||||
void onServiceDied(@NonNull XposedService service);
|
void onServiceDied(@NonNull XposedService service);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String TAG = "XposedServiceHelper";
|
private static final String TAG = "XposedServiceHelper";
|
||||||
private static final Set<XposedService> mCache = new HashSet<>();
|
private static final Set<XposedService> mCache = new HashSet<>();
|
||||||
private static ServiceListener mListener = null;
|
private static OnServiceListener mListener = null;
|
||||||
|
|
||||||
static void onBinderReceived(IBinder binder) {
|
static void onBinderReceived(IBinder binder) {
|
||||||
if (binder == null) return;
|
if (binder == null) return;
|
||||||
|
|
@ -48,12 +51,12 @@ public final class XposedServiceHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a ServiceListener to receive service binders from Xposed frameworks<br/>
|
* Register a ServiceListener to receive service binders from Xposed frameworks.<br/>
|
||||||
* This method should only be called once
|
* This method should only be called once.
|
||||||
*
|
*
|
||||||
* @param listener Listener to register
|
* @param listener Listener to register
|
||||||
*/
|
*/
|
||||||
public static void registerListener(ServiceListener listener) {
|
public static void registerListener(OnServiceListener listener) {
|
||||||
synchronized (mCache) {
|
synchronized (mCache) {
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
if (!mCache.isEmpty()) {
|
if (!mCache.isEmpty()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue