Commit Graph

318 Commits

Author SHA1 Message Date
agnostic-apollo
9d2ac14557 Fixed: Use ndkVersion specified in project properties or $JITPACK_NDK_VERSION env variable for termux-shared library 2025-05-30 12:06:45 +05:00
agnostic-apollo
da3a0ac4e2 Fixed: Add explicit serialVersionUID to Serializable classes like ReportInfo and TextIOInfo
Reading `ReportInfo` with `Bundle.getSerializable()` by `ReportActivity` is triggering exception when default algorithm is used for `serialVersionUID` in Termux:API plugin app when error notification created in `ResultReturner.returnData()` by `TermuxPluginUtils.sendPluginCommandErrorNotification()` is clicked.

```
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.termux/com.termux.shared.activities.ReportActivity}: android.os.BadParcelableException: Parcelable encountered IOException reading a Serializable object (name = com.termux.shared.models.ReportInfo)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4280)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4467)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:222)
	at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:133)
	at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:103)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2823)
	at android.os.Handler.dispatchMessage(Handler.java:110)
	at android.os.Looper.loopOnce(Looper.java:248)
	at android.os.Looper.loop(Looper.java:338)
	at android.app.ActivityThread.main(ActivityThread.java:9067)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932)
Caused by: android.os.BadParcelableException: Parcelable encountered IOException reading a Serializable object (name = com.termux.shared.models.ReportInfo)
	at android.os.Parcel.readSerializableInternal(Parcel.java:5520)
	at android.os.Parcel.readValue(Parcel.java:5038)
	at android.os.Parcel.readValue(Parcel.java:4702)
	at android.os.Parcel.-$$Nest$mreadValue(Unknown Source:0)
	at android.os.Parcel$LazyValue.apply(Parcel.java:4811)
	at android.os.Parcel$LazyValue.apply(Parcel.java:4764)
	at android.os.BaseBundle.unwrapLazyValueFromMapLocked(BaseBundle.java:446)
	at android.os.BaseBundle.getValueAt(BaseBundle.java:426)
	at android.os.BaseBundle.getValue(BaseBundle.java:397)
	at android.os.BaseBundle.getValue(BaseBundle.java:380)
	at android.os.BaseBundle.getValue(BaseBundle.java:373)
	at android.os.BaseBundle.getSerializable(BaseBundle.java:1522)
	at android.os.Bundle.getSerializable(Bundle.java:1339)
	at com.termux.shared.activities.ReportActivity.updateUI(ReportActivity.java:140)
	at com.termux.shared.activities.ReportActivity.onCreate(ReportActivity.java:93)
	at android.app.Activity.performCreate(Activity.java:9155)
	at android.app.Activity.performCreate(Activity.java:9133)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1521)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4262)
	... 13 more
Caused by: java.io.InvalidClassException: com.termux.shared.models.ReportInfo; local class incompatible: stream classdesc serialVersionUID = -5165426368218339031, local class serialVersionUID = 1
	at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:652)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1743)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1624)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1902)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1442)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
	at android.os.Parcel.readSerializableInternal(Parcel.java:5507)
	... 31 more

```

If using release APK with obfuscation enabled, then following exception will be triggered.

