| File | Download |
|---|---|
| api_agent.c | Download |
| api_agent_api23 | Download |
| install_api_agent.js | Download |
| relayctl.py | Download |
| server.py | Download |
| engmode_relay_compat.js | Download |
This setup installs a small native API-agent helper on your own KaiOS 3.x phone
after you have loaded JavaScript into system.localhost/proxy.html.
api_agent.c is the source file.
api_agent_api23 is the binary that gets copied to the phone.
~/android-ndk-r26d/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi23-clang \ -O2 -Wall -Wextra -fPIE -pie \ -DAGENT_HOST=\"192.168.40.252\" \ -DAGENT_PORT=9000 \ -DAGENT_TOKEN=\"kaios-local-relay\" \ api_agent.c -o api_agent_api23
Put api_agent_api23 in the same folder as server.py.
python server.py
Server running at http://0.0.0.0:9000 LAN URL: http://192.168.40.252:9000 Engmode relay token: kaios-local-relay
python relayctl.py snippet --public-server http://192.168.40.252:9000
javascript:(function(){var s=document.createElement('script');s.src='http://192.168.40.252:9000/install_api_agent.js?t='+Date.now();document.body.appendChild(s)})()
http://system.localhost/proxy.html
Then enter:
javascript:s=document.createElement('script')
Expected output:
[object HTMLScriptElement]
Then enter the generated snippet.
The bootstrap downloads:
http://YOUR_COMPUTER_IP:9000/api_agent_api23
Copies it to:
/data/local/service/api-daemon/api_agent_api23
And starts it in the background.
python relayctl.py latest
python relayctl.py agent-status
python relayctl.py agent-shell 'id; cat /proc/self/attr/current; uname -a' --wait --timeout 30
uid=0(root) gid=0(root) groups=0(root) context=u:r:api-daemon:s0
If the phone reboots or the agent stops polling, load the installer snippet
again from system.localhost/proxy.html.
python relayctl.py snippet --public-server http://192.168.40.252:9000 --script engmode_relay_compat.js