IOException: read failed: ENODEV (No such device)

wei220000 2015-07-26 09:42:34
FileInputStream buf = null;
try {
buf = new FileInputStream(new File("/dev/graphics/fb0"));// 读取文件内容
PixelFormat localPixelFormat1 = new PixelFormat();
PixelFormat.getPixelFormatInfo(pixelformat, localPixelFormat1);
int deepth = localPixelFormat1.bytesPerPixel;// 位深
byte[] piex = new byte[screenHeight * screenWidth * deepth];// 像素
DataInputStream dStream = new DataInputStream(buf);
Log.e("test","src:开始");
// dStream.readFully(piex);//ENODEV
while(dStream.read(piex, 0, screenHeight * screenWidth * deepth) != -1){
// 保存图片
int[] colors = new int[screenHeight * screenWidth];
for(int m=0;m<piex.length;m++){
if(m%4 == 0){
int r = (piex[m] & 0xFF);
int g = (piex[m+1] & 0xFF);
int b = (piex[m+2] & 0xFF);
int a = (piex[m+3] & 0xFF);
colors[m/4]= (a << 24) + (r <<16) + (g <<8) + b;
}
}
}

我想通过读取/dev/graphics/fb0文件来获取截图,程序前面已经获得了root权限,通过设置Log,也定位到问题出现在dStream.read(piex)中。不明白,一个简单的文件读取会出现没找到设备的错误。难道读取这个文件要需要什么权限?我也获得了root啊。
ShellUtil.getInstance().rootCommand("chmod 777 /dev/graphics/fb0\n");
而且root不成功的话,也不会出现这种提示吧。
...全文
661 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
在下个路口 2016-01-18
  • 打赏
  • 举报
回复
楼主,解决了吗?一样的问题,求助!
星空下的猫 2015-10-26
  • 打赏
  • 举报
回复
遇到同样的问题,正在求解过程当中。。。。
wei220000 2015-07-26
  • 打赏
  • 举报
回复
顶一个, adb shell screencap -p /sdcard/screen.png 虽然这种方法也能获取截图,但是做出来的一张图片,就有1.8M。。这还怎么敢做成视频?
wei220000 2015-07-26
  • 打赏
  • 举报
回复
沉了,沉了,看来大神们都在过周末,明天再顶。
wei220000 2015-07-26
  • 打赏
  • 举报
回复
要沉了。虽然现在5.0有系统支持屏幕录制,但是市面上老机型还是很多啊。

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