diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 608d34b8..bb6ced2c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,6 +8,12 @@ + + @@ -114,6 +120,15 @@ android:name="com.termux.app.TermuxService" android:exported="false" /> + + + + + + = Build.VERSION_CODES.O) { + this.startForegroundService(execIntent); + } else { + this.startService(execIntent); + } + } + + return Service.START_NOT_STICKY; + } + + private boolean allowExternalApps() { + File propsFile = new File(TermuxService.HOME_PATH + "/.termux/termux.properties"); + if (!propsFile.exists()) + propsFile = new File(TermuxService.HOME_PATH + "/.config/termux/termux.properties"); + + Properties props = new Properties(); + try { + if (propsFile.isFile() && propsFile.canRead()) { + try (FileInputStream in = new FileInputStream(propsFile)) { + props.load(new InputStreamReader(in, StandardCharsets.UTF_8)); + } + } + } catch (Exception e) { + Log.e("termux", "Error loading props", e); + } + + return props.getProperty("allow-external-apps", "false").equals("true"); + } +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 42ac4af8..d3a16a54 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,6 +2,8 @@ Termux Termux user + Run commands in Termux environment + Allow third-party applications to execute arbitrary commands within Termux environment. New session Failsafe Keyboard