Search code examples
androidbashadbprotocolsplex

Has anybody seen a C or C++ implementation of ADB push?


I wrote a small Plex playlist/media export utility to transfer playlists and media from Plex Media Server to Android. It uses the ADB executable to push files from the server to the phone, and works nicely; however I'd really like to port it to C or C++ and make a self-contained executable instead of a bash script with external dependencies.

A couple of days of googling turned up nothing but a bunch of false leads that ended up being wrappers for the ADB executable, and a document that explained how poorly documented the protocol is.

Has anybody run into any sort of self-contained library in any language that can do an ADB push?


Solution

  • Here are two libraries, though not in C++: Python, Haskell

    It's fairly safe to assume Python is already installed on any Linux system, so I'd go with that one. Moving bash to Python is also much easier than bash to C++.

    If you want to write your own in C++, the adb protocol is very well documented here.

    Also, why not just install the dependencies in the shell script? There are only a handful of package managers out there so it shouldn't take long to figure out the right package name for each linux flavor and have the shell auto download it. That would be the more standard solution, and would only be a few lines of bash.

    Or, you can just package your shell script and mark the dependencies in the package (The former will be easier, though both methods are easier than rewriting a bash script in another language). Then users would download the package based on which Linux flavor they have.