Commit Graph

1402 Commits

Author SHA1 Message Date
agnostic-apollo f1d411a5ab Fixed: Fix shared terminal transcript joining back lines
Regression of 370ac2bd caused in 5f71e3e7 by the (in)famous @trygveaa
2022-06-19 03:08:28 +05:00
agnostic-apollo 5fc2b4cd4a Added: Add `SCROLL` extra key to toggle auto scrolling of terminal to bottom on terminal text updates and termux activity return
The toggle will apply to each terminal session separately.

Closes #2535
2022-06-18 22:45:48 +05:00
agnostic-apollo a2df7d791a Fixed: Fix bootstrap not installing on app install
Previously, bootstrap was only installed if `$PREFIX` didn't exist, was empty or only had `$PREFIX/tmp`. But now with 03e1d14e, `$PREFIX/etc/termux/termux.env` was also created at app startup before bootstrap check was made, hence it was being assumed that bootstrap was already installed.

Now, bootstrap will be installed even if `$PREFIX/tmp`, `$PREFIX/etc/termux/termux.env.tmp` or `$PREFIX/etc/termux/termux.env` exist but no other files do.

Closes #2844
2022-06-18 05:53:26 +05:00
agnostic-apollo 82b1580312 Fixed: Fix `termux.properties` reload not working if the properties file didn't exist at app startup
Closes #2836
2022-06-15 18:31:29 +05:00
agnostic-apollo e92a6db06b Fixed: Ensure CSI parameter value is not greater than `9999` as per vt510 2022-06-15 05:05:04 +05:00
agnostic-apollo 4c47f4f732 Fixed: Fix CSI parameters parsing like for SGR sequences that start with a `;` or have sequential `;` characters
https://vt100.net/docs/vt510-rm/chapter4.html#S4.3.3

https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences

Credits for finding the issue belongs to @Screwtapello

https://github.com/mawww/kakoune/issues/4339#issuecomment-916980723

Closes #2272, Closes mawww/kakoune#4339
2022-06-15 05:05:04 +05:00
agnostic-apollo 26ff978b0f Changed: Use black or white cursor color based on terminal background instead of always white if colors.properties didn't have cursor color set
Credit for algorithm link belong to @Jamie-Landeg-Jones

Closes #2653
2022-06-14 19:13:19 +05:00
agnostic-apollo b80126fd61 Fixed: Catch exceptions if failed to bypass hidden API restrictions
Attempting to bypass restrictions while tests are running will fail due to call to `TermuxApplication.onCreate()` -> `TermuxShellEnvironment.init()` -> `SELinuxUtils.getContext()`
2022-06-14 04:08:03 +05:00
agnostic-apollo 162469f7ce Fixed: Fix message dialog button text not showing in day mode due to white text 2022-06-14 04:05:00 +05:00
agnostic-apollo e75680a884 Changed: Do not re-set component state if current state equals new state in `PackageUtils.setComponentState()` 2022-06-14 04:04:09 +05:00
agnostic-apollo af6ac30bb1 Added: Allow users to disable termux file view and share receivers
The user can add `disable-file-share-receiver=true` entry to `termux.properties` file to disable termux from showing in Android file `Share With` apps list.
The user can add `disable-file-view-receiver=true` entry to `termux.properties` file to disable termux from showing in Android file `Open With` apps list.

The default value is `false`. Restarting termux app or running `termux-reload-settings` command will update the behaviour instantaneously if changed.

Closes #2549
2022-06-14 04:03:29 +05:00
agnostic-apollo 79d799a99d Fixed: Fix `ExecutionCommand.pid` not being set for first and background terminal sessions since `TermuxTerminalSessionClientBase` was still being used instead of `TermuxTerminalSessionActivityClient`
This commit adds onto 841c41bf and implements the `setTerminalShellPid()` interface method in `TermuxTerminalSessionServiceClient` so that `pid` is set properly for all cases.
2022-06-13 16:11:13 +05:00
agnostic-apollo 841c41bf37 Added|Changed: Added `TermuxTerminalSessionServiceClient` and renamed `TermuxTerminalSessionClient` to `TermuxTerminalSessionActivityClient`
Addition of `TermuxTerminalSessionServiceClient` is required so that interface methods that `TermuxService` can handle without `TermuxActivity` should implemented instead of relying on base implementation of `TermuxTerminalSessionClientBase`.
2022-06-13 16:07:04 +05:00
agnostic-apollo c2ddc23ae5 Added: Add `MAX_PHANTOM_PROCESSES` and `DEVICE_CONFIG_SYNC_DISABLED` value to device info output like shown in Termux About page
Related commit b6963035
2022-06-12 02:50:38 +05:00
agnostic-apollo b69630355a Added: Add `PhantomProcessUtils` to get phantom processes related settings values
- `settings_enable_monitor_phantom_procs` feature flag value can be received with a call to `getFeatureFlagMonitorPhantomProcsValueString()`. Likely only available on Android `12L+`.

