Commit Graph

1425 Commits

Author SHA1 Message Date
agnostic-apollo f8e7ada143 Fixed: Fix typo from 43858dfb 2022-02-05 07:28:43 +05:00
agnostic-apollo f33758c7c0 Fixed: Fix typo from 43858dfb 2022-02-05 07:25:01 +05:00
agnostic-apollo c567cc3b92 Fixed: Fix app crash if failed to start TermuxService while in background due to android bg restrictions
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#services

https://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
2022-02-05 07:19:36 +05:00
agnostic-apollo 43858dfbb1 Fixed: Rename TermuxActivity isOnResumeAfterOnCreate to mIsOnResumeAfterOnCreate as per variable naming convention 2022-02-05 06:30:48 +05:00
agnostic-apollo b8c3db0b6e Fixed: Change extra keys and terminal input view background to black
Required for day/night theming and should fix issues where both views were translucent with light terminal color themes.
2022-02-05 06:28:22 +05:00
agnostic-apollo 622ff4fad4 Fixed: Fix issue where a colour tint/highlight would be added to the terminal on activity re-creation
The fix in c6b4114f was not working for it.
2022-02-05 06:26:23 +05:00
agnostic-apollo a56ed5771d Fixed: Fix terminal sessions being re-added if "New Session" shortcut or termux-reload-settings was used
If TermuxActivity was recreated then the original intent was re-delivered, resulting in a new session being re-added each time.

Closes #2566
2022-02-05 06:22:49 +05:00
agnostic-apollo 2a1c5a70da Docs: Fix issue link 2022-01-29 02:39:17 +05:00
agnostic-apollo 9b5aad9416 Fixed: Fix AppShell failsafe env 2022-01-28 18:06:05 +05:00
agnostic-apollo 95d7a154a4 Docs: Add notice that termux is broken on Android 12 2022-01-28 04:23:59 +05:00
agnostic-apollo 172a75e578 Changed: Do not recreate TermuxActivity enabled in 6631599f when TermuxService starts a session
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.
2022-01-28 04:03:48 +05:00
agnostic-apollo 4fd48a5aed Fixed: Fix termux session shortcuts not working after TermuxActivity recreation
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.
2022-01-28 03:56:39 +05:00
agnostic-apollo 81dd113157 Docs: Add notice that users should upgrade to v0.118.0 ASAP 2022-01-24 23:39:06 +05:00
agnostic-apollo 2452399a13 Added: Add explicit exported attribute for app components as required by Android 12
https://developer.android.com/about/versions/12/behavior-changes-12#exported
2022-01-23 19:46:46 +05:00
agnostic-apollo 6631599fb6 Added: Add support for shared day/night theming across termux apps
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.
2022-01-23 01:42:26 +05:00
agnostic-apollo f3f434af92 Changed: Rename ShareUtils openURL() to openUrl() 2022-01-23 01:42:26 +05:00
agnostic-apollo 6fea1fbddc Changed: Change ShareUtils.openSystemAppChooser() to public 2022-01-23 01:42:26 +05:00
agnostic-apollo a3cd058fb4 Update: Remove duplicate log tag prefix from TermuxOpenReceiver 2022-01-23 01:42:26 +05:00
agnostic-apollo b435d94888 Fixed: Do not open null or empty file paths passed to TermuxOpenReceiver 2022-01-23 01:42:26 +05:00
agnostic-apollo 3898ebdc74 Changed: Rename UriUtils getUriFilePath() to getUriFilePathWithFragment() 2022-01-23 01:42:26 +05:00
agnostic-apollo 1f3d3616a4 Fixed: Fix termux app restarting on samsung dex version < 3.0 when switching modes 2022-01-23 01:42:26 +05:00
agnostic-apollo b45ff8a407 Added: Store pid in ExecutionCommand for sessions and tasks 2022-01-23 01:42:26 +05:00
agnostic-apollo bf10c72661 Added: Add annotations and modifiers 2022-01-23 01:42:26 +05:00
agnostic-apollo 1fb4fe2510 Fixed: Fix FileUtils labels 2022-01-23 01:42:26 +05:00
agnostic-apollo 8e7e355fcb Fixed: Add accidentally removed import in 5252fbbe 2022-01-23 01:42:25 +05:00
agnostic-apollo 0fa0738cf6 Changed: Add uncommitted changes from 361bfb39 2022-01-23 01:41:57 +05:00
agnostic-apollo 998499d991 Changed: Remove redundant double quotes from string resources 2022-01-23 01:40:22 +05:00
agnostic-apollo 20a70b1a22 Fixed: Add uncommitted string resource changes 2022-01-23 01:40:22 +05:00
agnostic-apollo 5d202d082f Changed: Replace extra-keys Button with MaterialButton 2022-01-23 01:40:22 +05:00
agnostic-apollo bb1584decb Fixed: Remove unused imports 2022-01-23 01:40:22 +05:00
agnostic-apollo c1a0d6deff Changed: Rename ActivityUtilsErrno to ActivityErrno 2022-01-23 01:40:22 +05:00
agnostic-apollo 3f84b5345f Changed: Make ExtraKeysView private functions public and variables protected 2022-01-23 01:40:22 +05:00
agnostic-apollo 006bfeac8d Fixed: Fix termux background command logging at verbose level if CUSTOM_LOG_LEVEL was not passed 2022-01-23 01:40:22 +05:00
agnostic-apollo d222102635 Fixed: Catch rare RuntimeException while loading bell
java.lang.RuntimeException: Unable to resume activity {com.termux/com.termux.app.TermuxActivity}: android.content.res.Resources$NotFoundException: File res/raw/bell.ogg from drawable resource ID #0x7f0f0001
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3480)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3520)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6247)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
     Caused by: android.content.res.Resources$NotFoundException: File res/raw/bell.ogg from drawable resource ID #0x7f0f0001
        at android.content.res.ResourcesImpl.openRawResourceFd(ResourcesImpl.java:308)
        at android.content.res.Resources.openRawResourceFd(Resources.java:1272)
        at android.media.SoundPool.load(SoundPool.java:247)
        at com.termux.app.terminal.TermuxTerminalSessionClient.getBellSoundPool(TermuxTerminalSessionClient.java:257)
        at com.termux.app.terminal.TermuxTerminalSessionClient.onResume(TermuxTerminalSessionClient.java:82)
        at com.termux.app.TermuxActivity.onResume(TermuxActivity.java:290)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1270)
        at android.app.Activity.performResume(Activity.java:6861)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3457)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3520)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6247)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
     Caused by: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
        at android.content.res.AssetManager.openNonAssetFdNative(Native Method)
        at android.content.res.AssetManager.openNonAssetFd(AssetManager.java:467)
        at android.content.res.ResourcesImpl.openRawResourceFd(ResourcesImpl.java:306)
        at android.content.res.Resources.openRawResourceFd(Resources.java:1272)
        at android.media.SoundPool.load(SoundPool.java:247)
        at com.termux.app.terminal.TermuxTerminalSessionClient.getBellSoundPool(TermuxTerminalSessionClient.java:257)
        at com.termux.app.terminal.TermuxTerminalSessionClient.onResume(TermuxTerminalSessionClient.java:82)
        at com.termux.app.TermuxActivity.onResume(TermuxActivity.java:290)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1270)
        at android.app.Activity.performResume(Activity.java:6861)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3457)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3520)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6247)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
