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.
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
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
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.
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.
The `TermuxAppSharedProperties.properties` will exist in `termux-shared` library and only the single static instance will be reloaded whenever needed, instead of different activities and services maintaining their own instances. The classes in `termux-shared` library will also get access to the properties for their own needs.
The night mode set in `TermuxApplication` and terminal rows set in `TermuxService` will no longer require loading props from disk.
Updating `allow-external-apps` value will now require restarting termux or running `termux-reload-settings` since value will no longer be loaded from disk every time.
MONITOR_PHANTOM_PROCS will only be shown in Android 12+ devices and will be marked "<unsupported>" if its not supported in current android build. It will show in Termux Settings->About->Device Info->Software and in reports. Flag is available on Pixel Android 12L beta 3 and Android 13. Check FeatureFlagUtils for more details.
Getting supported feature flags and their values is done through reflection on android "android.util.FeatureFlagUtils" class and requires bypassing android hidden API restrictions.
Related issue #2366https://issuetracker.google.com/u/1/issues/205156966#comment27
The crash happens due to android 8.0 background restrictions if TermuxActivity is not in foreground/whitelist and attempts to start TermuxService. With this commit, the app will not crash but will just exit with a toast message.
https://developer.android.com/about/versions/oreo/background#serviceshttps://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/services/core/java/com/android/server/am/ActiveServices.java;l=722
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.termux/com.termux.app.TermuxActivity}: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=com.termux/.app.TermuxService }: app is in background uid UidRecord{533ae62 u0a187 TPSL idle procs:1 seq(0,0,0)}
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3082)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1832)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6821)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=com.termux/.app.TermuxService }: app is in background uid UidRecord{533ae62 u0a187 TPSL idle procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1587)
at android.app.ContextImpl.startService(ContextImpl.java:1542)
at android.content.ContextWrapper.startService(ContextWrapper.java:674)
at com.termux.app.TermuxActivity.onCreate(TermuxActivity.java:242)
at android.app.Activity.performCreate(Activity.java:7224)
at android.app.Activity.performCreate(Activity.java:7213)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
... 11 more
Closes#2552
Activity will only be recreated when `termux-reload-settings` is run or `night-mode` config does not equal current system mode when TermuxActivity is initially started. Running `termux-reload-settings` can cause some problems if some variable whose state should be maintained or reset is not being done so correctly, like termux session shortcuts weren't before 4fd48a5a. It requires further testing and any bugs should be reported.
The `List<KeyboardShortcut> mSessionShortcuts = new ArrayList<>()` declaration was causing shortcuts list to be of size 0 in `TermuxTerminalViewClient.onCodePoint()` after re-creation, which resulted in session shortcuts not working.
With this commit, activities will automatically change theme between day/night if `night-mode` `termux.properties` is not set or is set to `system` without requiring app restart.
Dialog theming will be fully added in a later commit and may currently be in an inconsistent state or have crashes.
The `uiMode` has been removed from `configChanges` of `TermuxActivity`, this may cause termux app to restart if samsung DEX mode is changed, if it does, then users should report it so that it can be fixed by re-adding the value and ignoring the change inside `TermuxActivity.onConfigurationChanged()`. The docs don't state if its necessary. Check related pull request #1446.
Running `termux-reload-settings` will also restart `TermuxActivity`, the activity data should be preserved.