【问题标题】:Android screen capture with root (service or background thread )使用 root 的 Android 屏幕截图(服务或后台线程)
【发布时间】:2013-08-26 08:47:44
【问题描述】:

鲨鱼安卓手机有应用截屏。

1) 当应用程序处于活动状态时,无需 root 即可捕获屏幕。

2)当应用程序返回堆栈时,例如返回HOME,需要root权限才能捕获屏幕。

我想知道以root权限实现功能2)。

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

【问题讨论】:

    标签: android root capture


    【解决方案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

    【讨论】:

    • 非常感谢,我找到了另一种解决方案。 chmod /dev/graphics/fb0
    • 更改设备权限不是一个好主意。但是你可以坚持任何你觉得舒服的解决方案。但是,我的问题是,如果您只有访问帧缓冲区的权限,您仍然需要自己进行图像编码。但是这些任务都在屏幕截图中处理,这将为您节省大量精力。我强烈建议您接受我的回答。
    • 是的。我读取了screencap.cpp,这个文件通过读取设备文件来捕获屏幕。该 chmod 想法适用于版本 2.3 或更早版本。非常感谢。
    猜你喜欢
    • 2015-07-29
    • 1970-01-01
    • 1970-01-01
    • 2020-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多