Refine service & Add flash ksu script (#2714)
This commit is contained in:
parent
4d5588778d
commit
b9d282cdfd
|
|
@ -37,7 +37,7 @@ public class LSPInjectedModuleService extends ILSPInjectedModuleService.Stub {
|
||||||
@Override
|
@Override
|
||||||
public Bundle requestRemotePreferences(String group, IRemotePreferenceCallback callback) {
|
public Bundle requestRemotePreferences(String group, IRemotePreferenceCallback callback) {
|
||||||
var bundle = new Bundle();
|
var bundle = new Bundle();
|
||||||
var userId = Binder.getCallingUid() % PER_USER_RANGE;
|
var userId = Binder.getCallingUid() / PER_USER_RANGE;
|
||||||
bundle.putSerializable("map", ConfigManager.getInstance().getModulePrefs(loadedModule.packageName, userId, group));
|
bundle.putSerializable("map", ConfigManager.getInstance().getModulePrefs(loadedModule.packageName, userId, group));
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
var groupCallbacks = callbacks.computeIfAbsent(group, k -> ConcurrentHashMap.newKeySet());
|
var groupCallbacks = callbacks.computeIfAbsent(group, k -> ConcurrentHashMap.newKeySet());
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import androidx.annotation.NonNull;
|
||||||
import org.lsposed.daemon.BuildConfig;
|
import org.lsposed.daemon.BuildConfig;
|
||||||
import org.lsposed.lspd.models.Module;
|
import org.lsposed.lspd.models.Module;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -228,13 +229,25 @@ public class LSPModuleService extends IXposedService.Stub {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParcelFileDescriptor openRemoteFile(String path, int mode) throws RemoteException {
|
public String[] listRemoteFiles() throws RemoteException {
|
||||||
|
var userId = ensureModule();
|
||||||
|
try {
|
||||||
|
var dir = ConfigFileManager.resolveModuleDir(loadedModule.packageName, FILES_DIR, userId, Binder.getCallingUid());
|
||||||
|
var files = dir.toFile().list();
|
||||||
|
return files == null ? new String[0] : files;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RemoteException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ParcelFileDescriptor openRemoteFile(String path) throws RemoteException {
|
||||||
var userId = ensureModule();
|
var userId = ensureModule();
|
||||||
ConfigFileManager.ensureModuleFilePath(path);
|
ConfigFileManager.ensureModuleFilePath(path);
|
||||||
try {
|
try {
|
||||||
var dir = ConfigFileManager.resolveModuleDir(loadedModule.packageName, FILES_DIR, userId, Binder.getCallingUid());
|
var dir = ConfigFileManager.resolveModuleDir(loadedModule.packageName, FILES_DIR, userId, Binder.getCallingUid());
|
||||||
return ParcelFileDescriptor.open(dir.resolve(path).toFile(), mode);
|
return ParcelFileDescriptor.open(dir.resolve(path).toFile(), ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_READ_WRITE);
|
||||||
} catch (Throwable e) {
|
} catch (IOException e) {
|
||||||
throw new RemoteException(e.getMessage());
|
throw new RemoteException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -246,19 +259,7 @@ public class LSPModuleService extends IXposedService.Stub {
|
||||||
try {
|
try {
|
||||||
var dir = ConfigFileManager.resolveModuleDir(loadedModule.packageName, FILES_DIR, userId, Binder.getCallingUid());
|
var dir = ConfigFileManager.resolveModuleDir(loadedModule.packageName, FILES_DIR, userId, Binder.getCallingUid());
|
||||||
return dir.resolve(path).toFile().delete();
|
return dir.resolve(path).toFile().delete();
|
||||||
} catch (Throwable e) {
|
} catch (IOException e) {
|
||||||
throw new RemoteException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] listRemoteFiles() throws RemoteException {
|
|
||||||
var userId = ensureModule();
|
|
||||||
try {
|
|
||||||
var dir = ConfigFileManager.resolveModuleDir(loadedModule.packageName, FILES_DIR, userId, Binder.getCallingUid());
|
|
||||||
var files = dir.toFile().list();
|
|
||||||
return files == null ? new String[0] : files;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
throw new RemoteException(e.getMessage());
|
throw new RemoteException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
|
||||||
workingDir("${projectDir}/release")
|
workingDir("${projectDir}/release")
|
||||||
commandLine(adb, "push", zipFileName, "/data/local/tmp/")
|
commandLine(adb, "push", zipFileName, "/data/local/tmp/")
|
||||||
}
|
}
|
||||||
val flashTask = task<Exec>("flash${variantCapped}") {
|
val flashMagiskTask = task<Exec>("flashMagisk${variantCapped}") {
|
||||||
group = "LSPosed"
|
group = "LSPosed"
|
||||||
dependsOn(pushTask)
|
dependsOn(pushTask)
|
||||||
commandLine(
|
commandLine(
|
||||||
|
|
@ -256,9 +256,22 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
|
||||||
"magisk --install-module /data/local/tmp/${zipFileName}"
|
"magisk --install-module /data/local/tmp/${zipFileName}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
task<Exec>("flashAndReboot${variantCapped}") {
|
task<Exec>("flashMagiskAndReboot${variantCapped}") {
|
||||||
group = "LSPosed"
|
group = "LSPosed"
|
||||||
dependsOn(flashTask)
|
dependsOn(flashMagiskTask)
|
||||||
|
commandLine(adb, "shell", "/system/bin/svc", "power", "reboot")
|
||||||
|
}
|
||||||
|
val flashKsuTask = task<Exec>("flashKsu${variantCapped}") {
|
||||||
|
group = "LSPosed"
|
||||||
|
dependsOn(pushTask)
|
||||||
|
commandLine(
|
||||||
|
adb, "shell", "su", "-c",
|
||||||
|
"ksud module install /data/local/tmp/${zipFileName}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
task<Exec>("flashKsuAndReboot${variantCapped}") {
|
||||||
|
group = "LSPosed"
|
||||||
|
dependsOn(flashKsuTask)
|
||||||
commandLine(adb, "shell", "/system/bin/svc", "power", "reboot")
|
commandLine(adb, "shell", "/system/bin/svc", "power", "reboot")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue