feat: add Termux/Android prerequisite detection
Detects when running in Termux on Android and checks for required prerequisites before starting the server: - Termux:API package installed - Location services enabled and accessible - Wake lock available Exits with informative error message if prerequisites not met. Adds `rf-mapper check-termux` command for manual verification. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -169,6 +169,9 @@ Note: Requires sudo for WiFi/Bluetooth scanning.
|
||||
web_parser.add_argument('--profile-requests', action='store_true', help='Enable profiling')
|
||||
web_parser.add_argument('--log-requests', action='store_true', help='Log requests')
|
||||
|
||||
# Check-termux command
|
||||
subparsers.add_parser('check-termux', help='Check Termux/Android prerequisites')
|
||||
|
||||
# Config command
|
||||
config_parser = subparsers.add_parser('config', help='Show/edit configuration')
|
||||
config_parser.add_argument(
|
||||
@@ -209,6 +212,8 @@ Note: Requires sudo for WiFi/Bluetooth scanning.
|
||||
run_status(data_dir)
|
||||
elif args.command == 'config':
|
||||
run_config(args, config)
|
||||
elif args.command == 'check-termux':
|
||||
run_check_termux()
|
||||
elif args.command == 'web':
|
||||
run_web_deprecated(args, config, data_dir)
|
||||
else:
|
||||
@@ -436,6 +441,19 @@ Home Assistant:
|
||||
""")
|
||||
|
||||
|
||||
def run_check_termux():
|
||||
"""Check Termux/Android prerequisites"""
|
||||
from .termux import is_termux, check_termux_prerequisites
|
||||
|
||||
if not is_termux():
|
||||
print("Not running in Termux/Android environment.")
|
||||
print("This check is only relevant when running on Android via Termux.")
|
||||
sys.exit(0)
|
||||
|
||||
success = check_termux_prerequisites(verbose=True)
|
||||
sys.exit(0 if success else 1)
|
||||
|
||||
|
||||
def get_pid_file(data_dir: Path) -> Path:
|
||||
"""Get path to PID file"""
|
||||
return data_dir / "rf-mapper.pid"
|
||||
@@ -534,6 +552,16 @@ def run_start(args, config: Config, data_dir: Path):
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
# Check Termux prerequisites if running on Android
|
||||
from .termux import is_termux, check_termux_prerequisites, setup_termux_signal_handlers
|
||||
|
||||
if is_termux():
|
||||
if not check_termux_prerequisites(verbose=True):
|
||||
print("Exiting due to missing prerequisites.")
|
||||
sys.exit(1)
|
||||
# Set up signal handlers for graceful shutdown
|
||||
setup_termux_signal_handlers()
|
||||
|
||||
host = args.host or config.web.host
|
||||
port = args.port or config.web.port
|
||||
debug = getattr(args, 'debug', False)
|
||||
|
||||
Reference in New Issue
Block a user