7

I'm a new to software development on Android.

I want to make an application like SetCPU that can manipulate CPU frequency in Android.

But I couldn't find some related APIs or materials.

I want to know following two things sincerely.

  1. Are there APIs to change the CPU frequency in Android?
  2. If not, are there some APIs in Linux?
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
zephyrus
  • 71
  • 1
  • 1
  • 2

3 Answers3

16

Some commands in ADB

Set Governor:

adb shell echo "userspace" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

Set Frequency in 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:

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:

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.

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 
Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
Sidartha Carvalho
  • 320
  • 1
  • 3
  • 6
  • On nexus 5X, Google Pixel and Nexus 6P there is no service like mpdecision. Do you also know what is the equivalent service that overrides CPU frequency on these devices. – Arpit Aggarwal Jun 15 '17 at 16:17
3

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.

Octavian Helm
  • 39,405
  • 19
  • 98
  • 102
-2

Looks like you need to root your device

http://www.pokedev.com/setcpu/