2022-01-23 01:40:22 +05:00
agnostic-apollo 7a386a7f2a Fixed: Fix ArrayIndexOutOfBoundsException when setting zero width terminal character
java.lang.ArrayIndexOutOfBoundsException: length=64; index=-1
at com.termux.terminal.TerminalRow.setChar(TerminalRow.java:127)
at com.termux.terminal.TerminalBuffer.setChar(TerminalBuffer.java:413)
at com.termux.terminal.TerminalEmulator.emitCodePoint(TerminalEmulator.java:2329)
at com.termux.terminal.TerminalEmulator.processCodePoint(TerminalEmulator.java:617)
at com.termux.terminal.TerminalEmulator.processByte(TerminalEmulator.java:513)
at com.termux.terminal.TerminalEmulator.append(TerminalEmulator.java:480)
at com.termux.terminal.TerminalSession$MainThreadHandler.handleMessage(TerminalSession.java:339)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8349)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
2022-01-23 01:40:22 +05:00
agnostic-apollo b79ed509f1 Changed: Store app wide night mode in NightMode.APP_NIGHT_MODE so that libraries can use it directly without having to load or get it from termux properties 2022-01-23 01:40:22 +05:00
agnostic-apollo 1b794b3518 Fixed: Do not use colon character ":" in log tag since it is invalid and breaks logcat command filterspecs argument 2022-01-23 01:40:22 +05:00
agnostic-apollo 0a3efc537d Changed: Use PermissionUtils to request disabling battery optimizations in TermuxService 2022-01-23 01:40:22 +05:00
agnostic-apollo 36e49707ec Added: Add support to request Settings.ACTION* permissions to be requested via Service context 2022-01-23 01:40:22 +05:00
agnostic-apollo f857bf2968 Added: Add ActivityUtils.startActivity() and catch uncaught exceptions in TermuxActivity 2022-01-23 01:40:22 +05:00
agnostic-apollo b69d14119e Changed: Return Error instead of boolean for ActivityUtils.startActivityForResult() 2022-01-23 01:40:22 +05:00
agnostic-apollo 8c43b7f0a1 Changed: Remove TermuxConstants reference from PackageUtils 2022-01-23 01:40:22 +05:00
agnostic-apollo 6ff5572999 Changed!: Remove TermuxConstants reference from Logger and set DEFAULT_LOG_TAG at application startup
Plugin apps must do the same
2022-01-23 01:40:22 +05:00
agnostic-apollo 8e506859a6 Changed!: Rename TermuxTask to AppShell since its not part of termux-app or com.termux.shared.termux package 2022-01-23 01:40:22 +05:00
agnostic-apollo 361bfb3961 Changed!: Move to package-by-feature hierarchy for classes not using it since termux-shared is growing too big and layers are getting out of hand 2022-01-23 01:40:22 +05:00
agnostic-apollo 549a772d45 Added: Add UriScheme and move UriUtils to com.termux.shared.net package 2022-01-23 01:40:22 +05:00
agnostic-apollo 37b9bcf5af Changed!: Rename FileUtils readStringFromFile() to readTextFromFile() and writeStringToFile() to writeTextToFile() 2022-01-23 01:40:22 +05:00
agnostic-apollo 7bbc12c7c9 Fixed: Get file basename from Uri path when opening files in termux if failed to get it ContentResolver and EXTRA_TITLE 2022-01-23 01:40:22 +05:00
agnostic-apollo 74b23cb209 Fixed: Fix TermuxFileReceiverActivity failing to open files with "#" and remove hardcoded "content" and "file" strings and fix indentation
am start -a android.intent.action.VIEW -n com.termux/.filepicker.TermuxFileReceiverActivity -d "file:///data/data/com.termux/files/home/te#st.sh"
2022-01-23 01:40:22 +05:00
agnostic-apollo b559d5a0bd Fixed: Fix TermuxService failing to execute files with "#"
am startservice --user 0 -n com.termux/.app.TermuxService -a com.termux.service_execute -d "file:///data/data/com.termux/files/home/te#st.sh"
2022-01-23 01:40:22 +05:00