perf(scripting): parcel file descriptor
This commit is contained in:
@@ -6,7 +6,7 @@ import me.rhunk.snapenhance.bridge.scripting.AutoReloadListener;
|
||||
interface IScripting {
|
||||
List<String> getEnabledScripts();
|
||||
|
||||
@nullable String getScriptContent(String path);
|
||||
@nullable ParcelFileDescriptor getScriptContent(String path);
|
||||
|
||||
oneway void registerIPCListener(String channel, String eventName, IPCListener listener);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.rhunk.snapenhance.common.scripting
|
||||
|
||||
import android.content.Context
|
||||
import android.os.ParcelFileDescriptor
|
||||
import me.rhunk.snapenhance.bridge.scripting.IScripting
|
||||
import me.rhunk.snapenhance.common.logger.AbstractLogger
|
||||
import me.rhunk.snapenhance.common.scripting.type.ModuleInfo
|
||||
@@ -80,6 +81,12 @@ open class ScriptRuntime(
|
||||
modules.remove(scriptPath)
|
||||
}
|
||||
|
||||
fun load(scriptPath: String, pfd: ParcelFileDescriptor) {
|
||||
load(scriptPath, ParcelFileDescriptor.AutoCloseInputStream(pfd).use {
|
||||
it.readBytes().toString(Charsets.UTF_8)
|
||||
})
|
||||
}
|
||||
|
||||
fun load(scriptPath: String, content: String): JSModule? {
|
||||
logger.info("Loading module $scriptPath")
|
||||
return runCatching {
|
||||
|
||||
Reference in New Issue
Block a user