- `max_phantom_processes` value from `dumpsys activity settings` output can be received with a call to `getActivityManagerMaxPhantomProcesses()`. Requires granting Termux `DUMP` and `PACKAGE_USAGE_STATS` permission. Can be granted with `adb shell "pm grant com.termux android.permission.PACKAGE_USAGE_STATS; pm grant com.termux android.permission.DUMP"` and revoked with `adb shell "pm revoke com.termux android.permission.PACKAGE_USAGE_STATS; pm revoke com.termux android.permission.DUMP"`.

- `device_config_sync_disabled` settings global namespace value can be received with a call to `getSettingsGlobalDeviceConfigSyncDisabled()`.
2022-06-12 02:48:36 +05:00
agnostic-apollo 42eee49d30 Added: Add `SettingsProviderUtils` to get `Setting` global, secure and system namespace values 2022-06-12 02:35:46 +05:00
agnostic-apollo 03e1d14e1e Added: Write termux shell environment to `/data/data/com.termux/files/usr/etc/termux/termux.env` on app startup and package changes
The `termux.env` can be sourced by shells to set termux environment normally exported. This can be useful for users starting termux shells with `adb` `run-as` or `root`. The file will not contain `SHELL_CMD__` variables since those are shell command specific.

The items in the `termux.env` file have the format `export name="value"`.
The `"`\$` characters will be escaped with `a backslash `\`, like `\"` if characters are for literal value. Note that if `$` is escaped and if its part of variable, then variable expansion will not happen if `.env` file is sourced. The `\` at the end of a value line means line continuation. Value can contain newline characters.

The `termux.env` file should be sourceable by `POSIX` compliant shells like `bash`, `zsh`, `sh`, android's `mksh`, etc. Other shells with require manual parsing of the file to export variables.

Related discussion #2565
2022-06-12 00:51:19 +05:00
agnostic-apollo f76c20d036 Added: Init `TermuxShellEnvironment` at app startup
This will currently cache `TermuxAppShellEnvironment` so that its not regenerated for each shell started since it contains some slightly expensive operations.
2022-06-12 00:38:02 +05:00
agnostic-apollo 150b1ff99c Added: Add `ShellCommandShellEnvironment` and `TermuxShellCommandShellEnvironment` to export `ExecutionCommand` variables
This adds onto f102ea20 to build termux environment. Variables for `ExecutionCommand` app have the `SHELL_CMD__` scope. Docs will be provided for details of the variables.

- `SHELL_CMD__SHELL_ID`
- `SHELL_CMD__SHELL_NAME`
- `SHELL_CMD__APP_SHELL_NUMBER_SINCE_BOOT`
- `SHELL_CMD__TERMINAL_SESSION_NUMBER_SINCE_BOOT`
- `SHELL_CMD__APP_SHELL_NUMBER_SINCE_APP_START`
- `SHELL_CMD__TERMINAL_SESSION_NUMBER_SINCE_APP_START`

The commit also adds `SystemEventReceiver` to Termux app that will receive `ACTION_BOOT_COMPLETED`.
2022-06-12 00:38:02 +05:00
agnostic-apollo ebdab0e59c Changed: Update `TERMUX_APP__AM_SOCKET_SERVER_ENABLED` environment variable value if `termux-am-socket` server state changes 2022-06-12 00:33:08 +05:00
agnostic-apollo afc06cfd0a Added|Changed!: Add `TermuxAppShellEnvironment` and `TermuxAPIShellEnvironment` to export `Termux` and `Termux:API` app variables in `TermuxShellEnvironment`
This adds onto f102ea20 to build termux environment. Variables for `Termux` app have the `TERMUX_APP__` scope and variables for `Termux:API` app have `TERMUX_API_APP__` scope, which allows easier management for variables and know which variable belongs to which component. Some variables that were added in the last `termux-app` `v0.118.0` release have been renamed as per scoped variable design. The `TERMUX_VERSION` variable will stay as is for backward compatibility and will be duplicate of `TERMUX_APP__VERSION_NAME`. Docs will be provided for details of the variables.

