Skip to content
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

Allow connection via a UNIX socket as a faster alternative #471

Merged
merged 2 commits into from
Dec 23, 2021

Conversation

tareksander
Copy link
Member

@tareksander tareksander commented Dec 1, 2021

This creates a UNIX socket at application startup. You can send the extra arguments that would normally be passed to am over the socket, so there is no need to create a whole DalvikVM just to connect to the plugin every time.

The arguments get parsed with regex, string arguments have to be surrounded with double quotes every time. String argument arrays also have to be surrounded by double quotes. Other than that the options are parsed just like for am. I currently have implemented all options needed for the termux-api-package (I grep'd all possible extras from the scripts). If there is an error, the message gets send back over the socket. If the constructed Intent was successfully send to the receiver, a single null byte is send back to signify success. With that it even works when the process is terminated by the system, because no response means the process got killed.
There is also a dummy background service that can be started with am to keep the process running, so the socket doesn't get closed.

I tested it with:

  • termux-api-start
  • termux-api-stop
  • termux-audio-info
  • termux-battery-status
  • termux-brightness
  • termux-call-log
  • termux-camera-info
  • termux-camera-photo
  • termux-clipboard-get
  • termux-clipboard-set
  • termux-contact-list
  • termux-dialog

so far and it works well. On my phone the performance was ~10x better.
This should fix #63 good enough.

There is a corresponding PR for termux-api-package.

So clients can connect without having to call am if the plugin is
already running.
@Grimler91 Grimler91 merged commit 9e496d6 into termux:master Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants