A high-performance Android storage analyzer that bypasses MTP using a native C++ daemon, a Rust TCP bridge, and a React Treemap UI.
😤 The Problem
Ever plugged your Android phone into your PC to figure out what's eating all your storage?
Here's what happens with the standard USB connection (MTP):
- You open the phone in File Explorer / Finder
- Click on a folder with lots of files
- "Calculating size..." — hangs for 4+ minutes
- Eventually shows sizes, but navigating is painfully slow
- Trying to find large files? Good luck scrolling through hundreds of folders one by one
This is because MTP (Media Transfer Protocol) — the protocol your OS uses to talk to Android over USB — was designed in 2008 for MP3 players. It transfers file metadata one item at a time, with no caching, no parallel requests, and no way to do a fast recursive scan. It was never built for phones with 100GB+ of photos, videos, and apps.
SocketSweep bypasses MTP entirely.
⚡ How Fast?
In one /sdcard scan on a Samsung Galaxy S24 Ultra, the daemon reported 7.99 seconds of traversal for 93,194 files. Scan time varies with storage contents, device load, and cache state. Recorded scan timings
Traversal scales with worker count: on a Samsung Galaxy S24 Ultra, a 30,000-file synthetic tree measured 4.51 s → 2.95 s going from one to two daemon workers, with four (the app default) and eight workers within measurement variance. Worker-scaling record — reproduce it yourself with the scan worker benchmark.
Measure ADB and MTP file copy throughput separately using the transfer benchmark.
📸 What It Looks Like
Left: Connection Dashboard | Right: Interactive Treemap — click any block to drill down
🚀 How to Use
1. Download
| Platform | Download |
|---|---|
| 🪟 Windows | Installer (.exe) · Enterprise (.msi) |
| 🍎 macOS (Apple Silicon & Intel) | Disk Image (.dmg) |
| 🐧 Linux | AppImage · .deb |
AppImage updates: Starting with v1.2.0, AppImages include update information and a matching
.zsyncrelease asset for delta updates with AppImageUpdate. Updates follow the latest published stable release. Existing v1.1.1 downloads need one manual upgrade to an AppImage with this metadata.
Arch Linux (x86_64): Use the Linux AppImage linked above. In the download directory, run
chmod +x SocketSweep_1.3.0_amd64.AppImage, then./SocketSweep_1.3.0_amd64.AppImage(AppImage instructions). The.debdownload is for Debian/Ubuntu;pacmanrequires an Arch package.
macOS note: Since the build is ad-hoc signed, run this once after installing:
xattr -cr /Applications/SocketSweep.app
2. Enable USB Debugging on your phone
SocketSweep requires Android 12 (API 31) or newer.
Go to Settings → About Phone → tap "Build Number" 7 times to unlock Developer Options. Then go to Settings → Developer Options → enable "USB Debugging". If your device still doesn't show up afterwards, see Device Not Listed or Won't Connect.
3. Plug in and scan
- Connect your phone via USB cable
- Open SocketSweep
- Choose your phone under Android device. Click Refresh if it is not listed.
- Click Connect Device — the app pushes the daemon and starts scanning automatically. Use Rescan to scan again.
- Click on any block in the treemap to drill down. Found something huge you don't need? Delete it right from the app.
That's it. No apps to install on your phone, no Wi-Fi setup, no root required.
In development builds, File types shows counts and bytes by filename extension from the completed scan. See classification rules and coverage.
In development builds, Search finds entry names across the completed scan with bounded, fully paginated results. See matching rules and bounds.
The Package folders view groups scanned app-related folders by package ID. See coverage and recognized paths for its limits.
Verified scans without access errors are recorded locally when history storage is available. The results header compares compatible scans of the same device, folder and access mode; failed or cancelled scans never become baselines. See successful-scan history for the storage location, durability and comparison rules.
In a source build, choose the device in setup before connecting when multiple devices are ready. Refresh after plugging in or authorizing a phone. A selected device that disappears stays selected and blocks connection; another phone is never substituted automatically. See device selection for behavior and manual checks.
Optional: scan with root access
This option is available starting with v1.2.0; v1.1.1 does not expose it.
On an already-rooted device, enable Scan with root access (read-only) before
connecting. Choose App and user data (/data) to include private app files,
Internal data and system (/) for a broader internal scan, or Shared storage
(/sdcard). Rescan keeps the current scan location.
SocketSweep uses an already-root ADB shell when available; otherwise it requests
access through su. Approve shell access in your phone's root manager when
prompted. On supported debug builds, you can run adb root yourself before
connecting. SocketSweep does not restart ADB or root your device, and refuses a
root session unless the daemon confirms UID 0 and read-only mode.
Root scans disable deletion in the UI, bridge, and daemon. A daemon running as root is always read-only, even if the root option was left off. Disconnect and use an ordinary non-root ADB shell to restore the normal shared-storage workflow.
The internal / scan excludes /proc, /sys, /dev, /mnt, /storage,
/data_mirror, and /apex to avoid virtual files and duplicate views of storage.
It includes internal shared media through /data/media; removable storage is
outside this scan's scope. Virtual filesystems are skipped elsewhere too, and
files or directories with the same device/inode identity are counted once per
root scan. Symlinks are not followed below the scan root. Totals use logical file
sizes, rather than allocated blocks, so they need not match du or Android's
storage screen exactly. Access errors and excluded entries are shown in results.
🧠 How It Works (The Short Version)
Instead of going through MTP, SocketSweep does something completely different:
- Pushes a tiny C++ program (~1MB) to your phone via ADB
- That program scans the filesystem directly on the phone using native POSIX calls — this is why it's so fast (no MTP bottleneck)
- Streams the results back to your PC over a TCP socket through the USB cable
- Renders an interactive treemap in a React frontend so you can visually see what's taking space
The architecture was inspired by scrcpy — the "push a native binary via ADB, communicate over a local socket" pattern.
Each connection authenticates with a fresh 256-bit session secret before the
daemon accepts a command. The secret reaches the phone through a shell-owned
startup file with mode 0600; the daemon reads and removes that file before
listening. The app and daemon must use the same protocol version.
🏗 Architecture (For Developers)
SocketSweep has three layers:
flowchart TB
subgraph Host["Host Desktop"]
UI["React + SVG<br>Interactive Dashboard"]
Bridge["Rust / Tauri Backend<br>Command Orchestrator"]
UI <--> Bridge
end
subgraph Transport["ADB Protocol"]
Tunnel["Targeted ADB Port Forwarding<br>Allocated loopback ports"]
end
subgraph Device["Android Device"]
Daemon["C++17 Daemon<br>Headless Socket Server"]
Storage[("POSIX Filesystem<br>/sdcard")]
Daemon <--> Storage
end
Bridge <--> Tunnel
Tunnel <--> Daemon
Interaction Lifecycle
sequenceDiagram
participant U as React UI
participant R as Rust (Tauri)
participant A as ADB Shell
participant D as C++ Daemon (Android)
%% Connect Phase
U->>R: invoke("list_devices")
R->>A: adb devices -l
R-->>U: Serials, models and states
U->>R: invoke("init_daemon", { serial, rootMode })
R->>A: Release only this app's previous session
R->>A: Revalidate the chosen serial with adb devices -l
R->>A: -s serial: private directory, binary and startup secret
R->>A: -s serial: shell -T launch, allocate device port
R->>A: -s serial: forward --no-rebind tcp:0 tcp:device-port
R->>D: AUTH session secret (on every connection)
R->>D: PING with a bounded deadline
D-->>R: Protocol, UID and read-only handshake
R-->>U: Connected to selected serial
%% Scan Phase
U->>R: invoke("run_scan", { path, scanId, onProgress })
R->>D: TCP Send: `SCAN_STREAM /sdcard\n`
Note over D: Bounded POSIX Traversal
loop During traversal
D-->>R: Length-prefixed entry batches
R-->>U: Partial counts and recent entries
end
D-->>R: Completion totals, then EOF
R-->>U: Validated scan summary and bounded directory pages
%% Delete Phase
U->>R: invoke("delete_item", { generation, revision, nodeId })
Note over R: Resolve the allowed path from the current host scan
R->>D: TCP Send: `DELETE /sdcard/... \n`
Note over D: Descriptor-relative traversal and unlinkat<br/>Child symlinks are never followed
D-->>R: {"status":"ok"}
R-->>U: Update summary/revision and refresh affected pages
🔧 Development Setup (Building from Source)
Prerequisites
- Node.js (
^20.19.0,^22.13.0, or>=24, including frontend lint tooling) - Rust (v1.90+ with Cargo; native file locking for scan history)
- Android NDK (v26d or newer)
- Android SDK / ADB installed and added to your system
$PATH. - Python 3 for building the daemon.
1. Compile the C++ Daemon
Cross-compile the daemon for aarch64-linux-android:
# Optional: uncomment and replace to override a configured or auto-detected NDK
# export NDK="/path/to/your/android-ndk-r26d"
# Build the daemon
bash engine/build.sh
On Windows, run python engine/build_daemon.py from the repository root.
The script prefers NDK, then ANDROID_NDK_LATEST_HOME, then ANDROID_NDK_HOME.
If none is set, it searches configured and default Android SDK directories. An invalid
configured path fails explicitly rather than selecting a different toolchain.
This generates the stripped daemon binary in the engine/ directory and
copies it into src-tauri/bin/daemon, which Tauri bundles. Rebuild after changing
the daemon so local development uses the current protocol (v3).
The default build creates all four Android ABIs and copies them into the Tauri
resources. Use --abi arm64-v8a, --abi armeabi-v7a, --abi x86, or
--abi x86_64 to rebuild one target. The app chooses the first supported ABI
advertised by the selected device. All binaries target Android API 31
(Android 12) or newer. ARMv7 support therefore covers 32-bit Android 12+
systems; Android versions below 12 remain unsupported.
Startup checks the selected device's API level before requesting root access
or uploading the daemon and reports this minimum directly on older versions.
Ordinary storage scans use a bounded pool of four workers. For daemon-level
comparisons, append --threads N (1–8) after PORT TOKEN_FILE; one worker
provides a serial reference. The pending directory queue holds at most 64 jobs
and does not keep directory descriptors open. Root and --read-only scans
remain serial, retaining their exclusions and scan-wide inode deduplication.
The authenticated protocol and deletion checks apply to every worker setting.
For a controlled phone experiment across 1, 2, 4 and 8 workers, see the verified scan benchmark. It checks matching trees and reports scan/stream medians without changing the app's default.
The app uses scan stream v1 (advertised alongside protocol v3): bounded JSON frames arrive during traversal, with partial counts/recent entries and a cancel button. Successful results require verified totals, a terminal completion frame and EOF. Rebuild the daemon before running this version locally; older v3 binaries without the streaming capability are refused. See the stream contract for bounds, completion rules, cancellation and timing semantics. Results use the host-owned scan store with bounded queries for the frontend.
Current startup also requires the rebuilt daemon for owned session files, allocated ports, and lifetime cleanup.
2. Prepare ADB and install frontend dependencies
A fresh checkout requires the host Platform-Tools files before building or
running Tauri. On Linux and macOS, copy the executable adb from your installed Android SDK's
platform-tools directory to src-tauri/bin/adb. On Windows, copy
adb.exe, AdbWinApi.dll, and AdbWinUsbApi.dll from the same
platform-tools installation to src-tauri/bin/. Tauri picks up the
Windows resource list automatically.
From the repository root:
npm ci
3. Run the App
npm run tauri dev
Ensure your Android device is plugged in via USB and USB Debugging is enabled.
Tagged builds use the vX.Y.Z Git tag as the release version. CI applies
that version to the frontend package and Tauri configuration before packaging.
4. Run regression tests
# macOS/Linux: compiles the host daemon and uses disposable local files
python3 -m unittest discover -s tests -v
# Frontend helper tests; no app or connected device required
npm test
# Frontend, browser fixtures, Node helpers, and Vite/ESLint configuration
npm run lint
# Build the frontend first when testing from a clean checkout
npm run build
cargo test --locked --manifest-path src-tauri/Cargo.toml --lib
Lint uses the recommended ESLint/TypeScript rules and React's hook-order and effect-dependency rules. Warnings fail the gate. It does not reformat files; keep mechanical formatting separate from behavior changes. Frontend helper tests and lint run on every desktop CI platform; the Linux job also checks the built UI with mocked IPC at normal size, 1024×768, and 2× scale. EditorConfig supplies UTF-8/LF files with a final newline and the existing two-space frontend/config and four-space Rust/C++/Python indentation defaults.
For the optional, manually run ADB/MTP copy experiment, see the file-transfer baseline and export plan. Regression tests use offline fixtures and mocked ADB calls; they do not contact a phone.
CI also preserves matching daemon crash symbols separately from the stripped binary bundled with the app.
The line-based protocol preserves spaces in filenames. Paths containing a newline, carriage return, or null byte are rejected before sending, so they cannot cause a different file to be deleted. Scan responses containing invalid UTF-8 filenames are also rejected rather than replacing filename bytes.
Deletion is anchored to the directory opened for the successful scan. Child
directories are opened one component at a time without following symlinks, and
removal uses those handles instead of resolving the original full path again.
Detected changes to roots or directory entries stop deletion. Parent symlinks
and traversal into another filesystem are rejected. /sdcard root aliases remain supported.
Recursive deletion has a depth limit of 64 directories.
Deletion is not transactional: concurrent filesystem changes or permission errors can stop it after some entries were removed. Rescan before retrying. An operation already in progress uses the opened directory identities; renaming a path cannot redirect it into a different directory through a new symlink.
🛠 Troubleshooting
"0 Files" or Missing Folders
Android storage permissions can limit what the ADB shell can read. SocketSweep attempts to grant shared-storage access during connection:
adb shell appops set com.android.shell MANAGE_EXTERNAL_STORAGE allow
If scanning still shows nothing, check if your OEM requires extra toggles (e.g., Xiaomi needs "USB Debugging (Security settings)" enabled).
Samsung Auto Blocker
If you're on a Samsung device and USB Debugging is greyed out, you probably have Auto Blocker enabled. Go to Settings → Security → Auto Blocker and turn it off. Auto Blocker disables USB Debugging entirely, so no ADB-based tool (including SocketSweep) will work with it on. It's off by default — you'd only have this issue if you manually turned it on.
AppImage Fails to Launch on Arch Linux (Wayland)
If the AppImage crashes or fails to start on Arch Linux under a Wayland session, launch it with the Wayland client library preloaded:
LD_PRELOAD=/usr/lib/libwayland-client.so ./SocketSweep.AppImage
See this issue for more context.
Daemon Fails to Start
If you get Permission denied, make sure the daemon is being pushed to /data/local/tmp/. Modern Android blocks execution from /sdcard/. SocketSweep handles this automatically.
Device Not Listed or Won't Connect
The device picker reports each state directly — match it here:
| Picker state | Cause and fix |
|---|---|
unauthorized |
Approve the "Allow USB debugging?" prompt on the phone (check "Always allow" to skip it next time), then refresh. |
offline |
Reconnect the cable or try another USB port, then refresh. |
no permissions (Linux) |
Install your distro's ADB udev rules (e.g., android-sdk-udev-rules), replug, and refresh. |
| Phone missing entirely | Vendor quirks below — some vendors hide or disable USB debugging without telling you. |
Vendor quirks that hide USB debugging entirely:
- Xiaomi / MIUI: enable "USB debugging (security settings)" in addition to regular USB debugging — without it, devices may connect but scans come back empty (see "0 Files" above).
- Samsung: Auto Blocker disables USB debugging after updates or reboots — see "Samsung Auto Blocker" above.
- Windows hosts: install the Google USB driver or your OEM's ADB driver in Device Manager if the phone never enumerates.
💖 Support This Project
If SocketSweep saved you from the nightmare of MTP, consider supporting its development:
📄 License
SocketSweep is released under the GNU General Public License v3.0. See the LICENSE file for more details.
👋 Author
Built by Vishnu Srivatsava. Inspired by the architecture of scrcpy. Currently looking for Backend / Systems Engineering roles. Feel free to reach out on LinkedIn or via email.