Allow connection via a UNIX socket as a faster alternative#471
Merged
Grimler91 merged 2 commits intotermux:masterfrom Dec 23, 2021
Merged
Allow connection via a UNIX socket as a faster alternative#471Grimler91 merged 2 commits intotermux:masterfrom
Grimler91 merged 2 commits intotermux:masterfrom
Conversation
So clients can connect without having to call am if the plugin is already running.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
amto keep the process running, so the socket doesn't get closed.I tested it with:
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.