- 首先说明不是作假,是让antutu跑分的时候全开cpu
我们要知道向antutu 鲁大师等跑分app作为三方app运行在手机上的时候,也是收到cpu调度影响的,正常情况是不可能全核满频率跑的,对系统来说它就是个三方app 没啥特殊对待的。所以我们想要跑分上去可以在系统上做特殊处理
- 熟悉activity的启动流程的就知道Instrumentation.java 这个大管家的重要性,我们可以在这里监听应用是否在跑
public void callActivityOnResume(Activity activity) {
activity.mResumed = true;
activity.onResume();
+ String packageName = activity.getComponentName().getPackageName();
+ if("com.antutu.ABenchMark".equals(packageName)||"com.antutu.benchmark.full".equals(packageName)){
+ IActivityManager am = ActivityManager.getService();
+ try {
+ am.setCpuAll(true);
+ } catch (RemoteException ex) {
+ throw ex.rethrowFromSystemServer();
+ }
+
+
public void callActivityOnPause(Activity activity) {
activity.performPause();
+ String packageName = activity.getComponentName().getPackageName();
+ if("com.antutu.ABenchMark".equals(packageName)||"com.antutu.benchmark.full".equals(packageName)){
+ IActivityManager am = ActivityManager.getService();
+ try {
+ am.setCpuAll(false);
+ } catch (RemoteException ex) {
+ throw ex.rethrowFromSystemServer();
+ }
+ }
}
- 我们把全开cpu的方法放这里 ActivityManagerService.java (这里mtk平台提供了一个方法perfLockAcquire,高通平台类似,都能满足我们的目的)
+ @Override
+ public void setCpuAll(boolean enable){
+ //SystemProperties.set("persist.sys.cpu_all", enable? "1":"0");
+ if(enable){
+ setAllCpuOpen();
+ }else{
+ perfUnLockAcquireCpu();
+ }
+ }
+ /// @}
+
+ private int hander =0;
+ private void setAllCpuOpen(){
+ if(mPowerProxy==null) return;
+ int PERF_RES_CPUFREQ_MIN_CLUSTER_0 = 0x00400000;
+ int PERF_RES_CPUFREQ_MIN_CLUSTER_1 = 0x00400100;
+ int PERF_RES_CPUCORE_MIN_CLUSTER_0 = 0x00800000;
+ int PERF_RES_CPUCORE_MIN_CLUSTER_1 = 0x00800100;
+ int PERF_RES_DRAM_OPP_MIN = 0x01000000;
+ /* min of cluster 0 = 4 core=> 4L && L runs @ 1.3GHz atleast */
+ int[] perf_lock_opts =
+ {PERF_RES_CPUCORE_MIN_CLUSTER_0, 4,
+ PERF_RES_CPUCORE_MIN_CLUSTER_1, 4,
+ PERF_RES_CPUFREQ_MIN_CLUSTER_0, 2001000,//mt8788
+ PERF_RES_CPUFREQ_MIN_CLUSTER_1,1500000,
+ PERF_RES_DRAM_OPP_MIN,0};//mt8788
+ if (hander != 0) {
+ mPowerProxy.perfLockRelease(hander);
+ hander = 0;
+ }
+ hander = mPowerProxy.perfLockAcquire(hander, 10000, perf_lock_opts);//max 30s
+ if(hander>0){
+ mHandler.removeMessages(MSG_OPEN_ALL_CPU);
+ mHandler.sendEmptyMessageDelayed(MSG_OPEN_ALL_CPU,10000);
+ }
+ }
+ /**
+ * unlockCpu
+ */
+ public void perfUnLockAcquireCpu(){
+ if (hander != 0) {
+ if(mPowerProxy==null) return;
+ mHandler.removeMessages(MSG_OPEN_ALL_CPU);
+ mPowerProxy.perfLockRelease(hander);
+ hander = 0;
+ }
+ }
- 对于一些性能问题,可以让cpu全核开,看看还有没有问题,如果好了可以对这个场景做拉高cpu操作
固定当前频率
adb shell "echo 4 > /proc/ppm/policy/ut_fix_core_num"
adb shell "echo 0 > /proc/ppm/policy/ut_fix_freq_idx "
adb shell "echo 570000 > /proc/gpufreq/gpufreq_opp_freq"
adb shell cat /proc/cpufreq/MT_CPU_DVFS_LL/cpufreq_oppidx
adb shell cat /proc/cpufreq/MT_CPU_DVFS_LL/cpufreq_freq
adb shell cat /proc/gpufreq/gpufreq_opp_dump
adb shell "cat /proc/gpufreq/gpufreq_var_dump"
adb shell cat /proc/cpufreq/MT_CPU_DVFS_LL/cpufreq_oppidx
adb shell cat /proc/cpufreq/MT_CPU_DVFS_L/cpufreq_oppidx
大核:
cat /proc/cpufreq/MT_CPU_DVFS_L/cpufreq
小核:
cat /proc/cpufreq/MT_CPU_DVFS_LL/cpufreq
查看
:/ # cat /proc/cpufreq/MT_CPU_DVFS_L/cpufreq_oppidx 大核
[MT_CPU_DVFS_L/0]
cpufreq_oppidx = 15
0 (2001000, 101875)
1 (1961000, 101875)
2 (1927000, 101250)
3 (1897000, 100625)
4 (1868000, 100000)
5 (1838000, 97500)
6 (1809000, 93750)
7 (1779000, 90000)
8 (1750000, 85625)
9 (1617000, 81875)
10 (1484000, 78125)
11 (1351000, 74375)
12 (1218000, 70625)
13 (1085000, 66250)
14 (979000, 63125)
15 (900000, 61250)
:/ # cat /proc/ppm/policy/ut_fix_core_num 查看核数
cluster 0 fix core num = -1
cluster 1 fix core num = -1
:/ # ^C
/ # cat /proc/cpufreq/MT_CPU_DVFS_LL/cpufreq_oppidx 小核
[MT_CPU_DVFS_LL/4]
cpufreq_oppidx = 15
0 (1500000, 101875)
1 (1429000, 99375)
2 (1367000, 96250)
3 (1314000, 94375)
4 (1261000, 93125)
5 (1208000, 91250)
6 (1155000, 89375)
7 (1102000, 87500)
8 (1050000, 86250)
9 (948000, 82500)
10 (846000, 78750)
11 (745000, 75000)
12 (643000, 71250)
13 (542000, 67500)
14 (501000, 65625)
15 (400000, 62500)
Tab_10:/ #
切换成userspace
/ # echo userspace> sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
/ # echo userspace> sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
:/ # echo userspace> sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
:/ # echo userspace> sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
/ # echo userspace> sys/devices/system/cpu/cpu4/cpufreq/scaling_governor
:/ # echo userspace> sys/devices/system/cpu/cpu5/cpufreq/scaling_governor
/ # echo userspace> sys/devices/system/cpu/cpu6/cpufreq/scaling_governor
:/ # echo userspace> sys/devices/system/cpu/cpu7/cpufreq/scaling_governor
有效的固定频率方法:
怀疑是CPU 高档位有问题, 需要做实验确认.
adb shell "echo 4 4 > /proc/ppm/policy/ut_fix_core_num"
adb shell "echo 0 > /proc/ppm/root_cluster"
adb shell "echo 0 0 > /proc/ppm/policy/ut_fix_freq_idx"