Commit Graph

1482 Commits

Author SHA1 Message Date
agnostic-apollo
5f8a922201 Added: Allow users to disable termux-am server
The user can add `run-termux-am-socket-server=false` entry to `termux.properties` file to disable the `termux-am` server to run at app startup which is connected to by `$PREFIX/bin/termux-am` from the `termux-am-socket` package. The default value is `true`. Changes require `termux-app` to be force stopped and restarted to provide consistent state for all termux sessions and tasks.

The prop will be used in a later commit.
2022-04-23 00:36:12 +05:00
agnostic-apollo
9a71074c7d Added: Add function to ProcessUtils to get app process name for a pid from ActivityManager 2022-04-23 00:36:12 +05:00
agnostic-apollo
69cc65c3ac Added: Add functions to UserUtils to get user name for user id from PackageManager and Libcore 2022-04-23 00:36:12 +05:00
agnostic-apollo
bcd8f4c419 Added: Add TERMUX_APPS_DIR_PATH and TERMUX_APP.APPS_DIR_PATH and create them at application startup.
The termux files directory will also be checked and created if required at startup and code related to it will only be run if it is accessible. This can later also be used for init execution commands.

The `TERMUX_APP.APPS_DIR_PATH` will act as app specific directory for `termux-app` app related files. Other plugin apps will have their own directories under `TERMUX_APPS_DIR_PATH` if required.
2022-04-23 00:36:12 +05:00
agnostic-apollo
6bda7c4fc4 Added|Changed: Add Logger.logErrorPrivate*() functions which do not log errors that may contain potentially private info unless log level is debug or higher
Execution commands and other errors that may contain potentially private info should not be logged unless user has explicitly allowed it since apps with `READ_LOGS` permission would be able to read the data. A notification for failed executions commands would still be shown if enabled and required.
2022-04-23 00:36:12 +05:00
agnostic-apollo
89a08ff01a Fixed: Allow Object class object to be passed to ReflectionUtils.invokeField() 2022-04-23 00:36:12 +05:00
agnostic-apollo
c81d9c3346 Added: Add FileType.SOCKET support and add FileUtils.deleteSocketFile() function 2022-04-23 00:36:12 +05:00
agnostic-apollo
58c3d427e8 Fixed: Log and add to Error the current file type in FileUtils.deleteFile() in addition to allowed file types 2022-04-23 00:36:12 +05:00
agnostic-apollo
1b9ca91da5 Added: Add functions to DataUtils to get generic, space and tab indented strings 2022-04-23 00:36:12 +05:00
agnostic-apollo
9c7ec0cebd Added: Add functions that can be used by non main threads to set CrashHandler as the UncaughtExceptionHandler 2022-04-23 00:36:12 +05:00
agnostic-apollo
6b60adc079 Fixed: Do not stop the app if UncaughtExceptionHandler implemented by CrashHandler receives an exception on a non main thread
Rename function that should be used by main thread of apps to `setDefaultCrashHandler()`.

