diff options
Diffstat (limited to 'common/common.sh')
-rwxr-xr-x | common/common.sh | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/common/common.sh b/common/common.sh index d2b9ae3..ffb9466 100755 --- a/common/common.sh +++ b/common/common.sh @@ -10,10 +10,27 @@ pre_uninstall="" ret_value=0 timeout=10m +dir_sys_cpu="/sys/devices/system/cpu/" f_tmp_governor="/data/local/tmp/governor.txt" + +func_setgovernor(){ + local target_governor="$1" + local target_freq="$2" + if [ -z "${target_governor}" ]; then + return + fi + for cpu in $(adb shell "ls -d ${dir_sys_cpu}/cpu[0-9]*" |tr '\r' ' '); do + local dir_cpu_cpufreq="${cpu}/cpufreq" + adb shell "echo ${target_governor}>${dir_cpu_cpufreq}/scaling_governor" + if [ -n "${target_freq}" ]; then + adb shell "echo ${target_freq} >${dir_cpu_cpufreq}/scaling_setspeed" + fi + done +} + func_cleanup(){ - adb shell "cat ${f_tmp_governor} > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" - adb shell "cat ${f_tmp_governor} > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor" + local target_governor=$(adb shell cat ${f_tmp_governor}) + func_setgovernor "${target_governor}" adb shell rm ${f_tmp_governor} func_kill_uninstall "RotationOff.apk" "rotation.off" } @@ -40,8 +57,7 @@ function init(){ func_install_start_RotationAPK adb shell "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor > ${f_tmp_governor}" - adb shell "echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" - adb shell "echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor" + func_setgovernor "performance" } func_prepare_benchmark(){ |