Compare commits
10 Commits
2af767479d
...
ec7cb26aa2
| Author | SHA1 | Date |
|---|---|---|
|
|
ec7cb26aa2 | |
|
|
496b76fa3e | |
|
|
4351a73575 | |
|
|
cfa8fcc9c5 | |
|
|
b73eb6f901 | |
|
|
0d63ce21a8 | |
|
|
6daa337810 | |
|
|
b56c9fb4bd | |
|
|
43c4837d07 | |
|
|
9219a44112 |
|
|
@ -1,3 +1,3 @@
|
||||||
tasks.register("Delete", Delete::class) {
|
tasks.register("Delete", Delete::class) {
|
||||||
delete(rootProject.buildDir)
|
delete(rootProject.layout.buildDirectory)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
||||||
#Sun May 21 15:48:52 CST 2023
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
||||||
|
|
@ -83,10 +83,8 @@ done
|
||||||
# This is normally unused
|
# This is normally unused
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|
@ -133,18 +131,21 @@ location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
|
|
@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
|
|
@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ plugins {
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "io.github.libxposed.service"
|
namespace = "io.github.libxposed.service"
|
||||||
compileSdk = 33
|
compileSdk = 34
|
||||||
buildToolsVersion = "33.0.1"
|
buildToolsVersion = "34.0.0"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = 21
|
minSdk = 24
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
|
|
@ -20,8 +20,8 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,12 @@ package io.github.libxposed.service;
|
||||||
import io.github.libxposed.service.IXposedScopeCallback;
|
import io.github.libxposed.service.IXposedScopeCallback;
|
||||||
|
|
||||||
interface IXposedService {
|
interface IXposedService {
|
||||||
const int API = 100;
|
const int LIB_API = 101;
|
||||||
|
const int API = LIB_API; // compatibility alias
|
||||||
|
|
||||||
|
const long PROP_CAP_SYSTEM = 1L;
|
||||||
|
const long PROP_CAP_REMOTE = 1L << 1;
|
||||||
|
const long PROP_RT_API_PROTECTION = 1L << 2;
|
||||||
|
|
||||||
const int FRAMEWORK_PRIVILEGE_ROOT = 0;
|
const int FRAMEWORK_PRIVILEGE_ROOT = 0;
|
||||||
const int FRAMEWORK_PRIVILEGE_CONTAINER = 1;
|
const int FRAMEWORK_PRIVILEGE_CONTAINER = 1;
|
||||||
|
|
@ -18,7 +23,7 @@ interface IXposedService {
|
||||||
String getFrameworkVersion() = 3;
|
String getFrameworkVersion() = 3;
|
||||||
long getFrameworkVersionCode() = 4;
|
long getFrameworkVersionCode() = 4;
|
||||||
int getFrameworkPrivilege() = 5;
|
int getFrameworkPrivilege() = 5;
|
||||||
Bundle featuredMethod(String name, in Bundle args) = 6;
|
long getFrameworkProperties() = 6;
|
||||||
|
|
||||||
// scope utilities
|
// scope utilities
|
||||||
List<String> getScope() = 10;
|
List<String> getScope() = 10;
|
||||||
|
|
@ -31,7 +36,7 @@ interface IXposedService {
|
||||||
void deleteRemotePreferences(String group) = 22;
|
void deleteRemotePreferences(String group) = 22;
|
||||||
|
|
||||||
// remote file utilities
|
// remote file utilities
|
||||||
ParcelFileDescriptor openRemoteFile(String path, int mode) = 30;
|
String[] listRemoteFiles() = 30;
|
||||||
boolean deleteRemoteFile(String path) = 31;
|
ParcelFileDescriptor openRemoteFile(String name) = 31;
|
||||||
String[] listRemoteFiles() = 32;
|
boolean deleteRemoteFile(String name) = 32;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ plugins {
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "io.github.libxposed.service"
|
namespace = "io.github.libxposed.service"
|
||||||
compileSdk = 33
|
compileSdk = 34
|
||||||
buildToolsVersion = "33.0.1"
|
buildToolsVersion = "34.0.0"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = 21
|
minSdk = 24
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
|
|
@ -18,16 +18,9 @@ android {
|
||||||
resValues = false
|
resValues = false
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
isMinifyEnabled = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
isCoreLibraryDesugaringEnabled = true
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|
@ -40,8 +33,7 @@ android {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":interface"))
|
implementation(project(":interface"))
|
||||||
compileOnly("androidx.annotation:annotation:1.6.0")
|
compileOnly("androidx.annotation:annotation:1.7.1")
|
||||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<application>
|
||||||
|
<provider
|
||||||
|
android:name=".XposedProvider"
|
||||||
|
android:authorities="${applicationId}.XposedService"
|
||||||
|
android:exported="true"
|
||||||
|
tools:ignore="ExportedContentProvider" />
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
|
|
@ -1,28 +1,27 @@
|
||||||
package io.github.libxposed.service;
|
package io.github.libxposed.service;
|
||||||
|
|
||||||
import static android.os.ParcelFileDescriptor.MODE_READ_ONLY;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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({"resource", "unused"})
|
@SuppressWarnings("unused")
|
||||||
public final class XposedService {
|
public final class XposedService {
|
||||||
|
|
||||||
public final static class ServiceException extends RuntimeException {
|
public final static class ServiceException extends RuntimeException {
|
||||||
private ServiceException(RemoteException e) {
|
ServiceException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
ServiceException(RemoteException e) {
|
||||||
super("Xposed service error", e);
|
super("Xposed service error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +147,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 an error occurred
|
||||||
*/
|
*/
|
||||||
public int getAPIVersion() {
|
public int getAPIVersion() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -162,7 +161,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 an error occurred
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public String getFrameworkName() {
|
public String getFrameworkName() {
|
||||||
|
|
@ -177,7 +176,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 an error occurred
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public String getFrameworkVersion() {
|
public String getFrameworkVersion() {
|
||||||
|
|
@ -192,7 +191,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 an error occurred
|
||||||
*/
|
*/
|
||||||
public long getFrameworkVersionCode() {
|
public long getFrameworkVersionCode() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -202,11 +201,25 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Xposed framework properties of current implementation.
|
||||||
|
*
|
||||||
|
* @return Framework properties bitmask
|
||||||
|
* @throws ServiceException If the service is dead or an error occurred
|
||||||
|
*/
|
||||||
|
public long getFrameworkProperties() {
|
||||||
|
try {
|
||||||
|
return mService.getFrameworkProperties();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw new ServiceException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 an error occurred
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public Privilege getFrameworkPrivilege() {
|
public Privilege getFrameworkPrivilege() {
|
||||||
|
|
@ -218,32 +231,11 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Additional methods provided by specific Xposed framework.
|
|
||||||
*
|
|
||||||
* @param name Featured method name
|
|
||||||
* @param args Featured method arguments
|
|
||||||
* @return Featured method result
|
|
||||||
* @throws UnsupportedOperationException If the framework does not provide a method with given name
|
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
|
||||||
* @deprecated Normally, modules should never rely on implementation details about the Xposed framework,
|
|
||||||
* but if really necessary, this method can be used to acquire such information
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Nullable
|
|
||||||
public Bundle featuredMethod(@NonNull String name, @Nullable Bundle args) {
|
|
||||||
try {
|
|
||||||
return mService.featuredMethod(name, args);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw new ServiceException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 an error occurred
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public List<String> getScope() {
|
public List<String> getScope() {
|
||||||
|
|
@ -259,7 +251,7 @@ public final class XposedService {
|
||||||
*
|
*
|
||||||
* @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
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
* @throws ServiceException If the service is dead or an error occurred
|
||||||
*/
|
*/
|
||||||
public void requestScope(@NonNull String packageName, @NonNull OnScopeEventListener callback) {
|
public void requestScope(@NonNull String packageName, @NonNull OnScopeEventListener callback) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -274,7 +266,7 @@ public final class XposedService {
|
||||||
*
|
*
|
||||||
* @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
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
* @throws ServiceException If the service is dead or an error occurred
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String removeScope(@NonNull String packageName) {
|
public String removeScope(@NonNull String packageName) {
|
||||||
|
|
@ -286,18 +278,26 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get remote preferences from Xposed framework.
|
* Get remote preferences from Xposed framework. If the group does not exist, it will be created.
|
||||||
*
|
*
|
||||||
* @param group Group name
|
* @param group Group name
|
||||||
* @return The preferences, null if the framework is embedded
|
* @return The preferences
|
||||||
* @throws ServiceException If the service is dead or error occurred
|
* @throws ServiceException If the service is dead or an error occurred
|
||||||
|
* @throws UnsupportedOperationException If the framework is embedded
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@NonNull
|
||||||
public SharedPreferences getRemotePreferences(@NonNull String group) {
|
public SharedPreferences getRemotePreferences(@NonNull String group) {
|
||||||
return mRemotePrefs.computeIfAbsent(group, k -> {
|
return mRemotePrefs.computeIfAbsent(group, k -> {
|
||||||
try {
|
try {
|
||||||
return RemotePreferences.newInstance(this, k);
|
var instance = RemotePreferences.newInstance(this, k);
|
||||||
|
if (instance == null) {
|
||||||
|
throw new ServiceException("Framework returns null");
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
if (e.getCause() instanceof UnsupportedOperationException cause) {
|
||||||
|
throw cause;
|
||||||
|
}
|
||||||
throw new ServiceException(e);
|
throw new ServiceException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -307,7 +307,8 @@ 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 an error occurred
|
||||||
|
* @throws UnsupportedOperationException If the framework is embedded
|
||||||
*/
|
*/
|
||||||
public void deleteRemotePreferences(@NonNull String group) {
|
public void deleteRemotePreferences(@NonNull String group) {
|
||||||
deletionLock.writeLock().lock();
|
deletionLock.writeLock().lock();
|
||||||
|
|
@ -318,6 +319,9 @@ public final class XposedService {
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
if (e.getCause() instanceof UnsupportedOperationException cause) {
|
||||||
|
throw cause;
|
||||||
|
}
|
||||||
throw new ServiceException(e);
|
throw new ServiceException(e);
|
||||||
} finally {
|
} finally {
|
||||||
deletionLock.writeLock().unlock();
|
deletionLock.writeLock().unlock();
|
||||||
|
|
@ -325,39 +329,45 @@ public final class XposedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open an InputStream to read a file from the module's shared data directory.
|
* List all files in the module's shared data directory.
|
||||||
*
|
*
|
||||||
* @param name File name, must not contain path separators and . or ..
|
* @return The file list
|
||||||
* @return The InputStream
|
* @throws ServiceException If the service is dead or an error occurred
|
||||||
* @throws FileNotFoundException If the file does not exist, the path is forbidden or remote file is not supported by the framework
|
* @throws UnsupportedOperationException If the framework is embedded
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public FileInputStream openRemoteFileInput(@NonNull String name) throws FileNotFoundException {
|
public String[] listRemoteFiles() {
|
||||||
try {
|
try {
|
||||||
var file = mService.openRemoteFile(name, MODE_READ_ONLY);
|
var files = mService.listRemoteFiles();
|
||||||
if (file == null) throw new FileNotFoundException();
|
if (files == null) throw new ServiceException("Framework returns null");
|
||||||
return new FileInputStream(file.getFileDescriptor());
|
return files;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw new FileNotFoundException(e.getMessage());
|
if (e.getCause() instanceof UnsupportedOperationException cause) {
|
||||||
|
throw cause;
|
||||||
|
}
|
||||||
|
throw new ServiceException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open an OutputStream to write a file to the module's shared data directory.
|
* Open a file in the module's shared data directory. The file will be created if not exists.
|
||||||
*
|
*
|
||||||
* @param name File name, must not contain path separators and . or ..
|
* @param name File name, must not contain path separators and . or ..
|
||||||
* @param mode Operating mode
|
* @return The file descriptor
|
||||||
* @return The OutputStream
|
* @throws ServiceException If the service is dead or an error occurred
|
||||||
* @throws FileNotFoundException If the path is forbidden or remote file is not supported by the framework
|
* @throws UnsupportedOperationException If the framework is embedded
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public FileOutputStream openRemoteFileOutput(@NonNull String name, int mode) throws FileNotFoundException {
|
public ParcelFileDescriptor openRemoteFile(@NonNull String name) {
|
||||||
try {
|
try {
|
||||||
var file = mService.openRemoteFile(name, mode);
|
var file = mService.openRemoteFile(name);
|
||||||
if (file == null) throw new FileNotFoundException();
|
if (file == null) throw new ServiceException("Framework returns null");
|
||||||
return new FileOutputStream(file.getFileDescriptor());
|
return file;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw new FileNotFoundException(e.getMessage());
|
if (e.getCause() instanceof UnsupportedOperationException cause) {
|
||||||
|
throw cause;
|
||||||
|
}
|
||||||
|
throw new ServiceException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -366,30 +376,17 @@ public final class XposedService {
|
||||||
*
|
*
|
||||||
* @param name File name, must not contain path separators and . or ..
|
* @param name File name, must not contain path separators and . or ..
|
||||||
* @return true if successful, false if the file does not exist
|
* @return true if successful, false if the file does not exist
|
||||||
* @throws FileNotFoundException If the path is forbidden or remote file is not supported by the framework
|
* @throws ServiceException If the service is dead or an error occurred
|
||||||
|
* @throws UnsupportedOperationException If the framework is embedded
|
||||||
*/
|
*/
|
||||||
public boolean deleteRemoteFile(@NonNull String name) throws FileNotFoundException {
|
public boolean deleteRemoteFile(@NonNull String name) {
|
||||||
try {
|
try {
|
||||||
return mService.deleteRemoteFile(name);
|
return mService.deleteRemoteFile(name);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw new FileNotFoundException(e.getMessage());
|
if (e.getCause() instanceof UnsupportedOperationException cause) {
|
||||||
|
throw cause;
|
||||||
}
|
}
|
||||||
}
|
throw new ServiceException(e);
|
||||||
|
|
||||||
/**
|
|
||||||
* List all files in the module's shared data directory.
|
|
||||||
*
|
|
||||||
* @return The file list
|
|
||||||
* @throws FileNotFoundException If remote file is not supported by the framework
|
|
||||||
*/
|
|
||||||
@NonNull
|
|
||||||
public String[] listRemoteFiles() throws FileNotFoundException {
|
|
||||||
try {
|
|
||||||
var files = mService.listRemoteFiles();
|
|
||||||
if (files == null) throw new FileNotFoundException();
|
|
||||||
return files;
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw new FileNotFoundException(e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ pluginManagement {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library") version "8.0.1"
|
id("com.android.library") version "8.3.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue