feat:文件选择器增加为三种
This commit is contained in:
@@ -332,21 +332,34 @@ public class ConfigManager {
|
|||||||
private void deployGadgetConfigFile(String packageName, GadgetConfig gadgetConfig) {
|
private void deployGadgetConfigFile(String packageName, GadgetConfig gadgetConfig) {
|
||||||
try {
|
try {
|
||||||
// Create gadget config JSON
|
// Create gadget config JSON
|
||||||
String configJson = String.format(
|
String configJson;
|
||||||
"{\n" +
|
if ("script".equals(gadgetConfig.mode)) {
|
||||||
" \"interaction\": {\n" +
|
configJson = String.format(
|
||||||
" \"type\": \"listen\",\n" +
|
"{\n" +
|
||||||
" \"address\": \"%s\",\n" +
|
" \"interaction\": {\n" +
|
||||||
" \"port\": %d,\n" +
|
" \"type\": \"script\",\n" +
|
||||||
" \"on_port_conflict\": \"%s\",\n" +
|
" \"path\": \"%s\"\n" +
|
||||||
" \"on_load\": \"%s\"\n" +
|
" }\n" +
|
||||||
" }\n" +
|
"}",
|
||||||
"}",
|
gadgetConfig.scriptPath
|
||||||
gadgetConfig.address,
|
);
|
||||||
gadgetConfig.port,
|
} else {
|
||||||
gadgetConfig.onPortConflict,
|
configJson = String.format(
|
||||||
gadgetConfig.onLoad
|
"{\n" +
|
||||||
);
|
" \"interaction\": {\n" +
|
||||||
|
" \"type\": \"listen\",\n" +
|
||||||
|
" \"address\": \"%s\",\n" +
|
||||||
|
" \"port\": %d,\n" +
|
||||||
|
" \"on_port_conflict\": \"%s\",\n" +
|
||||||
|
" \"on_load\": \"%s\"\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}",
|
||||||
|
gadgetConfig.address,
|
||||||
|
gadgetConfig.port,
|
||||||
|
gadgetConfig.onPortConflict,
|
||||||
|
gadgetConfig.onLoad
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Write to temp file
|
// Write to temp file
|
||||||
String tempFile = context.getCacheDir() + "/" + gadgetConfig.gadgetName + ".config";
|
String tempFile = context.getCacheDir() + "/" + gadgetConfig.gadgetName + ".config";
|
||||||
@@ -573,10 +586,15 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class GadgetConfig {
|
public static class GadgetConfig {
|
||||||
|
public String mode = "server"; // "server" or "script"
|
||||||
|
// Server mode config
|
||||||
public String address = "0.0.0.0";
|
public String address = "0.0.0.0";
|
||||||
public int port = 27042;
|
public int port = 27042;
|
||||||
public String onPortConflict = "fail";
|
public String onPortConflict = "fail";
|
||||||
public String onLoad = "wait";
|
public String onLoad = "wait";
|
||||||
|
// Script mode config
|
||||||
|
public String scriptPath = "/data/local/tmp/script.js";
|
||||||
|
// Common config
|
||||||
public String gadgetName = "libgadget.so";
|
public String gadgetName = "libgadget.so";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user