Transfer is working, added tooling, debug scripts
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# Debug Tools
|
||||
|
||||
This folder contains debugging utilities for troubleshooting the Android File Handler application.
|
||||
|
||||
## Scripts
|
||||
|
||||
### `debug_adb.py`
|
||||
|
||||
Comprehensive ADB debugging script that helps diagnose device detection issues.
|
||||
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
poetry run python debug_tools/debug_adb.py
|
||||
```
|
||||
|
||||
**What it checks:**
|
||||
|
||||
- ADB binary path and existence
|
||||
- Direct ADB command execution
|
||||
- ADBManager device detection functionality
|
||||
- Manual parsing of ADB output
|
||||
- ADB version and server status
|
||||
|
||||
**When to use:**
|
||||
|
||||
- Android device is not being detected
|
||||
- ADB connectivity issues
|
||||
- Troubleshooting path problems
|
||||
- Verifying ADB installation
|
||||
|
||||
**Output interpretation:**
|
||||
|
||||
- ✅ "Device found: [DEVICE_ID]" means ADB is working correctly
|
||||
- ❌ "ADB binary not found" indicates path configuration issues
|
||||
- Empty device list suggests USB debugging is not enabled or device is not connected
|
||||
@@ -0,0 +1,111 @@
|
||||
"""
|
||||
Debug script for troubleshooting ADB device detection issues.
|
||||
|
||||
This script provides comprehensive debugging information for ADB connectivity,
|
||||
including binary path verification, device detection, and command execution testing.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Add the src directory to Python path for imports
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "src"))
|
||||
|
||||
from adb_manager import ADBManager
|
||||
|
||||
|
||||
def main():
|
||||
"""Run comprehensive ADB debugging tests."""
|
||||
print("=== ADB Device Detection Debug ===\n")
|
||||
|
||||
# Test 1: Check if ADB binary exists
|
||||
adb_manager = ADBManager()
|
||||
from adb_manager import ADB_BINARY_PATH
|
||||
|
||||
adb_path = ADB_BINARY_PATH
|
||||
print(f"1. ADB Binary Path: {adb_path}")
|
||||
print(f" ADB Binary Exists: {os.path.exists(adb_path)}\n")
|
||||
|
||||
if not os.path.exists(adb_path):
|
||||
print("❌ ADB binary not found! Check the platform-tools directory structure.")
|
||||
return
|
||||
|
||||
# Test 2: Run ADB command directly
|
||||
print("2. Testing ADB command directly...")
|
||||
try:
|
||||
import subprocess
|
||||
|
||||
result = subprocess.run(
|
||||
[adb_path, "devices"], capture_output=True, text=True, timeout=10
|
||||
)
|
||||
print(f" Return code: {result.returncode}")
|
||||
print(f" STDOUT: {repr(result.stdout)}")
|
||||
print(f" STDERR: {repr(result.stderr)}\n")
|
||||
except Exception as e:
|
||||
print(f" Error running ADB directly: {e}\n")
|
||||
|
||||
# Test 3: Test ADBManager device detection
|
||||
print("3. Testing with ADBManager...")
|
||||
try:
|
||||
result = adb_manager.run_adb_command(["devices"])
|
||||
print(f" Raw result: {result}")
|
||||
print(f" Raw result type: {type(result)}")
|
||||
|
||||
device = adb_manager.check_device()
|
||||
if device:
|
||||
print(f" Device found: {device}\n")
|
||||
else:
|
||||
print(" No device found by ADBManager\n")
|
||||
except Exception as e:
|
||||
print(f" Error with ADBManager: {e}\n")
|
||||
|
||||
# Test 4: Manual parsing for debugging
|
||||
print("4. Manual parsing of ADB output:")
|
||||
try:
|
||||
import subprocess
|
||||
|
||||
result = subprocess.run(
|
||||
[adb_path, "devices"], capture_output=True, text=True, timeout=10
|
||||
)
|
||||
print(f" Return code: {result.returncode}")
|
||||
|
||||
lines = result.stdout.strip().split("\n")
|
||||
print(" Output lines:")
|
||||
for i, line in enumerate(lines):
|
||||
print(f" Line {i}: {repr(line)}")
|
||||
if "\t" in line and "device" in line:
|
||||
device_id = line.split("\t")[0].strip()
|
||||
print(f" ✅ Found device: {device_id}")
|
||||
print()
|
||||
except Exception as e:
|
||||
print(f" Error in manual parsing: {e}\n")
|
||||
|
||||
# Test 5: Additional ADB info
|
||||
print("5. Additional ADB commands for debugging:")
|
||||
try:
|
||||
import subprocess
|
||||
|
||||
# ADB version
|
||||
version_result = subprocess.run(
|
||||
[adb_path, "version"], capture_output=True, text=True, timeout=5
|
||||
)
|
||||
print(f" ADB Version: {version_result.stdout.strip()}")
|
||||
|
||||
# Restart ADB server
|
||||
subprocess.run([adb_path, "kill-server"], capture_output=True, timeout=5)
|
||||
subprocess.run([adb_path, "start-server"], capture_output=True, timeout=5)
|
||||
|
||||
# Check devices again after restart
|
||||
devices_result = subprocess.run(
|
||||
[adb_path, "devices"], capture_output=True, text=True, timeout=10
|
||||
)
|
||||
print(f" Restarting ADB server...")
|
||||
print(f" After restart - Return code: {devices_result.returncode}")
|
||||
print(f" After restart - Output: {repr(devices_result.stdout)}")
|
||||
|
||||
except Exception as e:
|
||||
print(f" Error in additional tests: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to debug folder parsing
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, 'src')
|
||||
|
||||
from adb_manager import ADBManager
|
||||
|
||||
def main():
|
||||
adb = ADBManager()
|
||||
print("Testing folder parsing...")
|
||||
|
||||
result = adb.run_adb_command(['shell', 'ls', '-la', '/sdcard/'])
|
||||
print(f"Return code: {result[2]}")
|
||||
|
||||
lines = result[0].strip().split('\n')
|
||||
print(f"Total lines: {len(lines)}")
|
||||
print("\nFirst 10 lines:")
|
||||
for i, line in enumerate(lines[:10]):
|
||||
print(f" {i}: {repr(line)}")
|
||||
|
||||
print("\nParsing directories:")
|
||||
folders = []
|
||||
for i, line in enumerate(lines):
|
||||
if line.startswith('d'):
|
||||
parts = line.split()
|
||||
print(f" Line {i}: {len(parts)} parts")
|
||||
if len(parts) >= 8: # Changed from 9 to 8
|
||||
folder_name = ' '.join(parts[7:]) # Changed from 8 to 7
|
||||
print(f" Folder name: {repr(folder_name)}")
|
||||
if folder_name not in ['.', '..']:
|
||||
folders.append(folder_name)
|
||||
print(f" ✅ Added: {repr(folder_name)}")
|
||||
else:
|
||||
print(f" ❌ Skipped: {repr(folder_name)}")
|
||||
|
||||
print(f"\nFinal folders list ({len(folders)} items):")
|
||||
for folder in sorted(folders):
|
||||
print(f" - {repr(folder)}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user