# Complete Setup Instructions for Android Monitoring System ## ๐Ÿ“‹ OVERVIEW This guide provides step-by-step instructions for: 1. Setting up the web server on shared hosting 2. Creating the correct file structure 3. Configuring the database 4. Building the Android APK 5. Connecting the Android app to your web dashboard ## ๐ŸŒ PART 1: SHARED HOSTING SETUP ### Step 1: Prepare Your Hosting Account - Ensure your hosting supports: - PHP 7.4 or higher - MySQL 5.7 or higher - File uploads (at least 50MB) - SSL certificate (recommended) ### Step 2: Create Database 1. Login to your hosting control panel (cPanel/Plesk) 2. Go to "MySQL Databases" or "Database Management" 3. Create a new database named: `monitoring_db` 4. Create a database user with full privileges 5. Note down: Database name, username, password, and host (usually localhost) ### Step 3: Upload Files to Web Server #### File Structure on Your Server: ``` your-domain.com/ โ”œโ”€โ”€ php/ โ”‚ โ”œโ”€โ”€ config/ โ”‚ โ”‚ โ””โ”€โ”€ database.php โ”‚ โ”œโ”€โ”€ upload.php โ”‚ โ”œโ”€โ”€ get_commands.php โ”‚ โ”œโ”€โ”€ send_command.php โ”‚ โ”œโ”€โ”€ auth.php โ”‚ โ””โ”€โ”€ api.php โ”œโ”€โ”€ dashboard/ โ”‚ โ”œโ”€โ”€ index.html โ”‚ โ”œโ”€โ”€ styles.css โ”‚ โ””โ”€โ”€ script.js โ”œโ”€โ”€ uploads/ โ”‚ โ””โ”€โ”€ (this folder will be created automatically) โ””โ”€โ”€ database/ โ””โ”€โ”€ schema.sql ``` #### Upload Process: 1. **Create folders** on your server: - `/php/config/` - `/dashboard/` - `/uploads/` (set permissions to 755) - `/database/` 2. **Upload PHP files**: - Upload all files from `php/` folder to your server's `/php/` directory - Upload all files from `dashboard/` folder to your server's `/dashboard/` directory - Upload `database/schema.sql` to your server's `/database/` directory 3. **Set file permissions**: ``` uploads/ folder: 755 (read/write/execute) php/config/database.php: 644 (read/write for owner, read for others) All other files: 644 ``` ### Step 4: Configure Database Connection Edit `/php/config/database.php` with your hosting details: ```php ``` Visit: `https://your-domain.com/test_db.php` 2. **Test dashboard access**: Visit: `https://your-domain.com/dashboard/` - Should show login page - Login with the password you set in `DASHBOARD_PASSWORD` 3. **Test API endpoints**: Visit: `https://your-domain.com/php/api.php?action=devices` - Should return JSON data (may be empty initially) ### Step 7: Security Configuration 1. **Enable HTTPS** (if not already enabled) 2. **Change all default passwords** in `database.php` 3. **Set up .htaccess protection** (optional): Create `.htaccess` in dashboard folder: ```apache AuthType Basic AuthName "Restricted Access" AuthUserFile /path/to/.htpasswd Require valid-user ``` ## ๐Ÿ“ฑ PART 2: ANDROID APK BUILDING ### Prerequisites - Android Studio installed - Java Development Kit (JDK) 8 or higher - Android SDK configured ### Step 1: Prepare Android Project 1. **Open Android Studio** 2. **Import the project**: - File โ†’ Open - Navigate to `/android/` folder - Select the folder and click "OK" ### Step 2: Configure Server URL 1. **Open** `android/app/src/main/java/com/monitoring/app/MainActivity.kt` 2. **Find this line** (around line 50): ```kotlin serverUrlEditText.setText("https://your-server.com/monitoring/") ``` 3. **Replace with your actual server URL**: ```kotlin serverUrlEditText.setText("https://your-domain.com/php/") ``` ### Step 3: Update API Key (Important!) 1. **Open** `android/app/src/main/java/com/monitoring/app/network/HttpClient.kt` 2. **Find this line** (around line 30): ```kotlin private const val API_KEY = "monitoring_key_2024" // Change this in production ``` 3. **Replace with the same API_KEY you set in PHP**: ```kotlin private const val API_KEY = "your_secret_api_key_here" ``` ### Step 4: Build APK #### Method 1: Build APK (Recommended) 1. In Android Studio: **Build โ†’ Build Bundle(s) / APK(s) โ†’ Build APK(s)** 2. Wait for build to complete 3. Click "locate" in the notification 4. APK will be in: `android/app/build/outputs/apk/debug/app-debug.apk` #### Method 2: Generate Signed APK (For Production) 1. **Build โ†’ Generate Signed Bundle / APK** 2. Choose "APK" 3. Create new keystore or use existing 4. Fill in details and build 5. APK will be in: `android/app/build/outputs/apk/release/app-release.apk` ### Step 5: Install APK 1. **Transfer APK to Android device**: - USB cable - Email attachment - Cloud storage - ADB install: `adb install app-debug.apk` 2. **Enable Unknown Sources**: - Settings โ†’ Security โ†’ Unknown Sources (enable) - Or Settings โ†’ Apps โ†’ Special Access โ†’ Install Unknown Apps 3. **Install APK**: - Open APK file on device - Follow installation prompts ## ๐Ÿ”— PART 3: CONNECTING ANDROID TO WEB DASHBOARD ### Step 1: Configure Android App 1. **Open the monitoring app** on Android device 2. **Enter server URL**: `https://your-domain.com/php/` 3. **Grant all permissions** when prompted: - Camera - Microphone - Location (Fine and Coarse) - Storage (Read/Write) - Call Log - Contacts - Phone State - Vibration ### Step 2: Start Monitoring 1. **Tap "Start Monitoring"** 2. **App will show as foreground service** 3. **Device should appear in dashboard** within 30 seconds ### Step 3: Test Dashboard 1. **Open dashboard**: `https://your-domain.com/dashboard/` 2. **Login with your password** 3. **Go to "Devices" tab** - should see your device 4. **Go to "Remote Control" tab** - select your device 5. **Test commands**: - Vibrate device - Start live screen stream - Start live camera stream - Start live audio stream ## ๐Ÿงช PART 4: TESTING & VERIFICATION ### Test Checklist #### Web Server Tests: - [ ] Dashboard loads and login works - [ ] Database connection successful - [ ] API endpoints respond correctly - [ ] File uploads work (test with small file) #### Android App Tests: - [ ] App installs successfully - [ ] All permissions granted - [ ] App connects to server - [ ] Device appears in dashboard - [ ] Call logs are uploaded - [ ] Location tracking works - [ ] Media monitoring works - [ ] Remote commands execute #### Live Streaming Tests: - [ ] Screen streaming starts/stops - [ ] Camera streaming works (front/back) - [ ] Audio streaming records and uploads - [ ] Live views update in dashboard ### Troubleshooting #### Common Issues: 1. **"Database connection failed"**: - Check database credentials in `database.php` - Verify database exists and user has permissions - Check if MySQL service is running 2. **"Authentication failed"**: - Ensure API_KEY matches in both Android app and PHP config - Check device ID generation 3. **"App not connecting"**: - Verify server URL is correct - Check if HTTPS is working - Test API endpoints manually 4. **"Upload failed"**: - Check uploads folder permissions (755) - Verify file size limits - Check PHP upload settings 5. **"Dashboard not loading"**: - Check file permissions - Verify all files uploaded correctly - Check for PHP errors in hosting logs ## ๐Ÿ“‹ FINAL CHECKLIST ### Before Going Live: - [ ] Changed all default passwords - [ ] Enabled HTTPS/SSL - [ ] Set proper file permissions - [ ] Tested all functionality - [ ] Configured backup procedures - [ ] Set up monitoring/logging ### Security Reminders: - [ ] Use strong passwords - [ ] Enable HTTPS - [ ] Regular security updates - [ ] Monitor access logs - [ ] Backup database regularly ## ๐Ÿ“ž SUPPORT If you encounter issues: 1. Check error logs in hosting control panel 2. Verify all configuration settings 3. Test each component individually 4. Review troubleshooting section above ## ๐ŸŽฏ QUICK REFERENCE ### Important URLs: - Dashboard: `https://your-domain.com/dashboard/` - API Base: `https://your-domain.com/php/` - Test DB: `https://your-domain.com/test_db.php` ### Key Files to Edit: - `php/config/database.php` - Database and security settings - `MainActivity.kt` - Server URL in Android app - `HttpClient.kt` - API key in Android app ### Default Credentials (CHANGE THESE!): - Dashboard Password: `admin123` - API Key: `monitoring_key_2024` - Encryption Key: `monitoring_secret_key_2024` --- **โš ๏ธ IMPORTANT**: This system is for authorized monitoring only. Ensure compliance with applicable laws and regulations. **๐Ÿ”’ SECURITY**: Change all default passwords and enable HTTPS before use. **๐Ÿ“ฑ COMPATIBILITY**: Requires Android 7.0+ and modern web browser. --- End of Instructions