IOException: read failed: ENODEV (No such device)
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不成功的话,也不会出现这种提示吧。