通过java代码读取/ proc / kmsg文件

时间:2018-06-06 13:08:23

标签: android

我已经创建了一个系统应用程序,我正在尝试在root设备上运行它。我已经包含了android:sharedUserId =" android.uid.system"在清单文件中。该应用程序也由平台签名签名。还包括在外部存储器上读写的权限。通过这个应用程序,我试图读取/ proc / kmsg文件的内容并将其复制到SD卡上的另一个文件。我也尝试将应用程序移动到/ system / priv-app文件夹,但它出现此错误:java.io.FileNotFoundException:/ proc / kmsg:open failed:EPERM(不允许操作)。代码如下:

           FileInputStream ins = null; FileOutputStream outs = null; try{ File infile =new File("/proc/kmsg"); File outfile =new File("/sdcard/some_file.txt"); ins = new FileInputStream(infile);//THIS IS THROWING THE EXCEPTION outs = new FileOutputStream(outfile); byte[] buffer = new byte[1024]; int length; while ((length = ins.read(buffer)) > 0){ outs.write(buffer, 0, length); } ins.close(); outs.close(); } catch(IOException ioe){ ioe.printStackTrace(); }

有人可以建议解决方案吗?

0 个答案:

没有答案