Functions for other threads will be added in a later commit.
2022-04-23 00:36:12 +05:00
agnostic-apollo
5116d886c3 Changed: Add label parameter to ExecutionCommand getArgumentsLogString() and getArgumentsMarkdownString() functions for external usage 2022-04-23 00:36:12 +05:00
agnostic-apollo
02ab8324e9 Changed|Fixed: Do not add empty stacktraces entry to Error log and markdown String 2022-04-23 00:36:12 +05:00
agnostic-apollo
c095a6184b Changed: Rename TermuxCrashUtils sendPluginCrashReportNotification() to sendCrashReportNotification()` 2022-04-23 00:36:12 +05:00
agnostic-apollo
cc981d8a03 Changed: Move com.termux.app.utils.PluginUtils to com.termux.shared.termux.plugins.TermuxPluginUtils
This will allow plugins and `termux-shared` library to trigger plugin error notifications too and process plugin command results.
2022-04-23 00:36:12 +05:00
tareksander
007f9cd7f1 Changed: Set socket dir to /data/data/com.termux/files/api/
Using the TermuxConstants.TERMUX_FILES_DIR variable to get full path
TermuxConstants.TERMUX_FILES_DIR_PATH/api/am-socket.
2022-04-23 00:36:12 +05:00
tareksander
b025872029 Changed: Updated the termux-am-library dependency, because the repo is now part of the Termux github organization. 2022-04-23 00:36:12 +05:00
tareksander
2851175d8b Changed: Moved the am socket to PREFIX/var/run/am-socket 2022-04-23 00:36:12 +05:00
tareksander
3dee2eb486 Changed: Allow connections from root o sockets. 2022-04-23 00:36:12 +05:00
tareksander
33b88b5d4b Changed: Set termux-am-library to a tag instead of following the main branch. 2022-04-23 00:36:12 +05:00
tareksander
f366db0cb3 Added: LocalFilesystemSocket as an Interface to UNIX sockets in the filesystem. The UID of connecting programs is automatically checked against the processes UID and connections where the UID doesn't match are automatically rejected and logged.
Changed: LocalSocketListener now uses sockets in the filesystem.
2022-04-23 00:36:12 +05:00
tareksander
4aca16326c Added: termux-am-library to integrate am with Termux. 2022-04-23 00:36:12 +05:00
tareksander
e597ece75f Added: ArgumentTokenizer to com.termux.shared.shell 2022-04-23 00:36:12 +05:00
Henrik Grimler
9e06bfce1f Changed: Bump bootstrap to v2022.04.21-r1 2022-04-21 21:55:09 +02:00
agnostic-apollo
5794ab9a56 Added|Changed: Add support to switch to existing session instead of creating duplicate session for RUN_COMMAND intent
This is done via addition of the `com.termux.RUN_COMMAND_SESSION_CREATE_MODE` extra, which currently supports two values.

- `always` to always create a new session every time.
- `no-session-with-name` to create a new session only if no existing session exits with the same terminal session name.

The terminal session name will equal executable basename by default and dashes `-` in the basename will no longer be replaced with spaces when session name as done previously. The `com.termux.RUN_COMMAND_SESSION_NAME` extra can be used to set custom session name.

Usage:

You can use this with `Termux:Tasker` or `Termux:Widget`.

For example for `Termux:Widget`

- Create a wrapper script at `~/.shortcuts/tasks/my-script.sh` with following contents under `tasks` directory so that it runs in background app shell instead of a terminal session. Do not use terminal session runner for wrapper script, since it will open two sessions everytime otherwise, first for wrapper script, then for actual target executable. There would also be conflicts if both wrapper script and target executable have the same basename and it would be incorrectly assumed that session is already running.
- Replace the `bash` executable with actual target executable that you want to run in the terminal session if its not already running.
- Optionally set custom session name. By default it will set to executable basename and not the wrapper script name. To set it to wrapper script name, you can pass `$(basename "$0")`.
- Launch the wrapper script with widget. On first launch, a new terminal session should open but on subsequent launches, same terminal session should open.

Note that you can also pass `com.termux.RUN_COMMAND_SESSION_ACTION` to modify session action behaviour. Check https://github.com/termux/termux-app/wiki/RUN_COMMAND-Intent#run_command-intent-command-extras.

```

