Search code examples
androidadb

How to access adb directly from Android app?


Is it possible to communicate with the Android Debug Bridge (ADB) from inside an app if the service has been loaded through USB?

Here is the use case: I can take a screenshot of the framebuffer through ADB on an unrooted phone with no problem, but it is a little slow to transmit the entire raw buffer over USB, especially if I want to take more than a frame every 2 seconds. What I would like to do is access the framebuffer from inside an app on the phone which can then either transmit it over Wifi or do some compression first. ASL doesn't work on Jellybean (they shut down the loophole to install native services on /data/local), so I would just like to connect to the ADB service via some socket or whatever and issue the framebuffer request that way.

I am ok with having to connect via USB to load the ADB service, but once connected, I would like to do processing on the phone itself before transmission. And it must work on unrooted phones.

Is this possible?


Solution

  • Oneliner:

    $ adb shell screencap -p \| gzip -c \> /mnt/sdcard/s.png.gz; adb pull /mnt/sdcard/s.png.gz;