1
0
mirror of https://github.com/yurisieucuti/treble_evolution.git synced 2024-11-24 09:46:19 +00:00
treble_evolution/patches/platform_frameworks_base/0021-Automatically-detect-pick-up-sensor-so-that-an-overl.patch
2024-04-24 15:13:17 +00:00

51 lines
2.0 KiB
Diff

From f818799df4f75db19d4b2ae88fd7fa532f72928b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 20 Mar 2021 14:31:01 +0100
Subject: [PATCH 21/51] Automatically detect pick up sensor, so that an overlay
is required for the sole purpose of enabling pulse doze on pick up sensor
---
.../display/AmbientDisplayConfiguration.java | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/core/java/android/hardware/display/AmbientDisplayConfiguration.java b/core/java/android/hardware/display/AmbientDisplayConfiguration.java
index 47541ca16cda..28168b9208f5 100644
--- a/core/java/android/hardware/display/AmbientDisplayConfiguration.java
+++ b/core/java/android/hardware/display/AmbientDisplayConfiguration.java
@@ -25,6 +25,9 @@ import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.SparseArray;
+import android.hardware.SensorManager;
+import android.hardware.Sensor;
+
import com.android.internal.R;
import com.android.internal.util.ArrayUtils;
@@ -105,8 +108,20 @@ public class AmbientDisplayConfiguration {
/** @hide */
public boolean dozePickupSensorAvailable() {
- return mContext.getResources().getBoolean(R.bool.config_dozePulsePickup);
- }
+ SensorManager sm = mContext.getSystemService(SensorManager.class);
+ boolean found = false;
+ if(sm == null) {
+ android.util.Log.d("PHH", "Failed getting sensor manager, can't detect pickup sensor");
+ } else {
+ java.util.List<Sensor> sensors = sm.getSensorList(Sensor.TYPE_ALL);
+ for(Sensor s : sensors) {
+ if(Sensor.STRING_TYPE_PICK_UP_GESTURE.equals(s.getStringType())) {
+ found = true;
+ break;
+ }
+ }
+ }
+ return mContext.getResources().getBoolean(R.bool.config_dozePulsePickup) || found; }
/** @hide */
public boolean tapGestureEnabled(int user) {
--
2.25.1