am startservice --user 0 -n com.termux/com.termux.app.RunCommandService \
-a com.termux.RUN_COMMAND \
--es com.termux.RUN_COMMAND_PATH '/data/data/com.termux/files/usr/bin/bash' \
--es com.termux.RUN_COMMAND_SESSION_CREATE_MODE 'no-session-with-name' \
--es com.termux.RUN_COMMAND_SESSION_NAME "custom-name"
```
2022-04-08 02:42:54 +05:00
agnostic-apollo
ee32ef0c7e Changed: Maintain terminal session name in ExecutionCommand.sessionName in addition to TerminalSession.mSessionName 2022-04-08 02:42:54 +05:00
Alan Christian
8746db0d22 chore(gitignore): Remove unused ignore rules for crashlytics (#2683)
* Fix typo

* Remove crashlytics
2022-04-02 18:26:43 +05:30
agnostic-apollo
ce12b8ad2d Fixed: Fix Settings.ACTION_* permission requests result callback
Adding `FLAG_ACTIVITY_NEW_TASK` will start permission activity in separate task and `onActivityResult()` will be called early in the calling activity without grant/not-grant result being actually set.
2022-03-30 19:45:55 +05:00
agnostic-apollo
87a79a9b24 Added: Log intents received by and 2022-03-30 19:42:38 +05:00
agnostic-apollo
caa13b7047 Fixed: Fix pull request APKs commit hash 2022-03-18 06:31:43 +05:00
agnostic-apollo
5e820ad249 Added: Allow users to adjust $TMPDIR clear mechanism on termux exit
The `delete-tmpdir-files-older-than-x-days-on-exit` key can be used to adjust how many days old the access time should be of files that should be deleted from `$TMPDIR` on termux exit. The user can set an integer value between `-1` and `100000`. Set `-1` to delete no files, `0` to delete all files and `> 0` for `x` days. The default value is `3` days. So adding an entry like `delete-tmpdir-files-older-than-x-days-on-exit=10` to `termux.properties` file will make termux delete files older than `10` when termux is exited. After updating the value, either restart termux or run `termux-reload-settings` for changes to take effect.

Note that currently `> 0` will revert back to `0` since deletion is currently broken for empty sub directories and deletion needs to be done based on access time instead of modified time. It will need to be fixed in a later commit. Check `FileUtils.deleteFilesOlderThanXDays()`.

Related issue #2350
2022-03-17 22:35:31 +05:00
agnostic-apollo
25d21e9d2e Fixed: Fix wrong input type selected if toolbar is switched back to extra keys after tapping terminal if in text input mode
Closes #2503
2022-03-17 05:30:25 +05:00
agnostic-apollo
dd378738e3 Fixed: Add media-* symlinks to Android/media for all storages and external-0 symlink to Android/media of primary storage
The `~/external-0` and `~/media-0` should point to primary storage and `1+` to others, possibly portable sd cards.

Note that one can make portable sd card as primary storage as well instead of internal sd card with adoptable storage, which then links it to `/storage/emulated`, so the concept of `internal` and `external` sd card does not apply to primary storage for all cases.

https://android.stackexchange.com/questions/214233/how-to-free-internal-storage-by-moving-data-or-using-symlink-bind-mount-with-a/214706#214706

https://android.stackexchange.com/questions/217741/how-to-bind-mount-a-folder-inside-sdcard-with-correct-permissions/217936#217936

https://android.stackexchange.com/questions/205430/what-is-storage-emulated-0/205494#205494

https://source.android.com/devices/storage/adoptable

```
$ ls -l storage | cut -d ' ' -f 9-

audiobooks -> /storage/emulated/0/Audiobooks
dcim -> /storage/emulated/0/DCIM
documents -> /storage/emulated/0/Documents
downloads -> /storage/emulated/0/Download
external-0 -> /storage/emulated/0/Android/data/com.termux/files
external-1 -> /storage/XXXX-XXXX/Android/data/com.termux/files
media-0 -> /storage/emulated/0/Android/media/com.termux
media-1 -> /storage/XXXX-XXXX/Android/media/com.termux
movies -> /storage/emulated/0/Movies
music -> /storage/emulated/0/Music
pictures -> /storage/emulated/0/Pictures
podcasts -> /storage/emulated/0/Podcasts
shared -> /storage/emulated/0

