The biggest challenge with any Android surveillance tool is persistence. Android aggressively kills background processes. Here's how XeraX stays running no matter what.
Layer 1: Magisk service.d Watchdog
When root is available, XeraX installs a watchdog script in /data/adb/service.d/. This runs as root outside of any app's cgroup — meaning Android cannot kill it. It checks every 30 seconds if the surveillance daemon is running, and restarts it if not.
Layer 2: Termux:Boot
Even without root, XeraX registers with Termux:Boot. After every reboot, Termux is automatically launched and the daemon starts. You receive a "Surveillance ONLINE" Telegram message to confirm.
Layer 3: OOM Protection
XeraX sets oom_score_adj to -1000 on all its processes, making Android treat them as critical system processes that should not be killed under memory pressure.
Wake Lock
A Termux wake lock keeps the CPU from sleeping while the daemon is active, ensuring heartbeats and commands are processed in real time.
The result: XeraX stays online through reboots, Termux force-closes, battery optimization, and Doze mode.