Skip to content

Commit 9f4dda5

Browse files
committed
add perf boost if need
1 parent e8c299e commit 9f4dda5

File tree

12 files changed

+262
-192
lines changed

12 files changed

+262
-192
lines changed

app/src/main/java/com/fadisu/cpurun/fragment/CpuSettingsFragment.java

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
public class CpuSettingsFragment extends Fragment implements View.OnClickListener {
1818

19+
private static final String TAG = CpuSettingsFragment.class.getSimpleName();
20+
1921
private Context mContext;
2022

2123
private final static String[] GOVERNORS = CpuUtils.getCpuAvailableGovernorsList();
@@ -72,4 +74,6 @@ public void onClick(DialogInterface dialog, int which) {
7274
});
7375
builder.show();
7476
}
77+
78+
7579
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.fadisu.cpurun.util;
2+
3+
import android.content.Context;
4+
import android.os.Handler;
5+
import android.util.Log;
6+
7+
import com.mediatek.perfservice.PerfServiceWrapper;
8+
9+
/**
10+
* Created by Fadi.Su on 2018/2/5.
11+
*/
12+
public class CpuSettingsUtils {
13+
14+
private static String TAG = CpuSettingsUtils.class.getSimpleName();
15+
16+
/**
17+
* CPU 核数和频率全开,达到瞬间性能最优
18+
*/
19+
private static void perfBoost(Context mContext) {
20+
final int MIN_CPU_NUMBER = CpuUtils.getNumCpuCores();
21+
final int MAX_CPU_FREQ = (int) CpuUtils.getCpuMaxFreq();
22+
23+
final PerfServiceWrapper mPerfServiceWrapper = new PerfServiceWrapper(mContext);
24+
if (null != mPerfServiceWrapper) {
25+
final int mPerfHandle = mPerfServiceWrapper.userReg(MIN_CPU_NUMBER, MAX_CPU_FREQ);
26+
27+
if (-1 != mPerfHandle) {
28+
mPerfServiceWrapper.userEnableTimeoutMs(mPerfHandle, 500);
29+
Log.d(TAG, "userEnableTimeoutMs = " + mPerfHandle);
30+
31+
Handler handler = new Handler();
32+
handler.postDelayed(new Runnable() {
33+
@Override
34+
public void run() {
35+
mPerfServiceWrapper.userUnreg(mPerfHandle);
36+
Log.d(TAG, "userUnreg = " + mPerfHandle);
37+
}
38+
}, 600);
39+
}
40+
}
41+
}
42+
}

app/src/main/java/com/mediatek/perfservice/IPerfServiceWrapper.java

