Advanced Android device control system with modern web interface, wireless connectivity, and comprehensive automation features.
Phone Control Project v2.0 is a cross-platform solution for managing, controlling, and automating Android devices. It combines a Node.js web server, Python FastAPI backend, Electron desktop application, and modern web interface to provide comprehensive device management capabilities.
- Wireless ADB Connection: Connect devices over WiFi without USB cables
- Screen Mirroring: High-quality screen mirroring using scrcpy
- Cross-Platform Support: Windows, macOS, and Linux
- Advanced Automation: Batch operations, performance monitoring, and scripting
- Electron Desktop App: Native desktop experience with system integration
- Docker Support: Containerized deployment options
- Python FastAPI Backend: Robust API with comprehensive device management
- File Transfer: Drag-and-drop file transfers between device and computer
- Screen Recording: Built-in screen recording with customizable settings
- Remote device management and support
- Automated app testing and QA
- Device performance monitoring
- File synchronization and backups
- Multi-device orchestration
- Screen mirroring and recording
Phone-Control-Project/
├── src/
│ ├── api/
│ │ └── device_manager.py # Python FastAPI backend with advanced device management
│ ├── ui/
│ │ ├── index.html # Modern web interface with Tailwind CSS
│ │ └── app.js # Frontend JavaScript application logic
│ ├── utils/
│ │ └── automation.js # Device automation utilities and helpers
│ └── server.js # Node.js Express server with WebSocket support
├── Software/ # Bundled ADB and scrcpy executables
│ ├── adb.exe # Android Debug Bridge executable
│ ├── scrcpy.exe # Screen copy (scrcpy) executable
│ ├── scrcpy-server # Scrcpy server component
│ └── [DLL dependencies] # Required libraries (SDL2, FFmpeg codecs, etc.)
├── electron-main.js # Electron desktop application entry point
├── docker-compose.yml # Multi-container Docker orchestration
├── Dockerfile.api # Python API container configuration
├── Dockerfile.web # Node.js web server container configuration
├── package.json # Node.js dependencies and scripts
├── requirements.txt # Python dependencies
├── PHONECONTROL.BAT # Windows quick-launch script
├── setup.bat # Windows setup script (Chocolatey installation)
├── scrcpy_instructions.txt # Quick start guide for scrcpy
├── banner.png # Project banner/logo
└── README.md # Comprehensive project documentation
- Express 4.18.2: Web application framework
- Socket.IO 4.7.2: Real-time bidirectional event-based communication
- Multer 2.0.2: File upload handling middleware
- WebSockets (ws) 8.14.2: WebSocket client and server implementation
- node-adb 0.2.4: ADB wrapper for Node.js
Key Components:
- DeviceController class for device management
- REST API endpoints for device operations
- WebSocket server for real-time updates
- Process management for scrcpy
- FastAPI 0.104.1: Modern, high-performance web framework
- Uvicorn 0.24.0: ASGI server implementation
- Pydantic 2.5.0: Data validation using Python type annotations
- adb-shell 0.4.4: Pure Python ADB implementation
- pure-python-adb 0.3.0: Alternative ADB implementation
- OpenCV 4.8.1: Computer vision and image processing
- NumPy 1.25.2: Numerical computing library
- Pillow 10.1.0: Python Imaging Library
- Python-multipart 0.0.6: Multipart form data parser
Key Components:
- AdvancedDeviceManager class for device operations
- Async/await pattern for non-blocking operations
- Device discovery and detailed information retrieval
- File transfer (push/pull) operations
- Screenshot and screen recording capabilities
- WiFi debugging enablement
- Tailwind CSS 2.2.19: Utility-first CSS framework
- Font Awesome 6.0.0: Icon library
- Socket.IO Client: Real-time communication
- Vanilla JavaScript: No framework dependencies for lightweight performance
UI Features:
- Responsive design with gradient backgrounds
- Real-time device status updates
- Terminal-style command output
- Modal dialogs for WiFi setup
- Device card interface with quick actions
- Electron 38.0.0: Cross-platform desktop app framework
- Node Integration: Full Node.js API access
- IPC Communication: Inter-process communication
- Native Menus: Platform-specific menu bars
- File Dialogs: Native file selection dialogs
Electron Features:
- PhoneControlElectron class for app lifecycle
- Integrated Node.js server startup
- Keyboard shortcuts and accelerators
- Settings modal with localStorage persistence
- About dialog and external documentation links
- npm: Node.js package manager
- pip: Python package manager
- Webpack 5.88.2: Module bundler
- Nodemon 3.0.1: Auto-reload development server
- Jest 29.6.4: JavaScript testing framework
- Docker: Container platform
- Docker Compose 3.8: Multi-container orchestration
- Redis 7 Alpine: In-memory data structure store
- Nginx Alpine: Web server and reverse proxy
# Clone repository
git clone https://github.com/jtgsystems/Phone-Control-Project.git
cd Phone-Control-Project
# Install Node.js dependencies
npm install
# Install Python dependencies
pip install -r requirements.txt
# Start application
npm start# Start all services
docker-compose up -d
# Access web interface at http://localhost:3000
# API available at http://localhost:8000# Install dependencies
npm install
# Run in development mode
npm run electron-dev
# Run in production mode
npm run electronnpm start # Start Node.js server (production)
npm run dev # Start with auto-reload (nodemon)
npm run build # Build with Webpack
npm test # Run Jest tests
npm run install-deps # Install both npm and pip dependencies
npm run electron # Start Electron app
npm run electron-dev # Start Electron in development mode
npm run docker-build # Build Docker images
npm run docker-up # Start Docker containers
npm run docker-down # Stop Docker containers# Run FastAPI server directly
python -m uvicorn src.api.device_manager:app --host 0.0.0.0 --port 8000
# Or execute the module
python src/api/device_manager.pyPORT=3000 # Web server port
NODE_ENV=production # Node environment (development/production)API_HOST=0.0.0.0 # API bind address
API_PORT=8000 # API server port
PYTHONPATH=/app # Python module path (Docker)REDIS_URL=redis://localhost:6379 # Redis connection URL{
"bitrate": "8M", // Video bitrate (4M, 8M, 16M)
"maxSize": "1080", // Max resolution (720, 1080, 1440, 0 for original)
"renderer": "opengl", // Renderer (opengl, software)
"stayAwake": true, // Keep device awake
"showTouches": true // Show touch points
}- Window Size: 1200x800 (min 800x600)
- Default Bitrate: 8 Mbps
- Default Max Size: 1080p
- Default Renderer: OpenGL
- Settings Storage: localStorage (persistent)
GET /api/devices # List connected devices with details
POST /api/connect-wifi # Connect to device via WiFi
POST /api/enable-wifi/:deviceId # Enable WiFi debugging on device
Example Response - Get Devices:
{
"success": true,
"devices": [
{
"id": "ABC123XYZ",
"status": "device",
"model": "Pixel 6",
"android_version": "13",
"ip_address": "192.168.1.100",
"battery_level": 85,
"screen_resolution": "1080x2400"
}
]
}POST /api/scrcpy/start # Start screen mirroring
POST /api/scrcpy/stop # Stop screen mirroring
POST /api/screenshot/:deviceId # Take device screenshot
POST /api/upload/:deviceId # Upload file to device
POST /api/download/:deviceId # Download file from device
File Upload Parameters:
file: Multipart file uploadremote_path: Destination path on device (default: /sdcard/)
POST /api/shell-command # Execute shell command
POST /api/install-apk # Install APK file
POST /api/backup # Backup device data
Shell Command Request:
{
"device_id": "ABC123XYZ",
"command": "pm list packages"
}socket.emit('get-devices'); // Request device listsocket.on('devices-updated', (devices) => {}); // Device list updated
socket.on('error', (error) => {}); // Error occurredLocation: src/server.js
Capabilities:
- Device discovery via ADB
- WiFi connection management
- Scrcpy process control
- Shell command execution
- Device parsing and status tracking
Key Methods:
async getDevices() // Get list of connected devices
parseDevices(output) // Parse ADB devices output
async connectWiFi(ip, port) // Connect via WiFi
async enableWiFiDebugging(deviceId) // Enable WiFi debugging
startScrcpy(deviceId, options) // Start screen mirroring
stopScrcpy() // Stop screen mirroring
async executeAdbCommand(deviceId, cmd) // Execute ADB commandLocation: src/api/device_manager.py
Capabilities:
- Cross-platform ADB path detection
- Async device operations
- Detailed device information retrieval
- RSA signer authentication
- Screenshot and file transfer
- Performance monitoring integration
Key Methods:
async get_devices() # Get devices with detailed info
async connect_wifi(ip, port) # WiFi connection
async enable_wifi_debugging(device_id, port) # Enable WiFi debugging
async install_apk(device_id, apk_path) # Install APK
async push_file(device_id, local, remote) # Push file to device
async pull_file(device_id, remote, local) # Pull file from device
async execute_shell_command(device_id, cmd) # Execute shell command
async take_screenshot(device_id, output) # Take screenshot
async start_scrcpy(device_id, **options) # Start scrcpyLocation: src/utils/automation.js
Capabilities:
- Batch APK installation
- Device backup and restore
- File synchronization
- Performance monitoring
- Network speed testing
- Automated app testing
- Device optimization
- Screen recording
Key Methods:
async batchInstallApks(deviceId, apkPaths, progressCallback)
async backupDevice(deviceId, backupPath, options)
async syncFiles(deviceId, localPath, remotePath, direction)
async monitorPerformance(deviceId, duration)
async testNetworkSpeed(deviceId, testUrl)
async testApp(deviceId, packageName, testActions)
async optimizeDevice(deviceId)
async recordScreen(deviceId, duration, outputPath)Automation Examples:
// Batch install multiple APKs
const automation = new DeviceAutomation(deviceController);
const results = await automation.batchInstallApks('ABC123XYZ', [
'/path/to/app1.apk',
'/path/to/app2.apk',
'/path/to/app3.apk'
]);
// Monitor device performance for 60 seconds
const metrics = await automation.monitorPerformance('ABC123XYZ', 60000);
console.log('Average CPU:', metrics.summary.cpu.avg);
console.log('Peak Memory:', metrics.summary.memory.max);
console.log('Battery Drain:', metrics.summary.battery.drain);
// Automated app testing
const testActions = [
{ type: 'tap', x: 500, y: 1000 },
{ type: 'swipe', x1: 300, y1: 800, x2: 300, y2: 400, duration: 500 },
{ type: 'text', text: 'Hello World' },
{ type: 'key', keycode: 'KEYCODE_BACK' }
];
await automation.testApp('ABC123XYZ', 'com.example.app', testActions);
// Device optimization
const optimizeResults = await automation.optimizeDevice('ABC123XYZ');
console.log('Operations completed:', optimizeResults.operations);Location: src/ui/app.js
Capabilities:
- Socket.IO integration
- Real-time device updates
- WiFi connection modal
- Terminal output display
- Command execution
- File upload handling
Event Handlers:
- Device refresh
- WiFi connection setup
- Screen mirroring start
- Shell command execution
- File transfer initiation
phone-control-web (Node.js)
- Port: 3000
- Dockerfile:
Dockerfile.web - Base Image: node:18-alpine
- Volumes: src/, Software/
- Health Check: HTTP GET /api/health
phone-control-api (Python)
- Port: 8000
- Dockerfile:
Dockerfile.api - Base Image: python:3.11-slim
- Volumes: src/api/, Software/, /dev/bus/usb
- Privileged: true (USB access)
- Health Check: HTTP GET /api/health
redis (Cache)
- Port: 6379
- Image: redis:7-alpine
- Persistent Volume: redis_data
nginx (Reverse Proxy)
- Ports: 80, 443
- Image: nginx:alpine
- Volumes: nginx.conf, ssl/
- Depends On: web, api
- Bridge network: phone-control-network
- All services connected for inter-service communication
- Non-root users in containers
- Health checks for all services
- Privileged mode only for API (USB access)
- SSL certificate support (nginx)
- Multiple devices handled simultaneously
- Async/await pattern throughout Python backend
- Non-blocking WebSocket communication
- Process spawning for scrcpy (non-blocking)
- Optimized video compression with scrcpy
- Configurable bitrate (4M, 8M, 16M)
- Adaptive resolution (720p, 1080p, 1440p, original)
- OpenGL rendering for hardware acceleration
- Process cleanup on disconnect
- Automatic screenshot file deletion
- Smart resource monitoring
- Garbage collection optimization
- WebSocket for real-time updates (reduces HTTP overhead)
- Connection pooling in Redis
- Efficient ADB command batching
- Compressed data transfer
- Framework: Jest 29.6.4
- Coverage: Core device operations, automation utilities
- Command:
npm test
- API endpoint testing with FastAPI TestClient
- WebSocket event verification
- Docker container health checks
- USB device detection
- WiFi connection establishment
- Screen mirroring quality
- File transfer integrity
- Command execution accuracy
- Multi-device support
- Cross-platform compatibility
- Windows: 10, 11 (primary development platform)
- macOS: 10.15+ (Catalina and later)
- Linux: Ubuntu 18.04+, Debian 10+, Fedora 30+
- Minimum: Android 5.0 (API level 21)
- Recommended: Android 8.0+ (API level 26+)
- Tested: Android 11, 12, 13, 14
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
Symptoms: No devices appear in device list
Solutions:
- Ensure USB debugging is enabled on device
- Try different USB cable or port
- Install device-specific USB drivers (Windows)
- Run
adb devicesin terminal to verify connection - Restart ADB server:
adb kill-server && adb start-server
Symptoms: Unable to connect via WiFi
Solutions:
- Verify device and computer are on same network
- Check firewall settings (allow port 5555)
- Confirm IP address is correct:
adb shell ip route - Enable WiFi debugging while USB connected first
- Try manual connection:
adb connect <IP>:5555
Symptoms: Laggy or choppy screen mirroring
Solutions:
- Reduce video bitrate to 4M in settings
- Lower max resolution to 720p
- Switch renderer to software if OpenGL causes issues
- Check network bandwidth (for WiFi connections)
- Close other bandwidth-intensive applications
- Use USB connection instead of WiFi for best performance
Symptoms: Error when starting screen mirroring
Solutions:
- Ensure scrcpy is in Software/ directory
- Grant display capture permissions on device
- Check if another scrcpy instance is running
- Verify device screen is unlocked
- Try restarting device
Symptoms: Unable to push/pull files
Solutions:
- Check file path permissions on device
- Ensure sufficient storage space on device
- Verify file path syntax (use forward slashes)
- Check if device storage is mounted
- Try using /sdcard/ as base path
Symptoms: Docker container can't access USB devices
Solutions:
- Ensure privileged mode is enabled for API container
- Verify /dev/bus/usb is mounted correctly
- Check USB device permissions on host
- Restart Docker daemon after connecting device
- Use host network mode as alternative
- ✅ Modern web interface with Tailwind CSS
- ✅ WiFi ADB connection support
- ✅ Cross-platform compatibility
- ✅ Advanced automation utilities
- ✅ Electron desktop application
- ✅ Docker containerization
- ✅ Python FastAPI backend
- ✅ Real-time WebSocket communication
- ✅ File transfer capabilities
- ✅ Performance monitoring
- iOS Device Support: Extend to iOS devices using libimobiledevice
- Cloud Deployment: AWS, GCP, Azure deployment guides
- Machine Learning Automation: AI-powered test generation
- Plugin System: Extensible architecture for community plugins
- Multi-Language Support: i18n for interface localization
- Advanced Scripting: Lua/Python scripting interface
- Screen Recording UI: Built-in recording controls in web interface
- Multiple Device Mirroring: Simultaneous multi-device screens
- Device Groups: Manage devices in groups
- Scheduled Automation: Cron-like task scheduling
- Remote Access: Secure tunneling for remote device access
- Analytics Dashboard: Device usage and performance analytics
- GraphQL API support
- Mobile companion app (React Native)
- CI/CD integration for automated testing
- Device farm integration
- VNC/RDP-like remote control protocol
- Voice command integration
- All API inputs sanitized using Pydantic
- File upload restrictions (type, size)
- Command injection prevention
- Path traversal protection
- Sandboxed scrcpy processes
- Non-root users in Docker containers
- Limited shell command scope
- Process cleanup on errors
- Ready for authentication middleware integration
- Role-based access control preparation
- API key support (future)
- OAuth 2.0 compatibility (planned)
- HTTPS/SSL ready (nginx configuration)
- CORS configuration for API
- Certificate validation for production
- Secure WebSocket connections (WSS)
- Never commit credentials to repository
- Use environment variables for sensitive data
- Regular dependency updates (Dependabot enabled)
- Security audit with npm audit / pip-audit
- Minimal container attack surface (Alpine images)
- Fork the repository
- Clone your fork locally
- Create a feature branch:
git checkout -b feature-name - Install dependencies:
npm run install-deps - Make changes and test thoroughly
- Commit with clear messages:
git commit -m 'Add feature description' - Push to your fork:
git push origin feature-name - Create a Pull Request
- JavaScript: Follow Airbnb style guide
- Python: Follow PEP 8
- HTML/CSS: Consistent indentation (2 spaces)
- Commits: Conventional Commits format
- All new features must include tests
- Maintain or improve code coverage
- Test on multiple platforms if possible
- Document test cases in PR description
- GitHub: https://github.com/jtgsystems/Phone-Control-Project
- License: MIT License
- Author: JTG Systems
- Version: 2.0.0
- v2.0.0: Complete modernization with web interface, Docker, FastAPI
- v1.x: Original batch script-based implementation
- Enhanced documentation and README
- Added project banner
- Dependency security updates (Dependabot)
- Issues: https://github.com/jtgsystems/Phone-Control-Project/issues
- Discussions: https://github.com/jtgsystems/Phone-Control-Project/discussions
- Wiki: https://github.com/jtgsystems/Phone-Control-Project/wiki
# Start development server
npm run dev
# Run Electron in dev mode
npm run electron-dev
# Build for production
npm run build
# Run tests
npm test# Build containers
docker-compose build
# Start services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# Rebuild and restart
docker-compose up -d --build# List devices
adb devices
# Connect WiFi
adb connect 192.168.1.100:5555
# Enable WiFi debugging
adb tcpip 5555
# Shell access
adb shell
# Install APK
adb install app.apk
# Push file
adb push local.txt /sdcard/
# Pull file
adb pull /sdcard/remote.txt
# Screenshot
adb shell screencap /sdcard/screen.png
adb pull /sdcard/screen.png
# Screen recording
adb shell screenrecord /sdcard/video.mp4# Basic mirror
scrcpy
# Specific device
scrcpy -s ABC123XYZ
# Custom bitrate and resolution
scrcpy --video-bit-rate 8M --max-size 1080
# Stay awake and show touches
scrcpy --stay-awake --show-touches
# Record screen
scrcpy --record screen.mp4Last Updated: 2024-10 System: Phone Control Project v2.0 Built with ❤️ by JTG Systems
- FastAPI: 0.104.1