```
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.termux/com.termux.shared.activities.ReportActivity}: android.os.BadParcelableException: Parcelable encountered ClassNotFoundException reading a Serializable object (name = I0.a)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3864)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4006)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:111)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2462)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:240)
	at android.os.Looper.loop(Looper.java:351)
	at android.app.ActivityThread.main(ActivityThread.java:8377)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
Caused by: android.os.BadParcelableException: Parcelable encountered ClassNotFoundException reading a Serializable object (name = I0.a)
	at android.os.Parcel.readSerializableInternal(Parcel.java:5113)
	at android.os.Parcel.readValue(Parcel.java:4655)
	at android.os.Parcel.readValue(Parcel.java:4363)
	at android.os.Parcel.-$$Nest$mreadValue(Unknown Source:0)
	at android.os.Parcel$LazyValue.apply(Parcel.java:4461)
	at android.os.Parcel$LazyValue.apply(Parcel.java:4420)
	at android.os.BaseBundle.getValueAt(BaseBundle.java:394)
	at android.os.BaseBundle.getValue(BaseBundle.java:374)
	at android.os.BaseBundle.getValue(BaseBundle.java:357)
	at android.os.BaseBundle.getValue(BaseBundle.java:350)
	at android.os.BaseBundle.getSerializable(BaseBundle.java:1451)
	at android.os.Bundle.getSerializable(Bundle.java:1144)
	at com.termux.shared.activities.ReportActivity.updateUI(ReportActivity.java:136)
	at com.termux.shared.activities.ReportActivity.onCreate(ReportActivity.java:89)
	at android.app.Activity.performCreate(Activity.java:8397)
	at android.app.Activity.performCreate(Activity.java:8370)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1403)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3837)
	... 12 more
Caused by: java.lang.ClassNotFoundException: I0.a
	at java.lang.Class.classForName(Native Method)
	at java.lang.Class.forName(Class.java:536)
	at android.os.Parcel$2.resolveClass(Parcel.java:5090)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1733)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1624)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1902)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1442)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
	at android.os.Parcel.readSerializableInternal(Parcel.java:5096)
	... 29 more
Caused by: java.lang.ClassNotFoundException: I0.a
	... 38 more
```

Related issue https://github.com/termux/termux-api/issues/762
2025-05-23 02:27:29 +05:00
Wang Han
4de0caac5b Changed|Fixed: Bump org.lsposed.hiddenapibypass:hiddenapibypass to 6.1 to fix crash on Android 16 QPR1
```
Build fingerprint: 'google/shiba_beta/shiba:16/BP31.250502.008/13497110:user/release-keys'
Revision: 'MP1.0'
ABI: 'arm64'
Executable: /system/bin/app_process64
Cmdline: com.termux
pid: 22617, tid: 22617, name: com.termux  >>> com.termux <<<
uid: 10323
tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
pac_enabled_keys: 000000000000000f (PR_PAC_APIAKEY, PR_PAC_APIBKEY, PR_PAC_APDAKEY, PR_PAC_APDBKEY)
esr: 0000000092000006 (Data Abort Exception 0x24)
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x000000000000000c
Cause: null pointer dereference
    x0  0000000070b6f798  x1  0000000002159228  x2  000000000000000c  x3  00000000ebad6073
    x4  00000000ebad6074  x5  00000000ebad6075  x6  00000000ebad6076  x7  00000000ebad6077
    x8  00000000ebad6078  x9  00000000ebad6079  x10 00000000ebad607a  x11 00000000ebad607b
    x12 00000000ebad607c  x13 00000000ebad607d  x14 00000000ebad607e  x15 00000000ebad607f
    x16 0000007feda203f0  x17 0000007976776a9c  x18 0000007cd0e44000  x19 b400007b850b8be0
    x20 0000000000000000  x21 b400007b850b8ca0  x22 0000000000000000  x23 00000000021592b8
    x24 000000006413b378  x25 0000000070b99ee0  x26 0000000070b9fc78  x27 0000000000000000
    x28 0000000000000053  x29 0000000070b99ee0
    lr  0000007976776a98  sp  0000007feda203f0  pc  0000007976776b0c  pst 0000000080001000
    esr 0000000092000006
26 total frames
backtrace:
      #00 pc 00000000000c8b0c  /data/app/~~p_sHRwZKj3QVf_xeRMrR3g==/com.termux-rodTRD4IY6G2qtCPCrHfhw==/oat/arm64/base.odex (org.lsposed.hiddenapibypass.HiddenApiBypass.getDeclaredMethods+780)
      #01 pc 00000000000c8dc4  /data/app/~~p_sHRwZKj3QVf_xeRMrR3g==/com.termux-rodTRD4IY6G2qtCPCrHfhw==/oat/arm64/base.odex (org.lsposed.hiddenapibypass.HiddenApiBypass.setHiddenApiExemptions+68)
      #02 pc 00000000000ae560  /data/app/~~p_sHRwZKj3QVf_xeRMrR3g==/com.termux-rodTRD4IY6G2qtCPCrHfhw==/oat/arm64/base.odex (com.termux.shared.reflection.ReflectionUtils.bypassHiddenAPIReflectionRestrictions+448)
      #03 pc 00000000000a342c  /data/app/~~p_sHRwZKj3QVf_xeRMrR3g==/com.termux-rodTRD4IY6G2qtCPCrHfhw==/oat/arm64/base.odex (com.termux.shared.android.SELinuxUtils.getContext+108)
      #04 pc 00000000000c0b60  /data/app/~~p_sHRwZKj3QVf_xeRMrR3g==/com.termux-rodTRD4IY6G2qtCPCrHfhw==/oat/arm64/base.odex (com.termux.shared.termux.shell.command.environment.TermuxAppShellEnvironment.setTermuxAppEnvironment+3216)
      #05 pc 000000000009eafc  /data/app/~~p_sHRwZKj3QVf_xeRMrR3g==/com.termux-rodTRD4IY6G2qtCPCrHfhw==/oat/arm64/base.odex (com.termux.app.TermuxApplication.onCreate+1596)
      ...
      #22 pc 0000000000105c98  /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+104) (BuildId: ea93df5e792bbd2e0cbb71b2a7599aaa)
      #23 pc 000000000013121c  /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+908) (BuildId: ea93df5e792bbd2e0cbb71b2a7599aaa)
      #24 pc 000000000000459c  /system/bin/app_process64 (main+1212) (BuildId: a237cfae6965d7f0b950e5955c73432c)
      #25 pc 000000000006bb88  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+120) (BuildId: eecb0fc2ec8128ec92c091c0160586d1)
```

