Android Things: take a screenshot

How to take a screenshot via ADB for Android Things? I tried:

adb shell screencap -p /sdcard/screen.png adb pull /sdcard/screen.png adb shell rm /sdcard/screen.png 

and

 adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png 
+5
source share
2 answers

I could not get screepcap to work in the Android Things Developer Preview. The command results in a 0-dimensional file.

However, I recommend the following two options: either use a framebuffer or record video ( screenrecord seems to work) and subsequently convert it to an image with the appropriate tool. I will consider the first option, so the steps will be as follows:

  • Pull the framebuffer to the host machine . Note that you need to run adbd as root in order to pass the permission check:

     adb root adb pull /dev/graphics/fb0 screenshot 
  • Convert the source binary to an image with the tool you prefer. I am using ffmpeg . The command below may not work for you due to different screen resolution or pixel format. If so, make the right changes.

     ffmpeg -f rawvideo -pix_fmt rgb565 -s 800x480 -i screenshot screenshot.png 
+2
source

It seems that due to the old limited version of OpenGL in Android Things, described by Tatsuhiko Arai here , there is no way to get a screenshot through ADB, but you can record video (for example, from Android Studio or through ADB commands ), and not capture a frame from it for example via ffmpeg :

 ffmpeg -i device-2017-01-23-193539.mp4 -r 1 screen-%04d.png 

where device-2017-01-23-193539.mp4 is the name of the recorded file (via Android Studio).

+1
source

Source: https://habr.com/ru/post/1262494/


All Articles