-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix RunCommandService crash and foreground issue #1764
Fix RunCommandService crash and foreground issue #1764
Conversation
Hey, thanks! Could you maybe split the commit into two or three parts to keep the git history easier to follow? (For example fixing the crash in one, improving RUN_COMMAND functionality in one and adding the PREFIX/HOME expanding in one) Will test this out on my devices! |
Sure. Out at the moment, will do it when I get back. |
…startForeground()" function is not being called before running "startForegroundService()" in RunCommandService.
…lly in android >= 10 unless user manually clicks termux notification for "RUN_COMMAND" intents and "Termux:Tasker" plugin actions that have background mode "false" because of new restrictions of starting activities from background. This is done by adding "android.permission.SYSTEM_ALERT_WINDOW" permission in AndroidManifest.xml so that the user may optionally grant "Draw Over Apps" permission to termux to fix the issue.
1f6ae46
to
7063a3a
Compare
Hey, these commits now should be the same as the original single commit. Let me know if its working fine on your devices. I don't have a physical android >= 8 device. And forgot to mention, to produce the crash on |
@agnostic-apollo I have not been able to reproduce the crash on my android 10 (LineageOS) device, tasker reports another error:
This PR does not change anything on that device, but merging since it fixes the crash on your device. |
Well, u/DutchOfBurdock was the one who initially reported the issue on his device which I confirmed on android 10 avd, so the issue does exist for others. I personally use LG G5, Android 7.0 which obv doesn't have the issue. hmm, interesting that you can't reproduce it. LineageOS doesn't seem to have looser restrictions for background stuff according to this report. I have already mentioned this, but just confirming that have you disabled termux battery optimizations, if you disable those, then you are likely not going to get a crash. The entries you are getting by tasker are from its And thanks for the merge. |
Part of v0.100 release. |
Thanks. Congrats on the |
Ah, yes, I was running without battery optimization, so that is probably the reason.. Should have read the instructions more carefully..
Alright, I get a timeout then without my test script being executed, thanks for clarifying that! |
Glad you managed to get a crash ;) You are welcome. |
…d-crash-and-foreground-patch Fix RunCommandService crash and foreground issue
…d-crash-and-foreground-patch Fix RunCommandService crash and foreground issue
Because a random bug fix from 3 years ago? |
Мне нравится |
Великолепное чудо |
Since
startForeground()
function is not being called, occasionally termux is killed by android with the following exceptionI have added calls to
startForeground()
in bothonCreate()
andonStartCommand()
and have tested the in android 10 emulator and the fix seems to be working with no crashes yet. I even tested under low free RAM conditions in order to slow down the phone but termux still didn't crash. Of course, it could potentially still crash because the function may not be called in under5s
in all circumstances since its a framework issue. More details here. Disabling battery optimization is likely the better way but this also works and is the recommended way.Adding
android.permission.SYSTEM_ALERT_WINDOW
permission to fix the foreground issue seems to be the reasonable way to go since all the other exceptions to the rule do not really apply to termux, and without it, it greatly reduces usability of both theRUN_COMMAND
intents andTermux:Tasker
plugin. If a user has already set a certain command to be run in a foreground session from a background task like from tasker, it should run in foreground without user intervention. The hack that currently works for running termux commands from tasker is to do asleep 1; am start --user 0 -n com.termux/com.termux.app.TermuxActivity
after running theTermux:Tasker
plugin or TermuxCommand action, since tasker already has requestedandroid.permission.SYSTEM_ALERT_WINDOW
permission and also has an accessibility service, so it can actually start termux activity from its own background execution service, but termux itself can't from its own service. I haven't currently added a way for the user to request the permission from within termux, let me know if that is even required.Let me know if there are any other issues. Thanks