Related commit https://github.com/LSPosed/AndroidHiddenApiBypass/commit/9efadf06
Related commit https://android-review.googlesource.com/c/platform/libcore/+/3380841
Related commit https://cs.android.com/android/_/android/platform/libcore/+/0dc31afe

Closes #4556
2025-05-23 02:26:47 +05:00
agnostic-apollo
d2cd6ac2e5 Changed|Fixed: Bump org.lsposed.hiddenapibypass:hiddenapibypass to 5.0 to fix crash on Android 16
```
Build fingerprint: 'google/sdk_gphone64_x86_64/emu64xa:Baklava/BP22.250103.008/12932282:userdebug/dev-keys'
Revision: '0'
ABI: 'x86_64'
Timestamp: 2025-01-25
Process uptime: 1s
Cmdline: com.termux
pid: 4700, tid: 4700, name: com.termux  >>> com.termux <<<
uid: 10212
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x000000000000000c
Cause: null pointer dereference
    rax 0000000000000000  rbx 000071ad67c247b0  rcx 000000000000000c  rdx 000071abc520c888
    r8  00005f2000006018  r9  0000607c00006004  r10 000071abc423d68c  r11 000071abc4cca7c0
    r12 00007ffc65da8240  r13 000071ad67c24858  r14 00007ffc65da85d8  r15 000071ad67c247b0
    rdi 000071ad87c26110  rsi 00007ffc65da8148
    rbp 00007ffc65da8050  rsp 00007ffc65da8040  rip 000071abc4cca817
124 total frames
backtrace:
      #00 pc 00000000008ca817  /apex/com.android.art/lib64/libart.so (art::Unsafe_getObject(_JNIEnv*, _jobject*, _jobject*, long) (.__uniq.306581074569039686346581217366878976736)+87) (BuildId: 99c067c739342eb9769974bbb229d3b3)
      #01 pc 000000000022c80b  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+219) (BuildId: 99c067c739342eb9769974bbb229d3b3)
      #02 pc 0000000000211dd4  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+756) (BuildId: 99c067c739342eb9769974bbb229d3b3)
      #03 pc 0000000000556155  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+181) (BuildId: 99c067c739342eb9769974bbb229d3b3)
      #04 pc 00000000006dd182  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+2434) (BuildId: 99c067c739342eb9769974bbb229d3b3)
      #05 pc 0000000000233564  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+10804) (BuildId: 99c067c739342eb9769974bbb229d3b3)
      #06 pc 000000000022eb25  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+5) (BuildId: 99c067c739342eb9769974bbb229d3b3)
      #07 pc 0000000000080eb4  <anonymous:71ab3d335000> (org.lsposed.hiddenapibypass.HiddenApiBypass.getDeclaredMethods+0)
      ...
      #13 pc 0000000000080dd0  <anonymous:71ab3d335000> (org.lsposed.hiddenapibypass.HiddenApiBypass.setHiddenApiExemptions+0)
      ...
      #19 pc 0000000000080cf8  <anonymous:71ab3d335000> (org.lsposed.hiddenapibypass.HiddenApiBypass.addHiddenApiExemptions+0)
      ...
      #25 pc 0000000000005ab4  <anonymous:71ae82992000> (com.termux.shared.reflection.ReflectionUtils.bypassHiddenAPIReflectionRestrictions+0)
      ...
      #31 pc 0000000000004738  <anonymous:71ae86607000> (com.termux.shared.android.SELinuxUtils.getContext+0)
      ...
      #37 pc 0000000000005b48  <anonymous:71ae825d8000> (com.termux.shared.termux.shell.command.environment.TermuxAppShellEnvironment.setTermuxAppEnvironment+0)
      ...
      #43 pc 000000000000603c  <anonymous:71ae825d8000> (com.termux.shared.termux.shell.command.environment.TermuxShellEnvironment.init+0)
      ...
      #49 pc 0000000000006a68  <anonymous:71ae7e1c2000> (com.termux.app.TermuxApplication.onCreate+0)
```