- `TERMUX_APP__VERSION_NAME`
- `TERMUX_APP__VERSION_CODE`
- `TERMUX_APP__PACKAGE_NAME`
- `TERMUX_APP__PID` (previously `TERMUX_APP_PID`)
- `TERMUX_APP__UID`
- `TERMUX_APP__TARGET_SDK`
- `TERMUX_APP__IS_DEBUGGABLE_BUILD` (previously `TERMUX_IS_DEBUGGABLE_BUILD`)
- `TERMUX_APP__APK_RELEASE` (previously `TERMUX_APK_RELEASE`)
- `TERMUX_APP__APK_PATH`
- `TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE`
- `TERMUX_APP__SE_PROCESS_CONTEXT`
- `TERMUX_APP__SE_FILE_CONTEXT`
- `TERMUX_APP__SE_INFO`
- `TERMUX_APP__USER_ID`
- `TERMUX_APP__PROFILE_OWNER`
- `TERMUX_APP__PACKAGE_MANAGER` (previously `TERMUX_APP_PACKAGE_MANAGER`)
- `TERMUX_APP__PACKAGE_VARIANT` (previously `TERMUX_APP_PACKAGE_VARIANT`)
- `TERMUX_APP__FILES_DIR`
- `TERMUX_APP__AM_SOCKET_SERVER_ENABLED` (previously `TERMUX_APP_AM_SOCKET_SERVER_ENABLED`)

- `TERMUX_API_APP__VERSION_NAME` (previously `TERMUX_API_VERSION`)
2022-06-12 00:33:07 +05:00
agnostic-apollo 9749360caa Added: Add `UnixShellEnvironment.LOGIN_SHELL_BINARIES` variable for common/supported login shell binaries searched and add `fish` and `sh` shell as additional backups 2022-06-12 00:32:18 +05:00
agnostic-apollo 29d05cc72c Changed: All `ExecutionCommands` not managed by `TermuxShellManager` should have `id` `-1` 2022-06-12 00:32:18 +05:00
agnostic-apollo 2998558e9f Added: Add support in `AppShell` and `TermuxSession` for caller to add/override additional environment variables not added by `IShellEnvironment.setupShellCommandEnvironment()` 2022-06-12 00:32:18 +05:00
agnostic-apollo 13d93ccac7 Added: Add `TermuxShellManager` to manage all termux app wide shells 2022-06-12 00:32:18 +05:00
agnostic-apollo f102ea20b2 Added|Changed!: Implement new design for shell environment generation and add support for `MIT` licensed shell environment client
- `ShellEnvironmentClient` has been renamed to `IShellEnvironment` with certain changes to its interface methods, including requirement for `Execution` command itself for `setupShellCommandEnvironment()`.
- `UnixShellEnvironment` implements the `IShellEnvironment` interface as is the abstract base class of all other shell environments.
- `AndroidShellEnvironment` extends from the `UnixShellEnvironment` class and provides an environment that would work for Android shells. This is `MIT` licensed and can be used by users importing the `termux-shared` library or the library itself to run `AppShell` shells. Previously, `TermuxShellEnvironmentClient` existed which was `GPLv3` licensed and it would not have been possible to use it for non-GPL code.
- `TermuxShellEnvironment` extends from the `AndroidShellEnvironment` class and adds/overrides additional environment variables required for Termux shells to work, including setting `HOME`, `TMPDIR`, `PATH` and `LD_LIBRARY_PATH` appropriately. Termux app related variables will be added in a later commit. `TermuxShellEnvironment` replaces `TermuxShellEnvironmentClient` and is `GPLv3` licensed.
2022-06-12 00:32:18 +05:00
agnostic-apollo 0328d15ea7 Fixed: Fix duplicate logging of `file` word in `FileUtils.copyOrMoveFile()` 2022-06-11 14:24:26 +05:00
agnostic-apollo f9e9193c4e Added: Add package `APK_PATH`, `SE_PROCESS_CONTEXT`, `SE_FILE_CONTEXT` and `SE_INFO` when generating app info markdown string 2022-06-11 14:15:33 +05:00
agnostic-apollo 790481b802 Added: Add functions to `PackageUtils` to get base APK path of package 2022-06-11 14:12:58 +05:00
agnostic-apollo 1788013c80 Added: Add functions to `PackageUtils` to get `seInfo` and `seInfoUser` of package 2022-06-11 14:11:58 +05:00
agnostic-apollo 5759411109 Added: Add `SELinuxUtils` to get process and file paths security contexts 2022-06-11 14:10:34 +05:00
agnostic-apollo 0fd354a469 Changed: Ensure `TermuxSession` executable is `null` if its empty so that `login` shell can start 2022-06-11 13:55:49 +05:00
agnostic-apollo 042487c2b4 Changed: Ensure `AppShell` executable is not `null` before trying to execute it 2022-06-11 13:52:10 +05:00
agnostic-apollo b96fcb78fd Changed: Update termux twitter to https://twitter.com/termuxdevs 2022-06-11 02:41:09 +05:00
agnostic-apollo 9547869a52 Changed: Update funding link to https://termux.dev/donate 2022-06-11 02:41:09 +05:00
agnostic-apollo d29e20b0d0 Removed: Remove Termux game, root, science, unstable and x11 repo links since they have all been merged with https://github.com/termux/termux-packages 2022-06-11 02:41:09 +05:00
agnostic-apollo 0c22067b5e Added|Changed: Add termux site url and change donate url to https://termux.dev/donate 2022-06-11 02:41:09 +05:00
agnostic-apollo d287734aba Added|Changed!: Rename `SESSION_NAME` and `SESSION_CREATE_MODE` to `SHELL_NAME` and `SHELL_CREATE_MODE` and add support for `ShellCreateMode` to `AppShells`
Renamed extras `TERMUX_APP.TERMUX_SERVICE.EXTRA_SESSION_NAME` to `*.EXTRA_SHELL_NAME`, `TERMUX_APP.RUN_COMMAND_SERVICE.EXTRA_SESSION_NAME` to `*.EXTRA_SHELL_NAME`, `TERMUX_APP.TERMUX_SERVICE.EXTRA_SESSION_CREATE_MODE` to `*.EXTRA_SHELL_CREATE_MODE` and `TERMUX_APP.RUN_COMMAND_SERVICE.EXTRA_SESSION_CREATE_MODE` to `*.EXTRA_SHELL_CREATE_MODE`.

