Skip to content

Commit 92f6bef

Browse files
feat: proot debug toggle (Acode-Foundation#2563)
* feat: proot debug toggle * fix: persistence * fix: persistence
1 parent 5d5724b commit 92f6bef

7 files changed

Lines changed: 47 additions & 0 deletions

File tree

src/components/terminal/terminal.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,9 @@ export default class TerminalComponent {
702702

703703
const terminalValues = values.terminalSettings;
704704

705+
Executor.setProotDebug(terminalValues.prootDebug);
706+
Executor.BackgroundExecutor.setProotDebug(terminalValues.prootDebug);
707+
705708
await Terminal.startAxs(
706709
false,
707710
() => {},

src/components/terminal/terminalDefaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const DEFAULT_TERMINAL_SETTINGS = {
1717
fontLigatures: false,
1818
confirmTabClose: true,
1919
failsafeMode: false,
20+
prootDebug: false,
2021
// Touch selection settings
2122
touchSelectionTapHoldDuration: 600,
2223
touchSelectionMoveThreshold: 8,

src/plugins/terminal/src/android/BackgroundExecutor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
5252
case "loadLibrary":
5353
loadLibrary(args.getString(0), callbackContext);
5454
return true;
55+
case "setProotDebug":
56+
ProcessManager.prootDebug = args.getBoolean(0);
57+
callbackContext.success("PRoot debug " + (ProcessManager.prootDebug ? "enabled" : "disabled"));
58+
return true;
5559
default:
5660
callbackContext.error("Unknown action: " + action);
5761
return false;

src/plugins/terminal/src/android/Executor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,13 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
315315
return true;
316316
}
317317

318+
if (action.equals("setProotDebug")) {
319+
boolean enabled = args.getBoolean(0);
320+
ProcessManager.prootDebug = enabled;
321+
callbackContext.success("PRoot debug " + (enabled ? "enabled" : "disabled"));
322+
return true;
323+
}
324+
318325
if (action.equals("listProcesses")) {
319326
if (!isServiceBound || serviceMessenger == null) {
320327
callbackContext.success(new org.json.JSONArray());

src/plugins/terminal/src/android/ProcessManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
public class ProcessManager {
1515

1616
private final Context context;
17+
public static boolean prootDebug = false;
1718

1819
public ProcessManager(Context context) {
1920
this.context = context;
@@ -90,6 +91,10 @@ private void setupEnvironment(Map<String, String> env) {
9091
env.put("ANDROID_TZ", tz.getID());
9192

9293
env.put("FDROID", String.valueOf(isFdroidBuild()));
94+
95+
if (prootDebug) {
96+
env.put("PROOT_VERBOSE", "2");
97+
}
9398
}
9499

95100
/**

src/plugins/terminal/www/Executor.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ class Executor {
262262
exec(resolve, reject, this.ExecutorType, "loadLibrary", [path]);
263263
});
264264
}
265+
266+
setProotDebug(enabled) {
267+
return new Promise((resolve, reject) => {
268+
exec(resolve, reject, this.ExecutorType, "setProotDebug", [enabled]);
269+
});
270+
}
265271
}
266272

267273
//backward compatibility

src/settings/terminalSettings.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export default function terminalSettings() {
3535

3636
const terminalValues = values.terminalSettings;
3737

38+
Executor.setProotDebug(terminalValues.prootDebug);
39+
Executor.BackgroundExecutor.setProotDebug(terminalValues.prootDebug);
40+
3841
const items = [
3942
{
4043
key: "all_file_access",
@@ -232,6 +235,13 @@ export default function terminalSettings() {
232235
info: strings["terminal:failsafe-info"],
233236
category: categories.maintenance,
234237
},
238+
{
239+
key: "prootDebug",
240+
text: "PRoot Debug",
241+
checkbox: terminalValues.prootDebug,
242+
info: "Enable verbose PRoot logging (PROOT_VERBOSE=2). Useful for debugging sandbox issues.",
243+
category: categories.maintenance,
244+
},
235245
{
236246
key: "backup",
237247
text: strings.backup,
@@ -315,6 +325,17 @@ export default function terminalSettings() {
315325
}
316326
return;
317327

328+
case "prootDebug":
329+
appSettings.update({
330+
terminalSettings: {
331+
...values.terminalSettings,
332+
[key]: value,
333+
},
334+
});
335+
Executor.setProotDebug(value);
336+
Executor.BackgroundExecutor.setProotDebug(value);
337+
break;
338+
318339
default:
319340
appSettings.update({
320341
terminalSettings: {

0 commit comments

Comments
 (0)