Skip to Main Content
Lightning Talk Intermediate GPL-3.0 First Talk

Bypassing Android MTP: pushing a native C++ daemon via ADB for fast storage analysis

Proposal status is Approved
Session Description

We all have been through this tough battle at least once in our lives with MTP (Media Transfer Protocol), which is what every OS uses when you plug an Android phone in via USB. It was designed in 2008 for portable media players and transfers file metadata one item at a time with no caching or parallel requests. It does a round trip every time new info is needed because it works as a request-response protocol, so when you club this with modern tech with 100s of GBs of storage and tens of thousands of files, even calculating folder sizes takes several minutes, and if you are on macOS, the Finder app doesn't even show folder sizes at all. SocketSweep is an open source desktop app that bypasses this agonising MTP entirely. The main source of architectural inspiration is the scrcpy project by Genymobile, the idea of pushing a native binary to an Android device via ADB and communicating over a local socket.

So here's how it works: we have a cross-compiled C++ daemon (~1MB static binary, built with the Android NDK for aarch64) that gets pushed to the phone via adb push. Now the transferred daemon binds to a TCP socket on port 5050 and scans the filesystem using native POSIX calls like opendir/readdir/stat directly on the device, so there's no MTP bottleneck, it's plain raw system calls. Now the ADB port forwarding tunnels TCP 5050 on the phone to localhost:5050 on the PC, giving us a reliable bidirectional channel through the USB cable (with future scope of making it work over WiFi). Coming to the desktop side, we have a Rust/Tauri backend on the PC which manages the full lifecycle from pushing the daemon, setting up port forwarding, handling scoped storage permissions, and managing the TCP connection. The app uses a React frontend with an interactive treemap visualization.

A full /sdcard scan on my device, which is a Samsung S24 Ultra (256GB, ~47k files), took about 7 seconds.

In this lightning talk i'll walk through why MTP is slow at the protocol level, how the "push binary + socket" pattern from scrcpy can be applied to other problems, cross-compiling C++ for Android with the NDK, and how ADB port forwarding works as a communication layer.

Key Takeaways
  1. Why MTP is slow at the protocol level and why building better file manager apps on top of it doesn't fix the core problem

  2. How scrcpy's "push a native binary via ADB, communicate over a local socket" pattern can be reused to build your own Android tools

  3. A working example of this pattern: scanning 47k files in ~7 seconds vs several minutes over MTP

  4. Why this approach is future-proof: it runs through ADB debugging, not sideloading, so it continues to work even as Google tightens sideloading restrictions on Android

References

Session Categories

Introducing a FOSS project or a new version of a popular project
Technology architecture
Talk License: GPL-3.0

Which track are you applying for?

Android Open Source Project (AOSP)

Speakers

Vishnu Srivatsava Software Engineer

Software engineer who is into systems programming, Android/Linux internals, and security. Two-time CTF winner at IIIT Hyderabad. I've spent years tinkering with custom ROMs, bootloader unlocking, and open source software. Also a competitive speedcuber with a state record in 3x3 one-handed solving.

Vishnu Srivatsava
https://www.linkedin.com/in/vishnu-srivatsava-642222238/