Overview
TheDeviceManager class (core/device_manager.py:13) handles all ADB operations including device detection, file extraction, and backup dumping from Android devices.
Class Definition
core/device_manager.py
Constructor
__init__()
Directory where ADB binaries are stored/downloaded
Directory where extracted backups will be saved
adb_dir: Absolute path to ADB directoryoutput_dir: Output directory for backupsos_type: Detected OS (windows, linux, darwin)adb_executable: Path to adb executable
ADB Management
is_installed()
Checks if ADB is installed and accessible.
True if ADB executable exists and is accessible
download_adb()
Automatically downloads platform-specific ADB binaries.
- Detects operating system
- Downloads from
ADB_URLS[os_type] - Extracts to
adb_dir - Sets executable permissions (Unix)
- Updates
adb_executablepath
run_command()
Executes an ADB command and returns the result.
List of ADB command arguments (e.g., [‘devices’], [‘-s’, ‘serial’, ‘shell’, ‘ls’])
(return_code, stdout, stderr)
Device Discovery
get_devices()
Returns a list of connected Android devices.
List of device serial numbers
get_detailed_device_info()
Retrieves comprehensive device information.
Device serial number
Dictionary containing device properties:
- Model, Brand, Manufacturer, Device, Board
- Android Version, SDK, Security Patch
- Battery level, RAM (Total/Available)
- Storage (Total/Used/Free)
- WhatsApp Installations
get_users()
Retrieves user profiles from the device.
Device serial number
List of user dictionaries with ‘id’ and ‘name’ keys
check_packages()
Checks which WhatsApp packages are installed.
Device serial number
List of installed package names (com.whatsapp, com.whatsapp.w4b)
Backup Discovery
find_backups()
Scans device storage for WhatsApp backup files.
Device serial number
User profile ID (usually “0” for primary user)
Package name (com.whatsapp or com.whatsapp.w4b)
List of backup dictionaries containing:
- path: Full device path to backup file
- name: Filename (e.g., msgstore.db.crypt15)
- size: Human-readable file size
- Legacy:
/sdcard/WhatsApp/Databases - Android 11+:
/sdcard/Android/media/com.whatsapp/WhatsApp/Databases
find_media()
Locates WhatsApp Media folder on device.
Device serial number
User profile ID
Package name
Path to Media folder, or empty string if not found
File Operations
dump_backup()
Pulls a backup file from device to local storage.
Device serial number
Full path to backup file on device
User profile ID
“messenger” or “business”
Print status messages
Local path to dumped file, or empty string on failure
dump_media_with_progress()
Pulls entire Media folder with progress tracking.
Device serial number
Path to Media folder on device
Local directory to save media files
True if successful, False otherwise
- Counts total files before transfer
- Shows progress bar with tqdm
- Preserves directory structure
- Handles large media collections
Constants
ADB_URLS
Download URLs for platform-specific ADB binaries.
WHATSAPP_PACKAGES
Supported WhatsApp package identifiers.
Usage Example
Related
Device Scanning
Learn about device detection and scanning
Backup Extraction
Extract backups from devices
ADB Operations
Advanced ADB usage and troubleshooting
Platform Guides
Platform-specific setup instructions
