-
Notifications
You must be signed in to change notification settings - Fork 337
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
termux-api
command should detect if Termux:API plugin is not installed and print error.
#200
Comments
You are forgetting the delay an external call like this will cause. Anyways, this is already planned to be fixed with termux-am-socket updates. |
|
There is a 20ms delay even on a snapdragon 865. |
Not really noticeable. And the result can be cached for the case of batch api calls. |
Every delay matters as it adds up in sequential calls. And when certain API calls themselves take 25-30ms, then 20ms is hell of a lot of delay. There are better solutions for this case where app manages the state. As for other general caching for user scripts, read https://github.com/termux/termux-core-package/blob/0.1.0-prerelease/site/pages/en/projects/docs/usage/utils/termux-apps-info-app-version-name.md#rationale-and-design |
I mean you can cache |
A user can uninstall the app after caching and you will get wrong state on later calls. Read the relevant links, and there is a better solution for this case like I said, wait for it to be implemented. |
The doc is long. And as far as I understand it it describes saving some data to environment variables which will not work in this case since you can not save data to environment variables of parent process. Also it is possible to make |
App will save to env file and update it when any plugin app state changes. Scripts can source the file, parent process doesn't matter, and sourcing is an internal call in shell and is instant. There is no need for messing around with api scripts for this, am-socket can check if target app is installed before sending intent, that will be much faster, likely instant. |
The solution you suggest will work with 0.119+ but will not work for 0.118 or outdated forks like termux-monet (afaik some people still use it). My suggestion should work with any existing termux-app version and should not be too much complicated.
It implements simple timeout which should not add any delay (maybe a few nanosecs for a pollfd syscall), does not complicate the function much and does not change function logic. It will simply invoke the check in the case if Termux:API plugin did not respond. |
Timeouts is not possible, as termux-api app may connect or respond after a long time, like for location APIs. Its not my responsibility to support older app versions considering that both android 5 and 7 users can use latest versions. Fixing termux-am-socket will also fix issues for all intents, not just temrux-api, so a better and faster solution. |
Nobody says it should terminate the process in the case if there is no output. |
The delay exists if external call in shell/binary is made, plus lag due to binder shenanigans. If done in app, then there won't be a delay as Android caches package/application info states on its own using
Additionally, you are misunderstanding how temrux-api.c works, the waiting for app happens on blocking
|
You are right. We should poll
The program creates sockets with unique uuids for each invocation so should be fine. Otherwise we can use lock files to prevent concurrent access.
As I said before, the check should not be triggered if app actually responds. And the check will be performed only in the case if the program is idle for too long. If you still think it will create a delay we can do some other thing like creating global |
Feature description
You can invoke command like
echo $(pm path com.termux.api 2>&1 </dev/null)
in termux to get termux:api plugin apk path or get error otherwise, it should be usable to detect plugin installation even without PackageManager API (or JVM).Background information
Termux:X11 companion package can detect if main APK is installed or not via PackageManager API. Termux:API should do that too.
There are enough people coming to discord, matrix and reddit complaining about termux-api-based commands are hanging indefinitely.
Redirecting everything to /dev/null or anonymous pipes is necessary in command
echo $(pm path com.termux.api 2>&1 </dev/null)
, the same applies to the case if you are porting it to C.Related to:
#138
#153
#80
The text was updated successfully, but these errors were encountered: