写CPU0 / CPU频率/ cpuinfo_min_freq:打开失败:EACCES(权限被拒绝) [英] Writing cpu0/cpufreq/cpuinfo_min_freq: open failed: EACCES (Permission denied)

查看:2913
本文介绍了写CPU0 / CPU频率/ cpuinfo_min_freq:打开失败:EACCES(权限被拒绝)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设置最小/最大时钟速度有根的手机编程。从响应提出了一个建议下面就来<一href=\"http://stackoverflow.com/questions/26892198/setting-the-min-max-cpu-clock-rate-programmatically\">this问题,我发现<一个href=\"https://software.intel.com/sites/default/files/comment/1716807/how-to-change-frequency-on-linux-pub.txt\"相对=nofollow>一些文档这表明我的数据写入:

I am attempting to set the min/max clock speeds on a rooted phone programmatically. Following on from a suggestion made in response to this question, I found some documentation which suggests that I write the data to:

/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq

/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq

我已经有

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

在我的清单。此外,我可以成功的阅读的这两个文件。当我试图写文件,我得到了打开失败:EACCES(拒绝)。所以,我想......

in my manifest. Also I can successfully read both files. When I tried to write to the files, I got open failed: EACCES (Permission denied). So I tried...

Runtime.getRuntime().exec("su -c \"chmod 777 /sys/devices/system/cpu/cpu0/cpufreq/*\"");

...它的执行没有错误,但是这并没有区别。当我执行这两条线的第二个出现的错误:

...which executed without error, but this made no difference. The error occurs when I execute the second of these two lines:

File file = new File("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq");
BufferedWriter bw = new BufferedWriter(new FileWriter(file));  

我不知道我可以尝试下。

I'm not sure what I can try next.

编辑:以下mrPjer的建议,我跑了亚行的shell。我输入并导航到 / SYS /设备/系统/ CPU / CPU0 / CPU频率。接下来我键入

Following mrPjer's advice, I ran adb shell. I typed su and the navigated to /sys/devices/system/cpu/cpu0/cpufreq. I then typed

搭配chmod 777 scaling_max_freq

和确认键入了premissions已被接受

and confirmed that the premissions had been accepted by typing

ls -l命令scaling_max_freq

果然被列为 -rwxrwxrwx 。接下来我键入

and sure enough it was listed as -rwxrwxrwx. I then typed

回声124200&GT; scaling_max_freq

然后

猫scaling_max_freq

这个伤心地报道该文件是不变1512000。

sadly this reported that the file was unchanged as "1512000".

编辑:这个问题现在已经渐行渐远有些从原来的标题,所以我要发布一个编辑为<一个href=\"http://stackoverflow.com/questions/26933159/scaling-max-freq-resists-being-altered-despite-write-permission-and-a-rooted-dev\">a新的问题完全的。

This question has now drifted away somewhat from the original title, so I'm going to post the last edit as a new question altogether.

推荐答案

而不是改变对系统文件的权限,以全局可读/写(你真的不应该这样做),请尝试直接用root访问写入文件。

Instead of changing the permissions on the system files to globally readable / writable (which you really shouldn't do), try writing the files directly using root access.

您可以轻松地在您的通话肃使用echo代替CHMOD做到这一点。例如。

You can easily do this by using echo instead of chmod in your su call. E.g.

Runtime.getRuntime().exec("su -c \"echo 1234 > /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq\"");

该exec调用也应该返回一个Process对象上,您可以拨打WAITFOR(),它会给你调用的返回code。如果是大于零的任何不同,出事了。

The exec call should also return a Process object on which you can call waitFor() which will give you the return code of the call. If that is any different than zero, something went wrong.

最后,确认您真正做到获得root权限 - 执行苏请求时,做一个对话框弹出询问您是否允许动作

Finally, confirm that you actually do get root access - when executing the su request, does a dialog pop up asking you to allow the action?

此外,因为你正在编写根启用应用程序,看看在RootTools库:的 HTTPS://$c$c.google.com/p/roottools/wiki/Usage

Also, since you are writing root enabled apps, take a look at the RootTools library: https://code.google.com/p/roottools/wiki/Usage.

这篇关于写CPU0 / CPU频率/ cpuinfo_min_freq:打开失败:EACCES(权限被拒绝)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