termux-api icon indicating copy to clipboard operation
termux-api copied to clipboard

`termux-saf-managedir` select screen can disappear and stuck when swtich to other view

Open knyipab opened this issue 2 years ago • 1 comments

@tareksander

Problem description and Steps to reproducd termux-saf-managedir would pop a folder selection screen. If the user switch to other application or go to home screen.

Expected behavior Either end the terminal blocking or let the selection screen stay in recents.

Additional information My solution in the pull requests here is to let it stay in recent screens. I set android:excludeFromRecents="false" in AndroidManifest.xml and use finishAndRemoveTask(); replacing finish(); in the activity. I'm not very familiar with Android and not sure if there may be any side effects.

It solves the issue but there's more. If user swipes to kill the activity, it can't catch that to release the terminal. Just fyi, seems some stackoverflow solution is a service to monitor this.

knyipab avatar Mar 15 '22 10:03 knyipab

It solves the issue but there's more. If user swipes to kill the activity, it can't catch that to release the terminal. Just fyi, seems some stackoverflow solution is a service to monitor this.

I found the reason: As soon as the Activity is swiped away by the user there is no component alive in the process, so Android just kills it without running the Activity onDestroy method. Because the api helper binary still waits for Termux:API to send an answer, it hangs forever. Starting the KeepAliveService before starting the Activity fixes this.

tareksander avatar Mar 15 '22 17:03 tareksander