```

Closes #2481
2022-03-17 05:30:25 +05:00
agnostic-apollo
93d57f053b Added: Add ~/storage symlinks for documents, podcasts and audiobooks
The `audiobooks` symlink will only be made on Android `10+`

Closes #2648
2022-03-17 05:30:25 +05:00
agnostic-apollo
26e0fa2b9e Changed: Use thread to setup settings components
Getting plugin contexts may be considered as too much work on main thread in certain situations resulting in android complaining that app is not responding
2022-03-17 05:30:25 +05:00
agnostic-apollo
d25f7afd97 Changed: Share terminal transcript with ShareUtils 2022-03-17 05:30:25 +05:00
agnostic-apollo
e0074f280f Fixed: Fix typos 2022-03-17 05:30:25 +05:00
agnostic-apollo
cc58ddde31 Changed: Check crash log file whenever TermuxActivity is resumed instead of only on app startup
This adds onto 06dbfbdb since receiver would not be registered to receive `ACTION_NOTIFY_APP_CRASH` if `TermuxActivity` was not be in foreground
2022-03-17 02:10:51 +05:00
agnostic-apollo
477b36acd1 Added: Add support for ACTION_NOTIFY_APP_CRASH in receiver registered by TermuxActivity to notify users of plugin app crashes
Once plugins integrate changes for `TermuxCrashUtils.onPostLogCrash()`, they will send the `ACTION_NOTIFY_APP_CRASH` broadcast when an uncaught exception is caught by `CrashHandler`. If `TermuxActivity` is in foreground, then it will receive the broadcast and notify user of the crash by reading it from the crash log file without the user having to restart termux app to be notified.
2022-03-17 02:10:51 +05:00
agnostic-apollo
5f00531381 Changed: Move com.termux.app.utils.CrashUtils to com.termux.shared.termux.crash.TermuxCrashUtils so that plugins trigger plugin notifications too
Calls to `notifyAppCrashFromCrashLogFile()` will now be synchronized as well.
2022-03-17 02:10:51 +05:00
agnostic-apollo
4dbfc1fac8 Added: Add support for onPreLogCrash() and onPostLogCrash() in CrashHandler so that CrashHandlerClient can decide which exceptions to log and add custom logic 2022-03-17 02:10:51 +05:00
agnostic-apollo
4b07e4f4c0 Added: Add multi process support in TermuxAppSharedPreferences since plugin apps may need to read values modified by termux app process 2022-03-17 02:10:51 +05:00
agnostic-apollo
621545dd0a Added: Add support for getting termux app and plugin app info only in TermuxUtils.getAppInfoMarkdownString() 2022-03-17 02:10:51 +05:00
agnostic-apollo
9a65aa4589 Fixed: Do not add double heading if callingPackageName passed to TermuxUtils.getAppInfoMarkdownString() is a plugin app 2022-03-17 02:10:51 +05:00
agnostic-apollo
021cb60e23 Added: Add TERMUX_API_APT_* constants 2022-03-17 02:10:51 +05:00
agnostic-apollo
14c5fc7b1e Fixed: Suppress warnings for requiring android 11 to request MANAGE_EXTERNAL_STORAGE permission and call Environment.isExternalStorageManager() 2022-03-17 02:10:51 +05:00
agnostic-apollo
792c33c9a5 Fixed: Fix PermissionUtils.requestPermissions() not requesting multiple permissions correctly 2022-03-17 02:10:51 +05:00
agnostic-apollo
760ae78aff Docs: Add termux apps vulnerability disclosure post links to README 2022-03-11 20:17:48 +05:00
agnostic-apollo
c3ac30e2fb Added: Add ic_info and ic_settings 2022-03-11 20:16:50 +05:00
agnostic-apollo
b94dc7eea9 Changed|Deprecated: Move from shell command background mode to command runner
This starts the support for adb, root and other custom runners for shell commands. Previously only terminal and background tasks in app shells were supported.

`TERMUX_SERVICE.EXTRA_BACKGROUND` and `RUN_COMMAND_SERVICE.EXTRA_BACKGROUND` extras have been deprecated and instead respective `EXTRA_RUNNER` extra keys should be used. Currently supported extra values are `terminal-session` and `app-shell`. In future, `adb-shell` and `root-shell` are planned to be supported as well.
2022-03-10 02:51:56 +05:00