I was able to successfully execute these commands via ADB and was able to change CPU frequency.
adb root
adb shell
cd /sys/devices/system/cpu
echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 1152000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 1152000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
I wanna execute these via Java code, so I tried this approach:
Process suProcess = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
os.writeBytes("adb shell" + "\n");
os.flush();
but it gives exception on first line. java.io.Exception: Error running exec(). Command: [su] Working directory: null Environment: null
I'm executing these commands in system app, with custom ROM, android 5.0
Can you tell me how to execute these commands in java code? Or do I need to create a bash file to execute these commands?
from How to change CPU frequency via Java code (Or ADB commands via Java code)?
No comments:
Post a Comment