Linux 如何在Android中更改时钟频率?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4238959/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change clock frequency in Android?
提问by zephyrus
I'm a new to software development on Android.
我是 Android 软件开发的新手。
I want to make an application like SetCPUthat can manipulate CPU frequency in Android.
我想制作一个像SetCPU这样的应用程序,可以在 Android 中操纵 CPU 频率。
But I couldn't find some related APIs or materials.
但是我找不到一些相关的API或材料。
I want to know following two things sincerely.
我真诚地想知道以下两件事。
- Are there APIs to change the CPU frequency in Android?
- If not, are there some APIs in Linux?
- 是否有 API 可以更改 Android 中的 CPU 频率?
- 如果没有,Linux 中是否有一些 API?
回答by Octavian A. Damiean
There is no Java API to change the frequency of an Android device. The only way to do this is to get your hands dirty with the Kernel.
没有 Java API 可以更改 Android 设备的频率。做到这一点的唯一方法是使用内核弄脏你的手。
回答by Mike Donahoe
回答by Sidartha Carvalho
Some commands in ADB
ADB 中的一些命令
Set Governor:
设置总督:
adb shell echo "userspace" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Set Frequency in KHz:
以 KHz 为单位设置频率:
adb shell su -c "echo "702000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
//min frequency
adb shell su -c "echo "384000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"
//MAX frequency
adb shell su -c "echo "384000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"
Get current CPU Frequency:
获取当前 CPU 频率:
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
Show availables governors:
显示可用的州长:
adb shell su -c "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors"
Disable service that overwrite cpu online file:
禁用覆盖 cpu 在线文件的服务:
adb shell su -c "stop mpdecision"
It's necessary to do this before enabling or disabling core. mp decision is restarted if the system is restarted.
有必要在启用或禁用核心之前执行此操作。如果系统重新启动,mp 决定将重新启动。
Disable core:
禁用核心:
adb shell su -c "echo "0" > /sys/devices/system/cpu/cpu3/online"
If that doesn't work:
如果这不起作用:
& chmod 444 /sys/devices/system/cpu/cpu1/online