-
Notifications
You must be signed in to change notification settings - Fork 36
/
0032-Add-Mediatek-power-hints-on-touch.patch
127 lines (118 loc) · 5.64 KB
/
0032-Add-Mediatek-power-hints-on-touch.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
From a501d218943c17e76bb36d09083a133228eaf186 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 17 Jun 2023 08:31:55 -0400
Subject: [PATCH 32/46] Add Mediatek power hints on touch
Mediatek has multiple HALs (which existed concurrently), so it is a bit
of a mess.
From what I can tell, mOldMtkPerf is used on Android 10 vendors, while
mMtkPerf is used on Android 11/12 vendors.
If anyone has an Android 9 vendor and want to take a look, I think it
would be something like this:
vendor.mediatek.hardware.power.V2_0.IPower.powerHint()
On some devices, sending the touch boost isn't very helpful. Our guess
is that Android 12 rendering got a lot heavier, and then touch boost is
not enough. So, we add a property to /cheat/ and report a bigger boost:
APP_ROTATE.
On the few devices we've seen, touch boost only boosts scheduler, while
app rotate will also for cpu min frequency.
Experimentally using this app rotate boost indeed makes the device much
smoother.
Change-Id: I9f1eac5a20b98920a5d0c8204fe4d165ba069f5a
---
services/core/Android.bp | 4 +-
.../com/android/server/wm/DisplayPolicy.java | 49 +++++++++++++++++++
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/services/core/Android.bp b/services/core/Android.bp
index 735959270c11..05782235ea1c 100644
--- a/services/core/Android.bp
+++ b/services/core/Android.bp
@@ -186,7 +186,9 @@ java_library_static {
"com.android.sysprop.watchdog",
"ImmutabilityAnnotation",
"securebox",
- "vendor.samsung.hardware.sysinput-V1.2-java", // HIDL
+ // HIDL
+ "vendor.mediatek.hardware.mtkpower-V1.1-java",
+ "vendor.samsung.hardware.sysinput-V1.2-java",
],
javac_shard_size: 50,
javacflags: [
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 4a740f4fdd2f..6aefe7bf8de9 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -213,6 +213,9 @@ public class DisplayPolicy {
*/
private boolean mRemoteInsetsControllerControlsSystemBars;
+ private vendor.mediatek.hardware.mtkpower.V1_1.IMtkPerf mMtkPerf;
+ private vendor.mediatek.hardware.mtkpower.V1_0.IMtkPower mOldMtkPerf;
+
StatusBarManagerInternal getStatusBarManagerInternal() {
synchronized (mServiceAcquireLock) {
if (mStatusBarManagerInternal == null) {
@@ -420,6 +423,19 @@ public class DisplayPolicy {
mScreenOnEarly = true;
mScreenOnFully = true;
}
+ try {
+ mMtkPerf = vendor.mediatek.hardware.mtkpower.V1_1.IMtkPerf.getService();
+ } catch(Throwable t) {
+ android.util.Log.d("PHH-Power", "Retrieving mtkpower 1.0", t);
+ mMtkPerf = null;
+ }
+
+ try {
+ mOldMtkPerf = vendor.mediatek.hardware.mtkpower.V1_0.IMtkPower.getService();
+ } catch(Throwable t) {
+ android.util.Log.d("PHH-Power", "Retrieving mtkpower 1.0", t);
+ mOldMtkPerf = null;
+ }
final Looper looper = UiThread.getHandler().getLooper();
mHandler = new PolicyHandler(looper);
@@ -504,6 +520,17 @@ public class DisplayPolicy {
mService.mPowerManagerInternal.setPowerBoost(
Boost.INTERACTION, duration);
}
+ if(mOldMtkPerf != null) {
+ try {
+ android.util.Log.d("PHH-Power", "mtk1 fling power hint");
+ int hint = 36; // MTKPOWER_HINT_APP_TOUCH
+ if("rotate".equals(SystemProperties.get("persist.sys.phh.touch_hint")))
+ hint = 35; // MTKPOWER_HINT_APP_ROTATE
+ mOldMtkPerf.mtkPowerHint(hint, duration);
+ } catch(Throwable t) {
+ android.util.Log.d("PHH-Power", "Failed sending touch power hint", t);
+ }
+ }
}
@Override
@@ -522,6 +549,28 @@ public class DisplayPolicy {
if (listener != null) {
listener.onTouchStart();
}
+ if(mMtkPerf != null) {
+ try {
+ android.util.Log.d("PHH-Power", "mtk power hint");
+ int hint = 25; //MTKPOWER_HINT_APP_TOUCH
+ if("rotate".equals(SystemProperties.get("persist.sys.phh.touch_hint")))
+ hint = 24; // MTKPOWER_HINT_APP_ROTATE
+ mMtkPerf.perfCusLockHint(hint, 1000);
+ } catch(Throwable t) {
+ android.util.Log.d("PHH-Power", "Failed sending touch power hint", t);
+ }
+ }
+ if(mOldMtkPerf != null) {
+ try {
+ android.util.Log.d("PHH-Power", "mtk1 power hint");
+ int hint = 36; // MTKPOWER_HINT_APP_TOUCH
+ if("rotate".equals(SystemProperties.get("persist.sys.phh.touch_hint")))
+ hint = 35; // MTKPOWER_HINT_APP_ROTATE
+ mOldMtkPerf.mtkPowerHint(hint, 1000);
+ } catch(Throwable t) {
+ android.util.Log.d("PHH-Power", "Failed sending touch power hint", t);
+ }
+ }
}
@Override
--
2.34.1