对android的/sys/文件进行读写操作

需要读写 "/sys/devices/virtual/timed_output/vibrator/amp" 文件

我可以正常读,但是不知道怎么写。

代码如下:

public static void writeValue(String filename, String value) {
    //FileOutputStream fos = null;
    DataOutputStream os = null;
    try {
        /*fos = new FileOutputStream(new File(filename), false);
        fos.write(value.getBytes());
        fos.flush();*/

        Process p;

        p = Runtime.getRuntime().exec("su");
        os = new DataOutputStream(p.getOutputStream());  

       os.writeBytes(value + " > " + filename + "\n");
       os.writeBytes("exit\n");

       Log.w(TAG, value + " >> " + filename);

       os.flush();           
    } catch (IOException e) {
        Log.w(TAG, "Could not write to " + filename);
    } finally {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
                Log.d(TAG, "Could not close " + filename, e);
            }
        }
    }
}

我得到** Log.w(TAG, "Could not write to " + filename); **的返回值。

不知道应该怎么写入?需要什么许可么?要不要全部重建来匹配root访问?

os.writeBytes(value + " > " + filename + "\n");

这句不对
试试:

os.writeBytes("echo '"+value + "' > " + filename + "\n");

或者:

os.writeBytes("echo -n '"+value + "' > " + filename + "\n");

chmod 777 sys

mount -o remount rw /system /sys
chmod 777 sys

sys默认应该是root权限,我们应用程序是system权限,
你需要把sys改成system权限
chown system:system sys

请问一下你是怎么读取系统sys文件的呢