Related commit 40b4cafa47
Related issue https://github.com/LSPosed/AndroidHiddenApiBypass/issues/52

Closes #4368
2025-01-25 02:30:20 +05:00
agnostic-apollo
078eea2b74 Added: Rename app classes in TermuxConstants with _APP suffix added and add TERMUX_*_MAIN_ACTIVITY_NAME and TERMUX_*_LAUNCHER_ACTIVITY_NAME constants to each app class 2025-01-13 01:30:06 +05:00
agnostic-apollo
55cdef01e7 Fixed: Allow numbers and hyphens in domain extension for url selector
Closes #3550
2023-08-19 03:59:10 +05:00
agnostic-apollo
33295decbb Changed: Add PGUP and PGDN extra keys to repetitive keys so that long holding them triggers page scrolling instead of having to repeatedly press the key to change pages 2023-05-21 07:58:35 +05:00
Young-Lord
c6dce12510 Fix GitHub spelling 2023-01-23 11:13:48 +02:00
Frieder Bluemle
29cf9820e1 Fix GitHub spelling 2022-10-27 11:37:17 +03:00
EduardDurech
5bc3d2db8d Added: Add KEY_LAST_PENDING_INTENT_REQUEST_CODE to TermuxAPIAppSharedPreferences 2022-10-13 08:48:31 +05:00
agnostic-apollo
3f7a939313 Added: Add support for Share selected text of terminal in long hold MORE menu so that users don't have to copy and paste to move text between apps 2022-10-04 04:47:58 +05:00
agnostic-apollo
0c14c291b2 Changed: Use ShareUtils to copy and paste text and prevent potential NPE
The `copyTextToClipboard()` method has been updated to pass clip label when copying text to clipboard and `getTextFromClipboard()` and `getTextStringFromClipboardIfSet()` methods have been added to get current clipboard.
2022-10-04 04:29:15 +05:00
agnostic-apollo
8c1749ef96 Added|Changed: Add AppSharedPreferences to hold SharedPreferences of apps and inherit termux app prefrences from it 2022-09-29 02:45:31 +05:00
agnostic-apollo
605dd6c192 Added: Add check for if Termux has been granted Display Over Apps Permission if starting activities and services with termux-am-socket on Android 10+ 2022-07-06 02:53:36 +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
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
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
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