我正在使用模擬器。所以我肯定有root權限。 我用命令:爲什麼我無法從/ dev/graphics/fb0讀取數據?
adb pull /dev/graphics/fb0 d:/a
,然後用我的程序讀取這個文件,並生成一個bmp。它是成功的。但是,當我用純Java代碼來做到這一點:
Process process = Runtime.getRuntime().exec("su -c cat /dev/graphics/fb0");
process.waitFor();
InputStream is = process.getInputStream();
is.read(buffer, 0, width*height*2);
緩衝區不能得到正確的數據。所有的數據都是0,而前幾行的正確值是0xFF。
然後我嘗試:
adb shell
cat /dev/graphics/fb0 > /sdcard/tmp
的tmp文件也得到了正確的數據。 爲什麼純java代碼失敗?我使用Process類的方式是否錯誤?