Renamed `enum` class `SessionCreateMode` to `ShellCreateMode`, `sessionName` field to `shellName`, `sessionCreateMode` to `shellCreateMode` in `ExecutionCommand`.

The `TermuxService` `AppShells`/`TermuxTasks` will now consider `ShellCreateMode` as well before starting tasks as done for `TermuxSessions` via 5794ab9a

New task command to not create new foreground session and switch to existing session if one already exits with `shellName` is

```
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_SHELL_CREATE_MODE 'no-shell-with-name' \
--es com.termux.RUN_COMMAND_SHELL_NAME "custom-name"
```

New task command to not create new background task if one already exits with `shellName` is

```
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/top' \
--esa com.termux.RUN_COMMAND_ARGUMENTS '-n,5' \
--es com.termux.RUN_COMMAND_SHELL_CREATE_MODE 'no-shell-with-name' \
--es com.termux.RUN_COMMAND_SHELL_NAME "custom-name" \
--es com.termux.RUN_COMMAND_RUNNER "app-shell"
```
2022-06-11 02:41:09 +05:00
agnostic-apollo 46cfea09ec Added: Add support for plugin apps to set TERMUX_APP_PACKAGE_VARIANT and TERMUX_APP_PACKAGE_MANAGER from Termux app APK BuildConfig.TERMUX_PACKAGE_VARIANT 2022-06-03 00:09:18 +05:00
agnostic-apollo 980bf8f0ae Added: Add support to get termux app package context with code classloader for plugin usage 2022-06-01 00:06:05 +05:00
agnostic-apollo 231ecff5f0 Changed: Do not modify code points for virtual or soft keyboard events
Closes #2799
2022-05-29 22:44:57 +05:00
agnostic-apollo c1c46dfcfc Changed: Change `TERMUX_APP.APPS_DIR_PATH` basename from `termux-app` to `com.termux`
The apps directory will now use the unique package name of apps for basename that can be automatically generated instead of having to be hardcoded.

`termux-am-socket` will be upgraded to `v1.4.0` for respective change.
2022-05-29 08:28:20 +05:00
agnostic-apollo 37f08c4fcc Fixed: Fix `Settings.ACTION_*` permission requests for non-activity contexts
This was caused by ce12b8ad

Closes #2769
2022-05-29 07:42:53 +05:00
agnostic-apollo a50387b553 Changed: Change termux support email from termuxreports@groups.io to support@termux.dev 2022-05-29 07:42:53 +05:00
agnostic-apollo 30cb848639 Fixed: Do not setup plugin and crash notification channel on API `< 24` since NotificationManager.IMPORTANCE_HIGH requires API 24 2022-05-29 06:54:01 +05:00
agnostic-apollo b04f209f17 Added: Add TERMUX_DEVS key SHA-256 digest to official signing keys list 2022-05-24 01:20:44 +05:00
agnostic-apollo 7b222ba392 Changed: Export correct PATH and also export LD_LIBRARY_PATH for `apt-android-5` variant instead of on Android 5/6
Overrides 4e08f76f
2022-05-24 01:20:43 +05:00
Henrik Grimler 899ef71e17 Changed: Bump android-7 bootstraps to v2022.04.28-r5 2022-05-24 01:19:45 +05:00
Henrik Grimler 4d084c02e7 Changed: Bump android-5 bootstraps to v2022.04.28-r6 2022-05-24 01:19:45 +05:00
agnostic-apollo 18a1a33e83 Added: Enable `TERMUX_PACKAGE_VARIANT` `apt-android-5` builds 2022-05-24 01:19:45 +05:00