+27-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
public interface IPerfServiceWrapper {
77

88
public static final int SCN_NONE = 0;
9+
10+
// 切换应用
911
public static final int SCN_APP_SWITCH = 1; /* apply for both launch/exit */
12+
1013
public static final int SCN_PACKAGE_SWITCH = 2;
1114
public static final int SCN_GAME_LAUNCH = 3;
1215
public static final int SCN_APP_LAUNCH = 4;
16+
17+
// 旋转应用
1318
public static final int SCN_APP_ROTATE = 5;
1419
public static final int SCN_APP_TOUCH = 6;
1520
public static final int SCN_SW_FRAME_UPDATE = 7;
@@ -65,6 +70,7 @@ public interface IPerfServiceWrapper {
6570

6671
// 获取内存频率级别
6772
public static final int CMD_GET_MEM_FREQ_LEVEL_COUNT = 4;
73+
6874
public static final int CMD_GET_PERF_INDEX_MIN = 5;
6975
public static final int CMD_GET_PERF_INDEX_MAX = 6;
7076
public static final int CMD_GET_PERF_NORMALIZED_INDEX_MAX = 7;
@@ -106,14 +112,14 @@ public interface IPerfServiceWrapper {
106112
public static final int CMD_SET_GPU_FREQ_MAX = 9;
107113

108114
// 设置图形模式,参数1个:DRAM模式:0-默认模式,1-低功耗模式,2-还是默认模式,3-高性能模式
115+
public static final int CMD_SET_VCORE = 10;
116+
117+
// 设置关屏模式,一个参数,模式值。0-关屏无效,1-关屏有效,2-关屏暂停,打开恢复
109118
//enum {
110119
// SCREEN_OFF_DISABLE = 0,
111120
// SCREEN_OFF_ENABLE = 1,
112121
// SCREEN_OFF_WAIT_RESTORE = 2,
113122
//};
114-
public static final int CMD_SET_VCORE = 10;
115-
116-
// 设置关屏模式,一个参数,模式值。0-关屏无效,1-关屏有效,2-关屏暂停,打开恢复
117123
public static final int CMD_SET_SCREEN_OFF_STATE = 11;
118124

119125
// 设置高速频率,一个参数
@@ -124,14 +130,32 @@ public interface IPerfServiceWrapper {
124130

125131
// 设置above speed hispeed,一个参数
126132
public static final int CMD_SET_CPUFREQ_ABOVE_HISPEED_DELAY = 14;
133+
134+
// 设置CPU簇的最少核数
127135
public static final int CMD_SET_CLUSTER_CPU_CORE_MIN = 15;
136+
137+
// 设置CPU簇的最多核数
128138
public static final int CMD_SET_CLUSTER_CPU_CORE_MAX = 16;
139+
140+
// 设置CPU簇的最低频率值
129141
public static final int CMD_SET_CLUSTER_CPU_FREQ_MIN = 17;
142+
143+
// 设置CPU簇的最高频率值
130144
public static final int CMD_SET_CLUSTER_CPU_FREQ_MAX = 18;
145+
146+
// 设置root簇
131147
public static final int CMD_SET_ROOT_CLUSTER = 19;
148+
149+
// 设置CPU温度的最高阈值
132150
public static final int CMD_SET_CPU_UP_THRESHOLD = 20;
151+
152+
// 设置CPU温度的最低阈值
133153
public static final int CMD_SET_CPU_DOWN_THRESHOLD = 21;
154+
155+
// 设置性能优化的索引值
134156
public static final int CMD_SET_PERF_INDEX = 22;
157+
158+
// 设置普通性能优化的索引值
135159
public static final int CMD_SET_NORMALIZED_PERF_INDEX = 23;
136160
public static final int CMD_SET_PPM_MODE = 24;
137161
public static final int CMD_SET_RUSH_BOOST_ENABLED = 25;

vendor/mediatek/proprietary/hardware/perfservice/Android.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ LOCAL_PATH:= $(call my-dir)
3838
ifneq ($(wildcard $(LOCAL_PATH)/$(shell echo $(MTK_PLATFORM) | tr A-Z a-z)),)
3939

4040
include $(LOCAL_PATH)/$(shell echo $(MTK_PLATFORM) | tr A-Z a-z)/Android.mk \
41-
$(LOCAL_PATH)/perfservicenative/Android.mk \
41+
$(LOCAL_PATH)/setBrightnessValueBg/Android.mk \
4242
$(LOCAL_PATH)/perf_native_test/Android.mk
4343

4444
else # mt[xxxx] folder exist
4545

46-
include $(LOCAL_PATH)/perfservicenative/Android.mk \
46+
include $(LOCAL_PATH)/setBrightnessValueBg/Android.mk \
4747
$(LOCAL_PATH)/perf_native_test/Android.mk
4848

4949
endif # mt[xxxx] folder not exist

vendor/mediatek/proprietary/hardware/perfservice/perf_native_test/Android.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LOCAL_SRC_FILES := \
77
perf_native_test.cpp
88

99
#LOCAL_FORCE_STATIC_EXECUTABLE := true
10-
LOCAL_C_INCLUDES += $(MTK_PATH_SOURCE)/hardware/perfservice/perfservicenative
10+
LOCAL_C_INCLUDES += $(MTK_PATH_SOURCE)/hardware/perfservice/setBrightnessValueBg
1111
LOCAL_SHARED_LIBRARIES += libc libdl libcutils
1212
LOCAL_MODULE := perf_native_test
1313
LOCAL_PROPRIETARY_MODULE := true

vendor/mediatek/proprietary/hardware/perfservice/perf_native_test/README

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ It needs the following libs from AOSP:
1515
2. libdl.so
1616

1717
and the following libs from MediaTek:
18-
1. libperfservicenative.so
18+
1. libsetBrightnessValueBg.so
1919

2020
HOW TO USE IT?
2121
==============

vendor/mediatek/proprietary/hardware/perfservice/perf_native_test/perf_native_test.cpp

+26-26
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#include <cutils/properties.h>
1717

1818

19-
#include "PerfServiceNative.h"
19+
#include "setBrightnessValueBg.h"
2020

21-
#define LIB_FULL_NAME "libperfservicenative.so"
21+
#define LIB_FULL_NAME "libsetBrightnessValueBg.so"
2222
#define GIFTATTR_DEBUGPROP "debug.perf.giftEnable"
2323

2424
void (*perfBoostEnable)(int) = NULL;
@@ -349,7 +349,7 @@ static int load_api(void)
349349

350350
handle = dlopen(LIB_FULL_NAME, RTLD_NOW);
351351

352-
func = dlsym(handle, "PerfServiceNative_boostEnable");
352+
func = dlsym(handle, "setBrightnessValueBg_boostEnable");
353353
perfBoostEnable = reinterpret_cast<ena>(func);
354354

355355
if (perfBoostEnable == NULL) {
@@ -358,7 +358,7 @@ static int load_api(void)
358358
return -1;
359359
}
360360

361-
func = dlsym(handle, "PerfServiceNative_boostDisable");
361+
func = dlsym(handle, "setBrightnessValueBg_boostDisable");
362362
perfBoostDisable = reinterpret_cast<disa>(func);
363363

364364
if (perfBoostDisable == NULL) {
@@ -367,7 +367,7 @@ static int load_api(void)
367367
return -1;
368368
}
369369

370-
func = dlsym(handle, "PerfServiceNative_boostEnableTimeout");
370+
func = dlsym(handle, "setBrightnessValueBg_boostEnableTimeout");
371371
perfBoostEnableTimeout = reinterpret_cast<ena_timeout>(func);
372372

373373
if (perfBoostEnableTimeout == NULL) {
@@ -376,7 +376,7 @@ static int load_api(void)
376376
return -1;
377377
}
378378

379-
func = dlsym(handle, "PerfServiceNative_boostEnableTimeoutMs");
379+
func = dlsym(handle, "setBrightnessValueBg_boostEnableTimeoutMs");
380380
perfBoostEnableTimeoutMs = reinterpret_cast<ena_timeout_ms>(func);
381381

382382
if (perfBoostEnableTimeoutMs == NULL) {
@@ -385,7 +385,7 @@ static int load_api(void)
385385
return -1;
386386
}
387387

388-
func = dlsym(handle, "PerfServiceNative_userReg");
388+
func = dlsym(handle, "setBrightnessValueBg_userReg");
389389
perfUserScnReg = reinterpret_cast<user_reg>(func);
390390

391391
if (perfUserScnReg == NULL) {
@@ -394,7 +394,7 @@ static int load_api(void)
394394
return -1;
395395
}
396396

397-
func = dlsym(handle, "PerfServiceNative_userRegBigLittle");
397+
func = dlsym(handle, "setBrightnessValueBg_userRegBigLittle");
398398
perfUserScnRegBigLittle = reinterpret_cast<user_reg_big_little>(func);
399399

400400
if (perfUserScnRegBigLittle == NULL) {
@@ -403,7 +403,7 @@ static int load_api(void)
403403
return -1;
404404
}
405405

406-
func = dlsym(handle, "PerfServiceNative_userUnreg");
406+
func = dlsym(handle, "setBrightnessValueBg_userUnreg");
407407
perfUserScnUnreg = reinterpret_cast<user_unreg>(func);
408408

409409
if (perfUserScnUnreg == NULL) {
@@ -412,7 +412,7 @@ static int load_api(void)
412412
return -1;
413413
}
414414

415-
func = dlsym(handle, "PerfServiceNative_userGetCapability");
415+
func = dlsym(handle, "setBrightnessValueBg_userGetCapability");
416416
perfUserGetCapability = reinterpret_cast<user_get_capability>(func);
417417

418418
if (perfUserGetCapability == NULL) {
@@ -421,7 +421,7 @@ static int load_api(void)
421421
return -1;
422422
}
423423

424-
func = dlsym(handle, "PerfServiceNative_userRegScn");
424+
func = dlsym(handle, "setBrightnessValueBg_userRegScn");
425425
perfUserRegScn = reinterpret_cast<user_reg_scn>(func);
426426

427427
if (perfUserRegScn == NULL) {
@@ -430,7 +430,7 @@ static int load_api(void)
430430
return -1;
431431
}
432432

433-
func = dlsym(handle, "PerfServiceNative_userRegScnConfig");
433+
func = dlsym(handle, "setBrightnessValueBg_userRegScnConfig");
434434
perfUserRegScnConfig = reinterpret_cast<user_reg_scn_config>(func);
435435

436436
if (perfUserRegScnConfig == NULL) {
@@ -439,7 +439,7 @@ static int load_api(void)
439439
return -1;
440440
}
441441

442-
func = dlsym(handle, "PerfServiceNative_userUnregScn");
442+
func = dlsym(handle, "setBrightnessValueBg_userUnregScn");
443443
perfUserUnregScn = reinterpret_cast<user_unreg_scn>(func);
444444

445445
if (perfUserUnregScn == NULL) {
@@ -448,7 +448,7 @@ static int load_api(void)
448448
return -1;
449449
}
450450

451-
func = dlsym(handle, "PerfServiceNative_userEnable");
451+
func = dlsym(handle, "setBrightnessValueBg_userEnable");
452452
perfUserScnEnable = reinterpret_cast<user_enable>(func);
453453

454454
if (perfUserScnEnable == NULL) {
@@ -457,7 +457,7 @@ static int load_api(void)
457457
return -1;
458458
}
459459

460-
func = dlsym(handle, "PerfServiceNative_userDisable");
460+
func = dlsym(handle, "setBrightnessValueBg_userDisable");
461461
perfUserScnDisable = reinterpret_cast<user_disable>(func);
462462

463463
if (perfUserScnDisable == NULL) {
@@ -466,7 +466,7 @@ static int load_api(void)
466466
return -1;
467467
}
468468

469-
func = dlsym(handle, "PerfServiceNative_userEnableTimeout");
469+
func = dlsym(handle, "setBrightnessValueBg_userEnableTimeout");
470470
perfUserScnEnableTimeout = reinterpret_cast<user_enable_timeout>(func);
471471

472472
if (perfUserScnEnableTimeout == NULL) {
@@ -475,7 +475,7 @@ static int load_api(void)
475475
return -1;
476476
}
477477

478-
func = dlsym(handle, "PerfServiceNative_userEnableTimeoutMs");
478+
func = dlsym(handle, "setBrightnessValueBg_userEnableTimeoutMs");
479479
perfUserScnEnableTimeoutMs = reinterpret_cast<user_enable_timeout_ms>(func);
480480

481481
if (perfUserScnEnableTimeoutMs == NULL) {
@@ -484,7 +484,7 @@ static int load_api(void)
484484
return -1;
485485
}
486486

487-
func = dlsym(handle, "PerfServiceNative_userResetAll");
487+
func = dlsym(handle, "setBrightnessValueBg_userResetAll");
488488
perfUserScnResetAll = reinterpret_cast<user_reset_all>(func);
489489

490490
if (perfUserScnResetAll == NULL) {
@@ -493,7 +493,7 @@ static int load_api(void)
493493
return -1;
494494
}
495495

496-
func = dlsym(handle, "PerfServiceNative_userDisableAll");
496+
func = dlsym(handle, "setBrightnessValueBg_userDisableAll");
497497
perfUserScnDisableAll = reinterpret_cast<user_disable_all>(func);
498498

499499
if (perfUserScnDisableAll == NULL) {
@@ -502,7 +502,7 @@ static int load_api(void)
502502
return -1;
503503
}
504504

505-
func = dlsym(handle, "PerfServiceNative_dumpAll");
505+
func = dlsym(handle, "setBrightnessValueBg_dumpAll");
506506
perfDumpAll = reinterpret_cast<dump_all>(func);
507507

508508
if (perfDumpAll == NULL) {
@@ -511,7 +511,7 @@ static int load_api(void)
511511
return -1;
512512
}
513513

514-
func = dlsym(handle, "PerfServiceNative_setFavorPid");
514+
func = dlsym(handle, "setBrightnessValueBg_setFavorPid");
515515
perfSetFavorPid = reinterpret_cast<set_favor_pid>(func);
516516

517517
if (perfSetFavorPid == NULL) {
@@ -520,7 +520,7 @@ static int load_api(void)
520520
return -1;
521521
}
522522

523-
func = dlsym(handle, "PerfServiceNative_notifyDisplayType");
523+
func = dlsym(handle, "setBrightnessValueBg_notifyDisplayType");
524524
perfNotifyDisplayType = reinterpret_cast<notify_display_type>(func);
525525

526526
if (perfNotifyDisplayType == NULL) {
@@ -529,7 +529,7 @@ static int load_api(void)
529529
return -1;
530530
}
531531

532-
func = dlsym(handle, "PerfServiceNative_notifyUserStatus");
532+
func = dlsym(handle, "setBrightnessValueBg_notifyUserStatus");
533533
perfNotifyUserStatus= reinterpret_cast<notify_user_status>(func);
534534

535535
if (perfNotifyUserStatus == NULL) {
@@ -538,7 +538,7 @@ static int load_api(void)
538538
return -1;
539539
}
540540

541-
func = dlsym(handle, "PerfServiceNative_getClusterInfo");
541+
func = dlsym(handle, "setBrightnessValueBg_getClusterInfo");
542542
perfGetClusterInfo = reinterpret_cast<get_cluster_info>(func);
543543

544544
if (perfGetClusterInfo == NULL) {
@@ -547,7 +547,7 @@ static int load_api(void)
547547
return -1;
548548
}
549549

550-
func = dlsym(handle, "PerfServiceNative_getGiftAttr");
550+
func = dlsym(handle, "setBrightnessValueBg_getGiftAttr");
551551
perfGetGiftAttr = reinterpret_cast<get_gift_attr>(func);
552552

553553
if (perfGetGiftAttr == NULL) {
@@ -556,7 +556,7 @@ static int load_api(void)
556556
return -1;
557557
}
558558

559-
func = dlsym(handle, "PerfServiceNative_reloadWhiteList");
559+
func = dlsym(handle, "setBrightnessValueBg_reloadWhiteList");
560560
perfReloadWhiteList = reinterpret_cast<reload_white_list>(func);
561561

562562
if (perfReloadWhiteList == NULL) {

0 commit comments

Comments
 (0)