本文介绍了安卓读fb0总是给我黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的设备是运行 Jelly Bean 4.2 的 Nexus 4.我正在尝试记录屏幕并将其发送出去.互联网上的大多数代码通过读取/dev/graphics/fb0 来完成上限.它在某些设备和旧系统中运行良好.但是当我在我的设备上尝试它时,它失败了.它只给我黑屏和原始数据中的所有0".我已经运行adb root"来获得 root 权限,尝试了chmod 777 fb0"、cat fb0 >/sdcard/fb0".我也尝试过像mmap"和memcpy"这样的代码来获取数据.但都失败了.我在互联网上搜索过,似乎没有解决方案.并且一些线程说内核可能会禁止您读取 fb0.有人对此有想法吗?

My device is Nexus 4 running Jelly Bean 4.2. I'm trying to record the screen and send it out. Most codes on internet do the cap by read /dev/graphics/fb0. It works fine in some devices and the older systems. But when I try it on my device, it fail. It only gives me blackscreen and all "0" in the raw data. I have run "adb root" to get the root permission, tried "chmod 777 fb0", "cat fb0 > /sdcard/fb0". Also I have tried codes like "mmap" and "memcpy" to get the data. But all fail. I have searched on internet and there seems no solution. And some threads said that the kernel may forbid you reading the fb0. Anyone have idea on that?

推荐答案

随着硬件的进步,您越来越不可能找到包含屏幕内容的实际帧缓冲区.

As the hardware advances, you're less and less likely to find an actual framebuffer with the screen contents in it.

如评论中所述,adb 使用screencap"命令,该命令通过 Binder 调用联系 surfaceflinger,如果失败则返回 /dev/graphcs/fb0.后一种路径现在很少使用了.

As noted in the comments, adb uses the "screencap" command, which contacts surfaceflinger through a Binder call, falling back on /dev/graphcs/fb0 if that fails. The latter path is rarely used now.

如果你真的想深入了解它是如何工作的,你需要研究一下surfaceflinger 是如何进行组合的,尤其是hwcomposer HAL.硬件作曲家采用多个gralloc 表面并在扫描输出期间合成它们.它的工作方式因设备而异;hwcomposer 的实现通常由图形芯片制造商完成.

If you really want to dig into how this works, you need to examine how surfaceflinger does composition, especially the hwcomposer HAL. The hardware composer takes multiple gralloc surfaces and composites them during scan-out. How this works differs from device to device; the hwcomposer implementation is usually done by the graphics chip manufacturer.

屏幕截图生成,由应用框架用于为最近的应用"功能生成缩略图,应用 HWC 执行的相同合成步骤,但仅适用于 GLES.从 Android 4.2 开始,硬件合成器无法合成到缓冲区中.

Screen shot generation, used by the app framework to generate the thumbnails for the "recent apps" feature, applies the same composition steps HWC does but exclusively with GLES. As of Android 4.2, the hardware composer isn't able to composite into a buffer.

有时硬件作曲家平底船",例如因为要合成的层数超出了硬件的处理能力.在这种情况下,surfaceflinger 会恢复为 GLES 合成,并且会有一个缓冲区某处包含完整的图像;打开 /dev/graphics/fb0 是否能找到它是另一回事.

Sometimes the hardware composer "punts", e.g. because there are more layers to composite than the hardware can handle. In that case, surfaceflinger reverts to GLES composition, and there will be a buffer somewhere that has the complete image; whether or not you'll find it by opening /dev/graphics/fb0 is a different matter.

一些起点:

这篇关于安卓读fb0总是给我黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-31 22:34