1
0
mirror of https://github.com/ponces/treble_aosp.git synced 2024-11-24 21:26:23 +00:00
treble_aosp/patches/trebledroid/platform_frameworks_base/0032-Add-Mediatek-power-hints-on-touch.patch
2024-07-21 01:50:08 +01:00

128 lines
5.6 KiB
Diff

From b3ac1c493a2487279951cbdc32a8ab6c8f673817 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/54] 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 1934f8196639..eb2520546e8f 100644
--- a/services/core/Android.bp
+++ b/services/core/Android.bp
@@ -255,7 +255,9 @@ java_library_static {
"net_flags_lib",
"stats_flags_lib",
"core_os_flags_lib",
- "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 7f3df958664c..d02360adf06e 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -216,6 +216,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) {
@@ -425,6 +428,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);
@@ -509,6 +525,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
@@ -527,6 +554,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