使用root(服务或后台线程)的Android屏幕截图

时间:2013-08-26 08:47:44

标签: android root capture

当鲨鱼安卓手机有一个应用程序捕获屏幕。

1)当app处于活动状态时,捕获屏幕没有root。

2)当app返回堆栈时,如返回HOME,需要root权限才能捕获屏幕。

我想知道具有root权限的函数2)的实现。

在我看来,root权限意味着获得root shell,刷新一些命令和exec。所以我混淆了如何在shell命令中捕获屏幕。

1 个答案:

答案 0 :(得分:1)

如果你有root权限甚至是shell权限,你可以使用screenshot或screencap命令,供你参考:

root@android:/system/bin # screenshot -h                                   
unknown option -- husage: screenshot [-s soundfile] filename.png
   -s: play a sound effect to signal success
   -i: autoincrement to avoid overwriting filename.png

root@android:/system/bin # screencap -h                                      
    usage: screencap [-hp] [-d display-id] [FILENAME]
       -h: this message
       -p: save the file as a png.
       -d: specify the display id to capture, default 0.
    If FILENAME ends with .png it will be saved as a png.
    If FILENAME is not given, the results will be printed to stdout.

如果您的设备没有这些本地程序,您可以自己编写一个。源代码位于:https://android.googlesource.com/platform/frameworks/base/+/master/cmds/screencap/screencap.cpp